|
|
@@ -117,6 +117,21 @@ static void process_ext_command(foc_cmd_body_t *command) {
|
|
|
|
|
|
}
|
|
|
|
|
|
+static u8 ignore_with_speed[] = {Foc_Set_Gear_Limit, Foc_Conf_Pid, Foc_Set_Throttle_throld, Foc_Set_Config, Foc_Set_eBrake_Throld, Foc_Start_Write_TRQ_Table, Foc_Write_TRQ_Table, Foc_End_Write_TRQ_Table, Foc_SN_Write};
|
|
|
+
|
|
|
+static bool _can_process_with_speed(u8 cmd) {
|
|
|
+ int size = ARRAY_SIZE(ignore_with_speed);
|
|
|
+ if (!mc_is_start() || PMSM_FOC_GetSpeed() < 0.1f) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ for (int i = 0; i < size; i++) {
|
|
|
+ if (ignore_with_speed[i] == cmd) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+}
|
|
|
+
|
|
|
static void process_foc_command(foc_cmd_body_t *command) {
|
|
|
u8 erroCode = 0;
|
|
|
u8 response[32];
|
|
|
@@ -125,6 +140,10 @@ static void process_foc_command(foc_cmd_body_t *command) {
|
|
|
process_ext_command(command);
|
|
|
return;
|
|
|
}
|
|
|
+ if (!_can_process_with_speed(command->cmd)) {
|
|
|
+ erroCode = FOC_NowAllowed_With_Speed;
|
|
|
+ goto cmd_end;
|
|
|
+ }
|
|
|
switch (command->cmd) {
|
|
|
case Foc_Start_Motor:
|
|
|
{
|
|
|
@@ -503,6 +522,7 @@ static void process_foc_command(foc_cmd_body_t *command) {
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
+cmd_end:
|
|
|
sys_debug("err = %d\n", erroCode);
|
|
|
response[0] = command->cmd;
|
|
|
response[1] = CAN_MY_ADDRESS;
|