| | |
| | | } |
| | | |
| | | u16 tag_time_recv[TAG_NUM_IN_SYS]; |
| | | u8 usart_send[25]; |
| | | u8 usart_send[100]; |
| | | u8 battary,button; |
| | | extern uint8_t g_pairstart; |
| | | void tag_sleep_configuraion(void) |
| | |
| | | } |
| | | } |
| | | u8 anclost_times=0; |
| | | u8 exsistbase_list[MAX_NEARBASE_NUM]; |
| | | u8 exsistbase_list[MAX_NEARBASE_NUM],report_num; |
| | | void NearPoll(void) |
| | | { |
| | | static u8 mainbase_lost_count=0,flag_finalsend; |
| | |
| | | } |
| | | //nearbase_num=0; |
| | | recbase_num=0; |
| | | |
| | | tx_near_msg[BATTARY_IDX] = Get_Battary(); |
| | | tx_near_msg[BUTTON_IDX] = !READ_KEY0; |
| | | tx_near_msg[SEQUENCE_IDX] = frame_seq_nb++; |
| | |
| | | if(rec_nearbaseid==nearbaseid_list[0]) |
| | | { |
| | | //////////////////////////////////æ¶é´åæ¥ |
| | | memcpy(&sync_timer,&rx_buffer[ANCTIMEMS],2); |
| | | memcpy(&tmp_time,&rx_buffer[ANCTIMEUS],2); |
| | | exsistbase_list[0]=1; |
| | | // memcpy(&tagslotpos,&rx_buffer[TAGSLOTPOS],2); |
| | | |
| | | tmp_time=tmp_time+450; |
| | | if(tmp_time>999) |
| | | { |
| | | tmp_time-=999; |
| | | sync_timer++; |
| | | if(sync_timer>=1010) |
| | | {sync_timer=0;} |
| | | } |
| | | TIM3->CNT=tmp_time; |
| | | // memcpy(&sync_timer,&rx_buffer[ANCTIMEMS],2); |
| | | // memcpy(&tmp_time,&rx_buffer[ANCTIMEUS],2); |
| | | // exsistbase_list[0]=1; |
| | | //// memcpy(&tagslotpos,&rx_buffer[TAGSLOTPOS],2); |
| | | // |
| | | // tmp_time=tmp_time+450; |
| | | // if(tmp_time>999) |
| | | // { |
| | | // tmp_time-=999; |
| | | // sync_timer++; |
| | | // if(sync_timer>=1010) |
| | | // {sync_timer=0;} |
| | | // } |
| | | // TIM3->CNT=tmp_time; |
| | | |
| | | // if(tagslotpos>max_slotpos) |
| | | // tagslotpos=tagslotpos%(max_slotpos+1); |
| | |
| | | dwt_writetxfctrl(28+nearbase_num*4, 0);//设å®åéæ°æ®é¿åº¦ |
| | | if(temp_dist!=0x1ffff) |
| | | { |
| | | #ifndef USART_INTEGRATE_OUTPUT |
| | | usart_send[2] = 1;//æ£å¸¸æ¨¡å¼ |
| | | usart_send[3] = 17;//æ°æ®æ®µé¿åº¦ |
| | | usart_send[4] = frame_seq_nb;//æ°æ®æ®µé¿åº¦ |
| | |
| | | checksum = Checksum_u16(&usart_send[2],17); |
| | | memcpy(&usart_send[19],&checksum,2); |
| | | UART_PushFrame(usart_send,21); |
| | | #endif |
| | | } |
| | | //result=dwt_starttx(DWT_START_TX_DELAYED);//设å®ä¸ºå»¶è¿åé |
| | | }else{ |
| | |
| | | LED0_BLINK; |
| | | if(temp_dist!=0x1ffff) |
| | | { |
| | | #ifndef USART_INTEGRATE_OUTPUT |
| | | usart_send[2] = 1;//æ£å¸¸æ¨¡å¼ |
| | | usart_send[3] = 17;//æ°æ®æ®µé¿åº¦ |
| | | usart_send[4] = frame_seq_nb;//æ°æ®æ®µé¿åº¦ |
| | |
| | | checksum = Checksum_u16(&usart_send[2],17); |
| | | memcpy(&usart_send[19],&checksum,2); |
| | | UART_PushFrame(usart_send,21); |
| | | #endif |
| | | |
| | | //dwt_setdelayedtrxtime(final_tx_time);//设置finalå
åéæ¶é´T5 |
| | | // result=dwt_starttx(DWT_START_TX_DELAYED);//设å®ä¸ºå»¶è¿åé |
| | |
| | | } |
| | | } |
| | | } |
| | | report_num=0; |
| | | for (i=0;i<nearbase_num;i++) |
| | | { |
| | | nearbaseid_list[i]=true_nearbase_idlist[i]; |
| | | nearbase_distlist[i]=true_nearbase_distlist[i]; |
| | | nearbase_distlist[i]=true_nearbase_distlist[i]; |
| | | if(nearbase_distlist[i]!=0x1ffff) |
| | | { |
| | | memcpy(&usart_send[3+6*report_num],&nearbaseid_list[i],2); |
| | | memcpy(&usart_send[5+6*report_num],&nearbase_distlist[i],4); |
| | | report_num++; |
| | | } |
| | | } |
| | | #ifdef USART_INTEGRATE_OUTPUT |
| | | usart_send[2] = report_num;//æ£å¸¸æ¨¡å¼ |
| | | checksum = Checksum_u16(&usart_send[2],report_num*6+1); |
| | | memcpy(&usart_send[3+report_num*6],&checksum,2); |
| | | UART_PushFrame(usart_send,5+report_num*6); |
| | | #endif |
| | | // if(mainbase_lost_count>5) |
| | | // { |
| | | // //tag_state=DISCPOLL; |
| | |
| | | } |
| | | uint32_t frame_len; |
| | | uint32_t resp_tx_time; |
| | | uint8_t rec_nearbase_num; |
| | | uint8_t rec_nearbase_num,anc_report_num; |
| | | void Anchor_RecPoll(void) |
| | | { |
| | | tmp_time=TIM3->CNT; |
| | |
| | | { |
| | | misdist_num=0; |
| | | tagdist_list[taglist_pos] = hex_dist; |
| | | his_dist[taglist_pos]=hex_dist; |
| | | his_dist[taglist_pos]=hex_dist; |
| | | #ifndef USART_INTEGRATE_OUTPUT |
| | | usart_send[2] = 1;//æ£å¸¸æ¨¡å¼ |
| | | usart_send[3] = 17;//æ°æ®æ®µé¿åº¦ |
| | | usart_send[4] = frame_seq_nb;//æ°æ®æ®µé¿åº¦ |
| | |
| | | checksum = Checksum_u16(&usart_send[2],17); |
| | | memcpy(&usart_send[19],&checksum,2); |
| | | UART_PushFrame(usart_send,21); |
| | | #else |
| | | memcpy(&usart_send[3+6*anc_report_num],&tag_id_recv,2); |
| | | memcpy(&usart_send[5+6*anc_report_num],&tagdist_list[taglist_pos],4); |
| | | anc_report_num++; |
| | | #endif |
| | | }else{ |
| | | misdist_num++; |
| | | } |