picofuse

Data Structures | Typedefs
pwm.h File Reference

PWM (Pulse Width Modulation) interface. More...

#include "gpio.h"
#include <stdbool.h>
#include <stdint.h>
Include dependency graph for pwm.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  hw_pwm_config_t
 PWM configuration. More...
 

Typedefs

typedef struct hw_pwm_t hw_pwm_t
 Opaque PWM handle.
 
typedef void(* hw_pwm_callback_t) (hw_pwm_t *pwm, void *userdata)
 PWM wrap callback function pointer. More...
 

Functions

Lifecycle
hw_pwm_thw_pwm_init (hw_gpio_t *gpio, hw_pwm_callback_t callback, void *userdata, const hw_pwm_config_t *config)
 Initialize a PWM output on a GPIO pin. More...
 
hw_pwm_thw_pwm_init_device (const char *device, uint8_t channel, const hw_pwm_config_t *config)
 Initialize a PWM output from a platform-specific device path. More...
 
void hw_pwm_deinit (hw_pwm_t *pwm)
 Deinitialize a PWM handle. More...
 
Configuration
bool hw_pwm_set_period_ns (hw_pwm_t *pwm, uint64_t period_ns)
 Set the PWM period. More...
 
uint64_t hw_pwm_get_period_ns (const hw_pwm_t *pwm)
 Get the configured PWM period. More...
 
bool hw_pwm_set_duty_percent (hw_pwm_t *pwm, float duty_percent)
 Set duty cycle percentage. More...
 
float hw_pwm_get_duty_percent (const hw_pwm_t *pwm)
 Get duty cycle percentage. More...
 
bool hw_pwm_set_config (hw_pwm_t *pwm, const hw_pwm_config_t *config)
 Apply a complete PWM configuration. More...
 
bool hw_pwm_get_config (const hw_pwm_t *pwm, hw_pwm_config_t *out_config)
 Read current PWM configuration. More...
 
Control
void hw_pwm_set_enabled (hw_pwm_t *pwm, bool enabled)
 Enable or disable PWM output. More...
 
bool hw_pwm_get_enabled (const hw_pwm_t *pwm)
 Query whether PWM output is enabled. More...
 
Interrupts
bool hw_pwm_irq_supported (void)
 Check whether PWM wrap interrupt callbacks are supported. More...
 

Detailed Description

PWM (Pulse Width Modulation) interface.

Definition in file pwm.h.