| | |
| | | |
| | | static uint8_t tx_near_msg[80] = {0}; |
| | | |
| | | static uint32_t frame_seq_nb = 0; |
| | | uint32_t frame_seq_nb = 0, frame_seq_nb2 = 0; |
| | | static uint32_t status_reg = 0; |
| | | static uint8_t rx_buffer[100]; |
| | | static uint64_t poll_tx_ts; |
| | |
| | | flag_rxon=1; |
| | | neartimout_timer=0; |
| | | get_newbase=0; |
| | | timeout=ceil((float)nearbase_num*0.4)+3; |
| | | timeout=ceil((float)nearbase_num*SLOT_SCALE)+3; |
| | | //timeout=5; |
| | | mainbase_dist=100000; |
| | | mainbase_lost_count++; |
| | |
| | | dwt_writetxdata(28+nearbase_num*4, tx_nearfinal_msg, 0);//å°åéæ°æ®åå
¥DW1000 |
| | | dwt_writetxfctrl(28+nearbase_num*4, 0);//设å®åéæ°æ®é¿åº¦ |
| | | memcpy(&rec_tagpos_binary,&rx_buffer[NEARMSG_EMPTYSLOTPOS_INDEX],4); |
| | | |
| | | if(temp_dist!=0x1ffff) |
| | | { |
| | | #ifndef USART_INTEGRATE_OUTPUT |
| | | usart_send[2] = 1;//æ£å¸¸æ¨¡å¼ |
| | | usart_send[3] = 17;//æ°æ®æ®µé¿åº¦ |
| | | usart_send[4] = frame_seq_nb;//æ°æ®æ®µé¿åº¦ |
| | | if(g_com_map[DEV_ROLE]) |
| | | { |
| | | memcpy(&usart_send[5],&dev_id,2); |
| | | memcpy(&usart_send[7],&rec_nearbaseid,2); |
| | | }else{ |
| | | memcpy(&usart_send[5],&rec_nearbaseid,2); |
| | | memcpy(&usart_send[7],&dev_id,2); |
| | | } |
| | | memcpy(&usart_send[9],&rx_buffer[DIST_IDX],4); |
| | | usart_send[13] = battary; |
| | | usart_send[14] = button; |
| | | 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);//设å®ä¸ºå»¶è¿åé |
| | | //dwt_writetxdata(4,&tx_near_msg[FINAL_MSG_RESP_RX_NEARBASE_IDX+(rec_nearbasepos+1)*4], FINAL_MSG_RESP_RX_NEARBASE_IDX+(rec_nearbasepos+1)*4);//å°åéæ°æ®åå
¥DW1000 |
| | | } |
| | | |
| | | |
| | | }else{ |
| | |
| | | usart_send[2] = 1;//æ£å¸¸æ¨¡å¼ |
| | | usart_send[3] = 17;//æ°æ®æ®µé¿åº¦ |
| | | usart_send[4] = frame_seq_nb;//æ°æ®æ®µé¿åº¦ |
| | | if(g_com_map[DEV_ROLE]) |
| | | { |
| | | memcpy(&usart_send[5],&dev_id,2); |
| | | memcpy(&usart_send[7],&rec_nearbaseid,2); |
| | | memcpy(&usart_send[7],&rec_nearbaseid,2); |
| | | }else{ |
| | | memcpy(&usart_send[5],&rec_nearbaseid,2); |
| | | memcpy(&usart_send[7],&dev_id,2); |
| | | } |
| | | memcpy(&usart_send[9],&rx_buffer[DIST_IDX],4); |
| | | usart_send[13] = battary; |
| | | usart_send[14] = button; |
| | | checksum = Checksum_u16(&usart_send[2],17); |
| | | memcpy(&usart_send[19],&checksum,2); |
| | | // UART_PushFrame(usart_send,21); |
| | | UART_PushFrame(usart_send,21); |
| | | #endif |
| | | |
| | | //dwt_setdelayedtrxtime(final_tx_time);//设置finalå
åéæ¶é´T5 |
| | |
| | | } |
| | | |
| | | // printf("%d,%d",temp_sync_timer2,temp_sync_timer1); |
| | | // #ifdef USART_INTEGRATE_OUTPUT |
| | | // usart_send[2] = 4;//æ£å¸¸æ¨¡å¼ |
| | | // usart_send[3] = report_num*6+2;//æ£å¸¸æ¨¡å¼ |
| | | // checksum = Checksum_u16(&usart_send[2],report_num*6+2); |
| | | // memcpy(&usart_send[4+report_num*6],&checksum,2); |
| | | // UART_PushFrame(usart_send,6+report_num*6); |
| | | // #endif |
| | | #ifdef USART_INTEGRATE_OUTPUT |
| | | usart_send[2] = 4;//æ£å¸¸æ¨¡å¼ |
| | | usart_send[3] = report_num*6+2;//æ£å¸¸æ¨¡å¼ |
| | | checksum = Checksum_u16(&usart_send[2],report_num*6+2); |
| | | memcpy(&usart_send[4+report_num*6],&checksum,2); |
| | | UART_PushFrame(usart_send,6+report_num*6); |
| | | #endif |
| | | // if(mainbase_lost_count>5) |
| | | // { |
| | | // //tag_state=DISCPOLL; |
| | |
| | | |
| | | battary = rx_buffer[BATTARY_IDX]; |
| | | button = rx_buffer[BUTTON_IDX]; |
| | | frame_seq_nb = rx_buffer[SEQUENCE_IDX]; |
| | | frame_seq_nb2 = rx_buffer[SEQUENCE_IDX]; |
| | | if(result==0) |
| | | { |
| | | while (!((status_reg = dwt_read32bitreg(SYS_STATUS_ID)) & (SYS_STATUS_RXFCG | SYS_STATUS_ALL_RX_ERR)))///䏿æ¥è¯¢è¯çç¶æç´å°æ¥æ¶æåæè
åºç°é误 |
| | |
| | | dwt_write32bitreg(SYS_STATUS_ID, SYS_STATUS_ALL_RX_ERR); |
| | | } |
| | | } |
| | | u8 misdist_num[TAG_NUM_IN_SYS],seize_anchor; |
| | | extern uint16_t configremotetagID; |
| | | extern u8 remotetag_paralen; |
| | | u8 misdist_num[TAG_NUM_IN_SYS],seize_anchor,waittagconfig_reponse; |
| | | u8 Anchor_RecNearPoll(u8 ancrec_nearbasepos) //0 mainbase 1 first near_base |
| | | { |
| | | u8 motorstate; |
| | |
| | | tx_nearresp_msg[MAINBASE_INDEX]=flag_syncbase; |
| | | tx_nearresp_msg[MESSAGE_TYPE_IDX]=NEAR_RESPONSE; |
| | | tx_nearresp_msg[MOTORSTATE_INDEX]=(remotesend_state<<4)|motorstate; |
| | | if(remotesend_state) |
| | | waittagconfig_reponse=0; |
| | | if(remotesend_state&&!memcmp(&rx_buffer[TAG_ID_IDX],&configremotetagID,2)) |
| | | { |
| | | memcpy(&tx_nearresp_msg[REMOTEPARA_INDEX],remotetag_para,REMOTEPARA_LEN); |
| | | dwt_writetxdata(22+REMOTEPARA_LEN, tx_nearresp_msg, 0);//åå
¥åéæ°æ® |
| | | dwt_writetxfctrl(22+REMOTEPARA_LEN, 0);//设å®åéé¿åº¦ |
| | | memcpy(&tx_nearresp_msg[REMOTEPARA_INDEX],remotetag_para,remotetag_paralen); |
| | | dwt_writetxdata(22+remotetag_paralen, tx_nearresp_msg, 0);//åå
¥åéæ°æ® |
| | | dwt_writetxfctrl(22+remotetag_paralen, 0);//设å®åéé¿åº¦ |
| | | waittagconfig_reponse=1; |
| | | }else{ |
| | | dwt_writetxdata(22, tx_nearresp_msg, 0);//åå
¥åéæ°æ® |
| | | dwt_writetxfctrl(22, 0);//设å®åéé¿åº¦ |
| | |
| | | |
| | | battary = rx_buffer[BATTARY_IDX]; |
| | | button = rx_buffer[BUTTON_IDX]; |
| | | frame_seq_nb = rx_buffer[SEQUENCE_IDX]; |
| | | frame_seq_nb2 = rx_buffer[SEQUENCE_IDX]; |
| | | if(result==0) |
| | | { |
| | | while (!((status_reg = dwt_read32bitreg(SYS_STATUS_ID)) & (SYS_STATUS_RXFCG | SYS_STATUS_ALL_RX_ERR))&&!g_start_sync_flag)///䏿æ¥è¯¢è¯çç¶æç´å°æ¥æ¶æåæè
åºç°é误 |
| | |
| | | dis_after_filter=dist_cm; |
| | | hex_dist = dist_cm+(int16_t)g_com_map[DIST_OFFSET]; |
| | | g_flag_Taggetdist[taglist_pos]=0; |
| | | if(hex_dist>-1000&&hex_dist<100000) |
| | | if(hex_dist>-1000&&hex_dist<200000) |
| | | { |
| | | if(abs(hex_dist-his_dist[taglist_pos])<1500||misdist_num[taglist_pos]>3) |
| | | { |
| | |
| | | #ifndef USART_INTEGRATE_OUTPUT |
| | | usart_send[2] = 1;//æ£å¸¸æ¨¡å¼ |
| | | usart_send[3] = 17;//æ°æ®æ®µé¿åº¦ |
| | | usart_send[4] = frame_seq_nb;//æ°æ®æ®µé¿åº¦ |
| | | usart_send[4] = frame_seq_nb2;//æ°æ®æ®µé¿åº¦ |
| | | memcpy(&usart_send[5],&tag_id_recv,2); |
| | | memcpy(&usart_send[7],&dev_id,2); |
| | | memcpy(&usart_send[9],&tagdist_list[taglist_pos],4); |
| | |
| | | misdist_num[taglist_pos]++; |
| | | } |
| | | } |
| | | if(rx_buffer[TAGCONFIGSUCCESS_INDEX]==1&&waittagconfig_reponse) |
| | | { |
| | | waittagconfig_reponse = 0; |
| | | remotesend_state = 0; |
| | | usart_send[2] = 7;//æ£å¸¸æ¨¡å¼ |
| | | usart_send[3] = 5;//æ°æ®æ®µé¿åº¦ |
| | | memcpy(&usart_send[4],&tag_id_recv,2); |
| | | usart_send[6] = 1;//æ°æ®æ®µé¿åº¦ |
| | | checksum = Checksum_u16(&usart_send[2],5); |
| | | memcpy(&usart_send[7],&checksum,2); |
| | | UART_PushFrame(usart_send,9); |
| | | } |
| | | } |
| | | }else{ |
| | | //printf("%x/n",status_reg); |