2 flags with comments

Dependencies:   mbed-rtos mbed

Fork of rtos_signals by mbed official

Committer:
cathal66
Date:
Fri Feb 13 14:36:56 2015 +0000
Revision:
4:3925b40d3296
Parent:
1:6a8fcc666593
comments added with 2 flags

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
cathal66 4:3925b40d3296 4 PwmOut led(p25); //setup LED for PWM
emilmont 1:6a8fcc666593 5
emilmont 1:6a8fcc666593 6 void led_thread(void const *argument) {
emilmont 1:6a8fcc666593 7 while (true) {
emilmont 1:6a8fcc666593 8 // Signal flags that are reported as event are automatically cleared.
cathal66 4:3925b40d3296 9 Thread::signal_wait(0x2); //Wait for flag to be set after thread wait for 2000 msec
cathal66 4:3925b40d3296 10 led = 0.5; //dim LED to half brightness
cathal66 4:3925b40d3296 11 Thread::signal_wait(0x1); //Wait for flag to be set after thread wait for 100 msec
cathal66 4:3925b40d3296 12 led = 1; //turn off LED
emilmont 1:6a8fcc666593 13 }
emilmont 1:6a8fcc666593 14 }
emilmont 1:6a8fcc666593 15
emilmont 1:6a8fcc666593 16 int main (void) {
cathal66 4:3925b40d3296 17 Thread thread(led_thread); //start thread
emilmont 1:6a8fcc666593 18
emilmont 1:6a8fcc666593 19 while (true) {
cathal66 4:3925b40d3296 20 Thread::wait(1000); //thread wait for 1000 msec
cathal66 4:3925b40d3296 21 thread.signal_set(0x1); //set the flag for "0x1"
cathal66 4:3925b40d3296 22 Thread::wait(2000); //Thread wait for 2000 msec
cathal66 4:3925b40d3296 23 thread.signal_set(0x2); //set the flag for "0x2
emilmont 1:6a8fcc666593 24 }
emilmont 1:6a8fcc666593 25 }