Jose Rios / Mbed 2 deprecated Nucleo_GamepadUSB

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 // Pins connections: 5V-Vbus | GND-GND | Data+-PA_12 | Data--PA_11 
00002 // Cannot establish connection with full speed devices, why???
00003 
00004 #include "mbed.h"
00005 #include "USBHostGamepad.h"
00006 
00007 USBHostGamepad *pad;
00008 
00009 Serial serial(SERIAL_TX, SERIAL_RX);
00010 
00011 // LED
00012 DigitalOut led(LED1, 0); // Create the LED object and setup OFF
00013 
00014 int main()
00015 {    
00016     // USB Gamepad Initialize
00017     pad = new USBHostGamepad();
00018     if (!pad->connect()) {
00019         serial.printf("USB Connection failed\r\n");
00020         while(1);
00021     }
00022     else
00023     {
00024         led = 1;
00025         serial.printf("USB Connection stablished\r\n");
00026     }
00027     
00028     while(1)
00029     {
00030         USBHost::poll();
00031         
00032         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]);
00033         wait_ms(16);
00034     }
00035 }