| | |
| | | static dwt_config_t config = { |
| | | 2, /* 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; |
| | |
| | | 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) |
| | | if(tagpos[taglist_pos].tagid==tag_id_recv&&userdatasend_flag[taglist_pos] == 1) |
| | | { |
| | | memcpy(&tx_nearresp_msg[TAGPOS_INDEX],&tagpos[taglist_pos],16); |
| | | memcpy(&tx_nearresp_msg[TAGPOS_INDEX],&tagpos[taglist_pos],tagpos[taglist_pos].datalen+3); |
| | | tagpossend_flag = 1; |
| | | }else{ |
| | | tagpossend_flag = 0; |
| | |
| | | memcpy(&tx_nearresp_msg[DIST_IDX], &tagdist_list[taglist_pos], 4); |
| | | 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[MESSAGE_TYPE_IDX]=POS_RESPONSE; |
| | | //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+tagpossend_flag*16, tx_nearresp_msg, 0);//д???????? |
| | | dwt_writetxfctrl(28+tagpossend_flag*16, 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) |
| | |
| | | { |
| | | return 1; |
| | | } |
| | | if (rx_buffer[MESSAGE_TYPE_IDX] == NEAR_FINAL&&!memcmp(&rx_buffer[TAG_ID_IDX],&tag_id_recv,2)) //夿æ¯å¦ä¸ºFinalå
|
| | | if (rx_buffer[MESSAGE_TYPE_IDX] == POS_FINAL&&!memcmp(&rx_buffer[TAG_ID_IDX],&tag_id_recv,2)) //夿æ¯å¦ä¸ºFinalå
|
| | | { |
| | | |
| | | resp_tx_ts = get_tx_timestamp_u64();//è·å¾responseåéæ¶é´T3 |
| | |
| | | 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; |
| | |
| | | { |
| | | 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) |
| | |
| | | SyncPoll(sync_seq); |
| | | } |
| | | break; |
| | | case NEAR_MSG: |
| | | case POS_MSG: |
| | | if(anc_id_recv==dev_id) |
| | | { |
| | | rx_buffer[TAGSLOTPOS]=taglist_pos; |
| | | tx_near_msg[MESSAGE_TYPE_IDX] = NEAR_MSG; |
| | | tx_near_msg[MESSAGE_TYPE_IDX] = POS_MSG; |
| | | memcpy(&tx_near_msg[TAG_ID_IDX],&tag_id_recv,2); |
| | | memcpy(&tx_near_msg[NEARMSG_EMPTYSLOTPOS_INDEX],&tagpos_binary,4); |
| | | ancidlist_num=g_com_map[NEARBASE_NUM]; |
| | |
| | | } |
| | | |
| | | } |
| | | if(i==MAX_REGTAGNUM) |
| | | if(i==MAX_REGTAGNUM&&g_com_map[NEARSWITCH_DISTANCE_INDEX] != 0) |
| | | { |
| | | dwt_readdiagnostics(&d1); |
| | | LOS(&d1); |
| | |
| | | UART_PushFrame(usart_send,24); |
| | | } |
| | | break; |
| | | case NEAR_POLL: |
| | | case POS_POLL: |
| | | // GPIO_WriteBit(GPIOB, GPIO_Pin_10, Bit_SET); |
| | | |
| | | memcpy(&tag_id_recv,&rx_buffer[TAG_ID_IDX],2); |
| | |
| | | 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]; |