|
|
@@ -54,6 +54,9 @@ static bms_health_t _health;
|
|
|
static debounce_timer_t _load_detect_timer = {.max_count = 100, .interval = 10, ._timer.handler = load_detect_handler};
|
|
|
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;
|
|
|
+
|
|
|
void health_init(void){
|
|
|
/* 5238如果有异常情况,比如短路,负载移除,通过这个handler上报 */
|
|
|
ml5238_register_notify_handler(check_ml5238_state);
|
|
|
@@ -65,6 +68,11 @@ void health_init(void){
|
|
|
_health.is_work_temp_normal = 1;
|
|
|
}
|
|
|
|
|
|
+void health_log(void){
|
|
|
+ health_debug("soft short:%d\n", error_counts.soft_current_short);
|
|
|
+ health_debug("hard short:%d\n", error_counts.hard_current_short);
|
|
|
+}
|
|
|
+
|
|
|
bms_health_t *bms_health(){
|
|
|
return &_health;
|
|
|
}
|
|
|
@@ -120,6 +128,7 @@ static void check_ml5238_state(int event){
|
|
|
shark_timer_post(&_charger_detect_timer._timer, _charger_detect_timer.interval);
|
|
|
}else if (event == ML5238_Event_Short_Current) { //ml5238触发短路保护,充放电mos全部关闭
|
|
|
_health.load_current_short = 1;
|
|
|
+ error_counts.hard_current_short ++;
|
|
|
ml5238_enable_load_detect(1); //打开负载检测
|
|
|
shark_timer_post(&_load_detect_timer._timer, _load_detect_timer.interval);
|
|
|
}else if (event == ML5238_Event_Load_Disconnect) {
|
|
|
@@ -168,6 +177,7 @@ void check_current_state(void){
|
|
|
if (!_health.load_current_short){
|
|
|
if (soft_current_push(current)) {
|
|
|
_health.load_current_short = 1;
|
|
|
+ error_counts.soft_current_short ++;
|
|
|
//_discharger_over_current.count = 0;
|
|
|
ml5238_enable_load_detect(1); //打开负载检测
|
|
|
shark_timer_post(&_load_detect_timer._timer, _load_detect_timer.interval);
|