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 "USBHostSerial.h" 00003 00004 DigitalOut led(LED1); 00005 Serial pc(USBTX, USBRX); 00006 00007 void serial_task(void const*) { 00008 USBHostSerial serial; 00009 00010 while(1) { 00011 00012 // try to connect a serial device 00013 while(!serial.connect()) 00014 Thread::wait(500); 00015 00016 // in a loop, print all characters received 00017 // if the device is disconnected, we try to connect it again 00018 while (1) { 00019 00020 // if device disconnected, try to connect it again 00021 if (!serial.connected()) 00022 break; 00023 00024 // print characters received 00025 while (serial.available()) { 00026 printf("%c", serial.getc()); 00027 } 00028 00029 Thread::wait(50); 00030 } 00031 } 00032 } 00033 00034 int main() { 00035 Thread serialTask(serial_task, NULL, osPriorityNormal, 256 * 4); 00036 while(1) { 00037 led=!led; 00038 Thread::wait(500); 00039 } 00040 }
Generated on Tue Jul 12 2022 14:55:07 by
