Parcourir la source

Merge remote-tracking branch 'origin/master' into dev_0603

huhui il y a 5 ans
Parent
commit
e4f17c63e1

+ 3 - 1
Application/app/sox/iostate.c

@@ -48,7 +48,8 @@ void io_state_init(void){
 
 	small_current_short_irq_enable(1);
 	charger_detect_irq_enable(1);
-	
+	hall_1_detect_irq_enable(1);
+	hall_2_detect_irq_enable(1);
 	bms_message_update_insert(_io_state.hall_detect);
 
 	iostate_log();
@@ -158,6 +159,7 @@ void small_current_short_irq_handler(void){
 		io_debug("close aux power,cause the short irq\n");
 		return;
 	}
+	mcu_sleep_set_wakeup_source(WAKEUP_SOURCE_SMALL_POWER_SHORT);
 	_io_state.aux_lock_irq = 1;
 	shark_timer_post(&_small_current_irq_timer, 0);
 	//io_debug("aux lock irq\n");

+ 9 - 5
Application/bsp/mcu_power_sleep.c

@@ -30,15 +30,15 @@ uint32_t get_system_sleep_time(void){
 }
 
 static void enable_wakeup_irq(void){
-	hall_1_detect_irq_enable(1);
-	hall_2_detect_irq_enable(1);
+	//hall_1_detect_irq_enable(1);
+	//hall_2_detect_irq_enable(1);
 	shark_rtc_start_alarm(RTC_ALARM_FOR_SLEEP);
 }
 
 static void disable_wakeup_irq(void){
 	shark_rtc_stop_alarm();
-	hall_1_detect_irq_enable(0);
-	hall_2_detect_irq_enable(0);
+	//hall_1_detect_irq_enable(0);
+	//hall_2_detect_irq_enable(0);
 }
 
 static int _is_wakeup_source(void){
@@ -89,7 +89,11 @@ static int pre_deepsleep(void){
 	
 	wdog_set_timeout(WDOG_TIME_FOR_SLEEP);
 	wait_for_enter_dsleep();
-
+	if (_is_wakeup_source()) {
+		_wakeup_source = 0;
+		post_deepsleep();
+		return -1;
+	}
 	return 0;
 }
 

+ 1 - 0
Application/bsp/mcu_power_sleep.h

@@ -8,6 +8,7 @@
 #define WAKEUP_SOURCE_IR1   0x10
 #define WAKEUP_SOURCE_IR2   0x20
 #define WAKEUP_SOURCE_KEY   0x40
+#define WAKEUP_SOURCE_SMALL_POWER_SHORT 0x80
 void mcu_enter_deepsleep(void);
 uint32_t mcu_get_sleeptime(void);
 void mcu_sleep_set_wakeup_source(uint32_t source);