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

fix can not powerdown

Signed-off-by: huhui <huhui@sharkgulf.com>
huhui пре 5 година
родитељ
комит
f6b654e6f1
3 измењених фајлова са 5 додато и 8 уклоњено
  1. 2 6
      Application/app/sox/state.c
  2. 2 1
      Application/bsp/ml5238.c
  3. 1 1
      Project/SP700.uvoptx

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

@@ -14,7 +14,7 @@
 
 #define ALLOW_DEEP_SLEEP 1
 #define SLEEP_IGNORE_UNHEALTH 0
-#define ALLOW_POWER_DOWN 0 //disable power down for debug
+#define ALLOW_POWER_DOWN 1 //disable power down for debug
 #define ALLOW_5238_BALANCE 0
 
 static void _current_notify(void);
@@ -224,15 +224,11 @@ static void _process_power_down(void){
 		
 		nv_save_soc();
 		
-		ml5238_enable_charger_detect(AUX_VOL_IS_OPEN(), 1);
-		delay_us(2* 1000);
 		shark_uart_flush();
-		if (!ml5238_charger_is_disconnect(AUX_VOL_IS_OPEN())){//have charger, do'nt power down
+		if (io_state()->charger_detect_irq || io_state()->charger_detect){//have charger, do'nt power down
 			bms_health()->powerdown_lower_voltage = 0;
-			ml5238_enable_charger_detect(AUX_VOL_IS_OPEN(), 0);
 			return;
 		}
-		ml5238_enable_charger_detect(AUX_VOL_IS_OPEN(), 0);
 		start_aux_power(0);
 		discharger_open(0);
 		charger_open(0);

+ 2 - 1
Application/bsp/ml5238.c

@@ -2,7 +2,7 @@
 #include "libs/shark_libs.h"
 #include "spi.h"
 #include "ml5238.h"
-
+#include "libs/logger.h"
 static int ml5238_read(uint8_t regaddr, uint8_t *data);
 static void ml5238_clear_bits(uint8_t regaddr, uint8_t bit);
 static void ml5238_set_bits(uint8_t regaddr, uint8_t bit);
@@ -27,6 +27,7 @@ int ml5238_charger_is_disconnect(int small_current_on){
 	uint8_t fet = 0;
 	ml5238_read(ML5238_FET, &fet);	
 	ml5238_read(ML5238_PSENSE, &value);
+	sys_error("fet 0x%x, PSENSE 0x%x\n", fet, value);
 	if ((fet & FET_DF) || small_current_on){
 		return (value & PSENSE_PSL);
 	}

+ 1 - 1
Project/SP700.uvoptx

@@ -135,7 +135,7 @@
         <SetRegEntry>
           <Number>0</Number>
           <Key>DLGUARM</Key>
-          <Name></Name>
+          <Name>d</Name>
         </SetRegEntry>
         <SetRegEntry>
           <Number>0</Number>