basic with comments

Dependencies:   mbed-rtos mbed

Fork of Case_Study_rtos_signals by cathal deehy-power

Committer:
cathal66
Date:
Fri Feb 13 14:41:31 2015 +0000
Revision:
5:47c0e14dbd4a
Parent:
1:6a8fcc666593
basic with comments

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 5:47c0e14dbd4a 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 5:47c0e14dbd4a 9 Thread::signal_wait(0x1); //Wait for flag "0x1" to be set after thread wait for 1000 msec
cathal66 5:47c0e14dbd4a 10 led = !led; //toggle the LED
emilmont 1:6a8fcc666593 11 }
emilmont 1:6a8fcc666593 12 }
emilmont 1:6a8fcc666593 13
emilmont 1:6a8fcc666593 14 int main (void) {
cathal66 5:47c0e14dbd4a 15 Thread thread(led_thread); //start thread
emilmont 1:6a8fcc666593 16
emilmont 1:6a8fcc666593 17 while (true) {
cathal66 5:47c0e14dbd4a 18 Thread::wait(1000); //thread wait for 1000 msec
cathal66 5:47c0e14dbd4a 19 thread.signal_set(0x1); //set the flag for "0x1"
cathal66 5:47c0e14dbd4a 20
emilmont 1:6a8fcc666593 21 }
emilmont 1:6a8fcc666593 22 }