From 2fa2c5d4c6f576fd7a3ff8a96243eacebef6f4b1 Mon Sep 17 00:00:00 2001
From: WXK <287788329@qq.com>
Date: 星期三, 24 一月 2024 18:40:02 +0800
Subject: [PATCH] 暂时性提交

---
 Src/main.c |  105 ++++++++++++++++++++++++----------------------------
 1 files changed, 49 insertions(+), 56 deletions(-)

diff --git a/Src/main.c b/Src/main.c
index abab4af..51401ce 100644
--- a/Src/main.c
+++ b/Src/main.c
@@ -17,7 +17,6 @@
   ******************************************************************************
   */
 /* USER CODE END Header */
-
 /* Includes ------------------------------------------------------------------*/
 #include "main.h"
 
@@ -58,7 +57,7 @@
 /* USER CODE END PM */
 
 /* Private variables ---------------------------------------------------------*/
-ADC_HandleTypeDef hadc;
+ ADC_HandleTypeDef hadc;
 
 IWDG_HandleTypeDef hiwdg;
 
@@ -77,11 +76,11 @@
 /* Private function prototypes -----------------------------------------------*/
 void SystemClock_Config(void);
 static void MX_GPIO_Init(void);
-static void MX_LPTIM1_Init(void);
-static void MX_USART1_UART_Init(void);
-static void MX_SPI1_Init(void);
-void MX_ADC_Init(void);
+static void MX_ADC_Init(void);
 static void MX_DMA_Init(void);
+static void MX_LPTIM1_Init(void);
+static void MX_SPI1_Init(void);
+static void MX_USART1_UART_Init(void);
 static void MX_IWDG_Init(void);
 /* USER CODE BEGIN PFP */
 
@@ -101,6 +100,10 @@
 extern uint8_t module_power;
 extern float nomove_count;
 uint8_t imu_enable,motor_enable;	
+void READC_Init(void)
+{
+MX_ADC_Init();
+}
 u16 GetLPTime(void)
 {
 	u16 count=HAL_LPTIM_ReadCounter(&hlptim1);
@@ -429,12 +432,12 @@
 
   /* Initialize all configured peripherals */
   MX_GPIO_Init();
-  MX_LPTIM1_Init();
-  MX_DMA_Init();
-  MX_USART1_UART_Init();
-  MX_SPI1_Init();
   MX_ADC_Init();
-  MX_IWDG_Init();
+  MX_DMA_Init();
+  MX_LPTIM1_Init();
+  MX_SPI1_Init();
+  MX_USART1_UART_Init();
+//  MX_IWDG_Init();
   /* USER CODE BEGIN 2 */
     LED_LG_ON;
     Program_Init();
@@ -454,8 +457,8 @@
     }
     HAL_Delay(1500);
 
-    Lora_Init();
-
+//    Lora_Init();
+SwitchLoraSettingstest(469000000,7);
     Delay_Ms(10);
   /* USER CODE END 2 */
 
@@ -485,14 +488,15 @@
 		if(bat_percent>15)
 		{	
           LED_TB_ON;
-			Tag_App();
+//			Tag_App();
 			LED_TB_OFF;
 		}else{
 			LED_TR_ON;
-			Tag_App();
+//			Tag_App();
 			LED_TR_OFF;		
 		}
-
+        test1();
+        
 		//LED0_BLINK;		
 		IdleTask();	
 		if(waitusart_timer>0)
@@ -536,11 +540,14 @@
   /** Configure the main internal regulator output voltage
   */
   __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1);
+
   /** Configure LSE Drive Capability
   */
   HAL_PWR_EnableBkUpAccess();
-  __HAL_RCC_LSEDRIVE_CONFIG(RCC_LSEDRIVE_HIGH);
-  /** Initializes the CPU, AHB and APB busses clocks
+  __HAL_RCC_LSEDRIVE_CONFIG(RCC_LSEDRIVE_LOW);
+
+  /** Initializes the RCC Oscillators according to the specified parameters
+  * in the RCC_OscInitTypeDef structure.
   */
   RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI|RCC_OSCILLATORTYPE_LSI
                               |RCC_OSCILLATORTYPE_LSE;
@@ -556,7 +563,8 @@
   {
     Error_Handler();
   }
-  /** Initializes the CPU, AHB and APB busses clocks
+
+  /** Initializes the CPU, AHB and APB buses clocks
   */
   RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK
                               |RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2;
@@ -584,7 +592,7 @@
   * @param None
   * @retval None
   */
