|
|
@@ -72,7 +72,7 @@ static void init_detect_timer(void){
|
|
|
_load_detect_timer.interval = 10;
|
|
|
|
|
|
_charger_detect_timer._timer.handler = charger_detect_handler;
|
|
|
- _charger_detect_timer.max_count = 100;
|
|
|
+ _charger_detect_timer.max_count = 500;
|
|
|
_charger_detect_timer.interval = 10;
|
|
|
}
|
|
|
|
|
|
@@ -92,13 +92,15 @@ static void load_delect_handler(shark_timer_t *timer){
|
|
|
}
|
|
|
|
|
|
static void charger_detect_handler(shark_timer_t *timer){
|
|
|
- if (!io_state()->charger_detect) {
|
|
|
+ if (!io_state()->charger_detect || !bms_state_get()->charging) {
|
|
|
_charger_detect_timer.count ++;
|
|
|
}else {
|
|
|
_charger_detect_timer.count = 0;
|
|
|
}
|
|
|
if (_charger_detect_timer.count >= _charger_detect_timer.max_count){
|
|
|
_health.charger_over_current = 0;
|
|
|
+ _charger_detect_timer.count = 0;
|
|
|
+ health_warning("clear charger over current\n");
|
|
|
}else {
|
|
|
shark_timer_post(&_charger_detect_timer._timer, _charger_detect_timer.interval);
|
|
|
}
|
|
|
@@ -127,11 +129,15 @@ static void debug_health(void){
|
|
|
/* 检测电流情况,看是否过流等 */
|
|
|
static debounce_t _charger_over_current = {
|
|
|
.count = 0,
|
|
|
- .max_count = 10
|
|
|
+ .max_count = 70
|
|
|
};
|
|
|
void check_current_state(void){
|
|
|
//判断是否过流充电,放电过流通过5238来检测
|
|
|
- if (bms_state_get()->charging && !_health.charger_over_current) {
|
|
|
+ if (!bms_state_get()->charging){
|
|
|
+ _charger_over_current.count = 0;
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (!_health.charger_over_current) {
|
|
|
float current = measure_value()->load_current;
|
|
|
if (current > MAX_CURRENT_FOR_CHARGER) {
|
|
|
_charger_over_current.count ++;
|
|
|
@@ -141,11 +147,10 @@ void check_current_state(void){
|
|
|
if (_charger_over_current.count >= _charger_over_current.max_count){
|
|
|
_health.charger_over_current = 1;
|
|
|
_charger_over_current.count = 0;
|
|
|
+ health_warning("charger over current\n");
|
|
|
shark_timer_post(&_charger_detect_timer._timer, _charger_detect_timer.interval);
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- debug_health();
|
|
|
}
|
|
|
|
|
|
/* 检测pack电压,cell电压,pack电压过低触发powerdown*/
|