multi thread test(rtos)

Dependencies:   mbed-rtos mbed

Files at this revision

API Documentation at this revision

Comitter:
ryought
Date:
Mon Mar 18 06:49:19 2013 +0000
Commit message:
First commit;

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed-rtos.lib Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r 76241820e391 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Mon Mar 18 06:49:19 2013 +0000
@@ -0,0 +1,51 @@
+#include "mbed.h"
+#include "rtos.h"
+
+DigitalOut getcommand(LED1);
+Serial pc(USBTX, USBRX);
+DigitalOut leds[2] = {DigitalOut(LED2), DigitalOut(LED3)};
+DigitalOut threadled(LED4);
+
+char buf[2];
+char command[2];
+
+void led(void const *args) {
+    while(true) {
+        threadled = !threadled;
+        Thread::wait(100);
+    }
+}
+
+
+int main() {
+    Thread thread(led);
+
+    while(1) {
+    if (pc.readable()) {
+        pc.printf("something get\n");
+        buf[0] = pc.getc();
+        buf[1] = pc.getc();
+        if (buf[0] == 0xFF && buf[1] == 0xFF) {
+            getcommand = 1;
+            pc.printf("its a command!\n");
+            
+            for(int i = 0; i < 2; i++) {
+                pc.printf("mgmg\n");
+                command[i] = pc.getc();
+                pc.printf("%x\n", command[i]);
+            }
+            
+            switch (command[0]) {
+                case 0x01:
+                    leds[0] = !leds[0];
+                    pc.printf("led1 : on/off\n");
+                    break;
+                case 0x02:
+                    leds[1] = !leds[1];
+                    pc.printf("led2 : on/off\n");
+                    break;
+            }
+        }
+    }
+    }
+}
diff -r 000000000000 -r 76241820e391 mbed-rtos.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed-rtos.lib	Mon Mar 18 06:49:19 2013 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed-rtos/#53e6cccd8782
diff -r 000000000000 -r 76241820e391 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Mon Mar 18 06:49:19 2013 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/5e5da4a5990b
\ No newline at end of file