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