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/nuttx.git

commit 88f3d89920d311d3092511cada54ce281782c62c
Author: Michal Lenc <[email protected]>
AuthorDate: Mon Mar 6 12:41:11 2023 +0100

    pwm: add configuration option for dead time generators
    
    PWM drivers usually supports dead time generators that automatically
    insert output activation delay for complementary PWM outputs. This
    is usefull for some control purposes as control of H bridge for example.
    
    This commit adds an application to driver interface that can be used
    to set up those delays (if supported by the selected architecture)
    directly from the application. The set up remains the same as for duty
    cycle value.
    
    The whole addition is by default disabled. It can be enabled by config
    option PWM_DEADTIME.
    
    Signed-off-by: Michal Lenc <[email protected]>
---
 drivers/timers/Kconfig     | 18 ++++++++++++++++++
 include/nuttx/timers/pwm.h |  8 ++++++++
 2 files changed, 26 insertions(+)

diff --git a/drivers/timers/Kconfig b/drivers/timers/Kconfig
index d64889c2f7..155202cada 100644
--- a/drivers/timers/Kconfig
+++ b/drivers/timers/Kconfig
@@ -13,6 +13,10 @@ config ARCH_HAVE_PWM_OVERWRITE
        bool
        default n
 
+config ARCH_HAVE_PWM_DEADTIME
+       bool
+       default n
+
 config ARCH_HAVE_PWM_MULTICHAN
        bool
        default n
@@ -46,6 +50,20 @@ config PWM_OVERWRITE
                controlled from an application level the same way duty cycle or
                frequency is modified.
 
+config PWM_DEADTIME
+       bool "PWM Deadtime Support"
+       default n
+       depends on ARCH_HAVE_PWM_DEADTIME
+       ---help---
+               Some hardware will support deadtime generators that 
automatically
+               insert output activation delay for complementary PWM outputs. 
This
+               is usefull for H-bridge motor control for example. The deadtime
+               values are set from application level via the same IOCTL that 
sets
+               up duty cycle and frequency.
+
+               For detailed description about deadtime functionality please 
refer
+               to architecture manuals and datasheets.
+
 config PWM_MULTICHAN
        bool "PWM Multiple Output Channel Support"
        default n
diff --git a/include/nuttx/timers/pwm.h b/include/nuttx/timers/pwm.h
index c5af6e3c00..e560117b31 100644
--- a/include/nuttx/timers/pwm.h
+++ b/include/nuttx/timers/pwm.h
@@ -123,6 +123,10 @@ struct pwm_chan_s
 #ifdef CONFIG_PWM_OVERWRITE
   bool ch_outp_ovrwr;
   bool ch_outp_ovrwr_val;
+#endif
+#ifdef CONFIG_PWM_DEADTIME
+  ub16_t dead_time_a;
+  ub16_t dead_time_b;
 #endif
   int8_t channel;
 };
@@ -143,6 +147,10 @@ struct pwm_info_s
   ub16_t             duty;      /* Duty of the pulse train, "1"-to-"0" 
duration.
                                  * Maximum: 65535/65536 (0x0000ffff)
                                  * Minimum:     1/65536 (0x00000001) */
+#ifdef CONFIG_PWM_DEADTIME
+  ub16_t dead_time_a;           /* Dead time value for main output */
+  ub16_t dead_time_b;           /* Dead time value for complementary output */
+#endif
 #  ifdef CONFIG_PWM_PULSECOUNT
   uint32_t           count;     /* The number of pulse to generate.  0 means to
                                  * generate an indefinite number of pulses */

Reply via email to