Simple UART0 usage with SimpleLib

Dependencies:   mbed SimpleLib

Revision:
1:6a9f5827b72e
Parent:
0:60e8d7bb5545
Child:
2:d367033913a2
--- a/main.cpp	Sun Nov 07 11:32:25 2010 +0000
+++ b/main.cpp	Sat Nov 13 11:21:01 2010 +0000
@@ -1,41 +1,45 @@
-#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);
+#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);
 }
\ No newline at end of file