From 8e405075a9bc14ee38bfece2a410ee7d28dd306c Mon Sep 17 00:00:00 2001
From: zhyinch <zhyinch@gmail.com>
Date: 星期日, 21 十月 2018 16:48:44 +0800
Subject: [PATCH] 解决开机读不到IDbug

---
 源码/核心板/Src/application/dw_app.c |   25 +++++++++++++++++++------
 1 files changed, 19 insertions(+), 6 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 2499fa3..450a384 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"
@@ -30,7 +30,8 @@
 #include "Usart.h"
 #include "global_param.h"
 #include "filters.h"
-
+#include <stdio.h>
+#include "beep.h"
 
 
 /*------------------------------------ Marcos ------------------------------------------*/
@@ -82,7 +83,7 @@
 /*------------------------------------ Variables ------------------------------------------*/
 /* Default communication configuration. We use here EVK1000's default mode (mode 3). */
 static dwt_config_t config = {
-	5,               /* Channel number. */
+	2,               /* Channel number. */
 	DWT_PRF_64M,     /* Pulse repetition frequency. */
 	DWT_PLEN_128,    /* Preamble length. */
 	DWT_PAC8,        /* Preamble acquisition chunk size. Used in RX only. */
@@ -263,7 +264,7 @@
 }
 void Dw1000_App_Init(void)
 {
-	g_com_map[DEV_ID]=0x03;
+//	g_com_map[DEV_ID] = 0x02;
 	tx_poll_msg[MESSAGE_TYPE_IDX]=POLL;
 	tx_resp_msg[MESSAGE_TYPE_IDX]=RESPONSE;
 	tx_final_msg[MESSAGE_TYPE_IDX]=FINAL;
@@ -277,12 +278,15 @@
 	dwt_configuresleep(0x940, 0x7);
 	dwt_entersleep();
 }
+uint16_t g_Resttimer;
 uint8_t result;
 void Tag_App(void)//发送模式(TAG标签)
 {
 	uint32_t frame_len;
 	uint32_t final_tx_time;
 	
+	g_Resttimer=0;
+	UART_CheckReceive();
 	GPIO_ResetBits(SPIx_GPIO, SPIx_CS);
 	delay_us(2500);
 	GPIO_SetBits(SPIx_GPIO, SPIx_CS);
@@ -372,7 +376,7 @@
 	dwt_entersleep();
 	
 }
-uint16_t g_Resttimer;
+extern uint8_t g_pairstart;
 void Anchor_App(void)
 {
 	uint32_t frame_len;
@@ -388,7 +392,6 @@
 	while (!((status_reg = dwt_read32bitreg(SYS_STATUS_ID)) & (SYS_STATUS_RXFCG | SYS_STATUS_ALL_RX_ERR)))//不断查询芯片状态直到接收成功或者出现错误
 	{ 
 		UART_CheckReceive();
-		UART_CheckSend();
 		g_Resttimer=0;
 	};
 
@@ -412,7 +415,7 @@
 		tx_resp_msg[TAG_ID_IDX] = tag_id_recv;
 
 		
-		if (rx_buffer[MESSAGE_TYPE_IDX] == POLL) //判断是否是poll包数据
+		if (rx_buffer[MESSAGE_TYPE_IDX] == POLL&&tag_id_recv!= g_com_map[PAIR_ID]) //判断是否是poll包数据
 		{
 			/* Retrieve poll reception timestamp. */
 			poll_rx_ts = get_rx_timestamp_u64();//获得Poll包接收时间T2
@@ -494,7 +497,17 @@
 					g_UWB_com_interval = 0;
 					dis_after_filter=dist_cm;
 					g_Tagdist[tag_id_recv]=dist_cm;
+					if(g_pairstart==1&&dist_cm<20)
+					{
+						g_pairstart=0;
+						g_com_map[PAIR_ID]=tag_id_recv;
+						save_com_map_to_flash();
+						BEEP2_ON;
+						delay_ms(1000);
+						printf("Pair Finish PairID: %d. \r\n",g_com_map[PAIR_ID]);
+					}
 					g_flag_Taggetdist[tag_id_recv]=0;
+					printf("Anchor ID: %d, Tag ID: %d, Dist = %d cm\n", g_com_map[DEV_ID], tag_id_recv, (uint16_t)dis_after_filter);
 					//dis_after_filter = LP_Frac_Update(p_Dis_Filter, dist_cm);
 
 				}

--
Gitblit v1.9.3