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


The following commit(s) were added to refs/heads/master by this push:
     new 3b1967e  examples/foc: add an option to disable motor controller logic
3b1967e is described below

commit 3b1967ec71140e8210a29d9ffbc044537b61324c
Author: raiden00pl <[email protected]>
AuthorDate: Wed Feb 16 13:32:30 2022 +0100

    examples/foc: add an option to disable motor controller logic
    
    This is useful feature for debug purposes.
---
 examples/foc/Kconfig         | 9 +++++++++
 examples/foc/foc_motor_b16.c | 6 ++++++
 examples/foc/foc_motor_f32.c | 6 ++++++
 examples/foc/foc_thr.h       | 2 ++
 4 files changed, 23 insertions(+)

diff --git a/examples/foc/Kconfig b/examples/foc/Kconfig
index 0311350..21a1333 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 07acb4f..d0c7322 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 9ee37f1..cc32d7d 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 a3ded48..2a8237e 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
 };
 

Reply via email to