examples/foc: terminate the control thread if no work to do
This commit is contained in:
parent
420da4589e
commit
429f5a166f
@ -352,6 +352,14 @@ int foc_fixed16_thr(FAR struct foc_ctrl_env_s *envp)
|
|||||||
PRINTF("ERROR: foc_dev_params_set failed %d!\n", ret);
|
PRINTF("ERROR: foc_dev_params_set failed %d!\n", ret);
|
||||||
goto errout;
|
goto errout;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Terminate control thread */
|
||||||
|
|
||||||
|
if (motor.ctrl_state == FOC_CTRL_STATE_TERMINATE)
|
||||||
|
{
|
||||||
|
PRINTF("TERMINATE CTRL THREAD\n");
|
||||||
|
goto errout;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -353,6 +353,14 @@ int foc_float_thr(FAR struct foc_ctrl_env_s *envp)
|
|||||||
PRINTF("ERROR: foc_dev_prams_set failed %d!\n", ret);
|
PRINTF("ERROR: foc_dev_prams_set failed %d!\n", ret);
|
||||||
goto errout;
|
goto errout;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Terminate control thread */
|
||||||
|
|
||||||
|
if (motor.ctrl_state == FOC_CTRL_STATE_TERMINATE)
|
||||||
|
{
|
||||||
|
PRINTF("TERMINATE CTRL THREAD\n");
|
||||||
|
goto errout;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -1120,6 +1120,13 @@ int foc_motor_control(FAR struct foc_motor_b16_s *motor)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case FOC_CTRL_STATE_TERMINATE:
|
||||||
|
{
|
||||||
|
/* Do nothing */
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
PRINTF("ERROR: invalid ctrl_state=%d\n", motor->ctrl_state);
|
PRINTF("ERROR: invalid ctrl_state=%d\n", motor->ctrl_state);
|
||||||
|
@ -1112,6 +1112,19 @@ int foc_motor_control(FAR struct foc_motor_f32_s *motor)
|
|||||||
{
|
{
|
||||||
motor->foc_mode = FOC_HANDLER_MODE_IDLE;
|
motor->foc_mode = FOC_HANDLER_MODE_IDLE;
|
||||||
|
|
||||||
|
#ifndef CONFIG_EXAMPLES_FOC_HAVE_RUN
|
||||||
|
/* Terminate */
|
||||||
|
|
||||||
|
motor->ctrl_state += 1;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case FOC_CTRL_STATE_TERMINATE:
|
||||||
|
{
|
||||||
|
/* Do nothing */
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -88,7 +88,8 @@ enum foc_controller_state_e
|
|||||||
FOC_CTRL_STATE_RUN_INIT,
|
FOC_CTRL_STATE_RUN_INIT,
|
||||||
FOC_CTRL_STATE_RUN,
|
FOC_CTRL_STATE_RUN,
|
||||||
#endif
|
#endif
|
||||||
FOC_CTRL_STATE_IDLE
|
FOC_CTRL_STATE_IDLE,
|
||||||
|
FOC_CTRL_STATE_TERMINATE
|
||||||
};
|
};
|
||||||
|
|
||||||
/* FOC thread data */
|
/* FOC thread data */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user