![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Simple UART0 usage with SimpleLib
main.cpp
- Committer:
- Alkorin
- Date:
- 2010-11-07
- Revision:
- 0:60e8d7bb5545
- Child:
- 1:6a9f5827b72e
File content as of revision 0:60e8d7bb5545:
#include "mbed.h" #include "mbed_globals.h" #include "serial.h" Serial pc(USBTX, USBRX); void serialOut(unsigned char c) { SERIAL_PUTCHAR(c); } void serialOutString(const char * c) { while (*c) { SERIAL_PUTCHAR(*c); c++; } } void serialIn(void) { // Check if interrupt is pending if(!SERIAL_CHECK_INTERRUPT()) return; // While some data to read while (SERIAL_DATA_TO_READ()) { char c = SERIAL_GETCHAR(); serialOut('['); serialOut(c); serialOut(']'); } } int main() { LEDS_INIT(); LEDS_SET(LED1); // Hardware Init pc.baud(9600); pc.attach(&serialIn); while (1); }