PWM¶
Overview¶
API Reference¶
-
group
pwm_interface
PWM Interface.
Typedefs
-
typedef u8_t
pwm_flags_t
¶ Provides a type to hold PWM configuration flags.
-
typedef
pwm_pin_set_t
¶ Callback API upon setting the pin See pwm_pin_set_cycles() for argument description.
-
typedef
pwm_get_cycles_per_sec_t
¶ Callback API upon getting cycles per second See pwm_get_cycles_per_sec() for argument description.
Functions
-
int
pwm_pin_set_cycles
(struct device *dev, u32_t pwm, u32_t period, u32_t pulse, pwm_flags_t flags)¶ Set the period and pulse width for a single PWM output.
- Parameters
dev
: Pointer to the device structure for the driver instance.pwm
: PWM pin.period
: Period (in clock cycle) set to the PWM. HW specific.pulse
: Pulse width (in clock cycle) set to the PWM. HW specific.flags
: Flags for pin configuration (polarity).
- Return Value
0
: If successful.Negative
: errno code if failure.
-
int
pwm_get_cycles_per_sec
(struct device *dev, u32_t pwm, u64_t *cycles)¶ Get the clock rate (cycles per second) for a single PWM output.
- Parameters
dev
: Pointer to the device structure for the driver instance.pwm
: PWM pin.cycles
: Pointer to the memory to store clock rate (cycles per sec). HW specific.
- Return Value
0
: If successful.Negative
: errno code if failure.
-
static int
pwm_pin_set_usec
(struct device *dev, u32_t pwm, u32_t period, u32_t pulse, pwm_flags_t flags)¶ Set the period and pulse width for a single PWM output.
- Parameters
dev
: Pointer to the device structure for the driver instance.pwm
: PWM pin.period
: Period (in microseconds) set to the PWM.pulse
: Pulse width (in microseconds) set to the PWM.flags
: Flags for pin configuration (polarity).
- Return Value
0
: If successful.Negative
: errno code if failure.
-
static int
pwm_pin_set_nsec
(struct device *dev, u32_t pwm, u32_t period, u32_t pulse, pwm_flags_t flags)¶ Set the period and pulse width for a single PWM output.
- Parameters
dev
: Pointer to the device structure for the driver instance.pwm
: PWM pin.period
: Period (in nanoseconds) set to the PWM.pulse
: Pulse width (in nanoseconds) set to the PWM.flags
: Flags for pin configuration (polarity).
- Return Value
0
: If successful.Negative
: errno code if failure.
-
struct
pwm_driver_api
¶ - #include <pwm.h>
PWM driver API definition.
-
typedef u8_t