From 3a9451238daf56e5dc2f6a8a1532c650aa9120b8 Mon Sep 17 00:00:00 2001
From: yincheng.zhong <634916154@qq.com>
Date: 星期六, 22 七月 2023 11:53:50 +0800
Subject: [PATCH] 初步调通,气压能正常读取,可以定位

---
 Src/main.c |   60 +++++++++++++++++++++++++++++++++++++++++++-----------------
 1 files changed, 43 insertions(+), 17 deletions(-)

diff --git a/Src/main.c b/Src/main.c
index 10c9245..cab5e34 100644
--- a/Src/main.c
+++ b/Src/main.c
@@ -28,7 +28,7 @@
 #include "global_param.h"
 #include "TrackingDiff.h"
 #include "dw_app.h"
-
+#include "BMP390.h"
 #define NSH1 0x0001
 #define GP   0x0002
 #define DEBUG_MODE
@@ -219,6 +219,10 @@
         {
         g_com_map[STATIONARY_TIME]=10;
         }
+				if(g_com_map[NOMOVESLEEP_TIME]<120)
+				{
+					g_com_map[NOMOVESLEEP_TIME] = 120;
+				}
         
 }
 uint8_t uwb_active_flag = 0;
@@ -234,9 +238,9 @@
 	hardware_pici= STMFLASH_ReadHalfWord(FLASH_HARDWARE_VERSION_MAP+2);
 	hardware_type= STMFLASH_ReadHalfWord(FLASH_HARDWARE_VERSION_MAP+4);
 	//deca_sleep(1000);
-	g_com_map[VERSION] = (2<<8)|3;
-    
-//	g_com_map[DEV_ID]=0x7;
+	g_com_map[VERSION] = (2<<8)|2;
+  ErrorConfig_Handler();
+	//g_com_map[DEV_ID]=0x9444;
 #ifdef DEBUG_MODE
 //	g_com_map[DEV_ROLE]=1;
 	//	g_com_map[DEV_ID]=0x4009;
@@ -271,19 +275,19 @@
 	current_time=GetLPTime();
     nomovesleep_time = g_com_map[NOMOVESLEEP_TIME];
     interval = g_com_map[COM_INTERVAL];
-    if(active_flag==0)
-	{   
-        interval=1000;
-		imu_enable=1;
-		nomovesleep_time = 10;
-		motor_enable=0;
-	}
+//    if(active_flag==0)
+//	{   
+//        interval=1000;
+//		imu_enable=1;
+//		nomovesleep_time = 10;
+//		motor_enable=0;
+//	}
     tag_frequency = 1000/interval;
 		if (HAL_LPTIM_TimeOut_Start_IT(&hlptim1, LPTIMER_1S_COUNT, slot_startcount) != HAL_OK)  //system time is 1010ms   1 puls=30.518us
   {
     Error_Handler();
   }
-   printf("固件版本:SS双路定位标签-防撞基站 V%d.%d. \r\n",g_com_map[VERSION]>>8,g_com_map[VERSION]&0xff);
+   printf("固件版本:L051-嘉峪关-定位标签防撞基站 V%d.%d. \r\n",g_com_map[VERSION]>>8,g_com_map[VERSION]&0xff);
 //g_com_map[NOMOVESLEEP_TIME]=5;
 //	printf("标签ID: %d .\r\n",dev_id);
 //	printf("通讯间隔: %d ms.\r\n",g_com_map[COM_INTERVAL]);
@@ -354,6 +358,28 @@
 {
 		//SCB->AIRCR = 0X05FA0000|(unsigned int)0x04; //软复位回到bootloader   
 }
+int Pressure_Para[11],Temperature_Para[3];
+extern float Altitude;
+u8 BMP390_ID;
+u8 Config;
+void BarInit(void)
+{
+	    /*气压计*/
+
+    BMP390_ID = BMP390_Init();
+    Parameter_Reading(Pressure_Para,Temperature_Para);
+	//Judge the relevant state of the sensor
+	Config = BMP390_Read_Byte(ERR_REG_Addr);
+	if(Config&0x01) 
+    printf("Fatal Error");
+	else 
+    printf("No errors.");
+	if((Config>>1)&0x01) 
+    printf("Failed.");
+	else 
+    printf("Successful.");
+    /*气压计*/
+}
 /* USER CODE END 0 */
 
 /**
@@ -362,7 +388,7 @@
   */
 int main(void)
 {
-  /* USER CODE BEGIN 1 */
+  /* USER CODE BEGIN 1 */ 
 
   /* USER CODE END 1 */
 
@@ -385,7 +411,7 @@
   /* Initialize all configured peripherals */
   MX_GPIO_Init();
   MX_LPTIM1_Init();
-    MX_DMA_Init();
+  MX_DMA_Init();
   MX_USART1_UART_Init();
   MX_SPI1_Init();
   MX_ADC_Init();
@@ -402,10 +428,10 @@
 //	dwt_configuresleep(DWT_PRESRV_SLEEP | DWT_CONFIG, DWT_WAKE_CS | DWT_WAKE_WK| DWT_SLP_EN);
 //	dwt_entersleep();
 //	waitusart_timer=tag_frequency*USART_KEEPWAKE_TIME;;
-    dwt_setinterrupt(  DWT_INT_RFCG | (DWT_INT_ARFE | DWT_INT_RFSL | DWT_INT_SFDT | DWT_INT_RPHE | DWT_INT_RFCE | DWT_INT_RFTO | DWT_INT_RXPTO), 1);
-    dwt_setrxtimeout(0);//设定接收超时时间,0位没有
-    dwt_rxenable(0);
+
+		BarInit();
 	DW_DISABLE;
+    
 	 if(HAL_UART_Receive_DMA(&huart1,m_EUART_DMA_RXBuf,EUART_RX_BUF_SIZE))
 	{
 	 Error_Handler();

--
Gitblit v1.9.3