|
@@ -129,26 +129,23 @@ static debounce_t _charger_over_current = {
|
|
|
.max_count = 70
|
|
.max_count = 70
|
|
|
};
|
|
};
|
|
|
void check_current_state(void){
|
|
void check_current_state(void){
|
|
|
- //判断是否过流充电,放电过流通过5238来检测
|
|
|
|
|
- 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 ++;
|
|
|
|
|
- }else {
|
|
|
|
|
- _charger_over_current.count = 0;
|
|
|
|
|
- }
|
|
|
|
|
- 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);
|
|
|
|
|
|
|
+ if (bms_state_get()->charging) {
|
|
|
|
|
+ if (!_health.charger_over_current) {
|
|
|
|
|
+ float current = measure_value()->load_current;
|
|
|
|
|
+ if (current > MAX_CURRENT_FOR_CHARGER) {
|
|
|
|
|
+ _charger_over_current.count ++;
|
|
|
|
|
+ }else {
|
|
|
|
|
+ _charger_over_current.count = 0;
|
|
|
|
|
+ }
|
|
|
|
|
+ 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);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
- }
|
|
|
|
|
- if (!bms_state_get()->charging){
|
|
|
|
|
|
|
+ }else{
|
|
|
|
|
+ _charger_over_current.count = 0;
|
|
|
if (!_health.load_current_short && (abs(measure_value()->load_current) >= MAX_CURRENT_FOR_DISCHARGER)){
|
|
if (!_health.load_current_short && (abs(measure_value()->load_current) >= MAX_CURRENT_FOR_DISCHARGER)){
|
|
|
_health.load_current_short = 1;
|
|
_health.load_current_short = 1;
|
|
|
ml5238_enable_load_detect(1); //打开负载检测
|
|
ml5238_enable_load_detect(1); //打开负载检测
|