Reading data from a USB Gamepad with USB-Host mode.
Fork of Nucleo_Ex04_USBPAD by
main.cpp
- Committer:
- jose_23991
- Date:
- 2016-04-28
- Revision:
- 1:94e011434208
- Parent:
- 0:b5f79b4f741d
- Child:
- 2:7c1379b29ce6
File content as of revision 1:94e011434208:
// Pins connections: 5V-Vbus | GND-GND | Data+-PA_12 | Data--PA_11 #include "mbed.h" #include "USBHostGamepad.h" USBHostGamepad *pad; Serial serial(SERIAL_TX, SERIAL_RX); // LED DigitalOut led(LED1, 0); // Create the LED object and setup OFF int main() { // USB Gamepad Initialize pad = new USBHostGamepad(); if (!pad->connect()) { serial.printf("USB Connection failed\r\n"); while(1); } else { led = 1; serial.printf("USB Connection stablished\r\n"); } while(1) { USBHost::poll(); serial.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]); wait_ms(16); } }