zephyr/drivers/pwm/pwm_handlers.c
Henrik Brix Andersen db611e6781 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>
2020-01-07 18:13:18 +01:00

29 lines
834 B
C

/*
* Copyright (c) 2017 Intel Corporation
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <syscall_handler.h>
#include <drivers/pwm.h>
static inline int z_vrfy_pwm_pin_set_cycles(struct device *dev, u32_t pwm,
u32_t period, u32_t pulse,
pwm_flags_t flags)
{
Z_OOPS(Z_SYSCALL_DRIVER_PWM(dev, pin_set));
return z_impl_pwm_pin_set_cycles((struct device *)dev, pwm, period,
pulse, flags);
}
#include <syscalls/pwm_pin_set_cycles_mrsh.c>
static inline int z_vrfy_pwm_get_cycles_per_sec(struct device *dev, u32_t pwm,
u64_t *cycles)
{
Z_OOPS(Z_SYSCALL_DRIVER_PWM(dev, get_cycles_per_sec));
Z_OOPS(Z_SYSCALL_MEMORY_WRITE(cycles, sizeof(u64_t)));
return z_impl_pwm_get_cycles_per_sec((struct device *)dev,
pwm, (u64_t *)cycles);
}
#include <syscalls/pwm_get_cycles_per_sec_mrsh.c>