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
|
@ -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.
|
||||
*/
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue