ok

Dependencies:   mbed-rtos mbed

Fork of rtos_signals by mbed official

Committer:
avnisha
Date:
Tue Mar 04 21:39:55 2014 +0000
Revision:
4:84ab1b5e8265
Parent:
1:6a8fcc666593
ok

Who changed what in which revision?

UserRevisionLine numberNew contents of line
emilmont 1:6a8fcc666593 1 #include "mbed.h"
emilmont 1:6a8fcc666593 2 #include "rtos.h"
emilmont 1:6a8fcc666593 3
avnisha 4:84ab1b5e8265 4 void proxy_thread(void const *argument);
avnisha 4:84ab1b5e8265 5 DigitalOut led1(LED1);
avnisha 4:84ab1b5e8265 6 DigitalOut led2(LED2);
avnisha 4:84ab1b5e8265 7 InterruptIn fire(p14);
avnisha 4:84ab1b5e8265 8 Thread *proxy_ptr;
emilmont 1:6a8fcc666593 9
avnisha 4:84ab1b5e8265 10 /*
avnisha 4:84ab1b5e8265 11 * PROXY thread that works with and is triggered by the ISR
avnisha 4:84ab1b5e8265 12 */
avnisha 4:84ab1b5e8265 13
avnisha 4:84ab1b5e8265 14 void proxy_thread(void const *argument) {
avnisha 4:84ab1b5e8265 15 while (true) {
avnisha 4:84ab1b5e8265 16 printf("proxy - waiting for signal \n\r");
avnisha 4:84ab1b5e8265 17 Thread::signal_wait(0x1, osWaitForever);
avnisha 4:84ab1b5e8265 18 printf("proxy - got signal \n\r");
avnisha 4:84ab1b5e8265 19 led1 = !led1;
emilmont 1:6a8fcc666593 20 }
emilmont 1:6a8fcc666593 21 }
emilmont 1:6a8fcc666593 22
avnisha 4:84ab1b5e8265 23
avnisha 4:84ab1b5e8265 24 /*
avnisha 4:84ab1b5e8265 25 * ISR - does minimal work and passes the buck to PROXY thread
avnisha 4:84ab1b5e8265 26 */
avnisha 4:84ab1b5e8265 27
avnisha 4:84ab1b5e8265 28 void ISR1() {
avnisha 4:84ab1b5e8265 29 led2 = !led2;
avnisha 4:84ab1b5e8265 30 proxy_ptr->signal_set(0x1);
avnisha 4:84ab1b5e8265 31 }
avnisha 4:84ab1b5e8265 32
avnisha 4:84ab1b5e8265 33
avnisha 4:84ab1b5e8265 34
avnisha 4:84ab1b5e8265 35
emilmont 1:6a8fcc666593 36 int main (void) {
emilmont 1:6a8fcc666593 37
avnisha 4:84ab1b5e8265 38 fire.rise(&ISR1);
avnisha 4:84ab1b5e8265 39 Thread thread(proxy_thread);
avnisha 4:84ab1b5e8265 40 proxy_ptr = &thread;
avnisha 4:84ab1b5e8265 41
avnisha 4:84ab1b5e8265 42 printf("main ... testing signals\n\r");
emilmont 1:6a8fcc666593 43 while (true) {
emilmont 1:6a8fcc666593 44 Thread::wait(1000);
avnisha 4:84ab1b5e8265 45 printf("main ... wait loop\n\r");
emilmont 1:6a8fcc666593 46 }
emilmont 1:6a8fcc666593 47 }