Sfoglia il codice sorgente

fix bug that soft current protect

Signed-off-by: huhui <huhui@sharkgulf.com>
huhui 5 anni fa
parent
commit
78b288516e
1 ha cambiato i file con 16 aggiunte e 19 eliminazioni
  1. 16 19
      Application/app/sox/health.c

+ 16 - 19
Application/app/sox/health.c

@@ -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); //打开负载检测