basic with comments

Dependencies:   mbed-rtos mbed

Fork of Case_Study_rtos_signals2 by cathal deehy-power

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 #include "rtos.h"
00003 
00004 PwmOut led(p25);                            //setup LED for PWM
00005 
00006 void led_thread(void const *argument) {
00007     while (true) {
00008         // Signal flags that are reported as event are automatically cleared.
00009         Thread::signal_wait(0x2);           //Wait for flag "0x1" to be set after thread wait for 1000 msec
00010         led = !led;                          //toggle the LED
00011     }
00012 }
00013 
00014 int main (void) {
00015     Thread thread(led_thread);              //start thread
00016     
00017     while (true) {
00018         Thread::wait(1000);                 //thread wait for 1000 msec
00019         thread.signal_set(0x2);             //set the flag for "0x1"
00020 
00021     }
00022 }