LPC1768 with mbed OS (5) and RawSerial test

Fork of rtos_basic by Mbed

Files at this revision

API Documentation at this revision

Comitter:
tbotsQ
Date:
Mon Jan 23 09:39:33 2017 +0000
Parent:
10:dc33cd3f4eb9
Commit message:
Initial version

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed-os.lib Show annotated file Show diff for this revision Revisions of this file
diff -r dc33cd3f4eb9 -r 87d2ef890844 main.cpp
--- a/main.cpp	Thu Jan 12 23:35:40 2017 +0000
+++ b/main.cpp	Mon Jan 23 09:39:33 2017 +0000
@@ -1,21 +1,21 @@
 #include "mbed.h"
- 
+
 DigitalOut led1(LED1);
 DigitalOut led2(LED2);
-Thread thread;
- 
-void led2_thread() {
-    while (true) {
-        led2 = !led2;
-        wait(1);
-    }
+
+RawSerial pc(USBTX, USBRX);
+
+void callback() {
+    // Note: you need to actually read from the serial to clear the RX interrupt
+    printf("%c\n", pc.getc());
+    led2 = !led2;
 }
- 
+
 int main() {
-    thread.start(led2_thread);
-    
-    while (true) {
+    pc.attach(&callback);
+
+    while (1) {
         led1 = !led1;
         wait(0.5);
     }
-}
+}
\ No newline at end of file
diff -r dc33cd3f4eb9 -r 87d2ef890844 mbed-os.lib
--- a/mbed-os.lib	Thu Jan 12 23:35:40 2017 +0000
+++ b/mbed-os.lib	Mon Jan 23 09:39:33 2017 +0000
@@ -1,1 +1,1 @@
-https://github.com/ARMmbed/mbed-os/#2885c1b41e63158cb6faf5f107cd821ae06ef26c
+https://github.com/ARMmbed/mbed-os/#34c1facf42a174f47fdf9002cd8c6bf10ac41744