Basic example showing the Signals API

Dependencies:   mbed-rtos mbed

mbed 2 and mbed OS 5

This is an mbed 2 example. mbed OS 5 has intergrated the mbed library with mbed-rtos. For an mbed-os example, please see:

Import programrtos_signals

signals example

Files at this revision

API Documentation at this revision

Comitter:
emilmont
Date:
Fri Jul 13 10:58:06 2012 +0000
Parent:
0:19f3d184e2ea
Child:
2:8adee3edba28
Commit message:
First implementation

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
--- a/main.cpp	Fri Jul 13 10:55:48 2012 +0000
+++ b/main.cpp	Fri Jul 13 10:58:06 2012 +0000
@@ -0,0 +1,21 @@
+#include "mbed.h"
+#include "rtos.h"
+
+DigitalOut led(LED1);
+
+void led_thread(void const *argument) {
+    while (true) {
+        // Signal flags that are reported as event are automatically cleared.
+        Thread::signal_wait(0x1);
+        led = !led;
+    }
+}
+
+int main (void) {
+    Thread thread(led_thread);
+    
+    while (true) {
+        Thread::wait(1000);
+        thread.signal_set(0x1);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed-rtos.lib	Fri Jul 13 10:58:06 2012 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed-rtos/#01158bb7600c