| | |
| | | uint32_t frame_len; |
| | | uint32_t final_tx_time; |
| | | u32 start_poll; |
| | | u8 i,j,getsync_flag=0,timeout; |
| | | u8 i,j,getsync_flag=0,timeout,flag_ancreadpara=0; |
| | | dwt_setrxaftertxdelay(POLL_TX_TO_RESP_RX_DLY_UUS); //设置发送后开启接收,并设定延迟时间 |
| | | dwt_setrxtimeout(10000); |
| | | tag_succ_times = 0; |
| | |
| | | |
| | | dwt_forcetrxoff(); |
| | | flag_rxon=0; |
| | | if(flag_ancreadpara) |
| | | { |
| | | u16 calCRC; |
| | | tx_near_msg[MESSAGE_TYPE_IDX] = NEAR_PRAAREPLY; |
| | | memcpy(&tx_near_msg[MESSAGE_PARAREPLY_IDX],g_com_map,SENDANCPARA_LEN); |
| | | calCRC = CRC_Compute((uint8_t*)g_com_map,SENDANCPARA_LEN); |
| | | memcpy(&tx_near_msg[MESSAGE_PARAREPLY_IDX+SENDANCPARA_LEN],&calCRC,2); |
| | | dwt_writetxdata(14+SENDANCPARA_LEN, tx_near_msg, 0);//将发送数据写入DW1000 |
| | | dwt_writetxfctrl(14+SENDANCPARA_LEN, 0);//设定发送数据长度 |
| | | } |
| | | dwt_setdelayedtrxtime(final_tx_time); |
| | | result=dwt_starttx(DWT_START_TX_DELAYED);//设定为延迟发送 |
| | | flag_finalsend=0; |
| | |
| | | resp_rx_ts = get_rx_timestamp_u64(); //获得RESPONSE接收时间T4 |
| | | recbase_num++; |
| | | memcpy(&rec_nearbaseid,&rx_buffer[ANCHOR_ID_IDX],2); |
| | | rec_remotepara_state=rx_buffer[MOTORSTATE_INDEX]>>4; |
| | | if(rec_remotepara_state==1) |
| | | rec_remotepara_state = rx_buffer[MOTORSTATE_INDEX]>>4; |
| | | if(rec_remotepara_state != 0) |
| | | { |
| | | para_update = 1; |
| | | memcpy(rec_remotepara,&rx_buffer[REMOTEPARA_INDEX],para_len); |
| | | para_update = rec_remotepara_state; |
| | | memcpy(rec_remotepara,&rx_buffer[REMOTEPARA_INDEX],7); |
| | | if(para_update==2) |
| | | { |
| | | flag_ancreadpara = 1; |
| | | } |
| | | } |
| | | if(last_nearbase_num==0) |
| | | { |
| | |
| | | { |
| | | motor_state=rx_buffer[MOTORSTATE_INDEX]; |
| | | } |
| | | final_msg_set_ts(&tx_near_msg[FINAL_MSG_RESP_RX_NEARBASE_IDX+(rec_nearbasepos)*4], resp_rx_ts); |
| | | final_msg_set_ts(&tx_near_msg[FINAL_MSG_RESP_RX_NEARBASE_IDX+(rec_nearbasepos)*4], resp_rx_ts); |
| | | |
| | | dwt_writetxdata(28+nearbase_num*4, tx_near_msg, 0);//将发送数据写入DW1000 |
| | | dwt_writetxfctrl(28+nearbase_num*4, 0);//设定发送数据长度 |
| | | |
| | |
| | | } |
| | | dwt_write32bitreg(SYS_STATUS_ID, SYS_STATUS_ALL_RX_ERR| SYS_STATUS_TXFRS |SYS_STATUS_RXFCG); |
| | | //HAL_GPIO_WritePin(LED0_GPIO, GPIO_PIN_9, GPIO_PIN_RESET); |
| | | if(para_update) |
| | | if(para_update==1) |
| | | { |
| | | uint16_t calCRC; |
| | | calCRC = CRC_Compute(rec_remotepara,5); |