| | |
| | | NEARPOLL, |
| | | }tag_state=GETNEARMSG; |
| | | static dwt_config_t config = { |
| | | 2, /* Channel number. */ |
| | | 3, /* Channel number. */ |
| | | DWT_PRF_64M, /* Pulse repetition frequency. */ |
| | | DWT_PLEN_64, /* Preamble length. */ |
| | | DWT_PLEN_128, /* Preamble length. */ |
| | | DWT_PAC8, /* Preamble acquisition chunk size. Used in RX only. */ |
| | | 9, /* TX preamble code. Used in TX only. */ |
| | | 9, /* RX preamble code. Used in RX only. */ |
| | |
| | | static uint8_t tx_final_msg[60] = {0}; |
| | | static uint8_t tx_resp_msg[22] = {0}; |
| | | static uint8_t tx_nearpoll_msg[80] = {0}; |
| | | static uint8_t tx_nearresp_msg[80] = {0}; |
| | | static uint8_t tx_nearresp_msg[90] = {0}; |
| | | static uint8_t tx_nearfinal_msg[80] = {0}; |
| | | |
| | | static uint8_t tx_near_msg[80] = {0}; |
| | |
| | | dwt_write32bitreg(SYS_STATUS_ID, SYS_STATUS_RXFCG | SYS_STATUS_TXFRS);//æ¸
æ¥æ å¿ä½ |
| | | frame_len = dwt_read32bitreg(RX_FINFO_ID) & RX_FINFO_RXFLEN_MASK;//æ°æ®é¿åº¦ |
| | | dwt_readrxdata(rx_buffer, frame_len, 0);//è¯»åæ¥æ¶æ°æ® |
| | | if (rx_buffer[MESSAGE_TYPE_IDX] == FINAL&&!memcmp(&rx_buffer[TAG_ID_IDX],&tag_id_recv,2)) //夿æ¯å¦ä¸ºFinalå
|
| | | if (rx_buffer[MESSAGE_TYPE_IDX] == DISCOVERFINAL&&!memcmp(&rx_buffer[TAG_ID_IDX],&tag_id_recv,2)) //夿æ¯å¦ä¸ºFinalå
|
| | | { |
| | | uint32_t poll_tx_ts, resp_rx_ts, final_tx_ts; |
| | | uint32_t poll_rx_ts_32, resp_tx_ts_32, final_rx_ts_32; |
| | |
| | | } |
| | | uint32_t time_monitor[10]; |
| | | extern uint16_t configremotetagID; |
| | | extern u8 remotetag_paralen; |
| | | extern u8 remotetag_paralen,userdatasend_flag[TAG_NUM_IN_SYS]; |
| | | u8 finalsend=0; |
| | | u16 signalpower_list[TAG_NUM_IN_SYS]; |
| | | uint32_t poll_tx_ts, resp_rx_ts, final_tx_ts; |
| | |
| | | double Ra, Rb, Da, Db; |
| | | int64_t tof_dtu; |
| | | u32 errortimes,goodtimes; |
| | | u8 tagpossend_flag; |
| | | u8 Anchor_RecNearPoll(u8 ancrec_nearbasepos) //0 mainbase 1 first near_base |
| | | { |
| | | |
| | |
| | | dwt_setrxaftertxdelay(RESP_TX_TO_FINAL_RX_DLY_UUS+(rec_nearbase_num+1-ancrec_nearbasepos)*DELAY_BETWEEN_TWO_FRAME_UUS);//设置åé宿åå¼å¯æ¥æ¶å»¶è¿æ¶é´ |
| | | dwt_setrxtimeout(FINAL_RX_TIMEOUT_UUS);//æ¥æ¶è¶
æ¶æ¶é´ |
| | | //dwt_readdiagnostics(&d1); |
| | | |
| | | if(tagpos[taglist_pos].tagid==tag_id_recv&&userdatasend_flag[taglist_pos] == 1) |
| | | { |
| | | memcpy(&tx_nearresp_msg[TAGPOS_INDEX],&tagpos[taglist_pos],tagpos[taglist_pos].datalen+3); |
| | | tagpossend_flag = 1; |
| | | }else{ |
| | | tagpossend_flag = 0; |
| | | } |
| | | if(new_tagid) |
| | | { |
| | | tagdist_list[taglist_pos]=0x1ffff; |
| | |
| | | memcpy(&tx_nearresp_msg[ANC_SIGNALPOWER],&signalpower_list[taglist_pos],2); |
| | | tx_nearresp_msg[MAINBASE_INDEX]=flag_syncbase; |
| | | tx_nearresp_msg[MESSAGE_TYPE_IDX]=NEAR_RESPONSE; |
| | | tx_nearresp_msg[MOTORSTATE_INDEX]=(remotesend_state<<4)|motorstate; |
| | | //tx_nearresp_msg[MOTORSTATE_INDEX]=(remotesend_state<<4)|motorstate; |
| | | waittagconfig_reponse=0; |
| | | finalsend = 0; |
| | | if(pwtag.remain_time>0) |
| | |
| | | if(finalsend == 0) |
| | | { |
| | | memcpy(&tx_nearresp_msg[MAXRANGE_DISTANCE],&g_com_map[MAXRANGDIST_INDEX],2); |
| | | dwt_writetxdata(28, tx_nearresp_msg, 0);//åå
¥åéæ°æ® |
| | | dwt_writetxfctrl(28, 0);//设å®åéé¿åº¦ |
| | | dwt_writetxdata(28+tagpossend_flag*(tagpos[taglist_pos].datalen+3), tx_nearresp_msg, 0);//д???????? |
| | | dwt_writetxfctrl(28+tagpossend_flag*(tagpos[taglist_pos].datalen+3), 0);//?Ú
??????? |
| | | } |
| | | |
| | | // if(remotesend_state&&tag_id_recv==configremotetagID) |
| | |
| | | LED0_BLINK; //æ¯æå䏿¬¡é讯åéªç䏿¬¡ |
| | | dis_after_filter=dist_cm; |
| | | hex_dist = dist_cm+(int16_t)g_com_map[DIST_OFFSET]; |
| | | |
| | | userdatasend_flag[taglist_pos] =0; |
| | | if(hex_dist>-1000&&hex_dist<200000) |
| | | { |
| | | g_flag_Taggetdist[taglist_pos]=0; |
| | |
| | | g_Tagdist[taglist_pos]=hex_dist; |
| | | signalpower_list[taglist_pos] = ((uint8_t)firstpath_power<<8)|(uint8_t)((rx_power-firstpath_power)*10); |
| | | // #ifndef USART_INTEGRATE_OUTPUT |
| | | // usart_send[2] = 1;//æ£å¸¸æ¨¡å¼ |
| | | // usart_send[3] = 17;//æ°æ®æ®µé¿åº¦ |
| | | // 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); |
| | | // usart_send[13] = battary; |
| | | // usart_send[14] = button; |
| | | // usart_send[15] = firstpath_power; |
| | | // usart_send[16] = (rx_power-firstpath_power)*10; |
| | | // usart_send[17] = tag_frequency; |
| | | // usart_send[18] = tag_slotpos; |
| | | // checksum = Checksum_u16(&usart_send[2],17); |
| | | // memcpy(&usart_send[19],&checksum,2); |
| | | // // UART_PushFrame(usart_send,21); |
| | | usart_send[2] = 1;//æ£å¸¸æ¨¡å¼ |
| | | usart_send[3] = 17;//æ°æ®æ®µé¿åº¦ |
| | | 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); |
| | | usart_send[13] = battary; |
| | | usart_send[14] = button; |
| | | usart_send[15] = firstpath_power; |
| | | usart_send[16] = (rx_power-firstpath_power)*10; |
| | | usart_send[17] = tag_frequency; |
| | | usart_send[18] = tag_slotpos; |
| | | checksum = Checksum_u16(&usart_send[2],17); |
| | | memcpy(&usart_send[19],&checksum,2); |
| | | //UART_PushFrame(usart_send,21); |
| | | // #else |
| | | // memcpy(&usart_send_anc[4+6*anc_report_num],&tag_id_recv,2); |
| | | // memcpy(&usart_send_anc[6+6*anc_report_num],&tagdist_list[taglist_pos],4); |
| | |
| | | { |
| | | uint16_t checksum; |
| | | case DISCOVERPOLL: |
| | | if (anchor_type == rx_buffer[ANCHOR_ID_IDX]) |
| | | if (anchor_type == rx_buffer[ANCHOR_ID_IDX]&&g_com_map[NEARSWITCH_DISTANCE_INDEX] != 0) |
| | | { |
| | | taglist_pos=CmpTagInList(tag_id_recv); |
| | | if(taglist_pos==taglist_num) |
| | |
| | | } |
| | | |
| | | } |
| | | if(i==MAX_REGTAGNUM) |
| | | if(i==MAX_REGTAGNUM&&g_com_map[NEARSWITCH_DISTANCE_INDEX] != 0) |
| | | { |
| | | dwt_readdiagnostics(&d1); |
| | | LOS(&d1); |
| | |
| | | memcpy(&recnearbaselist_id,&rx_buffer[NEARBASEID_INDEX],rec_nearbase_num*2); |
| | | memcpy(&recnearbaselist_dist,&rx_buffer[NEARBASEID_INDEX+rec_nearbase_num*2],rec_nearbase_num*4+4); |
| | | memcpy(&rec_taganc_signalpower_list,&rx_buffer[NEARBASEID_INDEX+rec_nearbase_num*6+4],rec_nearbase_num*2+2); |
| | | if(anc_id_recv == dev_id ) |
| | | if(anc_id_recv == dev_id||g_com_map[OUTPUTALLNEARPOLLMSG] == 1 ) |
| | | { |
| | | usart_send[2] = 0x0c;//æ£å¸¸æ¨¡å¼ |
| | | usart_send[2] = 0x0c;//æ£å¸¸æ¨¡å¼ |
| | | usart_send[3] = 15+8*(rec_nearbase_num+1);//æ°æ®æ®µé¿åº¦ |
| | | memcpy(&usart_send[4],&tag_id_recv,2); |
| | | usart_send[6] = rx_buffer[SEQUENCE_IDX]; |