drivers: pwm: add support for inverted PWM signals
Add support for requesting an inverted PWM pulse (active-low) when setting up the period and pulse width of a PWM pin. This is useful when driving external, active-low circuitry (e.g. an LED) with a PWM signal. All in-tree PWM drivers is updated to match the new API signature, but no driver support for inverted PWM signals is added yet. All in-tree PWM consumers are updated to pass a flags value of 0 (0 meaning default, which is normal PWM polarity). Fixes #21384. Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
This commit is contained in:
parent
def1f0e2d5
commit
db611e6781
24 changed files with 152 additions and 38 deletions
|
@ -123,7 +123,8 @@ static bool any_other_channel_is_active(u8_t channel,
|
|||
}
|
||||
|
||||
static int pwm_nrfx_pin_set(struct device *dev, u32_t pwm,
|
||||
u32_t period_cycles, u32_t pulse_cycles)
|
||||
u32_t period_cycles, u32_t pulse_cycles,
|
||||
pwm_flags_t flags)
|
||||
{
|
||||
/* We assume here that period_cycles will always be 16MHz
|
||||
* peripheral clock. Since pwm_nrfx_get_cycles_per_sec() function might
|
||||
|
@ -134,6 +135,11 @@ static int pwm_nrfx_pin_set(struct device *dev, u32_t pwm,
|
|||
struct pwm_nrfx_data *data = dev->driver_data;
|
||||
u8_t channel;
|
||||
|
||||
if (flags) {
|
||||
/* PWM polarity not supported (yet?) */
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
/* Check if PWM pin is one of the predefiend DTS config pins.
|
||||
* Return its array index (channel number),
|
||||
* or NRF_PWM_CHANNEL_COUNT if not initialized through DTS.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue