From 724f1e7164d903eb14151bb352e483fa0b2ea0fc Mon Sep 17 00:00:00 2001
From: chen <15335560115@163.com>
Date: 星期四, 02 一月 2025 09:59:27 +0800
Subject: [PATCH] 去掉打印,恢复默认不测距下1HZ20ua左右稳定测距版本

---
 keil/include/main/main.c |   37 +++++++++++++++++++++++++++----------
 1 files changed, 27 insertions(+), 10 deletions(-)

diff --git a/keil/include/main/main.c b/keil/include/main/main.c
index 8482d1b..d18fcd3 100644
--- a/keil/include/main/main.c
+++ b/keil/include/main/main.c
@@ -61,9 +61,12 @@
 #define TEST_UART_MODE TEST_UART_DMA_MODE
 
 #define NUM_SAMPLES 1
-#define SLEEP_START_TIME 120
+#define SLEEP_START_TIME 10
+#define FREQ_LOST_TIME 5
+#define NOTAG_FREQ  1
 uint8_t enable_sleep_count,sleep_flag;
-#define DEBUG_MODE
+//#define DEBUG_MODE
+
 struct UART_CFG_T test_uart_cfg =
 {
         .parity = UART_PARITY_NONE,
@@ -109,7 +112,8 @@
 uint8_t bat_percent;
 extern uint32_t dev_id;
 extern uint8_t group_id;
-uint8_t tag_frequence;
+extern float freqlost_count;
+uint8_t tag_frequency;
 void UartDeinit(void);
 void UartInit(void);
 void Program_Init(void);
@@ -134,14 +138,25 @@
 static void sleep_timer_callback(void *dev, uint32_t time)
 {
     //sleep_timer_start(__MS_TO_32K_CNT(1000));
+	static uint8_t lost_jumpcount=0;
 		enable_sleep_count++;
 	if(enable_sleep_count==SLEEP_START_TIME){
 
 		enable_sleep_count=0;
 		sleep_flag=1;
 	}
-		g_start_send_flag=1;
-    //LOG_INFO(TRACE_MODULE_APP, "Sleep timer interrupt callback\r\n");
+//	if(freqlost_count++>FREQ_LOST_TIME)
+//	{
+//				tag_frequency = NOTAG_FREQ;
+//        if(lost_jumpcount++>=4) //无测距情况下,每5秒发一次;
+//        {
+//            lost_jumpcount = 0;
+//            g_start_send_flag=1;
+//        }
+//	}else{
+//		g_start_send_flag=1;
+//	}
+	g_start_send_flag=1;
 }
 static void adc_callback(void *data, uint32_t number)
 {
@@ -177,8 +192,8 @@
 parameter_init();//g_com_map表初始化
 group_id=g_com_map[GROUP_ID];
 memcpy(&dev_id ,&g_com_map[DEV_ID],2);
-tag_frequence=1000/g_com_map[COM_INTERVAL];	
-g_com_map[VERSION] = (1<<8)|3;
+tag_frequency=1000/g_com_map[COM_INTERVAL];	
+g_com_map[VERSION] = (1<<8)|5;
 LOG_INFO(TRACE_MODULE_APP,"设备ID: %x .\r\n",dev_id);
 LOG_INFO(TRACE_MODULE_APP,"固件版本:UWB-标签 V%d.%d. \r\n",g_com_map[VERSION]>>8,g_com_map[VERSION]&0xff);
 }
@@ -250,7 +265,7 @@
     //sys_timer_open();
 		
     gpio_open();
-    //board_led_init();
+    board_led_init();
 		
 		 //uart_open(UART_ID0, &test_uart_cfg);
 		
@@ -262,9 +277,10 @@
 		//adc_open(&usr_adc_cfg);
 		//adc_get(&sample[0], NUM_SAMPLES, adc_callback);//adc采样
     // Enable sleep timer
+		Tag_uwb_init();
     sleep_timer_open(true, SLEEP_TIMER_MODE_RELOAD, sleep_timer_callback);
 		//sleep_timer_start(__MS_TO_32K_CNT(g_com_map[COM_INTERVAL]));//测试
-		sleep_timer_start(__MS_TO_32K_CNT(500));//测试
+		sleep_timer_start(__MS_TO_32K_CNT(SLEEP_COUNT));//测试
 		//board_5V_input_init(voltage_input_handler);//有修改3.3V会一直高电平导致无法进入休眠
 		#ifdef BOXING 
 				io_pin_mux_set(IO_PIN_5, IO_FUNC0);//波形测试
@@ -279,8 +295,9 @@
 			//LOG_INFO(TRACE_MODULE_APP, "测距ing");
 			
 			g_start_send_flag = 0;
-			
+			gpio_pin_set(LED_PIN);//亮
 			TagRange();
+			gpio_pin_clr(LED_PIN);//灭
 			IdleTask();	
 			}else{
 			IdleTask();	

--
Gitblit v1.9.3