| | |
| | | volatile uint32_t time32_incr; |
| | | uint8_t tt=0; |
| | | uint8_t g_start_send_flag = 0,sync_seq=0,usart_send_flag; |
| | | u16 usart_timer=0; |
| | | u16 usart_timer=0,pollsendtimer=0; |
| | | uint16_t sysscal; |
| | | u16 tag_recv_timer, tag_timer; |
| | | u16 tag_recv_timer, tag_timer,last_polltime,userdata_timer; |
| | | extern uint16_t g_Resttimer,heartbeat_timer,sync_timer; |
| | | extern uint8_t g_pairstart; |
| | | u8 neartimout_timer=0; |
| | | extern u16 tyncpoll_time; |
| | | |
| | | extern uint8_t g_pairstart,getrange_success; |
| | | u8 neartimout_timer=0,flag_syncbase=0,flag_newsecond=0; |
| | | extern u16 tyncpoll_time,target_time; |
| | | extern uint32_t synclost_timer,current_syncid; |
| | | uint8_t juststart_timer=2,justselftest_timer=2,selftesttimer,rflosttimer; |
| | | extern u8 juststart_flag,justsleftest_flag,rf_flag; |
| | | void TIM3_IRQHandler(void) //TIM3?? |
| | | { |
| | | if (TIM_GetITStatus(TIM3, TIM_IT_Update) != RESET) //??TIM3???????? |
| | | { |
| | | TIM_ClearITPendingBit(TIM3, TIM_IT_Update ); //??TIMx?????? |
| | | |
| | | main_logic(); |
| | | userdata_timer++; |
| | | time32_incr++; |
| | | heartbeat_timer++; |
| | | sync_timer++; |
| | | neartimout_timer++; |
| | | if(sync_timer>=1010) |
| | | {sync_timer=0;} |
| | | neartimout_timer++; |
| | | synclost_timer++; |
| | | if(g_com_map[DEV_ROLE]||g_com_map[ANC_POLL]) |
| | | { |
| | | if(pollsendtimer++>=g_com_map[COM_INTERVAL]) |
| | | { |
| | | pollsendtimer = 0; |
| | | g_start_send_flag = 1; |
| | | } |
| | | } |
| | | //GPIO_WriteBit(GPIOA, GPIO_Pin_10, Bit_RESET); |
| | | if(sync_timer>=1000) |
| | | { |
| | | // if(getrange_success==0) |
| | | // { |
| | | // NVIC_SystemReset(); |
| | | // } |
| | | flag_newsecond=1; |
| | | //GPIO_WriteBit(GPIOA, GPIO_Pin_10, Bit_SET); |
| | | sync_timer=0; |
| | | if(juststart_timer>0) |
| | | { |
| | | juststart_timer--; |
| | | juststart_flag = 1; |
| | | }else{ |
| | | juststart_flag = 0; |
| | | } |
| | | if(justselftest_timer>0) |
| | | { |
| | | justselftest_timer--; |
| | | justsleftest_flag = 1; |
| | | }else{ |
| | | justsleftest_flag = 0; |
| | | } |
| | | if(rflosttimer>10) |
| | | { |
| | | rf_flag = 1; |
| | | }else{ |
| | | rflosttimer++; |
| | | rf_flag = 0; |
| | | } |
| | | selftesttimer++; |
| | | TagListUpdate(); |
| | | } |
| | | |
| | | if(g_Resttimer++>2000) |
| | | if(g_Resttimer++>10000) |
| | | { |
| | | //NVIC_SystemReset(); |
| | | } |
| | |
| | | { |
| | | tag_recv_timer++; |
| | | TagDistClear(); |
| | | if(g_com_map[ALARM_DEV]!=0) |
| | | main_logic(); |
| | | #ifdef USART_INTEGRATE_OUTPUT |
| | | if(usart_timer++>=g_com_map[COM_INTERVAL]) |
| | | if(g_com_map[ANC_POLL]) |
| | | { |
| | | usart_timer=0; |
| | | if(sync_timer==target_time) |
| | | { |
| | | // g_start_send_flag=1; |
| | | } |
| | | } |
| | | |
| | | #ifdef USART_INTEGRATE_OUTPUT |
| | | if(sync_timer%g_com_map[COM_INTERVAL]==0) |
| | | { |
| | | |
| | | usart_send_flag=1; |
| | | } |
| | | #endif |
| | |
| | | { |
| | | sync_seq=0xff; |
| | | } |
| | | |
| | | if(sync_timer==0) |
| | | if(synclost_timer>SYNCLOST_TIME) |
| | | { |
| | | TagListUpdate(); |
| | | if(dev_id==0) |
| | | SyncPoll(0); |
| | | flag_syncbase=1; |
| | | } |
| | | }else{ //鏍囩鍚屾澶勭悊 |
| | | if((sync_timer-10)%g_com_map[COM_INTERVAL]==tyncpoll_time&&sync_timer>=10) |
| | | |
| | | if(flag_syncbase) //鏈ā鍧楁槸鍚屾鍩虹珯 |
| | | { |
| | | GPIO_WriteBit(GPIOA, GPIO_Pin_9, Bit_SET); |
| | | g_start_send_flag=1; |
| | | if(sync_timer==995) |
| | | { |
| | | current_syncid = g_com_map[DEV_ID]; |
| | | sync_seq=0; |
| | | SyncPoll(sync_seq,current_syncid); |
| | | } |
| | | } |
| | | }else{ //鏍囩鍚屾澶勭悊 |
| | | if(sync_timer==target_time) |
| | | { |
| | | |
| | | last_polltime=sync_timer; |
| | | // GPIO_WriteBit(GPIOA, GPIO_Pin_9, Bit_SET); |
| | | // g_start_send_flag=1; |
| | | } |
| | | |
| | | } |
| | |
| | | // } |
| | | |
| | | } |
| | | void HardFalut_Handler(void) |
| | | { |
| | | while(1) |
| | | { |
| | | NVIC_SystemReset(); |
| | | } |
| | | |
| | | } |
| | | |