![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
beacon_test
Diff: main.cpp
- Revision:
- 0:01033178af60
diff -r 000000000000 -r 01033178af60 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Mon May 18 07:06:12 2015 +0000 @@ -0,0 +1,44 @@ +#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 + } +} \ No newline at end of file