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.
Fork of USBHID_HelloWorld by
main.cpp
00001 #include "mbed.h" 00002 #include "USBHID.h" 00003 00004 //We declare a USBHID device. By default input and output reports are 64 bytes long. 00005 USBHID hid(8, 8); 00006 00007 Serial pc(USBTX, USBRX); 00008 00009 //This report will contain data to be sent 00010 HID_REPORT send_report; 00011 HID_REPORT recv_report; 00012 00013 DigitalOut l1(LED1); 00014 00015 int main(void) 00016 { 00017 send_report.length = 8; 00018 00019 while (1) { 00020 00021 //Fill the report 00022 for (int i = 0; i < send_report.length; i++) 00023 send_report.data[i] = rand() & 0xff; 00024 00025 //Send the report 00026 hid.send(&send_report); 00027 00028 //try to read a msg 00029 if(hid.readNB(&recv_report)) { 00030 l1 = !l1; 00031 for(int i = 1; i < recv_report.length; i++) { 00032 pc.printf("%d ", recv_report.data[i]); 00033 } 00034 pc.printf("\r\n"); 00035 } 00036 } 00037 }
Generated on Thu Jul 14 2022 01:10:48 by
1.7.2
