From 3a5a4a7ac4e8804ea9cc8d20c3f1d1c04ca699a4 Mon Sep 17 00:00:00 2001
From: zhyinch <zhyinch@gmail.com>
Date: 星期二, 26 十一月 2019 08:39:44 +0800
Subject: [PATCH] 测距成功

---
 源码/核心板/Src/application/dw_app.h |    2 +-
 源码/核心板/Src/application/dw_app.c |   18 +++++++++---------
 2 files changed, 10 insertions(+), 10 deletions(-)

diff --git "a/\346\272\220\347\240\201/\346\240\270\345\277\203\346\235\277/Src/application/dw_app.c" "b/\346\272\220\347\240\201/\346\240\270\345\277\203\346\235\277/Src/application/dw_app.c"
index a2ebafa..6ea181d 100644
--- "a/\346\272\220\347\240\201/\346\240\270\345\277\203\346\235\277/Src/application/dw_app.c"
+++ "b/\346\272\220\347\240\201/\346\240\270\345\277\203\346\235\277/Src/application/dw_app.c"
@@ -21,7 +21,7 @@
 static uint8_t tx_sync_msg[14] = {0};
 static uint8_t tx_final_msg[60] = {0};
 static uint8_t tx_resp_msg[22] = {0};
-static uint8_t tx_near_msg[32] = {0};
+static uint8_t tx_near_msg[80] = {0};
 
 static uint32_t frame_seq_nb = 0;	
 static uint32_t status_reg = 0;
@@ -326,8 +326,8 @@
 	memcpy(&tx_near_msg[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(sizeof(tx_near_msg), tx_near_msg, 0);//将Poll包数据传给DW1000,将在开启发送时传出去
-	dwt_writetxfctrl(sizeof(tx_near_msg), 0);//设置超宽带发送数据长度
+	dwt_writetxdata(24, tx_near_msg, 0);//将Poll包数据传给DW1000,将在开启发送时传出去
+	dwt_writetxfctrl(24, 0);//设置超宽带发送数据长度
 	dwt_starttx(DWT_START_TX_IMMEDIATE | DWT_RESPONSE_EXPECTED);//开启发送,发送完成后等待一段时间开启接收,等待时间在dwt_setrxaftertxdelay中设置
 
 	neartimout_timer=0;
@@ -353,7 +353,6 @@
 								resp_rx_ts = get_rx_timestamp_u64();										//获得RESPONSE接收时间T4	
 								recbase_num++;
 								memcpy(&rec_nearbaseid,&rx_buffer[ANCHOR_ID_IDX],2);
-								rec_nearbasepos=FindNearBasePos(rec_nearbaseid);
 								if(rec_nearbaseid==mainbase_id)
 								{
 									//时间同步
@@ -378,13 +377,14 @@
 									dwt_setdelayedtrxtime(final_tx_time);//设置final包发送时间T5
 									final_tx_ts = (((uint64_t)(final_tx_time & 0xFFFFFFFE)) << 8) + TX_ANT_DLY;//final包实际发送时间是计算时间加上发送天线delay
 									final_msg_set_ts(&tx_near_msg[FINAL_MSG_POLL_TX_TS_IDX], poll_tx_ts);//将T1,T4,T5写入发送数据
-									final_msg_set_ts(&tx_near_msg[FINAL_MSG_RESP_RX_TS_IDX], resp_rx_ts);
+									final_msg_set_ts(&tx_near_msg[FINAL_MSG_RESP_RX_NEARBASE_IDX], resp_rx_ts);
 									final_msg_set_ts(&tx_near_msg[FINAL_MSG_FINAL_TX_TS_IDX], final_tx_ts);
 									tx_near_msg[MESSAGE_TYPE_IDX]=NEAR_FINAL;
-									dwt_writetxdata(sizeof(tx_near_msg), tx_near_msg, 0);//将发送数据写入DW1000
-									dwt_writetxfctrl(sizeof(tx_near_msg), 0);//设定发送数据长度
+									dwt_writetxdata(28+nearbase_num*4, tx_near_msg, 0);//将发送数据写入DW1000
+									dwt_writetxfctrl(28+nearbase_num*4, 0);//设定发送数据长度
 									result=dwt_starttx(DWT_START_TX_DELAYED);//设定为延迟发送			
 								}else{
+									rec_nearbasepos=FindNearBasePos(rec_nearbaseid);
 									final_msg_set_ts(&tx_near_msg[FINAL_MSG_RESP_RX_NEARBASE_IDX+rec_nearbasepos*4], resp_rx_ts);								
 									memcpy(&nearbase_distlist[rec_nearbasepos],&rx_buffer[DIST_IDX],4);
 									dwt_writetxdata(sizeof(tx_near_msg), tx_near_msg, 0);//将发送数据写入DW1000
@@ -599,8 +599,8 @@
 
 			memcpy(&tx_near_msg[DIST_IDX], &tagdist_list[taglist_pos], 4);
 			tx_near_msg[MESSAGE_TYPE_IDX]=NEAR_RESPONSE;
-			dwt_writetxdata(sizeof(tx_near_msg), tx_near_msg, 0);//写入发送数据
-			dwt_writetxfctrl(sizeof(tx_near_msg), 0);//设定发送长度
+			dwt_writetxdata(24, tx_near_msg, 0);//写入发送数据
+			dwt_writetxfctrl(24, 0);//设定发送长度
 			result = dwt_starttx(DWT_START_TX_DELAYED | DWT_RESPONSE_EXPECTED);//延迟发送,等待接收
 
 			battary = rx_buffer[BATTARY_IDX];
diff --git "a/\346\272\220\347\240\201/\346\240\270\345\277\203\346\235\277/Src/application/dw_app.h" "b/\346\272\220\347\240\201/\346\240\270\345\277\203\346\235\277/Src/application/dw_app.h"
index c2f91da..b7a69d9 100644
--- "a/\346\272\220\347\240\201/\346\240\270\345\277\203\346\235\277/Src/application/dw_app.h"
+++ "b/\346\272\220\347\240\201/\346\240\270\345\277\203\346\235\277/Src/application/dw_app.h"
@@ -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 400
+#define RESP_RX_TO_FINAL_TX_DLY_UUS 410
 /* Receive response timeout. See NOTE 5 below. */
 #define RESP_RX_TIMEOUT_UUS 600
 

--
Gitblit v1.9.3