Explorar o código

刹车灯处理

Signed-off-by: huhui <huhui@sharkgulf.com>
huhui %!s(int64=2) %!d(string=hai) anos
pai
achega
812ba03d46
Modificáronse 1 ficheiros con 11 adicións e 5 borrados
  1. 11 5
      Applications/foc/motor/motor.c

+ 11 - 5
Applications/foc/motor/motor.c

@@ -812,11 +812,6 @@ bool mc_auto_hold(bool hold) {
 	}else {
 		PMSM_FOC_AutoHold(hold);
 	}
-	if (motor.b_auto_hold) {
-		gpio_brk_light_enable(true);
-	}else {
-		gpio_brk_light_enable(false);
-	}
 	cpu_exit_critical(mask);
 	return true;
 }
@@ -1147,6 +1142,15 @@ static bool mc_process_force_running(void) {
 	}
 	return false;
 }
+
+static void mc_process_brake_light(void) {
+	bool can_lighting = false;
+	if (motor.b_break || motor.b_auto_hold || eCtrl_is_eBrk_Running() || (motor.b_start && !PMSM_FOC_Is_Start() && motor_encoder_get_speed() > CONFIG_ZERO_SPEED_RPM)) {
+		can_lighting = true;
+	}
+	gpio_brk_light_enable(can_lighting);
+}
+
 #ifdef CONFIG_CRUISE_ENABLE_ACCL
 static void mc_process_curise(void) {
 	static bool can_pause_resume = false;
@@ -1305,6 +1309,8 @@ void Sched_MC_mTask(void) {
 		return;
 	}
 
+	mc_process_brake_light();
+
 	if ((runMode != CTRL_MODE_OPEN) || (motor.mode != CTRL_MODE_OPEN)) {
 #ifndef CONFIG_DQ_STEP_RESPONSE
 		mc_autohold_process();