![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Simple UART0 usage with SimpleLib
main.cpp
- Committer:
- Alkorin
- Date:
- 2010-11-13
- Revision:
- 1:6a9f5827b72e
- Parent:
- 0:60e8d7bb5545
- Child:
- 2:d367033913a2
File content as of revision 1:6a9f5827b72e:
#include "mbed.h" #include "mbed_globals.h" #include "interrupts.h" #include "serial.h" #include "leds.h" Serial pc(USBTX, USBRX); void serialOut(unsigned char c) { SERIAL_PUTCHAR(c); } void serialOutString(const char * c) { while (*c) { SERIAL_PUTCHAR(*c); c++; } } SERIAL_INTERRUPT_HANDLER(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() { // Hardware Init // SERIAL_INIT(); // SERIAL_SETBAUD(9600); pc.baud(9600); SERIAL_ENABLE_INTERRUPT(SERIAL_INT_RX); serialOutString("Simple UART Sample Code\r\n"); while (1); }