Browse Source

加入pd down调试

Signed-off-by: huhui <huhui@sharkgulf.com>
huhui 4 years ago
parent
commit
3cfd17f25a
1 changed files with 5 additions and 3 deletions
  1. 5 3
      Application/app/sox/state.c

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

@@ -47,6 +47,7 @@ static int no_hall_time[5];
 static int no_hall_count = 0;
 u64 uart_frame_time = 0;
 static u32 uart_reinit_count = 0;
+static u32 pd_count = 0;
 
 static void put_no_hall_time(void){
 	no_hall_time[no_hall_count] = shark_get_seconds();
@@ -132,7 +133,7 @@ void bms_state_log(void){
 	state_debug("ml5238 cali: %d\n", ml5238_cali_count);
 	state_debug("ps charger mask:in %d, %d\n", _bms_state.ps_charger_mask, _bms_state.ps_charger_in);
 	state_debug("open dfet %d - %d - 0x%x - %d\n", open_dfet, open_dfet_failt, close_dfet_reson, close_dfet_no_hall);
-	state_debug("Reset Reson 0x%x, 0x%x\n", bsp_get_rst_reson(), shark_rtc_get_pd_flags());
+	state_debug("Reset Reson 0x%x, 0x%x\n", bsp_get_rst_reson(), pd_count);
 	state_debug("BackUp value 0x%x\n", bsp_get_backup());
 	state_debug("Debug: %d, %d. uart reinit=%d\n", shark_uart_timeout(), io_state()->hall_detect, uart_reinit_count);
 	log_no_hall_time();
@@ -352,6 +353,7 @@ int bms_is_reset_befor_pd(void) {
 static void _process_power_down(void){
 #if (ALLOW_POWER_DOWN==1)
 	if (bms_health()->powerdown_lower_voltage){
+		pd_count ++;
 		if (system_force_pd == 0) {
 			ml5238_enable_all_mosfet(0);
 			if (shark_get_seconds() < (bms_health()->pd_time + 5)) {
@@ -360,11 +362,11 @@ static void _process_power_down(void){
 		}
 		state_debug("BMS System PowerDown!!\n");
 
+		bms_health()->powerdown_lower_voltage = 0;
 		if (bms_work_is_normal() && soc_update_by_ocv()) {
-			bms_health()->powerdown_lower_voltage = 0;
 			nv_save_all_soc();
-			bms_health()->powerdown_lower_voltage = 1;
 		}
+		bms_health()->powerdown_lower_voltage = 1;
 		
 		shark_uart_flush();
 		if (bms_work_is_normal()) {