This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx-apps.git

commit 3fda1294d76d271389d7a0b63444ac7685156e22
Author: raiden00pl <[email protected]>
AuthorDate: Sat Dec 4 17:34:58 2021 +0100

    examples/foc: move setpoint and vbus configuration from foc_adc.h to 
foc_cfg.h
---
 examples/foc/foc_adc.h       | 49 --------------------------------------------
 examples/foc/foc_cfg.h       | 49 ++++++++++++++++++++++++++++++++++++++++++++
 examples/foc/foc_main.c      |  2 +-
 examples/foc/foc_motor_b16.c |  1 -
 examples/foc/foc_motor_f32.c |  1 -
 5 files changed, 50 insertions(+), 52 deletions(-)

diff --git a/examples/foc/foc_adc.h b/examples/foc/foc_adc.h
index 28fcc04..deafd8c 100644
--- a/examples/foc/foc_adc.h
+++ b/examples/foc/foc_adc.h
@@ -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
diff --git a/examples/foc/foc_cfg.h b/examples/foc/foc_cfg.h
index cf6476d..25cee0e 100644
--- a/examples/foc/foc_cfg.h
+++ b/examples/foc/foc_cfg.h
@@ -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 */
diff --git a/examples/foc/foc_main.c b/examples/foc/foc_main.c
index a0a8359..134774c 100644
--- a/examples/foc/foc_main.c
+++ b/examples/foc/foc_main.c
@@ -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"
diff --git a/examples/foc/foc_motor_b16.c b/examples/foc/foc_motor_b16.c
index 0cee3ac..6c7ef65 100644
--- a/examples/foc/foc_motor_b16.c
+++ b/examples/foc/foc_motor_b16.c
@@ -29,7 +29,6 @@
 #include "foc_motor_b16.h"
 
 #include "foc_cfg.h"
-#include "foc_adc.h"
 #include "foc_debug.h"
 
 /****************************************************************************
diff --git a/examples/foc/foc_motor_f32.c b/examples/foc/foc_motor_f32.c
index 32d3a60..fa839a1 100644
--- a/examples/foc/foc_motor_f32.c
+++ b/examples/foc/foc_motor_f32.c
@@ -29,7 +29,6 @@
 #include "foc_motor_f32.h"
 
 #include "foc_cfg.h"
-#include "foc_adc.h"
 #include "foc_debug.h"
 
 /****************************************************************************

Reply via email to