mbed RTOS Timer

Files at this revision

API Documentation at this revision

Comitter:
rkuo2000
Date:
Thu Oct 20 12:50:58 2016 +0000
Commit message:
mbed RTOS Timer

Changed in this revision

.gitignore Show annotated file Show diff for this revision Revisions of this file
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 000000000000 -r e29211fd226e .gitignore
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/.gitignore	Thu Oct 20 12:50:58 2016 +0000
@@ -0,0 +1,4 @@
+.build
+.mbed
+projectfiles
+*.py*
diff -r 000000000000 -r e29211fd226e main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Thu Oct 20 12:50:58 2016 +0000
@@ -0,0 +1,26 @@
+#include "mbed.h"
+#include "rtos.h"
+
+DigitalOut LED[4] = {
+    DigitalOut(PD_8), // rgbled_B
+    DigitalOut(PD_9), // rgbled_R
+    DigitalOut(PA_4), // rgbled_G
+    DigitalOut(PG_0)  // greenled
+};
+
+void blink(void const *n) { 
+    LED[(int)n] = !LED[(int)n];
+}
+
+int main() {
+    RtosTimer led_1_timer(blink, osTimerPeriodic, (void *)0);
+    RtosTimer led_2_timer(blink, osTimerPeriodic, (void *)1);
+    RtosTimer led_3_timer(blink, osTimerPeriodic, (void *)2);
+    RtosTimer led_4_timer(blink, osTimerPeriodic, (void *)3);
+        
+    led_1_timer.start(2000);
+    led_2_timer.start(1000);
+    led_3_timer.start(500);
+    led_4_timer.start(250);
+    Thread::wait(osWaitForever);
+}
diff -r 000000000000 -r e29211fd226e mbed-os.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed-os.lib	Thu Oct 20 12:50:58 2016 +0000
@@ -0,0 +1,1 @@
+https://github.com/ARMmbed/mbed-os/#a6f3fd1a60d5df59246d7caf3f108c4d34e1808e