You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by ac...@apache.org on 2021/04/01 18:43:56 UTC

[incubator-nuttx] branch master updated (55517a5 -> 5bff5dc)

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

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


    from 55517a5  libdsp/fixed16: add openloop handler
     new 0f847c1  debug: add motor related debug messsages
     new 5bff5dc  motor/foc: use motor debug messages in FOC files

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 Kconfig                                     | 25 ++++++++++++++
 arch/arm/src/stm32/stm32_foc.c              | 34 +++++++++----------
 arch/sim/src/sim/up_foc.c                   | 51 ++++++++++++++---------------
 boards/arm/stm32/common/src/stm32_ihm07m1.c | 12 +++----
 boards/arm/stm32/common/src/stm32_ihm08m1.c | 12 +++----
 drivers/motor/foc/foc_dev.c                 | 44 ++++++++++++-------------
 include/debug.h                             | 26 +++++++++++++++
 7 files changed, 127 insertions(+), 77 deletions(-)

[incubator-nuttx] 02/02: motor/foc: use motor debug messages in FOC files

Posted by ac...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 5bff5dc971dcdedd6ce3578cffea0a981e5d0125
Author: raiden00pl <ra...@railab.me>
AuthorDate: Thu Apr 1 08:57:23 2021 +0200

    motor/foc: use motor debug messages in FOC files
---
 arch/arm/src/stm32/stm32_foc.c              | 34 +++++++++----------
 arch/sim/src/sim/up_foc.c                   | 51 ++++++++++++++---------------
 boards/arm/stm32/common/src/stm32_ihm07m1.c | 12 +++----
 boards/arm/stm32/common/src/stm32_ihm08m1.c | 12 +++----
 drivers/motor/foc/foc_dev.c                 | 44 ++++++++++++-------------
 5 files changed, 76 insertions(+), 77 deletions(-)

diff --git a/arch/arm/src/stm32/stm32_foc.c b/arch/arm/src/stm32/stm32_foc.c
index 1855eae..a1db348 100644
--- a/arch/arm/src/stm32/stm32_foc.c
+++ b/arch/arm/src/stm32/stm32_foc.c
@@ -964,7 +964,7 @@ static int stm32_foc_start(FAR struct foc_dev_s *dev, bool state)
   ret = stm32_foc_pwm_start(dev, state);
   if (ret < 0)
     {
-      pwrerr("ERROR: stm32_foc_pwm_start failed %d\n", ret);
+      mtrerr("stm32_foc_pwm_start failed %d\n", ret);
       goto errout;
     }
 
@@ -973,7 +973,7 @@ static int stm32_foc_start(FAR struct foc_dev_s *dev, bool state)
   ret = stm32_foc_adc_start(dev, state);
   if (ret < 0)
     {
-      pwrerr("ERROR: stm32_foc_adc_start failed %d\n", ret);
+      mtrerr("stm32_foc_adc_start failed %d\n", ret);
       goto errout;
     }
 
