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:
Henrik Brix Andersen 2019-11-13 14:46:37 +01:00 committed by Carles Cufí
commit db611e6781
24 changed files with 152 additions and 38 deletions

View file

@ -87,7 +87,8 @@ static u8_t pwm_channel_map(struct pwm_data *data, u8_t map_size,
}
static int pwm_nrf5_sw_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)
{
struct pwm_config *config;
NRF_TIMER_Type *timer;
@ -101,6 +102,11 @@ static int pwm_nrf5_sw_pin_set(struct device *dev, u32_t pwm,
timer = config->timer;
data = dev->driver_data;
if (flags) {
/* PWM polarity not supported (yet?) */
return -ENOTSUP;
}
/* check if requested period is allowed while other channels are
* active.
*/