From 4b0f6f4a2e83d9e56364e12cd2855eb1ff21d38a Mon Sep 17 00:00:00 2001
From: yincheng.zhong <634916154@qq.com>
Date: 星期六, 20 五月 2023 11:22:41 +0800
Subject: [PATCH] 2

---
 Src/main.c |   33 +++++++++++++++++++++------------
 1 files changed, 21 insertions(+), 12 deletions(-)

diff --git a/Src/main.c b/Src/main.c
index 3ef08be..7b6cd75 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,11 +159,12 @@
     //motor_state = 1;
 if(g_com_map[MOTOR_ENABLE])
 {
-    static u8 motor5s_state = 0;
+   static u8 motor5s_state = 0;
     if(motorskip_flag==0)
     {
-        if(motor_state==1)
+        if(motor_state==2)
         { 
+            
             if(motor5s_state)
             {
                 if(motor5s_timer>4)
@@ -180,11 +182,14 @@
                 } 
             }
         }else{
-            motor5s_state = 1;
-            motor5s_timer = 0;     
+            if(outside_count>3)
+            {
+                motor5s_state = 0;
+                motor5s_timer = 900;  
+            }                
         }
     }else{
-        if(motor5s_timer>7200)  //2个小时 7200
+        if(motor5s_timer>7200)  //2??? 7200
         {
            motorskip_flag = 0;
            motor5s_timer = 1000; 
@@ -310,12 +315,12 @@
 	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)|4;
+	g_com_map[VERSION] = (2<<8)|9;
     
 //	g_com_map[DEV_ID]=0x7;
 #ifdef DEBUG_MODE
 //	g_com_map[DEV_ROLE]=1;
-		g_com_map[DEV_ID]=0x4009;
+//		g_com_map[DEV_ID]=0x4009;
 //    g_com_map[ACTIVE_INDEX]=1;
 //	g_com_map[COM_INTERVAL]=50;
 //	g_com_map[MAX_REPORT_ANC_NUM]=1;
@@ -886,11 +891,11 @@
   GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
   HAL_GPIO_Init(BAT_MEAS_GND_GPIO_Port, &GPIO_InitStruct);
 
-  /*Configure GPIO pin : USER_KEY_Pin */
-  GPIO_InitStruct.Pin = USER_KEY_Pin;
+  /*Configure GPIO pins : USER_KEY_Pin PB14 */
+  GPIO_InitStruct.Pin = USER_KEY_Pin|GPIO_PIN_14;
   GPIO_InitStruct.Mode = GPIO_MODE_IT_FALLING;
   GPIO_InitStruct.Pull = GPIO_PULLUP;
-  HAL_GPIO_Init(USER_KEY_GPIO_Port, &GPIO_InitStruct);
+  HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
 
   /*Configure GPIO pin : INPUT_5V_Pin */
   GPIO_InitStruct.Pin = INPUT_5V_Pin;
@@ -921,6 +926,9 @@
   /* EXTI interrupt init*/
   HAL_NVIC_SetPriority(EXTI0_1_IRQn, 1, 0);
   HAL_NVIC_EnableIRQ(EXTI0_1_IRQn);
+
+  HAL_NVIC_SetPriority(EXTI4_15_IRQn, 1, 0);
+  HAL_NVIC_EnableIRQ(EXTI4_15_IRQn);
 
 }
 
@@ -1033,11 +1041,12 @@
 		
 	}
 
-	if(!GET_USERKEY)
+	if(!GET_USERKEY||!HAL_GPIO_ReadPin(USER_KEY_GPIO_Port,GPIO_PIN_14))
 	{
 		key_keeptime+=lptimedelay;
         if(key_keeptime>=3)
 		{
+            JianXieMotorProcess();
 			userkey_state = 1; 
 		}
 		if(key_keeptime>=KEY_KEEPRESET_TIME)

--
Gitblit v1.9.3