Simple LED blinking RTOS application with 3 threads

Dependencies:   mbed-rtos mbed

Fork of rtos_basic by mbed official

main.cpp

Committer:
icserny
Date:
2016-01-28
Revision:
7:84b7291a746d
Parent:
3:c92e21f305d8

File content as of revision 7:84b7291a746d:

/** 09_rtos_basic
 * RTOS LED blinking example running 3 threads
 * (main and two additional threads)
 *
 * Hardware requirement:
 *  - FRDM-KL25Z board
 */

#include "mbed.h"
#include "rtos.h"
 
DigitalOut led1(LED1);
DigitalOut led2(LED2);
DigitalOut led3(LED3);
 
void led2_thread(void const *args) {
    while (true) {
        led2 = !led2;
        Thread::wait(2000);
    }
}

void led3_thread(void const *args) {
    while (true) {
        led3 = !led3;
        Thread::wait(4000);
    }
}
 
int main() {
    Thread thread2(led2_thread);
    Thread thread3(led3_thread);
        
    while (true) {
        led1 = !led1;
        Thread::wait(1000);
    }
}