|
|
@@ -60,9 +60,6 @@ static debounce_timer_t _load_detect_timer = {.max_count = 100, .interval = 10,
|
|
|
static debounce_timer_t _charger_detect_timer = {.max_count = 500, .interval = 10, ._timer.handler = charger_detect_handler};
|
|
|
static shark_timer_t _clear_short_current_timer = {.handler = clear_short_current_handler};
|
|
|
static error_counts_t error_counts;
|
|
|
-static u16 discharger_lower_cell_voltage = 0;
|
|
|
-static u16 discharger_lower_voltage = 0;
|
|
|
-static u16 charger_over_cell_voltage = 0;
|
|
|
|
|
|
void health_init(void){
|
|
|
/* 5238如果有异常情况,比如短路,负载移除,通过这个handler上报 */
|
|
|
@@ -80,8 +77,7 @@ void health_log(void){
|
|
|
health_debug("hard short:%d\n", error_counts.hard_current_short);
|
|
|
health_debug("work temp: %d\n", _health.is_work_temp_normal);
|
|
|
health_debug("aux_short: %d, %d\n", error_counts.aux_short, error_counts.aux_real_short);
|
|
|
- health_debug("lower voltage: %d, %d, %d, %d\n", discharger_lower_cell_voltage, discharger_lower_voltage, error_counts.cell_under_voltage, error_counts.pack_under_voltage);
|
|
|
- health_debug("over voltage: %d\n", charger_over_cell_voltage);
|
|
|
+ health_debug("lower voltage: %d, %d\n", error_counts.cell_under_voltage, error_counts.pack_under_voltage);
|
|
|
health_debug("uart error %d, %d, %d\n", error_counts.uart_crc_error, error_counts.uart_len_error, error_counts.uart_dir_error);
|
|
|
health_debug("Temp abnormal: %d,%d,%d,%d\n", error_counts.discharger_high_temp, error_counts.charger_high_temp, error_counts.discharger_lower_temp, error_counts.charger_lower_temp);
|
|
|
}
|
|
|
@@ -273,10 +269,7 @@ void check_voltage_state(void) {
|
|
|
static uint16_t _charging = 0xFFFF;
|
|
|
if (_charging != bms_state_get()->charging) {
|
|
|
if (bms_state_get()->charging) {
|
|
|
- charger_over_cell_voltage = 0;
|
|
|
}else {
|
|
|
- discharger_lower_cell_voltage = 0;
|
|
|
- discharger_lower_voltage = 0;
|
|
|
error_counts.cell_under_voltage = 0;
|
|
|
}
|
|
|
_charging = bms_state_get()->charging;
|
|
|
@@ -290,7 +283,6 @@ void check_voltage_state(void) {
|
|
|
if (judge_debounce(!_health.sigle_cell_over_voltage, &_sigle_cell_charger_max_vol)){
|
|
|
_health.sigle_cell_over_voltage = 1;
|
|
|
push_event(Cell_Over_Vol, bms_state_get()->cell_max_vol);
|
|
|
- charger_over_cell_voltage = bms_state_get()->cell_max_vol;
|
|
|
sys_debug("sigle cell %d\n", bms_state_get()->cell_max_vol);
|
|
|
}
|
|
|
}else if ((bms_state_get()->cell_max_vol < SIGLE_CELL_MAX_CHARGER_VOLTAGE)){
|
|
|
@@ -309,7 +301,6 @@ void check_voltage_state(void) {
|
|
|
push_event(Cell_Under_Vol, bms_state_get()->cell_min_vol);
|
|
|
_single_low_judge_current(true);
|
|
|
error_counts.cell_under_voltage++;
|
|
|
- discharger_lower_cell_voltage = bms_state_get()->cell_min_vol;
|
|
|
}
|
|
|
}else if ((bms_state_get()->cell_min_vol >= min_discharger_cell_recovery_vol[_health.is_work_temp_normal])){
|
|
|
_single_low_judge_current(false);
|
|
|
@@ -324,7 +315,6 @@ void check_voltage_state(void) {
|
|
|
push_event(Pack_Under_Vol, bms_state_get()->pack_voltage);
|
|
|
_pack_low_judge_current(true);
|
|
|
error_counts.pack_under_voltage++;
|
|
|
- discharger_lower_voltage = bms_state_get()->pack_voltage;
|
|
|
}
|
|
|
}else if (bms_state_get()->pack_voltage >= min_discharger_recovery_vol[_health.is_work_temp_normal]){
|
|
|
_pack_low_judge_current(false);
|
|
|
@@ -336,7 +326,6 @@ void check_voltage_state(void) {
|
|
|
if ((bms_state_get()->cell_min_vol <= min_discharger_power_cell_vol[_health.is_work_temp_normal])){
|
|
|
if (judge_debounce(!_health.discharger_cell_shutpower_voltage, &_shut_discharger_cell_lower_voltage)){
|
|
|
_health.discharger_cell_shutpower_voltage = 1;
|
|
|
- discharger_lower_cell_voltage = bms_state_get()->cell_min_vol;
|
|
|
}
|
|
|
}else if ((bms_state_get()->cell_min_vol >= min_discharger_power_recovery_cell_vol[_health.is_work_temp_normal])){
|
|
|
if (judge_debounce(_health.discharger_cell_shutpower_voltage, &_shut_discharger_cell_lower_voltage)){
|
|
|
@@ -346,7 +335,6 @@ void check_voltage_state(void) {
|
|
|
if ((bms_state_get()->pack_voltage <= min_discharger_power_vol[_health.is_work_temp_normal])){
|
|
|
if (judge_debounce(!_health.discharger_shutpower_voltage, &_shut_discharger_lower_voltage)){
|
|
|
_health.discharger_shutpower_voltage = 1;
|
|
|
- discharger_lower_voltage = bms_state_get()->pack_voltage;
|
|
|
}
|
|
|
}else if ((bms_state_get()->pack_voltage >= min_discharger_power_recovery_vol[_health.is_work_temp_normal])){
|
|
|
if (judge_debounce(_health.discharger_shutpower_voltage, &_shut_discharger_lower_voltage)){
|