AVR MEGA Timer Counter (TC) driver.
Copyright (c) 2014-2018 Microchip Technology Inc. and its subsidiaries.
Macros | |
#define | TCCRB_OFFSET 1 |
#define | TCNT_OFFSET 4 |
Typedefs | |
typedef void(* | tc_callback_t )(void) |
Interrupt event callback function type. More... | |
typedef enum TC_CLKSEL_enum | TC_CLKSEL_t |
typedef enum TC_MODE_enum | TC_MODE_t |
Enumerations | |
enum | tc_cc_channel_t { TC_COMPA = 0X08, TC_COMPB = 0X0A, TC_COMPC = 0X0C } |
enum | TC_CLKSEL_enum { TC_CLKSEL_OFF_gc = (0x00), TC_CLKSEL_DIV1_gc = (0x01), TC_CLKSEL_DIV8_gc = (0x02), TC_CLKSEL_DIV64_gc = (0x03), TC_CLKSEL_DIV256_gc = (0x04), TC_CLKSEL_DIV1024_gc = (0x05), TC_EXT_CLK_FALLING_gc = (0x06), TC_EXT_CLK_RISING_gc = (0x07) } |
enum | TC_MODE_enum { NORMAL = 0X00, PWM_Mode1 = 0X01, PWM_Mode2 = 0X02, PWM_Mode3 = 0X03, CTC_Mode1 = 0X04, PWM_Mode4 = 0X05, PWM_Mode5 = 0X06, PWM_Mode6 = 0X07, PWM_Mode7 = 0X08, PWM_Mode8 = 0X09, PWM_Mode9 = 0X0A, PWM_Mode10 = 0X0B, CTC_Mode2 = 0X0C, PWM_Mode11 = 0X0E, PWM_Mode12 = 0X0F } |
Functions | |
static void | clear_compa_flag (volatile void *tc) |
Clears Compare Match Flag in channel A. More... | |
static void | clear_compb_flag (volatile void *tc) |
Clears Compare Match Flag in channel B. More... | |
static void | clear_compc_flag (volatile void *tc) |
Clears Compare Match Flag in channel C. More... | |
static void | clear_ovf_flag (volatile void *tc) |
Clears Overflow Flag. More... | |
void | tc_disable (volatile void *tc) |
Disable Timer. More... | |
static void | tc_disable_compa_int (volatile void *tc) |
Disable Compare Interrupt in channel A. More... | |
static void | tc_disable_compb_int (volatile void *tc) |
Disable Compare Interrupt in channel B. More... | |
static void | tc_disable_compc_int (volatile void *tc) |
Disable Compare Interrupt in channel C. More... | |
static void | tc_disable_ovf_int (volatile void *tc) |
Disable Overflow Interrupt. More... | |
void | tc_enable (volatile void *tc) |
Enable Timer. More... | |
static void | tc_enable_compa_int (volatile void *tc) |
Enable Compare Interrupt in channel A. More... | |
static void | tc_enable_compb_int (volatile void *tc) |
Enable Compare Interrupt in channel B. More... | |
static void | tc_enable_compc_int (volatile void *tc) |
Enable Compare Interrupt in channel C. More... | |
static void | tc_enable_ovf_int (volatile void *tc) |
Enable Overflow Interrupt. More... | |
static bool | tc_is_compa_match (volatile void *tc) |
Checks whether a Compare Match has occured in Channel A. More... | |
static bool | tc_is_compb_match (volatile void *tc) |
Checks whether a Compare Match has occured in Channel B. More... | |
static bool | tc_is_compc_match (volatile void *tc) |
Checks whether a Compare Match has occured in Channel C. More... | |
static bool | tc_is_overflow (volatile void *tc) |
Checks whether a timer has overflowed. More... | |
static uint16_t | tc_read_count (volatile void *tc) |
Reads the count value in the Timer Counter Register. More... | |
void | tc_set_compa_interrupt_callback (volatile void *tc, tc_callback_t callback) |
Register a Compare interrupt callback. More... | |
void | tc_set_compb_interrupt_callback (volatile void *tc, tc_callback_t callback) |
Register a Compare interrupt callback. More... | |
void | tc_set_compc_interrupt_callback (volatile void *tc, tc_callback_t callback) |
Register a Compare interrupt callback. More... | |
static void | tc_set_mode (volatile void *tc, TC_MODE_t mode) |
Sets a timer in a particular mode of operation. More... | |
void | tc_set_overflow_interrupt_callback (volatile void *tc, tc_callback_t callback) |
Register a Overflow interrupt callback. More... | |
static void | tc_write_cc (volatile void *tc, enum tc_cc_channel_t channel_index, uint16_t value) |
Write Compare register with timer Value. More... | |
static void | tc_write_clock_source (volatile void *tc, TC_CLKSEL_t TC_CLKSEL_enum) |
Select a source for a timer. More... | |
static void | tc_write_count (volatile void *tc, uint16_t value) |
Writes a count value to the Timer Counter Register. More... | |
#define TCCRB_OFFSET 1 |
Referenced by tc_set_clk_source(), tc_set_mode(), and tc_set_wg_mode().
#define TCNT_OFFSET 4 |
typedef void(* tc_callback_t)(void) |
Interrupt event callback function type.
The interrupt handler can be configured to do a function callback, the callback function must match the tc_callback_t type.
typedef enum TC_CLKSEL_enum TC_CLKSEL_t |
typedef enum TC_MODE_enum TC_MODE_t |
enum tc_cc_channel_t |
enum TC_CLKSEL_enum |
enum TC_MODE_enum |
|
inlinestatic |
Clears Compare Match Flag in channel A.
tc | Timer Address |
Referenced by tc_disable_compare_int(), tmr_disable_cc_interrupt(), and tmr_enable_cc_interrupt().
|
inlinestatic |
Clears Compare Match Flag in channel B.
tc | Timer Address |
Referenced by tc_disable_compare_int().
|
inlinestatic |
Clears Compare Match Flag in channel C.
tc | Timer Address |
Referenced by tc_disable_compare_int().
|
inlinestatic |
Clears Overflow Flag.
tc | Timer Address |
Referenced by tc_disable_overflow_int(), and tmr_disable_ovf_interrupt().
void tc_disable | ( | volatile void * | tc | ) |
Disable Timer.
tc | Timer Address |
References cpu_irq_restore(), cpu_irq_save(), and sysclk_disable_peripheral_clock().
Referenced by tc_stop(), and tmr_stop().
|
inlinestatic |
Disable Compare Interrupt in channel A.
tc | Timer Address |
Referenced by tc_disable_compare_int(), tmr_disable_cc_interrupt(), and tmr_init().
|
inlinestatic |
Disable Compare Interrupt in channel B.
tc | Timer Address |
Referenced by tc_disable_compare_int().
|
inlinestatic |
Disable Compare Interrupt in channel C.
tc | Timer Address |
Referenced by tc_disable_compare_int().
|
inlinestatic |
Disable Overflow Interrupt.
tc | Timer Address |
Referenced by tc_disable_overflow_int(), and tc_stop().
void tc_enable | ( | volatile void * | tc | ) |
Enable Timer.
tc | Timer Address |
References cpu_irq_restore(), cpu_irq_save(), and sysclk_enable_peripheral_clock().
Referenced by init_timer_isr(), and tmr_init().
|
inlinestatic |
Enable Compare Interrupt in channel A.
tc | Timer Address |
Referenced by initialize_EPD_timer(), and tmr_enable_cc_interrupt().
|
inlinestatic |
Enable Compare Interrupt in channel B.
tc | Timer Address |
|
inlinestatic |
Enable Compare Interrupt in channel C.
tc | Timer Address |
|
inlinestatic |
Enable Overflow Interrupt.
tc | Timer Address |
Referenced by tmr_disable_ovf_interrupt(), and tmr_init().
|
inlinestatic |
Checks whether a Compare Match has occured in Channel A.
tc | Timer Address |
|
inlinestatic |
Checks whether a Compare Match has occured in Channel B.
tc | Timer Address |
|
inlinestatic |
Checks whether a Compare Match has occured in Channel C.
tc | Timer Address |
|
inlinestatic |
Checks whether a timer has overflowed.
tc | Timer Address |
|
inlinestatic |
Reads the count value in the Timer Counter Register.
tc | Timer Address |
Referenced by tmr_read_count().
void tc_set_compa_interrupt_callback | ( | volatile void * | tc, |
tc_callback_t | callback | ||
) |
Register a Compare interrupt callback.
tc | Timer Address |
callback | Callback called once Compare interrupt occurs in channel A |
References tc_tccr1_compa_callback, tc_tccr3_compa_callback, tc_tccr4_compa_callback, and tc_tccr5_compa_callback.
Referenced by configure_tc_callback(), and initialize_EPD_timer().
void tc_set_compb_interrupt_callback | ( | volatile void * | tc, |
tc_callback_t | callback | ||
) |
Register a Compare interrupt callback.
tc | Timer Address |
callback | Callback called once Compare interrupt occurs in channel B |
References tc_tccr1_compb_callback, tc_tccr3_compb_callback, tc_tccr4_compb_callback, and tc_tccr5_compb_callback.
Referenced by configure_tc_callback().
void tc_set_compc_interrupt_callback | ( | volatile void * | tc, |
tc_callback_t | callback | ||
) |
Register a Compare interrupt callback.
tc | Timer Address |
callback | Callback called once Compare interrupt occurs in channel C |
References tc_tccr1_compc_callback, tc_tccr3_compc_callback, tc_tccr4_compc_callback, and tc_tccr5_compc_callback.
Referenced by configure_tc_callback().
|
inlinestatic |
Sets a timer in a particular mode of operation.
tc | Timer Address |
mode | Enum value of the selected mode |
References CTC_Mode1, NORMAL, and TCCRB_OFFSET.
Referenced by tmr_init().
void tc_set_overflow_interrupt_callback | ( | volatile void * | tc, |
tc_callback_t | callback | ||
) |
Register a Overflow interrupt callback.
tc | Timer Address |
callback | Callback called once Overflow interrupt occurs |
References tc_tccr1_ovf_callback, tc_tccr3_ovf_callback, tc_tccr4_ovf_callback, and tc_tccr5_ovf_callback.
Referenced by tmr_init().
|
inlinestatic |
Write Compare register with timer Value.
tc | Timer Address |
channel_index | Compare Channel to be used |
value | Compare value to be written |
Referenced by initialize_EPD_timer(), PWM_start_toggle(), and tmr_write_cmpreg().
|
inlinestatic |
Select a source for a timer.
tc | Timer Address |
TC_CLKSEL_enum | Select a source from enum type |
Referenced by tmr_init().
|
inlinestatic |
Writes a count value to the Timer Counter Register.
tc | Timer Address |
value | count to be written in the register |