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 USBHostSerial_HelloWorld by
main.cpp
- Committer:
- samux
- Date:
- 2013-03-13
- Revision:
- 2:8f3478b5d434
- Parent:
- 1:6b743a29c48a
File content as of revision 2:8f3478b5d434:
#include "mbed.h" #include "USBHostSerial.h" DigitalOut led(LED1); Serial pc(USBTX, USBRX); void serial_task(void const*) { USBHostSerial serial; while(1) { // try to connect a serial device while(!serial.connect()) Thread::wait(500); // in a loop, print all characters received // if the device is disconnected, we try to connect it again while (1) { // if device disconnected, try to connect it again if (!serial.connected()) break; // print characters received while (serial.available()) { printf("%c", serial.getc()); } Thread::wait(50); } } } int main() { Thread serialTask(serial_task, NULL, osPriorityNormal, 256 * 4); while(1) { led=!led; Thread::wait(500); } }