Procházet zdrojové kódy

start mc需要检查刹车状态

Signed-off-by: huhui <huhui@sharkgulf.com>
huhui před 3 roky
rodič
revize
ee98871c07

+ 0 - 3
Applications/foc/core/PMSM_FOC_Core.c

@@ -712,9 +712,6 @@ float PMSM_FOC_Get_iDC(void) {
 
 void PMSM_FOC_Brake(bool brake) {
 	_gFOC_Ctrl.in.b_eBrake = brake;
-	if (!_gFOC_Ctrl.in.b_motEnable) {
-		return;
-	}
 	if (_gFOC_Ctrl.in.b_eBrake & _gFOC_Ctrl.in.b_cruiseEna) {
 		_gFOC_Ctrl.in.b_cruiseEna = false;
 	}

+ 8 - 2
Applications/foc/motor/motor.c

@@ -18,6 +18,9 @@
 #include "foc/core/torque.h"
 #include "app/nv_storage.h"
 
+static bool mc_is_hwbrake(void);
+
+
 static motor_t motor = {
 	.s_direction = POSITIVE,
 };
@@ -96,6 +99,9 @@ bool mc_start(u8 mode) {
 		mc_stop();
 		return false;
 	}
+	if (mc_is_hwbrake()) {
+		PMSM_FOC_Brake(true);
+	}
 	return true;
 }
 
@@ -237,7 +243,7 @@ bool mc_throttle_released(void) {
 	return get_throttle_float() < THROTTLE_LOW_VALUE;
 }
 
-static bool mc_is_brake(void) {
+static bool mc_is_hwbrake(void) {
 #ifdef GPIO_BRAKE_IN_GROUP
 	int count = 50;
 	int settimes = 0;
@@ -274,7 +280,7 @@ void MC_Brake_IRQHandler(void) {
 	if (!motor.b_start) {
 		return;
 	}
-	if (mc_is_brake()) {
+	if (mc_is_hwbrake()) {
 		PMSM_FOC_Brake(true);
 	}else {
 		PMSM_FOC_Brake(false);