From 7abf818c189ba751b9c21110890b95b9a1881188 Mon Sep 17 00:00:00 2001
From: yincheng.zhong <634916154@qq.com>
Date: 星期五, 19 一月 2024 15:06:54 +0800
Subject: [PATCH] lora+UWB测距调通,一基站3标签,丢包率1%

---
 Src/main.c |   32 ++++++++++++++++----------------
 1 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/Src/main.c b/Src/main.c
index 1fce106..3f79808 100644
--- a/Src/main.c
+++ b/Src/main.c
@@ -38,7 +38,7 @@
 #define NSH1 0x0001
 #define GP   0x0002
 #define FLASH_HARDWARE_VERSION_MAP		(uint32_t)0x08004F00    //硬件版本号和批次信息位置
-//#define DEBUG_MODE
+#define DEBUG_MODE
 /* USER CODE END Includes */
 
 /* Private typedef -----------------------------------------------------------*/
@@ -216,6 +216,7 @@
 	__HAL_LPTIM_COMPARE_SET(&hlptim1, lpcount);
 
 }
+
 u8 active_flag,nomovesleeptime;
 void Program_Init(void)
 {	float temp;
@@ -228,6 +229,7 @@
 	hardware_type = STMFLASH_ReadHalfWord(FLASH_HARDWARE_VERSION_MAP+4);
 	//deca_sleep(1000);
 	g_com_map[VERSION] = (1<<8)|0;
+    testprogram();
 //    g_com_map[DEV_ID]=0x6777;
     #ifdef DEBUG_MODE
    // g_com_map[GROUP_ID]=21;
@@ -437,11 +439,11 @@
     LED_LG_ON;
     Program_Init();
     //	LIS3DH_Data_Init();	
-//    Uwb_Lora_Switch(1,0);
+    //    Uwb_Lora_Switch(1,0);
     Dw1000_Init();
     Dw1000_App_Init();
     Delay_Ms(10);
-//    Uwb_Lora_Switch(0,0);
+    // Uwb_Lora_Switch(0,0);
     //	HardWareTypeDiffConfig();
     dwt_configuresleep(DWT_PRESRV_SLEEP | DWT_CONFIG, DWT_WAKE_CS | DWT_WAKE_WK| DWT_SLP_EN);
     dwt_entersleep();
@@ -450,7 +452,7 @@
     {
      Error_Handler();
     }
-    HAL_Delay(2000);
+    HAL_Delay(1500);
 
     Lora_Init();
 
@@ -475,18 +477,16 @@
         memcpy(&TX_Buffer+3,&tx_num,1);
 //        printf("Lora发送%d",tx_num);
         HAL_GPIO_WritePin(GPIOA, GPIO_PIN_15, GPIO_PIN_SET);
-        poll_startcount=HAL_LPTIM_ReadCounter(&hlptim1);
-        poll_startcount=poll_startcount+557;//557代表17ms
-        if(poll_startcount>=32768)
-		{
-		poll_startcount -=32768;
-		}
+//        poll_startcount=HAL_LPTIM_ReadCounter(&hlptim1);
+//        poll_startcount=poll_startcount+557;//557代表17ms
+//        if(poll_startcount>=32768)
+//		{
+//            poll_startcount -=32768;
+//		}
 	    Radio.Send( &TX_Buffer, 4);
-
-        tx_num++;
-        delay_ms(3);
-
-
+        HAL_GPIO_WritePin(GPIOB, GPIO_PIN_12, GPIO_PIN_SET);
+        UWB_Wkup();
+        delay_us(700);
 		if(bat_percent>15)
 		{	
           LED_TB_ON;
@@ -953,7 +953,7 @@
     freqlost_count+=1/(float)tag_frequency;
     range_lost_time +=1/(float)tag_frequency;
 //    g_start_send_flag=1;
-    if(freqlost_count>FREQ_LOST_TIME)
+    if(0)//freqlost_count>FREQ_LOST_TIME)
     {
         tag_frequency = NOTAG_FREQ;
         if(lost_jumpcount++>=10) //无测距情况下,每5秒发一次;

--
Gitblit v1.9.3