PWM service for XMEGA.
Copyright (c) 2012-2018 Microchip Technology Inc. and its subsidiaries.
#include "tc.h"
Data Structures | |
struct | pwm_config |
PWM configuration. More... | |
Typedefs | |
typedef void(* | pwm_callback_t )(void) |
Interrupt callback type. More... | |
Enumerations | |
enum | pwm_channel_t { PWM_CH_A = 1, PWM_CH_B = 2, PWM_CH_C = 3, PWM_CH_D = 4 } |
PWM compare channel index. More... | |
enum | pwm_clk_sel { PWM_CLK_OFF = TC_CLKSEL_OFF_gc, PWM_CLK_DIV1 = TC_CLKSEL_DIV1_gc, PWM_CLK_DIV2 = TC_CLKSEL_DIV2_gc, PWM_CLK_DIV4 = TC_CLKSEL_DIV4_gc, PWM_CLK_DIV8 = TC_CLKSEL_DIV8_gc, PWM_CLK_DIV64 = TC_CLKSEL_DIV64_gc, PWM_CLK_DIV256 = TC_CLKSEL_DIV256_gc, PWM_CLK_DIV1024 = TC_CLKSEL_DIV1024_gc } |
Valid clock source indexes. More... | |
enum | pwm_tc_t { PWM_TCC0, PWM_TCC1, PWM_TCD0, PWM_TCD1, PWM_TCE0, PWM_TCE1, PWM_TCF0, PWM_TCF1 } |
Valid timer/counters to use. More... | |
Functions | |
static void | pwm_disable (struct pwm_config *config) |
Disable the PWM timer. More... | |
void | pwm_init (struct pwm_config *config, enum pwm_tc_t tc, enum pwm_channel_t channel, uint16_t freq_hz) |
Initialize PWM configuration struct and set correct I/O pin to output. More... | |
static void | pwm_overflow_int_callback (struct pwm_config *config, pwm_callback_t callback) |
Callback function for timer overflow interrupts. More... | |
static void | pwm_set_duty_cycle_percent (struct pwm_config *config, uint8_t duty_cycle_scale) |
Function to set PWM duty cycle. More... | |
void | pwm_set_frequency (struct pwm_config *config, uint16_t freq_hz) |
Calculate TC settings from PWM frequency. More... | |
void | pwm_start (struct pwm_config *config, uint8_t duty_cycle_scale) |
Start a PWM channel. More... | |
static void | pwm_stop (struct pwm_config *config) |
Function that stops the PWM timer. More... | |
static void | pwm_timer_reset (struct pwm_config *config) |
Function that resets the PWM timer. More... | |