From 7c12dad5dc25593b4e23ad0bc092be8cb9542167 Mon Sep 17 00:00:00 2001
From: yincheng.zhong <634916154@qq.com>
Date: 星期二, 01 十一月 2022 17:49:13 +0800
Subject: [PATCH] V1.37

---
 Src/application/dw_app.c |   27 +++++++++++++++++++++++++--
 1 files changed, 25 insertions(+), 2 deletions(-)

diff --git a/Src/application/dw_app.c b/Src/application/dw_app.c
index 6d5afed..d76461a 100644
--- a/Src/application/dw_app.c
+++ b/Src/application/dw_app.c
@@ -48,7 +48,7 @@
 #define POLL_TX_TO_RESP_RX_DLY_UUS 150
 /* This is the delay from Frame RX timestamp to TX reply timestamp used for calculating/setting the DW1000's delayed TX function. This includes the
  * frame length of approximately 2.66 ms with above configuration. */
-#define RESP_RX_TO_FINAL_TX_DLY_UUS 410
+#define RESP_RX_TO_FINAL_TX_DLY_UUS 2410
 
 /* Receive response timeout. See NOTE 5 below. */
 #define RESP_RX_TIMEOUT_UUS 600
@@ -297,6 +297,27 @@
 int16_t offset=2700;
 extern int16_t g_commap_antdelay;
 u8 motor_state,rec_remotepara_state,rec_remotepara[80];
+ double firstpath_power,firstpath_power2, rx_power,rec_firstpath_power;
+  double f1, f2, r1, r2;
+uint16_t F1,F2,F3,N,C;
+double B = 131072;
+double A = 121.74;
+double min_power;
+ dwt_rxdiag_t d1;
+double LOS(dwt_rxdiag_t *dia) {
+     F1 = dia->firstPathAmp1;
+     F2 = dia->firstPathAmp2;
+     F3 = dia->firstPathAmp3;
+     N = dia->rxPreamCount;
+     C = dia->maxGrowthCIR;
+    
+    firstpath_power=10* log10((F1*F1+F2*F2+F3*F3)/(N*N))-A;
+    rx_power=10*log10(C*B/(N*N))-A;
+
+ //   min_power =  - 10 * log10((F1 *F1 + F2 * F2 + F3 * F3) / (C *B));
+    return min_power;
+  }
+
 void NearPoll(void)
 {
 	
@@ -438,7 +459,9 @@
 									dwt_writetxfctrl(28+nearbase_num*4, 0);//设定发送数据长度
 									flag_getresponse=1;
 									memcpy(&rec_tagpos_binary,&rx_buffer[NEARMSG_EMPTYSLOTPOS_INDEX],4);
-									
+									dwt_readdiagnostics(&d1);
+                                    LOS(&d1);
+                                    tx_near_msg[TAGRXPOWER_IDX] = -(int)firstpath_power;
 								
 									//时间同步
 									ancsync_time=((sync_timer)*1000+tmp_time);	

--
Gitblit v1.9.3