Эх сурвалжийг харах

cell 均衡启动后,需要再电流回调中判断是否要停止均衡

Signed-off-by: huhui <huhui@sharkgulf.com>
huhui 3 жил өмнө
parent
commit
800199f527

+ 22 - 8
Application/app/sox/state.c

@@ -607,8 +607,13 @@ static void _check_mos_stat(void){
 		_check_mos_time = shark_get_seconds();
 	}
 }
-
+#if (ALLOW_5238_BALANCE==1)
+static bool check_stop_balance(void) ;
+#endif
 static void _current_notify(void){
+#if (ALLOW_5238_BALANCE==1)
+	check_stop_balance();
+#endif
 	check_charging();
 	check_current_state(); //check health of current
 	_check_mos_stat();
@@ -749,13 +754,7 @@ static u8 need_stop_balance(void) {
 }
 
 static void check_cell_balance(void){
-	if (!can_do_balance()) {
-		if (need_stop_balance()) {
-			if (_bms_state.pack_balancing){
-				_stop_balance();
-				shark_timer_cancel(&_balance_timer);
-			}
-		}
+	if (check_stop_balance()) {
 		return;
 	}
 	u16 mask = get_balance_maskV2();
@@ -766,6 +765,21 @@ static void check_cell_balance(void){
 	}
 	state_debug("Cell balance mask 0x%x\n", mask);
 }
+
+static bool check_stop_balance(void) {
+	if (!can_do_balance()) {
+		if (need_stop_balance()) {
+			if (_bms_state.pack_balancing){
+				_stop_balance();
+				push_event(Cell_balance, 0);
+				shark_timer_cancel(&_balance_timer);
+			}
+		}
+		return true;
+	}
+	return false;
+}
+
 #endif
 static void calc_cell_voltage(void){
 	uint16_t voltage = 0;