| | |
| | | static uint64_t final_rx_ts; |
| | | static uint32_t status_reg = 0; |
| | | extern uint8_t tx_near_msg[80]; |
| | | static uint8_t motor_state,result; |
| | | uint8_t motor_state; |
| | | static u8 result; |
| | | static uint64_t get_tx_timestamp_u64(void) |
| | | { |
| | | uint8_t ts_tab[5]; |
| | |
| | | *ts += ts_field[i] << (i * 8); |
| | | } |
| | | } |
| | | |
| | | u8 send_buffer[100]; |
| | | #define FZ_NEARBASENUM_INDEX 10 |
| | | #define FZ_NEARBASEID_INDEX 11 |
| | | void FZNearPoll(void) |
| | |
| | | uint32_t final_tx_time; |
| | | u32 start_poll; |
| | | u8 i,j,getsync_flag=0,timeout; |
| | | dwt_setrxaftertxdelay(POLL_TX_TO_RESP_RX_DLY_UUS); //设置发送后开启接收,并设定延迟时间 |
| | | dwt_setrxaftertxdelay(10); //设置发送后开启接收,并设定延迟时间 |
| | | dwt_setrxtimeout(RESP_RX_TIMEOUT_UUS); |
| | | tag_succ_times = 0; |
| | | //GPIO_WriteBit(GPIOA, GPIO_Pin_10, Bit_SET); |
| | |
| | | nearbase_num=next_nearbase_num; |
| | | recbase_num=0; |
| | | motor_state=0; |
| | | tx_near_msg[GROUP_ID_IDX] = group_id; |
| | | tx_near_msg[BATTARY_IDX] = bat_percent; |
| | | |
| | | memcpy(&send_buffer[TAG_ID_IDX], &dev_id, 2); |
| | | send_buffer[GROUP_ID_IDX] = group_id; |
| | | send_buffer[BATTARY_IDX] = bat_percent; |
| | | //tx_near_msg[BUTTON_IDX] = !GET_USERKEY|stationary_flag<<1; |
| | | tx_near_msg[SEQUENCE_IDX] = frame_seq_nb++; |
| | | tx_near_msg[FZ_NEARBASENUM_INDEX] = nearbase_num; |
| | | memcpy(&tx_near_msg[FZ_NEARBASEID_INDEX],&nearbaseid_list,nearbase_num*2); |
| | | tx_near_msg[MESSAGE_TYPE_IDX] = NEAR_POLL; |
| | | memcpy(&tx_near_msg[ANCHOR_ID_IDX],&mainbase_id,2); |
| | | dwt_writetxdata(13+2*nearbase_num, tx_near_msg, 0);//将Poll包数据传给DW1000,将在开启发送时传出去 |
| | | dwt_writetxfctrl(13+2*nearbase_num, 0);//设置超宽带发送数据长度 |
| | | dwt_starttx(DWT_START_TX_IMMEDIATE | DWT_RESPONSE_EXPECTED);//开启发送,发送完成后等待一段时间开启接收,等待时间在dwt_setrxaftertxdelay中设置 |
| | | send_buffer[SEQUENCE_IDX] = frame_seq_nb++; |
| | | send_buffer[FZ_NEARBASENUM_INDEX] = nearbase_num; |
| | | memcpy(&send_buffer[FZ_NEARBASEID_INDEX],&nearbaseid_list,nearbase_num*2); |
| | | send_buffer[MESSAGE_TYPE_IDX] = NEAR_POLL; |
| | | memcpy(&send_buffer[ANCHOR_ID_IDX],&mainbase_id,2); |
| | | dwt_writetxdata(35, send_buffer, 0);//将Poll包数据传给DW1000,将在开启发送时传出去 |
| | | dwt_writetxfctrl(35, 0);//设置超宽带发送数据长度 |
| | | dwt_starttx(DWT_START_TX_IMMEDIATE| DWT_RESPONSE_EXPECTED);//开启发送,发送完成后等待一段时间开启接收,等待时间在dwt_setrxaftertxdelay中设置 |
| | | |
| | | tx_near_msg[TAGCONFIGSUCCESS_INDEX] =0; |
| | | para_update = 0; |
| | |
| | | |
| | | neartimout_timer = 0; |
| | | recbase_num=0; |
| | | start_count=HAL_LPTIM_ReadCounter(&hlptim1); |
| | | timeout=ceil((float)nearbase_num*SLOT_SCALE)+3; |
| | | |
| | | while(neartimout_timer<timeout) |
| | | current_count=HAL_LPTIM_ReadCounter(&hlptim1); |
| | | end_count=start_count+(timeout<<5); |
| | | if(end_count>=32768) |
| | | {end_count-=32768;} |
| | | while(current_count<end_count||current_count>end_count+15000) |
| | | { |
| | | while (!((status_reg = dwt_read32bitreg(SYS_STATUS_ID)) & (SYS_STATUS_RXFCG | SYS_STATUS_ALL_RX_ERR)))//不断查询芯片状态直到成功接收或者发生错误 |
| | | { |
| | |
| | | } |
| | | } |
| | | |
| | | if(neartimout_timer>timeout) |
| | | current_count=HAL_LPTIM_ReadCounter(&hlptim1); |
| | | if(current_count>=end_count&¤t_count<end_count+15000) |
| | | break; |
| | | }; |
| | | if(status_reg==0xffffffff) |