Simple UART0 usage with SimpleLib

Dependencies:   mbed SimpleLib

Revision:
0:60e8d7bb5545
Child:
1:6a9f5827b72e
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Sun Nov 07 11:32:25 2010 +0000
@@ -0,0 +1,41 @@
+#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);
+}
\ No newline at end of file