beacon_test
Embed:
(wiki syntax)
Show/hide line numbers
main.cpp
00001 #include "mbed.h" 00002 #include "rtos.h" 00003 Serial pc(USBTX, USBRX); 00004 00005 int beacon_sc = 3; 00006 uint16_t schedcount=1; 00007 int beac_flag=0; 00008 InterruptIn sw1(PTC3); 00009 Timeout bea_timeout ; 00010 void T_SC(void const *args) 00011 { 00012 if(beac_flag==1){ 00013 printf("\n\rThe value of i in scheduler is %d\n",schedcount); } 00014 schedcount++; 00015 00016 } 00017 00018 void FUNC_BEA_TIMEOUT() 00019 { 00020 00021 beac_flag = 0; 00022 00023 } 00024 00025 void sw(){ 00026 beac_flag = 1; 00027 bea_timeout.attach(&FUNC_BEA_TIMEOUT,35.0 );} 00028 00029 void sw2(){ 00030 00031 beac_flag = 0; 00032 } 00033 00034 00035 int main(void) { 00036 RtosTimer t_sc_timer(T_SC,osTimerPeriodic); 00037 t_sc_timer.start(1000); 00038 sw1.rise(&sw); 00039 sw1.fall(&sw2); 00040 while(1) //required to prevent main from terminating 00041 { 00042 Thread::wait(10000); // this wait doesn't matter main is a thread of lowest priority 00043 } 00044 }
Generated on Wed Jul 13 2022 18:16:13 by
1.7.2