From b473b9e6b3a511358d127d5c8d3b56e42ab41bfc Mon Sep 17 00:00:00 2001 From: WXK <287788329@qq.com> Date: 星期三, 27 九月 2023 11:08:29 +0800 Subject: [PATCH] 1 --- Src/application/dw_app.c | 21 ++++++++++++--------- 1 files changed, 12 insertions(+), 9 deletions(-) diff --git a/Src/application/dw_app.c b/Src/application/dw_app.c index ffaba58..4b11118 100644 --- a/Src/application/dw_app.c +++ b/Src/application/dw_app.c @@ -71,7 +71,7 @@ #define FINAL_MSG_FINAL_TX_TS_IDX 18 #define FINAL_MSG_TS_LEN 4 -#define _UWB_4G +//#define _UWB_4G static dwt_config_t config = { #ifdef _UWB_4G @@ -182,7 +182,6 @@ /* Apply default antenna delay value. See NOTE 1 below. */ dwt_setrxantennadelay(RX_ANT_DLY); //设置接收天线延迟 dwt_settxantennadelay(TX_ANT_DLY); //设置发射天线延迟 - /* Set expected response's delay and timeout. See NOTE 4 and 5 below. * As this example only handles one incoming frame with always the same delay and timeout, those values can be set here once for all. */ //设置接收超时时间 @@ -350,7 +349,7 @@ #else clockOffsetRatio = anc_clockoffset[i] * (FREQ_OFFSET_MULTIPLIER * HERTZ_TO_PPM_MULTIPLIER_CHAN_5 / 1.0e6) ; #endif - rtd_init = tag_resprx[i] - poll_tx_ts; + rtd_init = tag_resprx[i] - poll_tx_ts&0xffffffff; rtd_resp = anc_resptx[i] - anc_pollrx[i]; tof = ((rtd_init - rtd_resp * (1 - clockOffsetRatio)) / 2.0) * DWT_TIME_UNITS; distance = tof * SPEED_OF_LIGHT; @@ -391,6 +390,7 @@ }; } +u16 numceshi; float range_lost_time = 0; u16 rec_nearbaseid,rec_nearbasepos; void NearPoll(void) @@ -399,8 +399,8 @@ uint32_t temp1,temp2,dw_systime; uint32_t frame_len; uint32_t final_tx_time; - u32 start_poll; - u8 i,j,getsync_flag=0,timeout,flag_ancreadpara=0; + u32 start_poll,timeout; + u8 i,j,getsync_flag=0,flag_ancreadpara=0; dwt_setrxaftertxdelay(POLL_TX_TO_RESP_RX_DLY_UUS); //设置发送后开启接收,并设定延迟时间 dwt_setrxtimeout(0); tag_succ_times = 0; @@ -426,7 +426,7 @@ dwt_writetxdata(13+4*nearbase_num, tx_near_msg, 0);//将Poll包数据传给DW1000,将在开启发送时传出去 dwt_writetxfctrl(13+4*nearbase_num, 0);//设置超宽带发送数据长度 dwt_starttx(DWT_START_TX_IMMEDIATE | DWT_RESPONSE_EXPECTED);//开启发送,发送完成后等待一段时间开启接收,等待时间在dwt_setrxaftertxdelay中设置 - + numceshi++; tx_near_msg[TAGCONFIGSUCCESS_INDEX] =0; para_update = 0; get_newbase = 0; @@ -435,7 +435,7 @@ flag_getresponse=0; start_count=HAL_LPTIM_ReadCounter(&hlptim1); recbase_num=0; - timeout=nearbase_num*SLOT_SCALE+10; + timeout=nearbase_num*SLOT_SCALE+20; //单位0.1ms end_count=start_count+(timeout<<2); if(end_count>=32768) {end_count-=32768;} @@ -443,6 +443,7 @@ mainbase_lost_count++; current_count=HAL_LPTIM_ReadCounter(&hlptim1); while(current_count<end_count||current_count>end_count+15000) + // while(1) { current_count=HAL_LPTIM_ReadCounter(&hlptim1); while (!((status_reg = dwt_read32bitreg(SYS_STATUS_ID)) & (SYS_STATUS_RXFCG | SYS_STATUS_ALL_RX_ERR)))//不断查询芯片状态直到成功接收或者发生错误 @@ -486,12 +487,14 @@ frame_len = dwt_read32bitreg(RX_FINFO_ID) & RX_FINFO_RXFLEN_MASK; //获得接收到的数据长度 dwt_readrxdata(rx_buffer, frame_len, 0); //读取接收数据 test2 = dwt_readcarrierintegrator(); + poll_tx_ts = get_tx_timestamp_u64(); //获得POLL发送时间T1 + resp_rx_ts = get_rx_timestamp_u64(); dwt_setrxtimeout(0);//DELAY_BETWEEN_TWO_FRAME_UUS*(nearbase_num+1-recbase_num)+10);//设定接收超时时间,0位没有超时时间 dwt_rxenable(0);//打开接收 if (rx_buffer[MESSAGE_TYPE_IDX] == MBX_RESPONSE&&!memcmp(&rx_buffer[TAG_ID_IDX],&dev_id,2)&&rx_buffer[GROUP_ID_IDX]==group_id) //判断接收到的数据是否是response数据 { - poll_tx_ts = get_tx_timestamp_u64(); //获得POLL发送时间T1 - resp_rx_ts = get_rx_timestamp_u64(); //获得RESPONSE接收时间T4 +// poll_tx_ts = get_tx_timestamp_u64(); //获得POLL发送时间T1 +// 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; -- Gitblit v1.9.3