From 5c6608fc16627430bcdbaf4917c608e61b7db77c Mon Sep 17 00:00:00 2001
From: yincheng.zhong <634916154@qq.com>
Date: 星期一, 24 四月 2023 10:26:57 +0800
Subject: [PATCH] 初步测试完成

---
 Src/application/dw_app.c |   39 ++++++++++++++++++++++++++++-----------
 1 files changed, 28 insertions(+), 11 deletions(-)

diff --git a/Src/application/dw_app.c b/Src/application/dw_app.c
index 71a1b17..9ab3192 100644
--- a/Src/application/dw_app.c
+++ b/Src/application/dw_app.c
@@ -76,9 +76,9 @@
 	DISCPOLL,
 	GETNEARMSG,
 	NEARPOLL,
-}tag_state=GETNEARMSG;
+}tag_state=NEARPOLL;
 static dwt_config_t config = {
-	2,               /* Channel number. */
+	5,               /* Channel number. */
 	DWT_PRF_64M,     /* Pulse repetition frequency. */
 	DWT_PLEN_128,    /* Preamble length. */
 	DWT_PAC8,        /* Preamble acquisition chunk size. Used in RX only. */
@@ -171,6 +171,16 @@
      * For initialisation, DW1000 clocks must be temporarily set to crystal speed. After initialisation SPI rate can be increased for optimum
      * performance. */
     Reset_DW1000();//重启DW1000 /* Target specific drive of RSTn line into DW1000 low for a period. */
+	Spi_ChangePrescaler(SPIx_PRESCALER_SLOW);	//设置为快速模式
+    dwt_initialise(DWT_LOADUCODE);//初始化DW1000
+    dwt_configcontinuousframemode(124800);
+	dwt_writetxfctrl(13, 0);
+	dwt_starttx(DWT_START_TX_IMMEDIATE);
+	while(GET_USERKEY)
+	{		
+			IdleTask();	
+	}
+   Reset_DW1000();//重启DW1000 /* Target specific drive of RSTn line into DW1000 low for a period. */
 	Spi_ChangePrescaler(SPIx_PRESCALER_SLOW);	//设置为快速模式
     dwt_initialise(DWT_LOADUCODE);//初始化DW1000
 	Spi_ChangePrescaler(SPIx_PRESCALER_FAST);	//设置为快速模式
@@ -295,7 +305,10 @@
 u8 nearbase_num=0,last_nearbase_num,next_nearbase_num,last_slotnum, para_update,para_len,stationary_flag=0;
 u32 rec_tagpos_binary;
 int16_t offset=2700;
+extern int16_t g_commap_antdelay;
 u8 motor_state,rec_remotepara_state,rec_remotepara[80];
+u8 flag_uwbrange_ok;
+int32_t uwb_dist;
 void NearPoll(void)
 {
 	
@@ -324,9 +337,10 @@
 	tx_near_msg[NEARBASENUM_INDEX] = nearbase_num;
 	memcpy(&tx_near_msg[NEARBASEID_INDEX],&nearbaseid_list,nearbase_num*2);
 	tx_near_msg[MESSAGE_TYPE_IDX] = NEAR_POLL;	
+    memcpy(&tx_near_msg[NEARBASEID_INDEX+nearbase_num*4],&g_commap_antdelay,2);
 	memcpy(&tx_near_msg[ANCHOR_ID_IDX],&mainbase_id,2);	
-	dwt_writetxdata(13+2*nearbase_num, tx_near_msg, 0);//将Poll包数据传给DW1000,将在开启发送时传出去
-	dwt_writetxfctrl(13+2*nearbase_num, 0);//设置超宽带发送数据长度
+	dwt_writetxdata(15+4*nearbase_num, tx_near_msg, 0);//将Poll包数据传给DW1000,将在开启发送时传出去
+	dwt_writetxfctrl(15+4*nearbase_num, 0);//设置超宽带发送数据长度
 	dwt_starttx(DWT_START_TX_IMMEDIATE | DWT_RESPONSE_EXPECTED);//开启发送,发送完成后等待一段时间开启接收,等待时间在dwt_setrxaftertxdelay中设置
 	
 	tx_near_msg[TAGCONFIGSUCCESS_INDEX] =0;
@@ -414,6 +428,9 @@
 									exsistbase_list[rec_nearbasepos]=KEEP_TIMES;
 									memcpy(&temp_dist,&rx_buffer[DIST_IDX],4);
 									nearbase_distlist[rec_nearbasepos]=temp_dist;
+                                    if(temp_dist!=0x1ffff)
+                                    {flag_uwbrange_ok = 1;
+                                    uwb_dist = temp_dist;}
 									if((rx_buffer[MOTORSTATE_INDEX]&0xf)!=3)
 										motor_state=rx_buffer[MOTORSTATE_INDEX]&0xf;
 									rec_remotepara_state=rx_buffer[MOTORSTATE_INDEX]>>4;
@@ -564,13 +581,13 @@
 				}
 			}
             #ifdef USART_INTEGRATE_OUTPUT	
-                usart_send[0] = 0x55;     
-                usart_send[1] = 0xAA;              
-				usart_send[2] = 4;//正常模式
-				usart_send[3] = report_num*6+2;//正常模式
-				checksum = Checksum_u16(&usart_send[2],report_num*6+2);
-				memcpy(&usart_send[4+report_num*6],&checksum,2);
-				USART_puts(usart_send,6+report_num*6);
+//                usart_send[0] = 0x55;     
+//                usart_send[1] = 0xAA;              
+//				usart_send[2] = 4;//正常模式
+//				usart_send[3] = report_num*6+2;//正常模式
+//				checksum = Checksum_u16(&usart_send[2],report_num*6+2);
+//				memcpy(&usart_send[4+report_num*6],&checksum,2);
+//				USART_puts(usart_send,6+report_num*6);
 			#endif
             
 			for(i=0;i<MAX_NEARBASE_NUM;i++)

--
Gitblit v1.9.3