|
|
@@ -2,7 +2,6 @@
|
|
|
#include "bsp/ml5238.h"
|
|
|
#include "bsp/cs1180.h"
|
|
|
#include "bsp/uart.h"
|
|
|
-#include "bsp/shark_rtc.h"
|
|
|
#include "bsp/mcu_power_sleep.h"
|
|
|
#include "app/sox/measure.h"
|
|
|
#include "app/sox/measure_task.h"
|
|
|
@@ -19,8 +18,6 @@
|
|
|
#define ALLOW_POWER_DOWN 1 //disable power down for debug
|
|
|
#define ALLOW_5238_BALANCE 1
|
|
|
#define IGNORE_DISCHARGER_LOW_VOL 0 //忽略放电欠压
|
|
|
-#define ALLOW_RESET_BEFORE_PD 1 //在powerdown之间先做一个reset
|
|
|
-#define PD_MAGIC 0x13EF5AA5
|
|
|
extern uint32_t bsp_get_rst_reson(void);
|
|
|
extern uint32_t bsp_get_backup(void);
|
|
|
static void _current_notify(void);
|
|
|
@@ -31,7 +28,6 @@ static void _debug_timer_handler(shark_timer_t *t);
|
|
|
static void _process_power_down(void);
|
|
|
static uint8_t calc_cell_voltage(void);
|
|
|
static int _can_close_mos_no_hall(void);
|
|
|
-extern void system_reboot(void);
|
|
|
|
|
|
static bms_state_t _bms_state;
|
|
|
static int pcb_temp = 100;
|
|
|
@@ -132,7 +128,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\n", bsp_get_rst_reson());
|
|
|
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();
|
|
|
@@ -344,18 +340,9 @@ static void _process_user_request(s32 health){
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-int bms_is_reset_befor_pd(void) {
|
|
|
- return (shark_rtc_get_pd_magic() != PD_MAGIC);
|
|
|
-}
|
|
|
-
|
|
|
static void _process_power_down(void){
|
|
|
#if (ALLOW_POWER_DOWN==1)
|
|
|
if (bms_health()->powerdown_lower_voltage){
|
|
|
- if (shark_rtc_get_pd_magic() != PD_MAGIC) {
|
|
|
- shark_rtc_set_pd_magic(PD_MAGIC);
|
|
|
- nv_save_all_soc();
|
|
|
- system_reboot();
|
|
|
- }
|
|
|
state_debug("BMS System PowerDown!!\n");
|
|
|
|
|
|
if (bms_work_is_normal() && soc_update_by_ocv()) {
|