@@ -1177,7 +1177,7 @@ static int stm32_foc_configure(FAR struct foc_dev_s *dev,
   ret = stm32_foc_adc_cfg(dev);
   if (ret < 0)
     {
-      pwrerr("ERROR: stm32_foc_adc_cfg failed %d\n", ret);
+      mtrerr("stm32_foc_adc_cfg failed %d\n", ret);
       goto errout;
     }
 
@@ -1186,7 +1186,7 @@ static int stm32_foc_configure(FAR struct foc_dev_s *dev,
   ret = stm32_foc_pwm_cfg(dev, cfg->pwm_freq);
   if (ret < 0)
     {
-      pwrerr("ERROR: stm32_foc_pwm_cfg failed %d\n", ret);
+      mtrerr("stm32_foc_pwm_cfg failed %d\n", ret);
       goto errout;
     }
 
@@ -1195,7 +1195,7 @@ static int stm32_foc_configure(FAR struct foc_dev_s *dev,
   ret = stm32_foc_notifier_cfg(dev, cfg->notifier_freq);
   if (ret < 0)
     {
-      pwrerr("ERROR: stm32_foc_notifier_cfg failed %d\n", ret);
+      mtrerr("stm32_foc_notifier_cfg failed %d\n", ret);
       goto errout;
     }
 
@@ -1263,7 +1263,7 @@ static int stm32_foc_setup(FAR struct foc_dev_s *dev)
   ret = board->ops->setup(dev);
   if (ret < 0)
     {
-      pwrerr("ERROR: board->setup failed %d\n", ret);
+      mtrerr("board->setup failed %d\n", ret);
       goto errout;
     }
 
@@ -1325,7 +1325,7 @@ static int stm32_foc_setup(FAR struct foc_dev_s *dev)
   ret = up_prioritize_irq(foc_dev->adc_irq, NVIC_SYSH_PRIORITY_DEFAULT);
   if (ret < 0)
     {
-      pwrerr("ERROR: up_prioritize_irq failed: %d\n", ret);
+      mtrerr("up_prioritize_irq failed: %d\n", ret);
       goto errout;
     }
 
@@ -1334,7 +1334,7 @@ static int stm32_foc_setup(FAR struct foc_dev_s *dev)
   ret = irq_attach(foc_dev->adc_irq, stm32_foc_adc_handler, NULL);
   if (ret < 0)
     {
-      pwrerr("ERROR: irq_attach failed: %d\n", ret);
+      mtrerr("irq_attach failed: %d\n", ret);
       goto errout;
     }
 
@@ -1348,7 +1348,7 @@ static int stm32_foc_setup(FAR struct foc_dev_s *dev)
   ret = stm32_foc_trace_init(dev);
   if (ret < 0)
     {
-      pwrerr("ERROR: stm32_foc_trace_init failed %d\n", ret);
+      mtrerr("stm32_foc_trace_init failed %d\n", ret);
       goto errout;
     }
 #endif
@@ -1358,7 +1358,7 @@ static int stm32_foc_setup(FAR struct foc_dev_s *dev)
   ret = stm32_foc_calibration_start(dev);
   if (ret < 0)
     {
-      pwrerr("ERROR: stm32_foc_calibration_start failed %d\n", ret);
+      mtrerr("stm32_foc_calibration_start failed %d\n", ret);
       goto errout;
     }
 
@@ -1684,7 +1684,7 @@ static int stm32_foc_calibration_start(FAR struct foc_dev_s *dev)
   DEBUGASSERT(pwm);
   DEBUGASSERT(adc);
 
-  pwrinfo("Start ADC offset calibration\n");
+  mtrinfo("Start ADC offset calibration\n");
 
   /* Call board-specific */
 
@@ -1775,7 +1775,7 @@ static int stm32_foc_calibration_start(FAR struct foc_dev_s *dev)
       STM32_ADC_OFFSET_SET(adc, ch, i, priv->data.curr_offset[i]);
     }
 
-  pwrinfo("ADC offset calibration - DONE!\n");
+  mtrinfo("ADC offset calibration - DONE!\n");
 
 errout:
 
@@ -1943,7 +1943,7 @@ static int stm32_foc_bind(FAR struct foc_dev_s *dev,
 
   if (dev->devno > CONFIG_MOTOR_FOC_INST)
     {
-      pwrerr("ERROR: unsupported STM32 FOC instance %d\n", dev->devno);
+      mtrerr("Unsupported STM32 FOC instance %d\n", dev->devno);
       ret = -EINVAL;
       goto errout;
     }
@@ -2114,7 +2114,7 @@ stm32_foc_initialize(int inst, FAR struct stm32_foc_board_s *board)
 
       default:
         {
-          pwrerr("ERROR: unsupported STM32 FOC instance %d\n", inst);
+          mtrerr("Unsupported STM32 FOC instance %d\n", inst);
           set_errno(EINVAL);
           goto errout;
         }
@@ -2164,7 +2164,7 @@ stm32_foc_initialize(int inst, FAR struct stm32_foc_board_s *board)
   foc_dev->pwm = (FAR struct stm32_pwm_dev_s *)stm32_pwminitialize(pwm_inst);
   if (foc_dev->pwm == NULL)
     {
-      pwrerr("ERROR: Failed to get PWM%d interface\n", pwm_inst);
+      mtrerr("Failed to get PWM%d interface\n", pwm_inst);
       set_errno(EINVAL);
       goto errout;
     }
@@ -2184,7 +2184,7 @@ stm32_foc_initialize(int inst, FAR struct stm32_foc_board_s *board)
 
   if (adc_inst != adc_cfg->intf)
     {
-      pwrerr("ERROR: configuration doesn't match %d, %d\n",
+      mtrerr("Configuration doesn't match %d, %d\n",
              adc_inst, adc_cfg->intf);
       set_errno(EINVAL);
       goto errout;
@@ -2197,7 +2197,7 @@ stm32_foc_initialize(int inst, FAR struct stm32_foc_board_s *board)
                                          adc_cfg->nchan);
   if (foc_dev->adc_dev == NULL)
     {
-      pwrerr("ERROR: Failed to get ADC%d interface\n", adc_cfg->intf);
+      mtrerr("Failed to get ADC%d interface\n", adc_cfg->intf);
       set_errno(EINVAL);
       goto errout;
     }
diff --git a/arch/sim/src/sim/up_foc.c b/arch/sim/src/sim/up_foc.c
index 72c70eb..3042737 100644
--- a/arch/sim/src/sim/up_foc.c
+++ b/arch/sim/src/sim/up_foc.c
@@ -175,7 +175,7 @@ static int sim_foc_pwm_setup(FAR struct foc_dev_s *dev, uint32_t freq)
   DEBUGASSERT(dev);
   DEBUGASSERT(sim);
 
-  pwrinfo("[PWM_SETUP] devno=%d freq=%d\n", dev->devno, freq);
+  mtrinfo("[PWM_SETUP] devno=%d freq=%d\n", dev->devno, freq);
 
   DEBUGASSERT(freq > 0);
 
@@ -200,14 +200,14 @@ static int sim_foc_start(FAR struct foc_dev_s *dev, bool state)
   irqstate_t                 flags;
   int                        ret = OK;
 
-  pwrinfo("[FOC_START] devno=%d state=%d\n", dev->devno, state);
+  mtrinfo("[FOC_START] devno=%d state=%d\n", dev->devno, state);
 
   /* Start PWM */
 
   ret = sim_foc_pwm_start(dev, state);
   if (ret < 0)
     {
-      pwrerr("ERROR: sim_foc_pwm_start failed %d\n", ret);
+      mtrerr("sim_foc_pwm_start failed %d\n", ret);
       goto errout;
     }
 
@@ -216,7 +216,7 @@ static int sim_foc_start(FAR struct foc_dev_s *dev, bool state)
   ret = sim_foc_adc_start(dev, state);
   if (ret < 0)
     {
-      pwrerr("ERROR: sim_foc_adc_start failed %d\n", ret);
+      mtrerr("sim_foc_adc_start failed %d\n", ret);
       goto errout;
     }
 
@@ -242,7 +242,7 @@ static int sim_foc_pwm_start(FAR struct foc_dev_s *dev, bool state)
 {
   DEBUGASSERT(dev);
 
-  pwrinfo("[PWM_START] devno=%d state=%d\n", dev->devno, state);
+  mtrinfo("[PWM_START] devno=%d state=%d\n", dev->devno, state);
 
   return OK;
 }
@@ -259,7 +259,7 @@ static int sim_foc_adc_setup(FAR struct foc_dev_s *dev)
 {
   DEBUGASSERT(dev);
 
-  pwrinfo("[ADC_SETUP] devno=%d\n", dev->devno);
+  mtrinfo("[ADC_SETUP] devno=%d\n", dev->devno);
 
   return OK;
 }
@@ -276,7 +276,7 @@ static int sim_foc_adc_start(FAR struct foc_dev_s *dev, bool state)
 {
   DEBUGASSERT(dev);
 
-  pwrinfo("[ADC_START] devno=%d state=%d\n", dev->devno, state);
+  mtrinfo("[ADC_START] devno=%d state=%d\n", dev->devno, state);
 
   return OK;
 }
@@ -297,7 +297,7 @@ static int sim_foc_notifier_cfg(FAR struct foc_dev_s *dev, uint32_t freq)
   DEBUGASSERT(dev);
   DEBUGASSERT(sim);
 
-  pwrinfo("[NOTIFIER_CFG] devno=%d freq=%d\n", dev->devno, freq);
+  mtrinfo("[NOTIFIER_CFG] devno=%d freq=%d\n", dev->devno, freq);
 
   DEBUGASSERT(freq > 0);
 
@@ -336,14 +336,14 @@ static int sim_foc_configure(FAR struct foc_dev_s *dev,
   DEBUGASSERT(cfg->pwm_freq > 0);
   DEBUGASSERT(cfg->notifier_freq > 0);
 
-  pwrinfo("[FOC_SETUP] devno=%d\n", dev->devno);
+  mtrinfo("[FOC_SETUP] devno=%d\n", dev->devno);
 
   /* Configure ADC */
 
   ret = sim_foc_adc_setup(dev);
   if (ret < 0)
     {
-      pwrerr("ERROR: sim_foc_adc_setup failed %d\n", ret);
+      mtrerr("sim_foc_adc_setup failed %d\n", ret);
       goto errout;
     }
 
@@ -352,7 +352,7 @@ static int sim_foc_configure(FAR struct foc_dev_s *dev,
   ret = sim_foc_pwm_setup(dev, cfg->pwm_freq);
   if (ret < 0)
     {
-      pwrerr("ERROR: sim_foc_pwm_setup failed %d\n", ret);
+      mtrerr("sim_foc_pwm_setup failed %d\n", ret);
       goto errout;
     }
 
@@ -361,7 +361,7 @@ static int sim_foc_configure(FAR struct foc_dev_s *dev,
   ret = sim_foc_notifier_cfg(dev, cfg->notifier_freq);
   if (ret < 0)
     {
-      pwrerr("ERROR: sim_foc_notifier_cfg failed %d\n", ret);
+      mtrerr("sim_foc_notifier_cfg failed %d\n", ret);
       goto errout;
     }
 
@@ -385,7 +385,7 @@ static int sim_foc_setup(FAR struct foc_dev_s *dev)
 {
   DEBUGASSERT(dev);
 
-  pwrinfo("[FOC_SETUP] devno=%d\n", dev->devno);
+  mtrinfo("[FOC_SETUP] devno=%d\n", dev->devno);
 
   /* Get HW configuration */
 
@@ -406,7 +406,7 @@ static int sim_foc_shutdown(FAR struct foc_dev_s *dev)
 {
   DEBUGASSERT(dev);
 
-  pwrinfo("[FOC_SHUTDOWN] devno=%d\n", dev->devno);
+  mtrinfo("[FOC_SHUTDOWN] devno=%d\n", dev->devno);
 
   return OK;
 }
@@ -426,7 +426,7 @@ static int sim_foc_ioctl(FAR struct foc_dev_s *dev, int cmd,
 
   DEBUGASSERT(dev);
 
-  pwrinfo("[FOC_IOCTL] devno=%d cmd=%d\n", dev->devno, cmd);
+  mtrinfo("[FOC_IOCTL] devno=%d cmd=%d\n", dev->devno, cmd);
 
   switch (cmd)
     {
@@ -456,7 +456,7 @@ static int sim_foc_notifier_handler(FAR struct foc_dev_s *dev)
   DEBUGASSERT(dev);
   DEBUGASSERT(sim);
 
-  pwrinfo("[FOC_NOTIFIER_HANDLER] devno=%d cntr=%d\n",
+  mtrinfo("[FOC_NOTIFIER_HANDLER] devno=%d cntr=%d\n",
           dev->devno, sim->notifier_cntr);
 
   flags = enter_critical_section();
@@ -500,14 +500,14 @@ static int sim_foc_pwm_duty_set(FAR struct foc_dev_s *dev,
       DEBUGASSERT(duty[i] >= 0);
     }
 
-  pwrinfo("[PWM_DUTY_SET] devno=%d duty= ", dev->devno);
+  mtrinfo("[PWM_DUTY_SET] devno=%d duty= ", dev->devno);
 
 #if CONFIG_MOTOR_FOC_PHASES == 2
-  pwrinfo("[%d %d]\n", duty[0], duty[1]);
+  mtrinfo("[%d %d]\n", duty[0], duty[1]);
 #elif CONFIG_MOTOR_FOC_PHASES == 3
-  pwrinfo("[%d %d %d]\n", duty[0], duty[1], duty[2]);
+  mtrinfo("[%d %d %d]\n", duty[0], duty[1], duty[2]);
 #elif CONFIG_MOTOR_FOC_PHASES == 4
-  pwrinfo("[%d %d %d %d]\n", duty[0], duty[1], duty[2], duty[3]);
+  mtrinfo("[%d %d %d %d]\n", duty[0], duty[1], duty[2], duty[3]);
 #else
 #  error
 #endif
@@ -551,14 +551,13 @@ static int sim_foc_bind(FAR struct foc_dev_s *dev,
   DEBUGASSERT(cb);
   DEBUGASSERT(sim);
 
-  pwrinfo("[FOC_BIND] devno=%d\n", dev->devno);
+  mtrinfo("[FOC_BIND] devno=%d\n", dev->devno);
 
   /* Do we support given FOC instance? */
 
   if (dev->devno > CONFIG_MOTOR_FOC_INST)
     {
-      pwrerr("ERROR: unsupported SIM FOC instance %d\n",
-             dev->devno);
+      mtrerr("unsupported SIM FOC instance %d\n", dev->devno);
       ret = -EINVAL;
       goto errout;
     }
@@ -583,7 +582,7 @@ static int sim_foc_fault_clear(FAR struct foc_dev_s *dev)
 {
   DEBUGASSERT(dev);
 
-  pwrinfo("[FAULT_CLEAR] devno=%d\n", dev->devno);
+  mtrinfo("[FAULT_CLEAR] devno=%d\n", dev->devno);
 
   return OK;
 }
@@ -601,7 +600,7 @@ static void sim_foc_trace(FAR struct foc_dev_s *dev, int type, bool state)
 {
   DEBUGASSERT(dev);
 
-  pwrinfo("[FOC_TRACE] devno=%d type=%d state=%d\n",
+  mtrinfo("[FOC_TRACE] devno=%d type=%d state=%d\n",
           dev->devno, type, state);
 }
 #endif  /* CONFIG_MOTOR_FOC_TRACE */
@@ -623,7 +622,7 @@ FAR struct foc_dev_s *sim_foc_initialize(int inst)
   FAR struct foc_lower_s *foc_lower = NULL;
   FAR struct foc_dev_s   *dev       = NULL;
 
-  pwrinfo("[FOC_INITIALIZE] inst=%d\n", inst);
+  mtrinfo("[FOC_INITIALIZE] inst=%d\n", inst);
 
   /* Reset data */
 
diff --git a/boards/arm/stm32/common/src/stm32_ihm07m1.c b/boards/arm/stm32/common/src/stm32_ihm07m1.c
index 76d5873..750e1b2 100644
--- a/boards/arm/stm32/common/src/stm32_ihm07m1.c
+++ b/boards/arm/stm32/common/src/stm32_ihm07m1.c
@@ -336,7 +336,7 @@ static void board_foc_trace(FAR struct foc_dev_s *dev, int type, bool state)
 
       default:
         {
-          pwrerr("ERROR: board_foc_trace type=%d not supported!\n", type);
+          mtrerr("board_foc_trace type=%d not supported!\n", type);
           DEBUGASSERT(0);
         }
     }
@@ -372,7 +372,7 @@ int board_ihm07m1_initialize(FAR struct stm32_foc_adc_s *adc_cfg)
       if (foc == NULL)
         {
           ret = -errno;
-          pwrerr("ERROR: failed to initialize STM32 FOC: %d\n", ret);
+          mtrerr("Failed to initialize STM32 FOC: %d\n", ret);
           goto errout;
         }
 
@@ -383,7 +383,7 @@ int board_ihm07m1_initialize(FAR struct stm32_foc_adc_s *adc_cfg)
       ret = foc_register(FOC_DEVPATH, foc);
       if (ret < 0)
         {
-          printf("ERROR: failed to register FOC device: %d\n", ret);
+          mtrerr("Failed to register FOC device: %d\n", ret);
           goto errout;
         }
 
@@ -417,7 +417,7 @@ int stm32_adc_setup(void)
     {
       if (g_foc_dev == NULL)
         {
-          pwrerr("ERROR: failed to get g_foc_dev device\n");
+          mtrerr("Failed to get g_foc_dev device\n");
           ret = -EACCES;
           goto errout;
         }
@@ -427,14 +427,14 @@ int stm32_adc_setup(void)
       adc = stm32_foc_adcget(g_foc_dev);
       if (adc == NULL)
         {
-          pwrerr("ERROR: failed to get ADC device: %d\n", ret);
+          mtrerr("Failed to get ADC device: %d\n", ret);
           goto errout;
         }
 
       ret = adc_register("/dev/adc0", adc);
       if (ret < 0)
         {
-          pwrerr("ERROR: adc_register failed: %d\n", ret);
+          mtrerr("adc_register failed: %d\n", ret);
           goto errout;
         }
 
diff --git a/boards/arm/stm32/common/src/stm32_ihm08m1.c b/boards/arm/stm32/common/src/stm32_ihm08m1.c
index 141179f..e15bb83 100644
--- a/boards/arm/stm32/common/src/stm32_ihm08m1.c
+++ b/boards/arm/stm32/common/src/stm32_ihm08m1.c
@@ -326,7 +326,7 @@ static void board_foc_trace(FAR struct foc_dev_s *dev, int type, bool state)
 
       default:
         {
-          pwrerr("ERROR: board_foc_trace type=%d not supported!\n", type);
+          mtrerr("board_foc_trace type=%d not supported!\n", type);
           DEBUGASSERT(0);
         }
     }
@@ -360,7 +360,7 @@ int board_ihm08m1_initialize(FAR struct stm32_foc_adc_s *adc_cfg)
       if (foc == NULL)
         {
           ret = -errno;
-          pwrerr("ERROR: failed to initialize STM32 FOC: %d\n", ret);
+          mtrerr("Failed to initialize STM32 FOC: %d\n", ret);
           goto errout;
         }
 
@@ -371,7 +371,7 @@ int board_ihm08m1_initialize(FAR struct stm32_foc_adc_s *adc_cfg)
       ret = foc_register(FOC_DEVPATH, foc);
       if (ret < 0)
         {
-          printf("ERROR: failed to register FOC device: %d\n", ret);
+          mtrerr("Failed to register FOC device: %d\n", ret);
           goto errout;
         }
 
@@ -405,7 +405,7 @@ int stm32_adc_setup(void)
     {
       if (g_foc_dev == NULL)
         {
-          pwrerr("ERROR: failed to get g_foc_dev device\n");
+          mtrerr("Failed to get g_foc_dev device\n");
           ret = -EACCES;
           goto errout;
         }
@@ -415,14 +415,14 @@ int stm32_adc_setup(void)
       adc = stm32_foc_adcget(g_foc_dev);
       if (adc == NULL)
         {
-          pwrerr("ERROR: failed to get ADC device: %d\n", ret);
+          mtrerr("Failed to get ADC device: %d\n", ret);
           goto errout;
         }
 
       ret = adc_register("/dev/adc0", adc);
       if (ret < 0)
         {
-          pwrerr("ERROR: adc_register failed: %d\n", ret);
+          mtrerr("adc_register failed: %d\n", ret);
           goto errout;
         }
 
diff --git a/drivers/motor/foc/foc_dev.c b/drivers/motor/foc/foc_dev.c
index 41de595..23ebe3f 100644
--- a/drivers/motor/foc/foc_dev.c
+++ b/drivers/motor/foc/foc_dev.c
@@ -272,7 +272,7 @@ static int foc_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
           ret = foc_start(dev);
           if (ret != OK)
             {
-              pwrerr("ERROR: MTRIOC_START failed %d\n", ret);
+              mtrerr("MTRIOC_START failed %d\n", ret);
             }
 
           break;
@@ -285,7 +285,7 @@ static int foc_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
           ret = foc_stop(dev);
           if (ret != OK)
             {
-              pwrerr("ERROR: MTRIOC_STOP failed %d\n", ret);
+              mtrerr("MTRIOC_STOP failed %d\n", ret);
             }
 
           break;
@@ -302,7 +302,7 @@ static int foc_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
           ret = foc_state_get(dev, state);
           if (ret != OK)
             {
-              pwrerr("ERROR: MTRIOC_GET_STATE failed %d\n", ret);
+              mtrerr("MTRIOC_GET_STATE failed %d\n", ret);
             }
 
           break;
@@ -317,7 +317,7 @@ static int foc_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
           ret = foc_fault_clear(dev);
           if (ret != OK)
             {
-              pwrerr("ERROR: MTRIOC_CLEAR_FAULT failed %d\n", ret);
+              mtrerr("MTRIOC_CLEAR_FAULT failed %d\n", ret);
             }
 
           break;
@@ -334,7 +334,7 @@ static int foc_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
           ret = foc_params_set(dev, params);
           if (ret != OK)
             {
-              pwrerr("ERROR: MTRIOC_SET_PARAMS failed %d\n", ret);
+              mtrerr("MTRIOC_SET_PARAMS failed %d\n", ret);
             }
 
           break;
@@ -351,7 +351,7 @@ static int foc_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
           ret = foc_cfg_set(dev, cfg);
           if (ret != OK)
             {
-              pwrerr("ERROR: MTRIOC_SET_CONFIG failed %d\n", ret);
+              mtrerr("MTRIOC_SET_CONFIG failed %d\n", ret);
             }
 
           break;
@@ -368,7 +368,7 @@ static int foc_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
           ret = foc_info_get(dev, info);
           if (ret != OK)
             {
-              pwrerr("ERROR: MTRIOC_GET_INFO failed %d\n", ret);
+              mtrerr("MTRIOC_GET_INFO failed %d\n", ret);
             }
 
           break;
@@ -378,7 +378,7 @@ static int foc_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
 
       default:
         {
-          pwrinfo("Forwarding unrecognized cmd: %d arg: %ld\n", cmd, arg);
+          mtrinfo("Forwarding unrecognized cmd: %d arg: %ld\n", cmd, arg);
 
           /* Call lower-half logic */
 
@@ -449,7 +449,7 @@ static int foc_setup(FAR struct foc_dev_s *dev)
 
   DEBUGASSERT(dev);
 
-  pwrinfo("FOC SETUP\n");
+  mtrinfo("FOC SETUP\n");
 
   /* Reset device data */
 
@@ -461,7 +461,7 @@ static int foc_setup(FAR struct foc_dev_s *dev)
   ret = foc_lower_bind(dev);
   if (ret < 0)
     {
-      pwrerr("ERROR: foc_lower_bind failed %d\n", ret);
+      mtrerr("foc_lower_bind failed %d\n", ret);
       set_errno(EINVAL);
       goto errout;
     }
@@ -471,7 +471,7 @@ static int foc_setup(FAR struct foc_dev_s *dev)
   ret = FOC_OPS_SETUP(dev);
   if (ret < 0)
     {
-      pwrerr("FOC_OPS_SETUP failed %d\n", ret);
+      mtrerr("FOC_OPS_SETUP failed %d\n", ret);
       goto errout;
     }
 
@@ -493,7 +493,7 @@ int foc_shutdown(FAR struct foc_dev_s *dev)
 
   DEBUGASSERT(dev);
 
-  pwrinfo("FOC SHUTDOWN\n");
+  mtrinfo("FOC SHUTDOWN\n");
 
   /* Call the lower-half shutdown */
 
@@ -516,14 +516,14 @@ static int foc_start(FAR struct foc_dev_s *dev)
 
   DEBUGASSERT(dev);
 
-  pwrinfo("FOC START\n");
+  mtrinfo("FOC START\n");
 
   /* Reset the notifier semaphore */
 
   ret = nxsem_reset(&dev->statesem, 0);
   if (ret < 0)
     {
-      pwrerr("ERROR: nxsem_reset failed %d\n", ret);
+      mtrerr("nxsem_reset failed %d\n", ret);
       goto errout;
     }
 
@@ -532,7 +532,7 @@ static int foc_start(FAR struct foc_dev_s *dev)
   ret = FOC_OPS_START(dev, true);
   if (ret < 0)
     {
-      pwrerr("ERROR: FOC_OPS_START failed %d !\n", ret);
+      mtrerr("FOC_OPS_START failed %d !\n", ret);
       goto errout;
     }
 
@@ -555,7 +555,7 @@ static int foc_stop(FAR struct foc_dev_s *dev)
 
   DEBUGASSERT(dev);
 
-  pwrinfo("FOC STOP\n");
+  mtrinfo("FOC STOP\n");
 
   /* Zero duty cycle */
 
@@ -566,7 +566,7 @@ static int foc_stop(FAR struct foc_dev_s *dev)
   ret = FOC_OPS_DUTY(dev, d_zero);
   if (ret < 0)
     {
-      pwrerr("ERROR: FOC_OPS_DUTY failed %d\n", ret);
+      mtrerr("FOC_OPS_DUTY failed %d\n", ret);
     }
 
   /* Stop the FOC */
@@ -574,7 +574,7 @@ static int foc_stop(FAR struct foc_dev_s *dev)
   ret = FOC_OPS_START(dev, false);
   if (ret < 0)
     {
-      pwrerr("ERROR: FOC_OPS_START failed %d\n", ret);
+      mtrerr("FOC_OPS_START failed %d\n", ret);
     }
 
   /* Reset device data */
@@ -606,7 +606,7 @@ static int foc_cfg_set(FAR struct foc_dev_s *dev, FAR struct foc_cfg_s *cfg)
 
   memcpy(&dev->cfg, cfg, sizeof(struct foc_cfg_s));
 
-  pwrinfo("FOC %" PRIu8 " PWM=%" PRIu32 " notifier=%" PRIu32 "\n",
+  mtrinfo("FOC %" PRIu8 " PWM=%" PRIu32 " notifier=%" PRIu32 "\n",
           dev->devno, dev->cfg.pwm_freq, dev->cfg.notifier_freq);
 
   /* Call arch configuration */
@@ -614,7 +614,7 @@ static int foc_cfg_set(FAR struct foc_dev_s *dev, FAR struct foc_cfg_s *cfg)
   ret = FOC_OPS_CONFIGURE(dev, &dev->cfg);
   if (ret < 0)
     {
-      pwrerr("FOC_OPS_CONFIGURE failed %d\n", ret);
+      mtrerr("FOC_OPS_CONFIGURE failed %d\n", ret);
       goto errout;
     }
 
@@ -681,7 +681,7 @@ static int foc_fault_clear(FAR struct foc_dev_s *dev)
   ret = FOC_OPS_FAULT_CLEAR(dev);
   if (ret < 0)
     {
-      pwrerr("ERROR: FOC_OPS_FAULT_CLEAR failed %d\n", ret);
+      mtrerr("FOC_OPS_FAULT_CLEAR failed %d\n", ret);
       goto errout;
     }
 
@@ -861,7 +861,7 @@ int foc_register(FAR const char *path, FAR struct foc_dev_s *dev)
 
   if (dev->devno > CONFIG_MOTOR_FOC_INST)
     {
-      pwrerr("ERROR: unsupported foc devno %d\n\n", dev->devno);
+      mtrerr("Unsupported foc devno %d\n\n", dev->devno);
       set_errno(EINVAL);
       ret = ERROR;
       goto errout;

[incubator-nuttx] 01/02: debug: add motor related debug messsages

Posted by ac...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 0f847c1514a5d8aa361c263524a363d6d6b41c06
Author: raiden00pl <ra...@railab.me>
AuthorDate: Thu Apr 1 08:56:42 2021 +0200

    debug: add motor related debug messsages
---
 Kconfig         | 25 +++++++++++++++++++++++++
 include/debug.h | 26 ++++++++++++++++++++++++++
 2 files changed, 51 insertions(+)

diff --git a/Kconfig b/Kconfig
index 56b30c6..7f5fa81 100644
--- a/Kconfig
+++ b/Kconfig
@@ -1709,6 +1709,31 @@ config DEBUG_WATCHDOG_INFO
 		Enable watchdog time informational output to SYSLOG.
 
 endif # DEBUG_WATCHDOG
+
+if DEBUG_MOTOR
+
+config DEBUG_MOTOR_ERROR
+	bool "Motor Error Output"
+	default n
+	depends on DEBUG_ERROR
+	---help---
+		Enable motor error output to SYSLOG.
+
+config DEBUG_MOTOR_WARN
+	bool "Motor Warnings Output"
+	default n
+	depends on DEBUG_WARN
+	---help---
+		Enable motor warning output to SYSLOG.
+
+config DEBUG_MOTOR_INFO
+	bool "Motor Informational Output"
+	default n
+	depends on DEBUG_INFO
+	---help---
+		Enable motor informational output to SYSLOG.
+
+endif # DEBUG_MOTOR
 endif # DEBUG_FEATURES
 
 config ARCH_HAVE_STACKCHECK
diff --git a/include/debug.h b/include/debug.h
index 9f2cb83..f75a1fa 100644
--- a/include/debug.h
+++ b/include/debug.h
@@ -731,6 +731,24 @@
 #  define wdinfo      _none
 #endif
 
+#ifdef CONFIG_DEBUG_MOTOR_ERROR
+#  define mtrerr      _err
+#else
+#  define mtrerr      _none
+#endif
+
+#ifdef CONFIG_DEBUG_MOTOR_WARN
+#  define mtrwarn     _warn
+#else
+#  define mtrwarn     _none
+#endif
+
+#ifdef CONFIG_DEBUG_MOTOR_INFO
+#  define mtrinfo     _info
+#else
+#  define mtrinfo     _none
+#endif
+
 /* Buffer dumping macros do not depend on varargs */
 
 #ifdef CONFIG_DEBUG_ERROR
@@ -995,6 +1013,14 @@
 #  define wdinfodumpbuffer(m,b,n)
 #endif
 
+#ifdef CONFIG_DEBUG_MOTOR
+#  define mtrerrdumpbuffer(m,b,n)  errdumpbuffer(m,b,n)
+#  define mtrinfodumpbuffer(m,b,n) infodumpbuffer(m,b,n)
+#else
+#  define mtrerrdumpbuffer(m,b,n)
+#  define mtrinfodumpbuffer(m,b,n)
+#endif
+
 /****************************************************************************
  * Public Function Prototypes
  ****************************************************************************/