Преглед изворни кода

fix wakeup by charger, need open charger mos when uart not active

Signed-off-by: huhui <huhui@sharkgulf.com>
huhui пре 5 година
родитељ
комит
7b4a22821e

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

@@ -167,6 +167,7 @@ void charger_detect_irq_handler(void){
 	mcu_sleep_set_wakeup_source(WAKEUP_SOURCE_CHARGER);
 	_io_state.charger_detect_irq = 1;
 	shark_timer_post(&_charger_detect_irq_timer, 2000);//延时2s给充电判断充足的时间
+	io_debug("charger detect\n");
 }
 
 void hall1_detect_irq_handler(void){

+ 3 - 2
Application/app/sox/state.c

@@ -80,6 +80,7 @@ int bms_work_mode_set(int mode, int start){
 
 void bms_state_log(void){
 	state_warning("Life Time: %d\n", shark_get_seconds());
+	state_warning("Sleep Time: %ds\n", get_system_sleep_time());
 	state_debug("Charging: %d\n", _bms_state.charging);
 	state_debug("WorkMode %d\n", _bms_state.work_mode);
 	state_debug("DMos: %d\n", ml5238_is_discharging());
@@ -262,7 +263,7 @@ static void _process_deepsleep(s32 health){
 #if (ALLOW_DEEP_SLEEP==1)
 	static u64 _sleep_time = 0;
 #if (SLEEP_IGNORE_UNHEALTH==0)
-	if ((health & Health_Fault_Can_Sleep) != Health_Fault_Can_Sleep){
+	if ((health != Health_Success) && ((health & Health_Fault_Can_Sleep) != Health_Fault_Can_Sleep)){
 		return;
 	}
 #endif
@@ -312,7 +313,7 @@ static void _process_iostate_changed(s32 unhealth){
 			charger_open(0);
 		}
 	}
-	if (io_state()->charger_detect && ((unhealth & Health_charger_Fault) == 0) && (_bms_state.cell_max_vol < SIGLE_CELL_MAX_CHARGER_VOLTAGE)) {
+	if (io_state()->charger_detect_irq && ((unhealth & Health_charger_Fault) == 0) && (_bms_state.cell_max_vol < SIGLE_CELL_MAX_CHARGER_VOLTAGE)) {
 		if (!ml5238_is_charging() && shark_uart_timeout()){//不在车上,底座上,充电柜上,检测到充电器插入,自动打开充电,否则的话,只能通过指令来打开充电mos
 			charger_open(1);
 		}

+ 1 - 1
Application/bsp/gpio.c

@@ -83,7 +83,7 @@ static void enable_exti4_15_irq(int enable){
 void charger_detect_irq_enable(int enable){
 	if (enable){
 		syscfg_exti_line_config(EXTI_SOURCE_GPIOB, EXTI_SOURCE_PIN10);
-		exti_init(EXTI_10, EXTI_INTERRUPT, EXTI_TRIG_BOTH);
+		exti_init(EXTI_10, EXTI_INTERRUPT, EXTI_TRIG_FALLING);
 		exti_flag_clear(EXTI_10);
 		enable_exti4_15_irq(1);
 	}else {

+ 1 - 0
Application/bsp/mcu_power_sleep.h

@@ -11,6 +11,7 @@
 void mcu_enter_deepsleep(void);
 uint32_t mcu_get_sleeptime(void);
 void mcu_sleep_set_wakeup_source(uint32_t source);
+uint32_t get_system_sleep_time(void);
 
 #endif /* _Mcu_Power_Sleep_H__ */