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 <michallenc@seznam.cz>
This commit is contained in:
Michal Lenc 2023-03-06 12:41:11 +01:00 committed by Xiang Xiao
parent b48f9d9b96
commit 88f3d89920
2 changed files with 26 additions and 0 deletions

View File

@ -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

View File

@ -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 */