examples/foc: move setpoint and vbus configuration from foc_adc.h to foc_cfg.h

This commit is contained in:
raiden00pl 2021-12-04 17:34:58 +01:00 committed by Xiang Xiao
parent edeaacedb0
commit 3fda1294d7
5 changed files with 50 additions and 52 deletions

View File

@ -31,55 +31,6 @@
* Pre-processor Definitions
****************************************************************************/
/* VBUS source must be specified */
#if defined(CONFIG_EXAMPLES_FOC_VBUS_CONST) && \
defined(CONFIG_EXAMPLES_FOC_VBUS_ADC)
# error
#endif
/* Velocity source must be specified */
#if defined(CONFIG_EXAMPLES_FOC_SETPOINT_CONST) && \
defined(CONFIG_EXAMPLES_FOC_SETPOINT_ADC)
# error
#endif
/* VBUS ADC scale factor */
#ifdef CONFIG_EXAMPLES_FOC_VBUS_ADC
# define VBUS_ADC_SCALE (CONFIG_EXAMPLES_FOC_ADC_VREF * \
CONFIG_EXAMPLES_FOC_VBUS_SCALE / \
CONFIG_EXAMPLES_FOC_ADC_MAX / \
1000.0f / \
1000.0f)
#endif
/* Velocity ADC scale factor */
#ifdef CONFIG_EXAMPLES_FOC_SETPOINT_ADC
# define SETPOINT_ADC_SCALE (1.0f / CONFIG_EXAMPLES_FOC_ADC_MAX)
#endif
/* If constant velocity is selected, velocity value must be provided */
#ifdef CONFIG_EXAMPLES_FOC_SETPOINT_CONST
# define SETPOINT_ADC_SCALE (1)
# if CONFIG_EXAMPLES_FOC_SETPOINT_CONST_VALUE == 0
# error
# endif
#endif
/* If constant VBUS is selected, VBUS value must be provided */
#ifdef CONFIG_EXAMPLES_FOC_VBUS_CONST
# define VBUS_ADC_SCALE (1)
# define VBUS_CONST_VALUE (CONFIG_EXAMPLES_FOC_VBUS_CONST_VALUE / 1000.0f)
# if CONFIG_EXAMPLES_FOC_VBUS_CONST_VALUE == 0
# error
# endif
#endif
/* Additional configuration if ADC support is required */
#ifdef CONFIG_EXAMPLES_FOC_HAVE_ADC

View File

@ -128,4 +128,53 @@
# endif
#endif
/* Setpoint source must be specified */
#if !defined(CONFIG_EXAMPLES_FOC_SETPOINT_CONST) && \
!defined(CONFIG_EXAMPLES_FOC_SETPOINT_ADC)
# error
#endif
/* Setpoint ADC scale factor */
#ifdef CONFIG_EXAMPLES_FOC_SETPOINT_ADC
# define SETPOINT_ADC_SCALE (1.0f / CONFIG_EXAMPLES_FOC_ADC_MAX)
#endif
/* If constant setpoint is selected, setpoint value must be provided */
#ifdef CONFIG_EXAMPLES_FOC_SETPOINT_CONST
# define SETPOINT_ADC_SCALE (1)
# if CONFIG_EXAMPLES_FOC_SETPOINT_CONST_VALUE == 0
# error
# endif
#endif
/* VBUS source must be specified */
#if !defined(CONFIG_EXAMPLES_FOC_VBUS_CONST) && \
!defined(CONFIG_EXAMPLES_FOC_VBUS_ADC)
# error
#endif
/* VBUS ADC scale factor */
#ifdef CONFIG_EXAMPLES_FOC_VBUS_ADC
# define VBUS_ADC_SCALE (CONFIG_EXAMPLES_FOC_ADC_VREF * \
CONFIG_EXAMPLES_FOC_VBUS_SCALE / \
CONFIG_EXAMPLES_FOC_ADC_MAX / \
1000.0f / \
1000.0f)
#endif
/* If constant VBUS is selected, VBUS value must be provided */
#ifdef CONFIG_EXAMPLES_FOC_VBUS_CONST
# define VBUS_ADC_SCALE (1)
# define VBUS_CONST_VALUE (CONFIG_EXAMPLES_FOC_VBUS_CONST_VALUE / 1000.0f)
# if CONFIG_EXAMPLES_FOC_VBUS_CONST_VALUE == 0
# error
# endif
#endif
#endif /* __EXAMPLES_FOC_FOC_CFG_H */

View File

@ -41,7 +41,7 @@
#include "foc_mq.h"
#include "foc_thr.h"
#include "foc_adc.h"
#include "foc_cfg.h"
#include "foc_debug.h"
#include "foc_device.h"
#include "foc_parseargs.h"

View File

@ -29,7 +29,6 @@
#include "foc_motor_b16.h"
#include "foc_cfg.h"
#include "foc_adc.h"
#include "foc_debug.h"
/****************************************************************************

View File

@ -29,7 +29,6 @@
#include "foc_motor_f32.h"
#include "foc_cfg.h"
#include "foc_adc.h"
#include "foc_debug.h"
/****************************************************************************