4-10-2015 BAE_RTOS_TEST

Dependencies:   mbed-rtos mbed

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 Serial pc(USBTX, USBRX);
00004 
00005 Thread *ptr_t_hk;
00006 Thread *ptr_t_acs;
00007 Thread *ptr_t_bea;
00008 
00009 void T_HK(void const *args)
00010 {
00011    while(1){
00012    Thread::signal_wait(0x2);
00013    pc.printf("HK thread here\r \n");
00014    }
00015     
00016     }
00017 void T_ACS(void const *args){
00018        while(1){
00019        Thread::signal_wait(0x1);
00020        pc.printf(" ACS thread here\r \n");
00021        }
00022 }
00023 void T_BEA(void const *args){
00024        while(1){
00025        Thread::signal_wait(0x3);
00026        pc.printf("BEA thread here\r \n");
00027        }
00028 }
00029 
00030 uint8_t schedcount=1;
00031 void T_SC(void const *args)
00032 {    
00033     
00034    
00035     if(schedcount == 4)                         //to reset the counter
00036     {
00037         schedcount = 1;
00038     }
00039      pc.printf("\n\rThe value of i in scheduler is %d\n\r",schedcount);
00040     if(schedcount%1==0)
00041     {
00042         ptr_t_acs -> signal_set(0x1);
00043     }
00044     
00045     if(schedcount%2==0)
00046     {
00047         ptr_t_hk -> signal_set(0x2);
00048         
00049     }
00050     if(schedcount%3==0)
00051     {
00052     
00053            ptr_t_bea -> signal_set(0x3);
00054         
00055     }
00056     schedcount++;
00057 }
00058 
00059 
00060 
00061 
00062 int main(){
00063     ptr_t_hk = new Thread(T_HK);
00064     ptr_t_acs = new Thread(T_ACS);                    
00065     ptr_t_bea = new Thread(T_BEA);
00066     
00067     ptr_t_acs->set_priority(osPriorityAboveNormal);
00068     ptr_t_hk->set_priority(osPriorityAboveNormal);
00069     ptr_t_bea->set_priority(osPriorityAboveNormal);
00070     RtosTimer t_sc_timer(T_SC,osTimerPeriodic);               // Initiating the scheduler thread
00071     t_sc_timer.start(10000);     
00072    
00073     while(1)                                                   //required to prevent main from terminating
00074     {   
00075         ;
00076     }
00077 }