Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
main.cpp
00001 #include "mbed.h" 00002 #include "USBHID.h" 00003 00004 //We declare a USBHID device. Input out output reports have a length of 8 bytes 00005 USBHID hid(8, 8); 00006 00007 //This report will contain data to be sent 00008 HID_REPORT send_report; 00009 HID_REPORT recv_report; 00010 00011 Serial pc(USBTX, USBRX); 00012 00013 int main(void) { 00014 send_report.length = 8; 00015 00016 while (1) { 00017 //Fill the report 00018 for (int i = 0; i < send_report.length; i++) { 00019 send_report.data[i] = rand() & 0xff; 00020 } 00021 00022 //Send the report 00023 hid.send(&send_report); 00024 00025 //try to read a msg 00026 if(hid.readNB(&recv_report)) { 00027 pc.printf("recv: "); 00028 for(int i = 0; i < recv_report.length; i++) { 00029 pc.printf("%d ", recv_report.data[i]); 00030 } 00031 pc.printf("\r\n"); 00032 } 00033 00034 wait(0.1); 00035 } 00036 }
Generated on Thu Jul 14 2022 20:16:36 by
1.7.2