test RTOS

Dependencies:   mbed-rtos mbed

Files at this revision

API Documentation at this revision

Comitter:
kazu_zamasu
Date:
Wed Apr 30 18:08:44 2014 +0000
Commit message:
test

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.lib Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Wed Apr 30 18:08:44 2014 +0000
@@ -0,0 +1,56 @@
+#include "mbed.h"
+#include "rtos.h"
+ 
+DigitalOut led1(P0_29);
+DigitalOut led2(P0_9);
+Serial pc(USBTX, USBRX); // tx, rx
+
+int a=0,b=0;
+void led1_thread(void const *argument) {
+    while (true) {
+        led1 = !led1;
+        Thread::wait(500);
+    }
+}
+
+void led2_thread(void const *argument) {
+    while (true) {
+        led2 = !led2;
+        a = a + 1;
+        Thread::wait(250);
+    }
+}
+
+void print_thread(void const *argument) {
+    while (true) {
+        b = b + 1;
+        Thread::wait(500);
+    }
+}
+
+ 
+int main() {
+    Thread th1(led1_thread);
+    Thread th2(led2_thread);
+    Thread th3(print_thread);
+    pc.baud(115200);
+    while ( b < 300 ) {
+     pc.printf("\033[1;1H");
+     pc.printf("LED_Count");
+     pc.printf("\033[2;1H");
+     pc.printf("%d",a);
+     pc.printf("\033[1;15H");
+     pc.printf("b++ count");
+     pc.printf("\033[2;15H");
+     pc.printf("%d",b);
+     }
+     pc.printf("\033[1;1H");
+     pc.printf("LED_Count");
+     pc.printf("\033[2;1H");
+     pc.printf("%d",a);
+     pc.printf("\033[1;15H");
+     pc.printf("b++ count");
+     pc.printf("\033[2;15H");
+     pc.printf("%d",b);
+
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed-rtos.lib	Wed Apr 30 18:08:44 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed-rtos/#5dfe422a963d
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.lib	Wed Apr 30 18:08:44 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/#6473597d706e