examples/foc: add an option to disable motor controller logic

This is useful feature for debug purposes.
This commit is contained in:
raiden00pl 2022-02-16 13:32:30 +01:00 committed by Xiang Xiao
parent e6b6c14f53
commit 3b1967ec71
4 changed files with 23 additions and 0 deletions

View File

@ -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

View File

@ -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:
{

View File

@ -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:
{

View File

@ -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
};