beacon_test

Dependencies:   mbed-rtos mbed

main.cpp

Committer:
gkumar
Date:
2015-05-18
Revision:
0:01033178af60

File content as of revision 0:01033178af60:

#include "mbed.h"
#include "rtos.h"
Serial pc(USBTX, USBRX);

int beacon_sc = 3;
uint16_t schedcount=1;
int beac_flag=0;
InterruptIn sw1(PTC3);
Timeout bea_timeout ;
void T_SC(void const *args)
{
    if(beac_flag==1){
         printf("\n\rThe value of i in scheduler is %d\n",schedcount); }
     schedcount++;
    
    }
    
void FUNC_BEA_TIMEOUT()
{
  
  beac_flag = 0;
  
}

void sw(){
    beac_flag = 1;
    bea_timeout.attach(&FUNC_BEA_TIMEOUT,35.0 );}
    
void sw2(){

    beac_flag = 0;
   }
    

int main(void) {
RtosTimer t_sc_timer(T_SC,osTimerPeriodic);
t_sc_timer.start(1000);
sw1.rise(&sw);
sw1.fall(&sw2);
while(1)                                                   //required to prevent main from terminating
    {   
        Thread::wait(10000);                        // this wait doesn't matter main is a thread of lowest priority 
       }
}