diff --git a/examples/foc/Kconfig b/examples/foc/Kconfig index 0311350b1..21a13332d 100644 --- a/examples/foc/Kconfig +++ b/examples/foc/Kconfig @@ -376,5 +376,14 @@ endif # EXAMPLES_FOC_HAVE_ALIGN endmenu # FOC controller parameters +config EXAMPLES_FOC_HAVE_RUN + bool + default y if !EXAMPLES_FOC_RUN_DISABLE + default n + +config EXAMPLES_FOC_RUN_DISABLE + bool "FOC Disable FOC motor controller" + default n + endif # EXAMPLES_FOC diff --git a/examples/foc/foc_motor_b16.c b/examples/foc/foc_motor_b16.c index 07acb4f2c..d0c7322a9 100644 --- a/examples/foc/foc_motor_b16.c +++ b/examples/foc/foc_motor_b16.c @@ -132,6 +132,7 @@ errout: } #endif +#ifdef CONFIG_EXAMPLES_FOC_HAVE_RUN /**************************************************************************** * Name: foc_runmode_init ****************************************************************************/ @@ -181,6 +182,7 @@ static int foc_runmode_init(FAR struct foc_motor_b16_s *motor) errout: return ret; } +#endif /**************************************************************************** * Name: foc_motor_configure @@ -582,6 +584,7 @@ errout: return ret; } +#ifdef CONFIG_EXAMPLES_FOC_HAVE_RUN /**************************************************************************** * Name: foc_motor_run ****************************************************************************/ @@ -682,6 +685,7 @@ static int foc_motor_run(FAR struct foc_motor_b16_s *motor) errout: return ret; } +#endif /**************************************************************************** * Public Functions @@ -1043,6 +1047,7 @@ int foc_motor_control(FAR struct foc_motor_b16_s *motor) } #endif +#ifdef CONFIG_EXAMPLES_FOC_HAVE_RUN case FOC_CTRL_STATE_RUN_INIT: { /* Initialize run controller mode */ @@ -1072,6 +1077,7 @@ int foc_motor_control(FAR struct foc_motor_b16_s *motor) break; } +#endif case FOC_CTRL_STATE_IDLE: { diff --git a/examples/foc/foc_motor_f32.c b/examples/foc/foc_motor_f32.c index 9ee37f165..cc32d7d7b 100644 --- a/examples/foc/foc_motor_f32.c +++ b/examples/foc/foc_motor_f32.c @@ -132,6 +132,7 @@ errout: } #endif +#ifdef CONFIG_EXAMPLES_FOC_HAVE_RUN /**************************************************************************** * Name: foc_runmode_init ****************************************************************************/ @@ -181,6 +182,7 @@ static int foc_runmode_init(FAR struct foc_motor_f32_s *motor) errout: return ret; } +#endif /**************************************************************************** * Name: foc_motor_configure @@ -566,6 +568,7 @@ errout: return ret; } +#ifdef CONFIG_EXAMPLES_FOC_HAVE_RUN /**************************************************************************** * Name: foc_motor_run ****************************************************************************/ @@ -666,6 +669,7 @@ static int foc_motor_run(FAR struct foc_motor_f32_s *motor) errout: return ret; } +#endif /**************************************************************************** * Public Functions @@ -1038,6 +1042,7 @@ int foc_motor_control(FAR struct foc_motor_f32_s *motor) } #endif +#ifdef CONFIG_EXAMPLES_FOC_HAVE_RUN case FOC_CTRL_STATE_RUN_INIT: { /* Initialize run controller mode */ @@ -1067,6 +1072,7 @@ int foc_motor_control(FAR struct foc_motor_f32_s *motor) break; } +#endif case FOC_CTRL_STATE_IDLE: { diff --git a/examples/foc/foc_thr.h b/examples/foc/foc_thr.h index a3ded480c..2a8237e6c 100644 --- a/examples/foc/foc_thr.h +++ b/examples/foc/foc_thr.h @@ -84,8 +84,10 @@ enum foc_controller_state_e #ifdef CONFIG_EXAMPLES_FOC_HAVE_ALIGN FOC_CTRL_STATE_ALIGN, #endif +#ifdef CONFIG_EXAMPLES_FOC_HAVE_RUN FOC_CTRL_STATE_RUN_INIT, FOC_CTRL_STATE_RUN, +#endif FOC_CTRL_STATE_IDLE };