Samuel Mokrani
/
USBMSD_SD_HID_HelloWorld
USB MSD HID composite device hello world
Diff: main.cpp
- Revision:
- 0:61e5ecd27a36
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Mon Jan 21 12:03:05 2013 +0000 @@ -0,0 +1,32 @@ +#include "mbed.h" +#include "USBMSD_SD.h" + +USBMSD_SD hid_sd(p5, p6, p7, p8, 8, 8); +DigitalOut l1(LED1); + +//This report will contain data to be sent +HID_REPORT send_report; +HID_REPORT recv_report; + +int main() { + send_report.length = 8; + + while (1) { + + //Fill the report + for (int i = 0; i < send_report.length; i++) + send_report.data[i] = rand() & 0xff; + + //Send the report + hid_sd.send(&send_report); + + //try to read a msg + if(hid_sd.readNB(&recv_report)) { + l1 = !l1; + for(int i = 1; i < recv_report.length; i++) { + printf("%d ", recv_report.data[i]); + } + printf("\r\n"); + } + } +} \ No newline at end of file