basic with comments

Dependencies:   mbed-rtos mbed

Fork of Case_Study_rtos_signals2 by cathal deehy-power

main.cpp

Committer:
cathal66
Date:
2015-05-08
Revision:
6:6263aeb45282
Parent:
5:47c0e14dbd4a

File content as of revision 6:6263aeb45282:

#include "mbed.h"
#include "rtos.h"

PwmOut led(p25);                            //setup LED for PWM

void led_thread(void const *argument) {
    while (true) {
        // Signal flags that are reported as event are automatically cleared.
        Thread::signal_wait(0x2);           //Wait for flag "0x1" to be set after thread wait for 1000 msec
        led = !led;                          //toggle the LED
    }
}

int main (void) {
    Thread thread(led_thread);              //start thread
    
    while (true) {
        Thread::wait(1000);                 //thread wait for 1000 msec
        thread.signal_set(0x2);             //set the flag for "0x1"

    }
}