From 9ff25be6f85a1dc8a04470437d6597399a45d11f Mon Sep 17 00:00:00 2001
From: WXK <287788329@qq.com>
Date: 星期五, 15 九月 2023 17:08:29 +0800
Subject: [PATCH] 1

---
 Src/application/dw_app.c |   19 +++++++++++++++----
 1 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/Src/application/dw_app.c b/Src/application/dw_app.c
index 0ac5c30..b994d8b 100644
--- a/Src/application/dw_app.c
+++ b/Src/application/dw_app.c
@@ -70,8 +70,15 @@
 #define FINAL_MSG_RESP_RX_TS_IDX 14
 #define FINAL_MSG_FINAL_TX_TS_IDX 18
 #define FINAL_MSG_TS_LEN 4
+
+//#define _UWB_4G
+
 static dwt_config_t config = {
-	5,               /* Channel number. */
+#ifdef _UWB_4G
+	2,               /* Channel number. */
+#else
+    5,
+#endif
 	DWT_PRF_64M,     /* Pulse repetition frequency. */
 	DWT_PLEN_64,    /* Preamble length. */
 	DWT_PAC8,        /* Preamble acquisition chunk size. Used in RX only. */
@@ -175,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. */
 				//设置接收超时时间
@@ -338,7 +344,11 @@
       {
 
          // exsistbase_list[i]--;
-          clockOffsetRatio = anc_clockoffset[i] * (FREQ_OFFSET_MULTIPLIER * HERTZ_TO_PPM_MULTIPLIER_CHAN_5 / 1.0e6) ;
+#ifdef _UWB_4G
+            clockOffsetRatio = anc_clockoffset[i] * (FREQ_OFFSET_MULTIPLIER * HERTZ_TO_PPM_MULTIPLIER_CHAN_2 / 1.0e6) ;
+#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_resp = anc_resptx[i] - anc_pollrx[i];
           tof = ((rtd_init - rtd_resp * (1 - clockOffsetRatio)) / 2.0) * DWT_TIME_UNITS;
@@ -424,7 +434,7 @@
 	flag_getresponse=0;
 	start_count=HAL_LPTIM_ReadCounter(&hlptim1);
 	recbase_num=0;
-	timeout=nearbase_num*SLOT_SCALE+10;
+	timeout=nearbase_num*SLOT_SCALE+50;
 	end_count=start_count+(timeout<<2);
 	if(end_count>=32768)
 	{end_count-=32768;}
@@ -432,6 +442,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)))//不断查询芯片状态直到成功接收或者发生错误

--
Gitblit v1.9.3