LED with mutex protect

Dependencies:   C12832 LM75B mbed-rtos mbed

Fork of Case_Study_rtos_basic_Mutex_LED by cathal deehy-power

Committer:
cathal66
Date:
Thu Feb 12 22:54:35 2015 +0000
Revision:
7:10edddb7f1a8
Parent:
3:c92e21f305d8
Child:
8:0f773a5937f0
Basic RTOS thread running

Who changed what in which revision?

UserRevisionLine numberNew contents of line
cathal66 7:10edddb7f1a8 1 #include "mbed.h" //Include the mbed.h file
cathal66 7:10edddb7f1a8 2 #include "rtos.h" //include the RTOS.h file
emilmont 1:491820ee784d 3
cathal66 7:10edddb7f1a8 4 DigitalOut led1(LED1); //Setup LED1 to the varible name led1
cathal66 7:10edddb7f1a8 5 DigitalOut led2(LED2); //Setup LED2 to the varible name led2
emilmont 1:491820ee784d 6
cathal66 7:10edddb7f1a8 7 void led2_thread(void const *args) { //Function or the thread to be called
cathal66 7:10edddb7f1a8 8 while (true) { //Super loop
cathal66 7:10edddb7f1a8 9 led2 = !led2; //Toggle led2
cathal66 7:10edddb7f1a8 10 Thread::wait(1000); //Thread wait 1 sec
cathal66 7:10edddb7f1a8 11 } //End Super loop
cathal66 7:10edddb7f1a8 12 } //End Function / thread
emilmont 1:491820ee784d 13
cathal66 7:10edddb7f1a8 14 int main() { //Main
cathal66 7:10edddb7f1a8 15 Thread thread(led2_thread); //Setup led2_thread as a thread with the name "thread"
emilmont 1:491820ee784d 16
cathal66 7:10edddb7f1a8 17 while (true) { //Super loop
cathal66 7:10edddb7f1a8 18 led1 = !led1; //Toggle led1
cathal66 7:10edddb7f1a8 19 Thread::wait(500); //thread wait 500msec
cathal66 7:10edddb7f1a8 20 } //End super loop
cathal66 7:10edddb7f1a8 21 } //End main