Atmel Software Framework

tc.h File Reference

AVR XMEGA Timer Counter (TC) driver.

Copyright (c) 2010-2016 Atmel Corporation. All rights reserved.

#include <compiler.h>
#include <parts.h>
#include "status_codes.h"
#include "pmic.h"
#include <sleepmgr.h>
#include <sysclk.h>

Macros

#define tc_is_tc0(void)   ((uint16_t)tc&0x40 ? false : true)
 Macro to check if type of passed TC is TC0_t. More...
 
#define tc_is_tc1(void)   ((uint16_t)tc&0x40 ? true : false)
 Macro to check if type of passed TC is TC1_t. More...
 

Typedefs

typedef void(* tc_callback_t )(void)
 Interrupt event callback function type. More...
 

Enumerations

enum  tc_cc_channel_mask_enable_t {
  TC_CCAEN = TC0_CCAEN_bm,
  TC_CCBEN = TC0_CCBEN_bm,
  TC_CCCEN = TC0_CCCEN_bm,
  TC_CCDEN = TC0_CCDEN_bm
}
 Timer Counter Capture Compare Channel index. More...
 
enum  tc_cc_channel_t {
  TC_CCA = 1,
  TC_CCB = 2,
  TC_CCC = 3,
  TC_CCD = 4
}
 Timer Counter Capture Compare Channel index. More...
 
enum  tc_dir_t {
  TC_UP = 0,
  TC_DOWN = 1
}
 Timer Counter Direction. More...
 
enum  TC_INT_LEVEL_t {
  TC_INT_LVL_OFF = 0x00,
  TC_INT_LVL_LO = 0x01,
  TC_INT_LVL_MED = 0x02,
  TC_INT_LVL_HI = 0x03
}
 TC interrupt levels. More...
 
enum  tc_wg_mode_t {
  TC_WG_NORMAL = TC_WGMODE_NORMAL_gc,
  TC_WG_FRQ = TC_WGMODE_FRQ_gc,
  TC_WG_SS = TC_WGMODE_SS_gc,
  TC_WG_DS_T = TC_WGMODE_DS_T_gc,
  TC_WG_DS_TB = TC_WGMODE_DS_TB_gc,
  TC_WG_DS_B = TC_WGMODE_DS_B_gc
}
 Timer Counter Waveform Generator mode. More...
 

Functions

static void tc_awex_clear_fault (AWEX_t *awex)
 AWeX extension : clears the Fault detection. More...
 
static void tc_awex_disable_cca_deadtime (AWEX_t *awex)
 AWeX extension : disable Deadtime insertion on ccA. More...
 
static void tc_awex_disable_ccb_deadtime (AWEX_t *awex)
 AWeX extension : disable Deadtime insertion on ccB. More...
 
static void tc_awex_disable_ccc_deadtime (AWEX_t *awex)
 AWeX extension : disable Deadtime insertion on ccD. More...
 
static void tc_awex_disable_ccd_deadtime (AWEX_t *awex)
 AWeX extension : disable Deadtime insertion on ccD. More...
 
static void tc_awex_disable_cwcm (AWEX_t *awex)
 AWeX extension disable Common waveform mode. More...
 
static void tc_awex_disable_fault_debug_break (AWEX_t *awex)
 AWeX extension : disable fault detection on debug break detection. More...
 
static void tc_awex_disable_pgm (AWEX_t *awex)
 AWeX extension disable pattern generator mode. More...
 
static void tc_awex_enable_cca_deadtime (AWEX_t *awex)
 AWeX extension : enable Deadtime insertion on ccA. More...
 
static void tc_awex_enable_ccb_deadtime (AWEX_t *awex)
 AWeX extension : enable Deadtime insertion on ccB. More...
 
static void tc_awex_enable_ccc_deadtime (AWEX_t *awex)
 AWeX extension : enable Deadtime insertion on ccC. More...
 
static void tc_awex_enable_ccd_deadtime (AWEX_t *awex)
 AWeX extension : enable Deadtime insertion on ccD. More...
 
static void tc_awex_enable_cwcm (AWEX_t *awex)
 AWeX extension enable. More...
 
static void tc_awex_enable_fault_debug_break (AWEX_t *awex)
 AWeX extension : enable fault detection on debug break detection. More...
 
static void tc_awex_enable_pgm (AWEX_t *awex)
 AWeX extension enable pattern generator mode. More...
 
