|
|
@@ -137,11 +137,17 @@ static debounce_t _charger_over_current = {
|
|
|
.count = 0,
|
|
|
.max_count = 70
|
|
|
};
|
|
|
+static debounce_t _discharger_over_current = {
|
|
|
+ .count = 0,
|
|
|
+ .max_count = 20
|
|
|
+};
|
|
|
+
|
|
|
/* 55 - 100A, 14 - I x I / 750 */
|
|
|
void check_current_state(void){
|
|
|
+ float current = measure_value()->load_current;
|
|
|
if (bms_state_get()->charging) {
|
|
|
+ _discharger_over_current.count = 0;
|
|
|
if (!_health.charger_over_current) {
|
|
|
- float current = measure_value()->load_current;
|
|
|
if (current > MAX_CURRENT_FOR_CHARGER) {
|
|
|
_charger_over_current.count ++;
|
|
|
}else {
|
|
|
@@ -156,10 +162,18 @@ void check_current_state(void){
|
|
|
}
|
|
|
}else{
|
|
|
_charger_over_current.count = 0;
|
|
|
- if (!_health.load_current_short && (abs(measure_value()->load_current) >= MAX_CURRENT_FOR_DISCHARGER)){
|
|
|
- _health.load_current_short = 1;
|
|
|
- ml5238_enable_load_detect(1); //´ò¿ª¸ºÔؼì²â
|
|
|
- shark_timer_post(&_load_detect_timer._timer, _load_detect_timer.interval);
|
|
|
+ if (!_health.load_current_short){
|
|
|
+ if ((abs(current) >= MAX_CURRENT_FOR_DISCHARGER)) {
|
|
|
+ _discharger_over_current.count++;
|
|
|
+ }else {
|
|
|
+ _discharger_over_current.count = 0;
|
|
|
+ }
|
|
|
+ if (_discharger_over_current.count >= _discharger_over_current.max_count) {
|
|
|
+ _health.load_current_short = 1;
|
|
|
+ _discharger_over_current.count = 0;
|
|
|
+ ml5238_enable_load_detect(1); //´ò¿ª¸ºÔؼì²â
|
|
|
+ shark_timer_post(&_load_detect_timer._timer, _load_detect_timer.interval);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|