Zephyr API Documentation 4.0.0-rc3
A Scalable Open Source RTOS
|
Public PWM Driver APIs. More...
#include <errno.h>
#include <stdint.h>
#include <zephyr/device.h>
#include <zephyr/devicetree.h>
#include <zephyr/sys_clock.h>
#include <zephyr/sys/math_extras.h>
#include <zephyr/toolchain.h>
#include <zephyr/dt-bindings/pwm/pwm.h>
#include <zephyr/syscalls/pwm.h>
Go to the source code of this file.
Data Structures | |
struct | pwm_dt_spec |
Container for PWM information specified in devicetree. More... | |
Macros | |
#define | PWM_DT_SPEC_GET_BY_NAME(node_id, name) |
Static initializer for a struct pwm_dt_spec. | |
#define | PWM_DT_SPEC_INST_GET_BY_NAME(inst, name) |
Static initializer for a struct pwm_dt_spec from a DT_DRV_COMPAT instance. | |
#define | PWM_DT_SPEC_GET_BY_NAME_OR(node_id, name, default_value) |
Like PWM_DT_SPEC_GET_BY_NAME(), with a fallback to a default value. | |
#define | PWM_DT_SPEC_INST_GET_BY_NAME_OR(inst, name, default_value) |
Like PWM_DT_SPEC_INST_GET_BY_NAME(), with a fallback to a default value. | |
#define | PWM_DT_SPEC_GET_BY_IDX(node_id, idx) |
Static initializer for a struct pwm_dt_spec. | |
#define | PWM_DT_SPEC_INST_GET_BY_IDX(inst, idx) |
Static initializer for a struct pwm_dt_spec from a DT_DRV_COMPAT instance. | |
#define | PWM_DT_SPEC_GET_BY_IDX_OR(node_id, idx, default_value) |
Like PWM_DT_SPEC_GET_BY_IDX(), with a fallback to a default value. | |
#define | PWM_DT_SPEC_INST_GET_BY_IDX_OR(inst, idx, default_value) |
Like PWM_DT_SPEC_INST_GET_BY_IDX(), with a fallback to a default value. | |
#define | PWM_DT_SPEC_GET(node_id) |
Equivalent to PWM_DT_SPEC_GET_BY_IDX(node_id, 0) . | |
#define | PWM_DT_SPEC_INST_GET(inst) |
Equivalent to PWM_DT_SPEC_INST_GET_BY_IDX(inst, 0) . | |
#define | PWM_DT_SPEC_GET_OR(node_id, default_value) |
Equivalent to PWM_DT_SPEC_GET_BY_IDX_OR(node_id, 0, default_value) . | |
#define | PWM_DT_SPEC_INST_GET_OR(inst, default_value) |
Equivalent to PWM_DT_SPEC_INST_GET_BY_IDX_OR(inst, 0, default_value) . | |
PWM capture configuration flags | |
#define | PWM_CAPTURE_TYPE_PERIOD (1U << PWM_CAPTURE_TYPE_SHIFT) |
PWM pin capture captures period. | |
#define | PWM_CAPTURE_TYPE_PULSE (2U << PWM_CAPTURE_TYPE_SHIFT) |
PWM pin capture captures pulse width. | |
#define | PWM_CAPTURE_TYPE_BOTH |
PWM pin capture captures both period and pulse width. | |
#define | PWM_CAPTURE_MODE_SINGLE (0U << PWM_CAPTURE_MODE_SHIFT) |
PWM pin capture captures a single period/pulse width. | |
#define | PWM_CAPTURE_MODE_CONTINUOUS (1U << PWM_CAPTURE_MODE_SHIFT) |
PWM pin capture captures period/pulse width continuously. | |
Typedefs | |
typedef uint16_t | pwm_flags_t |
Provides a type to hold PWM configuration flags. | |
typedef void(* | pwm_capture_callback_handler_t) (const struct device *dev, uint32_t channel, uint32_t period_cycles, uint32_t pulse_cycles, int status, void *user_data) |
PWM capture callback handler function signature. | |
Functions | |
int | pwm_set_cycles (const struct device *dev, uint32_t channel, uint32_t period, uint32_t pulse, pwm_flags_t flags) |
Set the period and pulse width for a single PWM output. | |
int | pwm_get_cycles_per_sec (const struct device *dev, uint32_t channel, uint64_t *cycles) |
Get the clock rate (cycles per second) for a single PWM output. | |
static int | pwm_set (const struct device *dev, uint32_t channel, uint32_t period, uint32_t pulse, pwm_flags_t flags) |
Set the period and pulse width in nanoseconds for a single PWM output. | |
static int | pwm_set_dt (const struct pwm_dt_spec *spec, uint32_t period, uint32_t pulse) |
Set the period and pulse width in nanoseconds from a struct pwm_dt_spec (with custom period). | |
static int | pwm_set_pulse_dt (const struct pwm_dt_spec *spec, uint32_t pulse) |
Set the period and pulse width in nanoseconds from a struct pwm_dt_spec. | |
static int | pwm_cycles_to_usec (const struct device *dev, uint32_t channel, uint32_t cycles, uint64_t *usec) |
Convert from PWM cycles to microseconds. | |
static int | pwm_cycles_to_nsec (const struct device *dev, uint32_t channel, uint32_t cycles, uint64_t *nsec) |
Convert from PWM cycles to nanoseconds. | |
static int | pwm_configure_capture (const struct device *dev, uint32_t channel, pwm_flags_t flags, pwm_capture_callback_handler_t cb, void *user_data) |
Configure PWM period/pulse width capture for a single PWM input. | |
int | pwm_enable_capture (const struct device *dev, uint32_t channel) |
Enable PWM period/pulse width capture for a single PWM input. | |
int | pwm_disable_capture (const struct device *dev, uint32_t channel) |
Disable PWM period/pulse width capture for a single PWM input. | |
int | pwm_capture_cycles (const struct device *dev, uint32_t channel, pwm_flags_t flags, uint32_t *period, uint32_t *pulse, k_timeout_t timeout) |
Capture a single PWM period/pulse width in clock cycles for a single PWM input. | |
static int | pwm_capture_usec (const struct device *dev, uint32_t channel, pwm_flags_t flags, uint64_t *period, uint64_t *pulse, k_timeout_t timeout) |
Capture a single PWM period/pulse width in microseconds for a single PWM input. | |
static int | pwm_capture_nsec (const struct device *dev, uint32_t channel, pwm_flags_t flags, uint64_t *period, uint64_t *pulse, k_timeout_t timeout) |
Capture a single PWM period/pulse width in nanoseconds for a single PWM input. | |
static bool | pwm_is_ready_dt (const struct pwm_dt_spec *spec) |
Validate that the PWM device is ready. | |
Public PWM Driver APIs.