-void MX_ADC_Init(void)
+static void MX_ADC_Init(void)
 {
 
   /* USER CODE BEGIN ADC_Init 0 */
@@ -596,6 +604,7 @@
   /* USER CODE BEGIN ADC_Init 1 */
 
   /* USER CODE END ADC_Init 1 */
+
   /** Configure the global features of the ADC (Clock, Resolution, Data Alignment and number of conversion)
   */
   hadc.Instance = ADC1;
@@ -619,6 +628,7 @@
   {
     Error_Handler();
   }
+
   /** Configure for the selected ADC regular channel to be converted.
   */
   sConfig.Channel = ADC_CHANNEL_VREFINT;
@@ -826,15 +836,7 @@
 
   /*Configure GPIO pin Output Level */
   HAL_GPIO_WritePin(GPIOA, DW_WKUP_Pin|DW_CTRL_Pin|LED2_G_Pin, GPIO_PIN_RESET);
-  //////////////////////////////////
-  HAL_GPIO_WritePin(GPIOA, GPIO_PIN_15, GPIO_PIN_RESET);
-  //////////////////////////////////
-  GPIO_InitStruct.Pin = GPIO_PIN_15;
-  GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
-  GPIO_InitStruct.Pull = GPIO_NOPULL;
-  GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
-  HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
-  
+
   /*Configure GPIO pin : PA0 */
   GPIO_InitStruct.Pin = GPIO_PIN_0;
   GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING;
@@ -843,7 +845,7 @@
 
   /*Configure GPIO pins : SCL_Pin SDA_Pin */
   GPIO_InitStruct.Pin = SCL_Pin|SDA_Pin;
-  GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_OD;
+  GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
   GPIO_InitStruct.Pull = GPIO_NOPULL;
   GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
   HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
@@ -855,16 +857,18 @@
   GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
   HAL_GPIO_Init(SPI_CS_GPIO_Port, &GPIO_InitStruct);
 
-  /*Configure GPIO pin : BAT_MEAS_GND_Pin */
-  GPIO_InitStruct.Pin = BAT_MEAS_GND_Pin;
-  GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_OD;
+  /*Configure GPIO pins : BAT_MEAS_GND_Pin PB10 LED1_G_Pin LED1_R_Pin
+                           RADIO_nRESET_Pin RADIO_NSS_Pin PB7 PWR_CTL_Pin */
+  GPIO_InitStruct.Pin = BAT_MEAS_GND_Pin|GPIO_PIN_10|LED1_G_Pin|LED1_R_Pin
+                          |RADIO_nRESET_Pin|RADIO_NSS_Pin|GPIO_PIN_7|PWR_CTL_Pin;
+  GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
   GPIO_InitStruct.Pull = GPIO_NOPULL;
   GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
-  HAL_GPIO_Init(BAT_MEAS_GND_GPIO_Port, &GPIO_InitStruct);
+  HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
 
   /*Configure GPIO pin : USER_KEY_Pin */
   GPIO_InitStruct.Pin = USER_KEY_Pin;
-  GPIO_InitStruct.Mode = GPIO_MODE_IT_FALLING;
+  GPIO_InitStruct.Mode = GPIO_MODE_EVT_FALLING;
   GPIO_InitStruct.Pull = GPIO_PULLUP;
   HAL_GPIO_Init(USER_KEY_GPIO_Port, &GPIO_InitStruct);
 
@@ -873,15 +877,6 @@
   GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
   GPIO_InitStruct.Pull = GPIO_NOPULL;
   HAL_GPIO_Init(RADIO_BUSY_GPIO_Port, &GPIO_InitStruct);
-
-  /*Configure GPIO pins : PB10 LED1_G_Pin LED1_R_Pin RADIO_nRESET_Pin
-                           RADIO_NSS_Pin PB7 PWR_CTL_Pin */
-  GPIO_InitStruct.Pin = GPIO_PIN_10|LED1_G_Pin|LED1_R_Pin|RADIO_nRESET_Pin
-                          |RADIO_NSS_Pin|GPIO_PIN_7|PWR_CTL_Pin;
-  GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
-  GPIO_InitStruct.Pull = GPIO_NOPULL;
-  GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
-  HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
 
   /*Configure GPIO pin : INPUT_5V_Pin */
   GPIO_InitStruct.Pin = INPUT_5V_Pin;
@@ -948,17 +943,17 @@
     freqlost_count+=1/(float)tag_frequency;
     range_lost_time +=1/(float)tag_frequency;
 //    g_start_send_flag=1;
-    if(0)//freqlost_count>FREQ_LOST_TIME)
-    {
-        tag_frequency = NOTAG_FREQ;
-        if(lost_jumpcount++>=10) //无测距情况下,每5秒发一次;
-        {
-            lost_jumpcount = 0;
-            g_start_send_flag=1;
-        }
-    }else{
+//    if(freqlost_count>FREQ_LOST_TIME)
+//    {
+//        tag_frequency = NOTAG_FREQ;
+//        if(lost_jumpcount++>=0) //无测距情况下,每5秒发一次;
+//        {
+//            lost_jumpcount = 0;
+//            g_start_send_flag=1;
+//        }
+//    }else{
         g_start_send_flag=1;
-    }
+//    }
     if(range_lost_time<1||freqlost_count>FREQ_LOST_TIME)
     {
         SetNextPollTime(0);
@@ -1017,5 +1012,3 @@
   /* USER CODE END 6 */
 }
 #endif /* USE_FULL_ASSERT */
-
-/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

--
Gitblit v1.9.3