diff --git a/examples/foc/foc_motor_f32.c b/examples/foc/foc_motor_f32.c index 134a0a326..733a2a001 100644 --- a/examples/foc/foc_motor_f32.c +++ b/examples/foc/foc_motor_f32.c @@ -531,6 +531,7 @@ static int foc_motor_setpoint(FAR struct foc_motor_f32_s *motor, uint32_t sp) #ifdef CONFIG_EXAMPLES_FOC_HAVE_IDENT case FOC_MMODE_IDENT_ONLY: #endif + case FOC_MMODE_IDLE: { /* Do nothing */ @@ -1005,6 +1006,11 @@ int foc_motor_init(FAR struct foc_motor_f32_s *motor, } else #endif + if (motor->envp->cfg->mmode == FOC_MMODE_IDLE) + { + motor->ctrl_state = FOC_CTRL_STATE_IDLE; + } + else { motor->ctrl_state = FOC_CTRL_STATE_INIT; } diff --git a/examples/foc/foc_parseargs.c b/examples/foc/foc_parseargs.c index f4e669a0b..fa4de580e 100644 --- a/examples/foc/foc_parseargs.c +++ b/examples/foc/foc_parseargs.c @@ -113,6 +113,7 @@ static void foc_help(void) #ifdef CONFIG_EXAMPLES_FOC_HAVE_IDENT PRINTF(" 5 - ident only\n"); #endif + PRINTF(" 6 - IDLE state\n"); #ifdef CONFIG_EXAMPLES_FOC_HAVE_TORQ PRINTF(" [-r] torque [x1000]\n"); @@ -343,23 +344,23 @@ int validate_args(FAR struct args_s *args) /* Example control mode */ - if ( + if (args->cfg.mmode != FOC_MMODE_IDLE && #ifdef CONFIG_EXAMPLES_FOC_HAVE_TORQ - args->cfg.mmode != FOC_MMODE_TORQ && + args->cfg.mmode != FOC_MMODE_TORQ && #endif #ifdef CONFIG_EXAMPLES_FOC_HAVE_VEL - args->cfg.mmode != FOC_MMODE_VEL && + args->cfg.mmode != FOC_MMODE_VEL && #endif #ifdef CONFIG_EXAMPLES_FOC_HAVE_POS - args->cfg.mmode != FOC_MMODE_POS && + args->cfg.mmode != FOC_MMODE_POS && #endif #ifdef CONFIG_EXAMPLES_FOC_HAVE_ALIGN - args->cfg.mmode != FOC_MMODE_ALIGN_ONLY && + args->cfg.mmode != FOC_MMODE_ALIGN_ONLY && #endif #ifdef CONFIG_EXAMPLES_FOC_HAVE_IDENT - args->cfg.mmode != FOC_MMODE_IDENT_ONLY && + args->cfg.mmode != FOC_MMODE_IDENT_ONLY && #endif - 1) + 1) { PRINTF("Invalid ctrl mode value %d s\n", args->cfg.mmode); goto errout; diff --git a/examples/foc/foc_thr.h b/examples/foc/foc_thr.h index f08a81437..629801141 100644 --- a/examples/foc/foc_thr.h +++ b/examples/foc/foc_thr.h @@ -79,6 +79,7 @@ enum foc_motor_mode_e #ifdef CONFIG_EXAMPLES_FOC_HAVE_IDENT FOC_MMODE_IDENT_ONLY = 5, /* Motor identification only */ #endif + FOC_MMODE_IDLE = 6, /* IDLE state */ }; /* Controller state */