Daiki Kato
/
USBHID_TestCase_mbed-os
USBHID test case for mbed-os.
Please refer to the following.
https://os.mbed.com/cookbook/USBHID-bindings-
main.cpp
- Committer:
- dkato
- Date:
- 2018-12-10
- Revision:
- 4:fbf649bca9d0
- Parent:
- 2:1db77338562f
File content as of revision 4:fbf649bca9d0:
#include "mbed.h" #include "USBHID.h" //We declare a USBHID device. Input out output reports have a length of 8 bytes USBHID hid(true, 8, 8); //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 = 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.send(&send_report); //try to read a msg if(hid.read_nb(&recv_report)) { pc.printf("recv: "); for(int i = 0; i < recv_report.length; i++) { pc.printf("%d ", recv_report.data[i]); } pc.printf("\r\n"); } wait(0.1); } }