static bool tc_awex_fault_is_detected (AWEX_t *awex)
 AWeX extension : returns if fault is detected. More...
 
static void tc_awex_fdmode_restart_cycle (AWEX_t *awex)
 AWeX extension : configures the Fault restart in cycle to cycle mode. More...
 
static void tc_awex_fdmode_restart_latched (AWEX_t *awex)
 AWeX extension : configures the Fault restart in latched mode. More...
 
static int8_t tc_awex_get_dti_high_buffer (AWEX_t *awex)
 AWeX extension : returns the deadtime buffer high nibble. More...
 
static int8_t tc_awex_get_dti_low_buffer (AWEX_t *awex)
 AWeX extension : returns the deadtime buffer low nibble. More...
 
static bool tc_awex_is_dti_high_buffer_valid (AWEX_t *awex)
 AWeX extension : returns if DTI high buffer is valid. More...
 
static bool tc_awex_is_dti_low_buffer_valid (AWEX_t *awex)
 AWeX extension : returns if DTI low buffer is valid. More...
 
static void tc_awex_set_dti_both (AWEX_t *awex, int16_t value)
 AWeX extension : configures symmetrical deadtime. More...
 
static void tc_awex_set_dti_both_buffer (AWEX_t *awex, int16_t value)
 AWeX extension : configures symmetrical deadtime buffer. More...
 
static void tc_awex_set_dti_high (AWEX_t *awex, int16_t value)
 AWeX extension : configures high side deadtime. More...
 
static void tc_awex_set_dti_low (AWEX_t *awex, int16_t value)
 AWeX extension : configures low side deadtime. More...
 
static void tc_awex_set_fault_detection_action (AWEX_t *awex, AWEX_FDACT_t fd_act)
 AWeX extension : configures fault action. More...
 
static void tc_awex_set_fault_detection_event (AWEX_t *awex, int8_t eventmask)
 AWeX extension : configures fault detection event. More...
 
static void tc_awex_set_output_override (AWEX_t *awex, int8_t value)
 AWeX extension : configures the port overdrive. More...
 
static bool tc_cc_buffer_is_valid (volatile void *tc, enum tc_cc_channel_t channel_index)
 Reports is Capture/Compare Buffer is valid. More...
 
static void tc_clear_cc_interrupt (volatile void *tc, enum tc_cc_channel_t channel_index)
 Clears Capture/Compare interrupt. More...
 
static void tc_clear_error (volatile void *tc)
 Clears the Error flag. More...
 
static void tc_clear_overflow (volatile void *tc)
 Clears the Overflow flag. More...
 
void tc_disable (volatile void *tc)
 Disable TC. More...
 
static void tc_disable_cc_channels (volatile void *tc, enum tc_cc_channel_mask_enable_t disablemask)
 Disables Compare/Capture channel. More...
 
static void tc_disable_delay (volatile void *tc)
 Disables delay. More...
 
void tc_enable (volatile void *tc)
 Enable TC. More...
 
static void tc_enable_cc_channels (volatile void *tc, enum tc_cc_channel_mask_enable_t enablemask)
 Enables Compare/Capture channel. More...
 
static void tc_enable_delay (volatile void *tc)
 Enables delay (used for 32bit timer mode) More...
 
static uint32_t tc_get_resolution (volatile void *tc)
 Get real resolution for a specified TC. More...
 
static void tc_hires_set_mode (HIRES_t *hires, HIRES_HREN_t hi_res_mode)
 Hi-Res Extension : configures the Hi-Res. More...
 
static bool tc_is_cc_interrupt (volatile void *tc, enum tc_cc_channel_t channel_index)
 Reports if Capture/Compare interrupt has occurred. More...
 
static bool tc_is_overflow (volatile void *tc)
 Tests if the Overflow flag is set. More...
 
static void tc_lock_update_buffers (volatile void *tc)
 Locks the Update of the Buffered registers. More...
 
static bool tc_period_buffer_is_valid (volatile void *tc)
 Tests if the Period Buffer is valid. More...
 
static uint16_t tc_read_cc (volatile void *tc, enum tc_cc_channel_t channel_index)
 Reads the Capture value. More...
 
static uint16_t tc_read_cc_buffer (volatile void *tc, enum tc_cc_channel_t channel_index)
 Reads the Capture/Compare Buffer value. More...
 
