Samuel Mokrani
/
USBHID_TestCase
USBHID test case
Revision 0:53dfbb3eae55, committed 2011-11-17
- Comitter:
- samux
- Date:
- Thu Nov 17 11:29:46 2011 +0000
- Child:
- 1:07d521565fd7
- Commit message:
Changed in this revision
USBDevice.lib | Show annotated file Show diff for this revision Revisions of this file |
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/USBDevice.lib Thu Nov 17 11:29:46 2011 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/samux/code/USBDevice/#98311370c1eb
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Thu Nov 17 11:29:46 2011 +0000 @@ -0,0 +1,35 @@ +#include "mbed.h" +#include "USBHID.h" + +//We declare a USBHID device. By default input and output reports are 64 bytes long. +USBHID hid; + +//This report will contain data to be sent +HID_REPORT send_report; +HID_REPORT recv_report; + +Serial pc(USBTX, USBRX); + +int main(void) { + send_report.length = 64; + + while (1) { + //Fill the report + for (int i = 0; i < send_report.length; i++) { + send_report.data[i] = rand() & 0xff; + } + + //Send the report + hid.send(&send_report); + + //try to read a msg + if(hid.readNB(&recv_report)) { + for(int i = 0; i < recv_report.length; i++) { + pc.printf("%d ", recv_report.data[i]); + } + pc.printf("\r\n"); + } + + wait(0.1); + } +} \ No newline at end of file