4 thread with comments

Dependencies:   C12832 LM75B mbed-rtos mbed

Fork of rtos_basic by mbed official

main.cpp

Committer:
cathal66
Date:
2015-02-13
Revision:
10:8635af078e7c
Parent:
9:b4346bf47dd7
Child:
11:530ae198e5f2

File content as of revision 10:8635af078e7c:

#include "mbed.h"                       //Include the mbed.h file   
#include "rtos.h"                       //include the RTOS.h file
#include "LM75B.h"
#include "C12832.h"

C12832 lcd(p5, p7, p6, p8, p11);

Serial pc(USBTX,USBRX);

PwmOut LED_red(p23);
PwmOut LED_blue(p25);

DigitalOut led1(LED1);                  //Setup LED1 to the varible name led1
DigitalOut led2(LED2);                  //Setup LED2 to the varible name led2

Mutex LED_B_Mutex;
Mutex LED_R_Mutex;
 
void led_dim(void const *args) {   //Function or the thread to be called
    while (true) {                      //Super loop
        LED_B_Mutex.lock();
        LED_R_Mutex.lock();
        LED_red = 1;  
        LED_blue = 0.5;  
        Thread::wait(800);
        LED_B_Mutex.unlock();  
        LED_R_Mutex.unlock();                    
 
        LED_B_Mutex.lock();
        LED_R_Mutex.lock();
        LED_red = 0.5;  
        LED_blue = 1;  
        Thread::wait(800);
        LED_B_Mutex.unlock();  
        LED_R_Mutex.unlock();             
    }                                   //End Super loop
}  
 
void led_R_B_flash(void const *args) {   //Function or the thread to be called
    while (true) {                      //Super loop
    
        LED_R_Mutex.lock();
        LED_B_Mutex.lock();
        LED_red = 0;  
        LED_blue = 1;  
        Thread::wait(800);
        LED_R_Mutex.unlock();  
        LED_B_Mutex.unlock();                    
 
        LED_R_Mutex.lock();
        LED_B_Mutex.lock();
        LED_red = 1;  
        LED_blue = 0;  
        Thread::wait(800);
        LED_R_Mutex.unlock();  
        LED_B_Mutex.unlock();              
    }                                   //End Super loop
}                                       //End Function / thread
 
int main() {                            //Main
    Thread thread_LED_Flash(led_R_B_flash);       
    Thread thread_LED_dim(led_dim);     
    
        while (1) {

            printf("Hello_World\r\n");           
            Thread::wait(5000);
        }

    
}                                       //End main