ok

Dependencies:   mbed-rtos mbed

Fork of rtos_signals by mbed official

Revision:
4:84ab1b5e8265
Parent:
1:6a8fcc666593
--- a/main.cpp	Tue Jun 04 15:54:12 2013 +0100
+++ b/main.cpp	Tue Mar 04 21:39:55 2014 +0000
@@ -1,21 +1,47 @@
 #include "mbed.h"
 #include "rtos.h"
 
-DigitalOut led(LED1);
+void        proxy_thread(void const *argument);
+DigitalOut  led1(LED1);
+DigitalOut  led2(LED2);
+InterruptIn fire(p14);
+Thread      *proxy_ptr;
 
-void led_thread(void const *argument) {
-    while (true) {
-        // Signal flags that are reported as event are automatically cleared.
-        Thread::signal_wait(0x1);
-        led = !led;
+/*
+ * PROXY thread that works with and is triggered by the ISR
+ */
+
+void proxy_thread(void const *argument) {
+    while (true) { 
+        printf("proxy - waiting for  signal \n\r");    
+        Thread::signal_wait(0x1, osWaitForever);
+        printf("proxy - got signal \n\r");
+        led1 = !led1;
     }
 }
 
+
+/*
+ * ISR - does minimal work and passes the buck to PROXY thread
+ */
+
+void ISR1() {
+    led2 = !led2;
+    proxy_ptr->signal_set(0x1);
+}
+
+
+
+
 int main (void) {
-    Thread thread(led_thread);
     
+    fire.rise(&ISR1);
+    Thread thread(proxy_thread);
+    proxy_ptr = &thread;  
+    
+    printf("main ... testing signals\n\r");
     while (true) {
         Thread::wait(1000);
-        thread.signal_set(0x1);
+        printf("main ... wait loop\n\r");
     }
 }