v2.0.0
Data Structures | Macros | Enumerations | Functions
pwm.h File Reference
`#include "pico.h"`
`#include "hardware/structs/pwm.h"`
`#include "hardware/regs/dreq.h"`
`#include "hardware/regs/intctrl.h"`
Include dependency graph for pwm.h:

Go to the source code of this file.

## Data Structures
struct | pwm_config

## Macros
#define | PARAM_ASSERTIONS_ENABLED_HARDWARE_PWM 0
#define | PWM_DREQ_NUM(slice_num)
| Returns the dreq_num_t used for pacing DMA transfers for a given PWM slice. More...
#define | PWM_GPIO_SLICE_NUM(gpio)
| Returns the PWM slice number for a given GPIO number.
#define | PWM_DEFAULT_IRQ_NUM()
| Returns the irq_num_t for the default PWM IRQ. More...

## Enumerations
enum | pwm_clkdiv_mode { PWM_DIV_FREE_RUNNING = 0 , PWM_DIV_B_HIGH = 1 , PWM_DIV_B_RISING = 2 , PWM_DIV_B_FALLING = 3 }
| PWM Divider mode settings. More...
enum | pwm_chan { PWM_CHAN_A = 0 , PWM_CHAN_B = 1 }

## Functions
static void | check_slice_num_param (__unused uint slice_num)
static uint | pwm_gpio_to_slice_num (uint gpio)
| Determine the PWM slice that is attached to the specified GPIO. More...
static uint | pwm_gpio_to_channel (uint gpio)
| Determine the PWM channel that is attached to the specified GPIO. More...
static void | pwm_config_set_phase_correct (pwm_config *c, bool phase_correct)
| Set phase correction in a PWM configuration. More...
static void | pwm_config_set_clkdiv (pwm_config *c, float div)
| Set PWM clock divider in a PWM configuration. More...
static void | pwm_config_set_clkdiv_int_frac (pwm_config *c, uint8_t integer, uint8_t fract)
| Set PWM clock divider in a PWM configuration using an 8:4 fractional value. More...
static void | pwm_config_set_clkdiv_int (pwm_config *c, uint div)
| Set PWM clock divider in a PWM configuration. More...
static void | pwm_config_set_clkdiv_mode (pwm_config *c, enum pwm_clkdiv_mode mode)
| Set PWM counting mode in a PWM configuration. More...
static void | pwm_config_set_output_polarity (pwm_config *c, bool a, bool b)
| Set output polarity in a PWM configuration. More...
static void | pwm_config_set_wrap (pwm_config *c, uint16_t wrap)
| Set PWM counter wrap value in a PWM configuration. More...
static void | pwm_init (uint slice_num, pwm_config *c, bool start)
| Initialise a PWM with settings from a configuration object. More...
static pwm_config | pwm_get_default_config (void)
| Get a set of default values for PWM configuration. More...
static void | pwm_set_wrap (uint slice_num, uint16_t wrap)
| Set the current PWM counter wrap value. More...
static void | pwm_set_chan_level (uint slice_num, uint chan, uint16_t level)
| Set the current PWM counter compare value for one channel. More...
static void | pwm_set_both_levels (uint slice_num, uint16_t level_a, uint16_t level_b)
| Set PWM counter compare values. More...
static void | pwm_set_gpio_level (uint gpio, uint16_t level)
| Helper function to set the PWM level for the slice and channel associated with a GPIO. More...
static uint16_t | pwm_get_counter (uint slice_num)
| Get PWM counter. More...
static void | pwm_set_counter (uint slice_num, uint16_t c)
| Set PWM counter. More...
static void | pwm_advance_count (uint slice_num)
| Advance PWM count. More...
static void | pwm_retard_count (uint slice_num)
| Retard PWM count. More...
static void | pwm_set_clkdiv_int_frac (uint slice_num, uint8_t integer, uint8_t fract)
| Set PWM clock divider using an 8:4 fractional value. More...
static void | pwm_set_clkdiv (uint slice_num, float divider)
| Set PWM clock divider. More...
static void | pwm_set_output_polarity (uint slice_num, bool a, bool b)
| Set PWM output polarity. More...
static void | pwm_set_clkdiv_mode (uint slice_num, enum pwm_clkdiv_mode mode)
| Set PWM divider mode. More...
static void | pwm_set_phase_correct (uint slice_num, bool phase_correct)
| Set PWM phase correct on/off. More...
static void | pwm_set_enabled (uint slice_num, bool enabled)
| Enable/Disable PWM. More...
static void | pwm_set_mask_enabled (uint32_t mask)
| Enable/Disable multiple PWM slices simultaneously. More...
static void | pwm_set_irq_enabled (uint slice_num, bool enabled)
| Enable PWM instance interrupt via the default PWM IRQ (PWM_IRQ_WRAP_0 on RP2350) More...
static void | pwm_set_irq0_enabled (uint slice_num, bool enabled)
| Enable PWM instance interrupt via PWM_IRQ_WRAP_0. More...
static void | pwm_irqn_set_slice_enabled (uint irq_index, uint slice_num, bool enabled)
| Enable PWM instance interrupt via either PWM_IRQ_WRAP_0 or PWM_IRQ_WRAP_1. More...
static void | pwm_set_irq_mask_enabled (uint32_t slice_mask, bool enabled)
| Enable multiple PWM instance interrupts via the default PWM IRQ (PWM_IRQ_WRAP_0 on RP2350) More...
static void | pwm_set_irq0_mask_enabled (uint32_t slice_mask, bool enabled)
| Enable multiple PWM instance interrupts via PWM_IRQ_WRAP_0. More...
static void | pwm_irqn_set_slice_mask_enabled (uint irq_index, uint slice_mask, bool enabled)
| Enable PWM instance interrupts via either PWM_IRQ_WRAP_0 or PWM_IRQ_WRAP_1. More...
static void | pwm_clear_irq (uint slice_num)
| Clear a single PWM channel interrupt. More...
static uint32_t | pwm_get_irq_status_mask (void)
| Get PWM interrupt status, raw for the default PWM IRQ (PWM_IRQ_WRAP_0 on RP2350) More...
static uint32_t | pwm_get_irq0_status_mask (void)
| Get PWM interrupt status, raw for the PWM_IRQ_WRAP_0. More...
static uint32_t | pwm_irqn_get_status_mask (uint irq_index)
| Get PWM interrupt status, raw for either PWM_IRQ_WRAP_0 or PWM_IRQ_WRAP_1. More...
static void | pwm_force_irq (uint slice_num)
| Force PWM interrupt for the default PWM IRQ (PWM_IRQ_WRAP_0 on RP2350) More...
static void | pwm_force_irq0 (uint slice_num)
| Force PWM interrupt via PWM_IRQ_WRAP_0. More...
static void | pwm_irqn_force (uint irq_index, uint slice_num)
| Force PWM interrupt via PWM_IRQ_WRAP_0 or PWM_IRQ_WRAP_1. More...
static uint | pwm_get_dreq (uint slice_num)
| Return the DREQ to use for pacing transfers to a particular PWM slice. More...