KRAI 2017 / Mbed 2 deprecated USBPAD

Dependencies:   mbed

Fork of Nucleo_Ex04_USBPAD by woodstock .

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 #include "USBHostGamepad.h"
00003 
00004 USBHostGamepad *pad;
00005 
00006 // LED
00007 DigitalOut red(PB_5);
00008 DigitalOut yellow(PA_10);
00009 
00010 int main()
00011 {    
00012     // USB Gmaepad Initialize
00013     pad = new USBHostGamepad();
00014     if (!pad->connect()) {
00015         printf("USB Gamepad not found.\r\n");
00016         while(1);
00017     }
00018     
00019     while(1)
00020     {
00021         USBHost::poll();
00022         
00023         red = pad->report[4] & 0x20;
00024         yellow = pad->report[4] & 0x40;
00025         
00026         printf("%02x %02x %02x %02x %02x %02x %02x %02x\r\n", pad->report[0],pad->report[1],pad->report[2],pad->report[3],pad->report[4],pad->report[5],pad->report[6],pad->report[7]);
00027         wait_ms(16);
00028     }
00029 }