static TC_CLKSEL_t tc_read_clock_source (volatile void *tc)
 Read Timer Clock Source. More...
 
static uint16_t tc_read_count (volatile void *tc)
 Reads the Counter value of the Timer. More...
 
static bool tc_read_error (volatile void *tc)
 Tests if the Error flag is set. More...
 
static uint16_t tc_read_period (volatile void *tc)
 Reads the Period value of the Timer. More...
 
static uint16_t tc_read_period_buffer (volatile void *tc)
 Reads the Period Buffer value of the Timer. More...
 
static void tc_reset (volatile void *tc)
 Reset the Timer. More...
 
static void tc_restart (volatile void *tc)
 Restart the Timer. More...
 
static void tc_set_8bits_mode (volatile void *tc)
 Configures the Timer in Byte mode. More...
 
void tc_set_cca_interrupt_callback (volatile void *tc, tc_callback_t callback)
 Set TC Capture Compare Channel A interrupt callback function. More...
 
static void tc_set_cca_interrupt_level (volatile void *tc, enum TC_INT_LEVEL_t level)
 Configures TC Capture Compare A Interrupt level. More...
 
void tc_set_ccb_interrupt_callback (volatile void *tc, tc_callback_t callback)
 Set TC Capture Compare Channel B interrupt callback function. More...
 
static void tc_set_ccb_interrupt_level (volatile void *tc, enum TC_INT_LEVEL_t level)
 Configures TC Capture Compare B Interrupt level. More...
 
void tc_set_ccc_interrupt_callback (volatile void *tc, tc_callback_t callback)
 Set TC Capture Compare Channel C interrupt callback function. More...
 
static void tc_set_ccc_interrupt_level (volatile void *tc, enum TC_INT_LEVEL_t level)
 Configures TC Capture Compare C Interrupt level. More...
 
void tc_set_ccd_interrupt_callback (volatile void *tc, tc_callback_t callback)
 Set TC Capture Compare Channel D interrupt callback function. More...
 
static void tc_set_ccd_interrupt_level (volatile void *tc, enum TC_INT_LEVEL_t level)
 Configures TC Capture Compare D Interrupt level. More...
 
static void tc_set_direction (volatile void *tc, enum tc_dir_t dir)
 Configure Timer Direction. More...
 
void tc_set_error_interrupt_callback (volatile void *tc, tc_callback_t callback)
 Set TC error interrupt callback function. More...
 
static void tc_set_error_interrupt_level (volatile void *tc, enum TC_INT_LEVEL_t level)
 Configures TC error Interrupt level. More...
 
static void tc_set_input_capture (volatile void *tc, TC_EVSEL_t eventsource, TC_EVACT_t eventaction)
 Enables Input capture mode. More...
 
void tc_set_overflow_interrupt_callback (volatile void *tc, tc_callback_t callback)
 Set TC overflow interrupt callback function. More...
 
static void tc_set_overflow_interrupt_level (volatile void *tc, enum TC_INT_LEVEL_t level)
 Configures TC overflow Interrupt level. More...
 
static void tc_set_resolution (volatile void *tc, uint32_t resolution)
 Select clock for a specified TC and resolution. More...
 
static void tc_set_wgm (volatile void *tc, enum tc_wg_mode_t wgm)
 Configures TC in the specified Waveform generator mode. More...
 
static void tc_unlock_update_buffers (volatile void *tc)
 Unlocks the Update of the Buffered registers. More...
 
static void tc_update (volatile void *tc)
 Update the Timer. More...
 
static void tc_write_cc (volatile void *tc, enum tc_cc_channel_t channel_index, uint16_t value)
 Writes the CC value. More...
 
static void tc_write_cc_buffer (volatile void *tc, enum tc_cc_channel_t channel_index, uint16_t buffer_value)
 Writes the Capture/Compare Buffer value. More...
 
static void tc_write_clock_source (volatile void *tc, TC_CLKSEL_t TC_CLKSEL_enum)
 Configure Timer Clock Source. More...
 
static void tc_write_count (volatile void *tc, uint16_t cnt_value)
 Write the Counter value of the Timer. More...
 
static void tc_write_period (volatile void *tc, uint16_t per_value)
 Writes the Period value of the Timer. More...
 
static void tc_write_period_buffer (volatile void *tc, uint16_t per_buf)
 Writes the Period Buffer value of the Timer. More...