From 2e872c0c712d5ea0cb9eccb84291fba9c39265a8 Mon Sep 17 00:00:00 2001
From: yincheng.zhong <634916154@qq.com>
Date: 星期二, 30 五月 2023 12:47:30 +0800
Subject: [PATCH] 1

---
 Src/main.c |   29 +++++++++++++++++++----------
 1 files changed, 19 insertions(+), 10 deletions(-)

diff --git a/Src/main.c b/Src/main.c
index aaada68..8073697 100644
--- a/Src/main.c
+++ b/Src/main.c
@@ -31,7 +31,7 @@
 
 #define NSH1 0x0001
 #define GP   0x0002
-#define DEBUG_MODE
+//#define DEBUG_MODE
 /* USER CODE END Includes */
 
 /* Private typedef -----------------------------------------------------------*/
@@ -137,6 +137,7 @@
 u16 current_time;
 float motor5s_timer=1000;
 uint8_t state5v,motorskip_flag;
+extern uint8_t outside_count;
 void IdleTask(void)
 {
 	
@@ -158,22 +159,22 @@
     //motor_state = 1;
 if(g_com_map[MOTOR_ENABLE])
 {
-    static u8 motor5s_state = 0,outside_count=0;
+   static u8 motor5s_state = 0;
     if(motorskip_flag==0)
     {
         if(motor_state==2)
         { 
-            outside_count =0;
+            
             if(motor5s_state)
             {
-                if(motor5s_timer>4)
+                if(motor5s_timer>2)
                 {
                     motor5s_timer = 0;
                     motor5s_state = 0;
                     JianXieMotorProcess();
                 }
             }else{           
-                if(motor5s_timer>300)
+                if(motor5s_timer>30)
                 {
                     motor5s_timer = 0;
                     motor5s_state = 1;
@@ -181,14 +182,14 @@
                 } 
             }
         }else{
-            if(outside_count++>3)
+            if(outside_count>3&&motor5s_state)
             {
-                motor5s_state = 1;
+                motor5s_state = 0;
                 motor5s_timer = 0;  
             }                
         }
     }else{
-        if(motor5s_timer>7200)  //2个小时 7200
+        if(motor5s_timer>7200)  //2??? 7200
         {
            motorskip_flag = 0;
            motor5s_timer = 1000; 
@@ -314,7 +315,7 @@
 	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)|8;
+	g_com_map[VERSION] = (2<<8)|15;
     
 //	g_com_map[DEV_ID]=0x7;
 #ifdef DEBUG_MODE
@@ -447,6 +448,7 @@
   MX_ADC_Init();
   //MX_TIM2_Init();
   /* USER CODE BEGIN 2 */
+  printf("启动时间:%d\r\n",HAL_GetTick());
 	LED_LG_ON;
 	Program_Init();
 	Accelerometer_Init();	
@@ -544,7 +546,7 @@
   /** Configure LSE Drive Capability
   */
   HAL_PWR_EnableBkUpAccess();
-  __HAL_RCC_LSEDRIVE_CONFIG(RCC_LSEDRIVE_LOW);
+  __HAL_RCC_LSEDRIVE_CONFIG(RCC_LSEDRIVE_HIGH);
   /** Initializes the RCC Oscillators according to the specified parameters
   * in the RCC_OscInitTypeDef structure.
   */
@@ -971,6 +973,7 @@
     tagslotpos = current_slotpos%200;
     flag_tagnewpos = 0;
 }
+uint16_t motorkeeptime_u16,last_motorkeep;
 float lptimedelay=0;
 void HAL_LPTIM_CompareMatchCallback(LPTIM_HandleTypeDef *hlptim)
 {
@@ -1002,6 +1005,12 @@
 	if(motor_keeptime>0)
 	{	
         motor_keeptime-=lptimedelay;
+        motorkeeptime_u16 = motor_keeptime;
+        if(motorkeeptime_u16%3==0&&motorkeeptime_u16!=last_motorkeep)
+        {
+            last_motorkeep=motorkeeptime_u16;
+            JianXieMotorProcess();
+        }
 	}
     if(motor_keeptime<0)
     {motor_keeptime = 0;}

--
Gitblit v1.9.3