From 7c93e39f66f75e445ddb224de1ce70ce6e0b0902 Mon Sep 17 00:00:00 2001
From: WXK <287788329@qq.com>
Date: 星期二, 26 三月 2024 17:51:12 +0800
Subject: [PATCH] V1.13

---
 Src/application/dw_ancapp.c |   23 ++++++++++++++---------
 1 files changed, 14 insertions(+), 9 deletions(-)

diff --git a/Src/application/dw_ancapp.c b/Src/application/dw_ancapp.c
index 2f5f250..3b0a160 100644
--- a/Src/application/dw_ancapp.c
+++ b/Src/application/dw_ancapp.c
@@ -180,6 +180,7 @@
 u16 basesystimer,uwb_losttimer;
 uint8_t remotesend_state,remotesend_index;
 uint16_t random_time;
+u32 value;
 uint8_t Anchor_RecNearPoll(uint8_t ancrec_nearbasepos) //0 mainbase  1 first near_base
 {
     uint8_t motorstate;
@@ -195,10 +196,10 @@
     if(rec_nearbase_num == ancrec_nearbasepos)//抢占模式
     {
         random_time = (GetLPTime()%100);
-        	resp_tx_time = (poll_rx_ts+((random_time+rec_nearbase_num*20 + POLL_RX_TO_RESP_TX_DLY_UUS+ancrec_nearbasepos*DELAY_BETWEEN_TWO_FRAME_UUS) * UUS_TO_DWT_TIME)) >> 8;//计算Response发送时间T3。
+        	resp_tx_time = (poll_rx_ts+((/*value+*/random_time+rec_nearbase_num*20 + POLL_RX_TO_RESP_TX_DLY_UUS+ancrec_nearbasepos*DELAY_BETWEEN_TWO_FRAME_UUS) * UUS_TO_DWT_TIME)) >> 8;//计算Response发送时间T3。
   
     }else{
-  			resp_tx_time = (poll_rx_ts + ((rec_nearbase_num*20+POLL_RX_TO_RESP_TX_DLY_UUS+ancrec_nearbasepos*DELAY_BETWEEN_TWO_FRAME_UUS) * UUS_TO_DWT_TIME)) >> 8;//计算Response发送时间T3。
+  			resp_tx_time = (poll_rx_ts + ((/*value+ */rec_nearbase_num*20+POLL_RX_TO_RESP_TX_DLY_UUS+ancrec_nearbasepos*DELAY_BETWEEN_TWO_FRAME_UUS) * UUS_TO_DWT_TIME)) >> 8;//计算Response发送时间T3。
     }
             dwt_setdelayedtrxtime(resp_tx_time);//设置Response发送时间T3
 			//dwt_setrxaftertxdelay(RESP_TX_TO_FINAL_RX_DLY_UUS+(rec_nearbase_num+1-ancrec_nearbasepos)*DELAY_BETWEEN_TWO_FRAME_UUS);//设置发送完成后开启接收延迟时间
@@ -229,19 +230,21 @@
 //               result = dwt_starttx(DWT_START_TX_DELAYED);
 ////               uwb_timeout = 0;
 //               if(result == 0)
+//               {
              uwb_timeout=lp_time;
-               while (!((status_reg = dwt_read32bitreg(SYS_STATUS_ID)) & (SYS_STATUS_TXFRS | SYS_STATUS_ALL_RX_ERR)))///不断查询芯片状态直到接收成功或者出现错误
+               while (!((status_reg = dwt_read32bitreg(SYS_STATUS_ID)) & SYS_STATUS_TXFRS ))///不断查询芯片状态直到接收成功或者出现错误
 			{
 
-                        current_time=HAL_LPTIM_ReadCounter(&hlptim1);
-        if(current_time>end_time+((32768/1000)*3)/*||current_time<end_time+15000*/)
-        { 
-//        printf("debug2 timec:%d timee:%d\r\n",current_time,end_time);
-        break;}
+//                        current_time=HAL_LPTIM_ReadCounter(&hlptim1);
+//        if(current_time>end_time+((32768/1000)*3)||current_time<end_time+15000)
+//        { 
+////        printf("debug2 timec:%d timee:%d\r\n",current_time,end_time);
+//        break;}
                     if(lp_time-uwb_timeout>2)
                         break;
             };
-            dwt_rxenable(0);
+//        }
+//            dwt_rxenable(0);
 
 }
 
@@ -357,6 +360,7 @@
                         Lora_tx_ancid[Lora_tx_ancnum]=tag_id_recv;
                         Lora_tx_ancdist[Lora_tx_ancnum]=rec_ancdistlist[i];
                         Lora_tx_anc_electricity[Lora_tx_ancnum]=battary;
+//                        printf("接收到uwb测距:%d",Lora_tx_ancdist[0]);
                         Lora_tx_ancnum++;
                         RX_TIMEOUTs_UWB++;
                      }
@@ -411,6 +415,7 @@
 						break;
 					}						
 				}
+                
 					if(i==rec_nearbase_num)
 					{
 						seize_anchor=1;   //抢占anchor

--
Gitblit v1.9.3