Microchip® Advanced Software Framework

tc.h File Reference
#include <avr32/io.h>

Data Structures

struct  tc_capture_opt_t
 Parameters when initializing a timer/counter in capture mode. More...
 
struct  tc_interrupt_t
 Timer/counter interrupts. More...
 
struct  tc_waveform_opt_t
 Parameters when initializing a timer/counter in waveform mode. More...
 

Macros

#define TC_INVALID_ARGUMENT   (-1)
 TC driver functions return value in case of invalid argument(s). More...
 
#define TC_NUMBER_OF_CHANNELS   (sizeof(((avr32_tc_t *)0)->channel) / sizeof(avr32_tc_channel_t))
 Number of timer/counter channels. More...
 
External Clock Signal 0 Selection
#define TC_CH0_EXT_CLK0_SRC_TCLK0   AVR32_TC_TC0XC0S_TCLK0
 
#define TC_CH0_EXT_CLK0_SRC_NO_CLK   AVR32_TC_TC0XC0S_NO_CLK
 
#define TC_CH0_EXT_CLK0_SRC_TIOA1   AVR32_TC_TC0XC0S_TIOA1
 
#define TC_CH0_EXT_CLK0_SRC_TIOA2   AVR32_TC_TC0XC0S_TIOA2
 
External Clock Signal 1 Selection
#define TC_CH1_EXT_CLK1_SRC_TCLK1   AVR32_TC_TC1XC1S_TCLK1
 
#define TC_CH1_EXT_CLK1_SRC_NO_CLK   AVR32_TC_TC1XC1S_NO_CLK
 
#define TC_CH1_EXT_CLK1_SRC_TIOA0   AVR32_TC_TC1XC1S_TIOA0
 
#define TC_CH1_EXT_CLK1_SRC_TIOA2   AVR32_TC_TC1XC1S_TIOA2
 
External Clock Signal 2 Selection
#define TC_CH2_EXT_CLK2_SRC_TCLK2   AVR32_TC_TC2XC2S_TCLK2
 
#define TC_CH2_EXT_CLK2_SRC_NO_CLK   AVR32_TC_TC2XC2S_NO_CLK
 
#define TC_CH2_EXT_CLK2_SRC_TIOA0   AVR32_TC_TC2XC2S_TIOA0
 
#define TC_CH2_EXT_CLK2_SRC_TIOA1   AVR32_TC_TC2XC2S_TIOA1
 
Event/Trigger Actions on Output
#define TC_EVT_EFFECT_NOOP   AVR32_TC_NONE
 
#define TC_EVT_EFFECT_SET   AVR32_TC_SET
 
#define TC_EVT_EFFECT_CLEAR   AVR32_TC_CLEAR
 
#define TC_EVT_EFFECT_TOGGLE   AVR32_TC_TOGGLE
 
RC Compare Trigger Enable
#define TC_NO_TRIGGER_COMPARE_RC   0
 
#define TC_TRIGGER_COMPARE_RC   1
 
Waveform Selection
#define TC_WAVEFORM_SEL_UP_MODE   AVR32_TC_WAVSEL_UP_NO_AUTO
 
#define TC_WAVEFORM_SEL_UP_MODE_RC_TRIGGER   AVR32_TC_WAVSEL_UP_AUTO
 
#define TC_WAVEFORM_SEL_UPDOWN_MODE   AVR32_TC_WAVSEL_UPDOWN_NO_AUTO
 
#define TC_WAVEFORM_SEL_UPDOWN_MODE_RC_TRIGGER   AVR32_TC_WAVSEL_UPDOWN_AUTO
 
TIOA or TIOB External Trigger Selection
#define TC_EXT_TRIG_SEL_TIOA   1
 
#define TC_EXT_TRIG_SEL_TIOB   0
 
External Event Selection
Attention
See this note for important details about this setting.
#define TC_EXT_EVENT_SEL_TIOB_INPUT   AVR32_TC_EEVT_TIOB_INPUT
 
#define TC_EXT_EVENT_SEL_XC0_OUTPUT   AVR32_TC_EEVT_XC0_OUTPUT
 
#define TC_EXT_EVENT_SEL_XC1_OUTPUT   AVR32_TC_EEVT_XC1_OUTPUT
 
#define TC_EXT_EVENT_SEL_XC2_OUTPUT   AVR32_TC_EEVT_XC2_OUTPUT
 
Edge Selection
#define TC_SEL_NO_EDGE   AVR32_TC_EEVTEDG_NO_EDGE
 
#define TC_SEL_RISING_EDGE   AVR32_TC_EEVTEDG_POS_EDGE
 
#define TC_SEL_FALLING_EDGE   AVR32_TC_EEVTEDG_NEG_EDGE
 
#define TC_SEL_EACH_EDGE   AVR32_TC_EEVTEDG_BOTH_EDGES
 
Burst Signal Selection
#define TC_BURST_NOT_GATED   AVR32_TC_BURST_NOT_GATED
 
#define TC_BURST_CLK_AND_XC0   AVR32_TC_BURST_CLK_AND_XC0
 
#define TC_BURST_CLK_AND_XC1   AVR32_TC_BURST_CLK_AND_XC1
 
#define TC_BURST_CLK_AND_XC2   AVR32_TC_BURST_CLK_AND_XC2
 
Clock Invert
#define TC_CLOCK_RISING_EDGE   0
 
#define TC_CLOCK_FALLING_EDGE   1
 
Clock Selection
#define TC_CLOCK_SOURCE_TC1   AVR32_TC_TCCLKS_TIMER_CLOCK1
 
#define TC_CLOCK_SOURCE_TC2   AVR32_TC_TCCLKS_TIMER_CLOCK2
 
#define TC_CLOCK_SOURCE_TC3   AVR32_TC_TCCLKS_TIMER_CLOCK3
 
#define TC_CLOCK_SOURCE_TC4   AVR32_TC_TCCLKS_TIMER_CLOCK4
 
#define TC_CLOCK_SOURCE_TC5   AVR32_TC_TCCLKS_TIMER_CLOCK5
 
#define TC_CLOCK_SOURCE_XC0   AVR32_TC_TCCLKS_XC0
 
#define TC_CLOCK_SOURCE_XC1   AVR32_TC_TCCLKS_XC1
 
#define TC_CLOCK_SOURCE_XC2   AVR32_TC_TCCLKS_XC2
 

Functions

int tc_configure_interrupts (volatile avr32_tc_t *tc, unsigned int channel, const tc_interrupt_t *bitfield)
 Enables various timer/counter interrupts. More...
 
int tc_get_interrupt_settings (volatile avr32_tc_t *tc, unsigned int channel)
 Reads timer/counter interrupt settings. More...
 
int tc_init_capture (volatile avr32_tc_t *tc, const tc_capture_opt_t *opt)
 Sets options for timer/counter capture initialization. More...
 
int tc_init_waveform (volatile avr32_tc_t *tc, const tc_waveform_opt_t *opt)
 Sets options for timer/counter waveform initialization. More...
 
int tc_read_ra (volatile avr32_tc_t *tc, unsigned int channel)
 Reads the channel's RA register and returns the value. More...
 
int tc_read_rb (volatile avr32_tc_t *tc, unsigned int channel)
 Reads the channel's RB register and returns the value. More...
 
int tc_read_rc (volatile avr32_tc_t *tc, unsigned int channel)
 Reads the channel's RC register and returns the value. More...
 
int tc_read_sr (volatile avr32_tc_t *tc, unsigned int channel)
 Reads the status register. More...
 
int tc_read_tc (volatile avr32_tc_t *tc, unsigned int channel)
 Reads the channel's TC counter and returns the value. More...
 
int tc_select_external_clock (volatile avr32_tc_t *tc, unsigned int channel, unsigned int ext_clk_sig_src)
 Selects which external clock to use and how to configure it. More...
 
int tc_software_trigger (volatile avr32_tc_t *tc, unsigned int channel)
 Performs a software trigger: the counter is reset and the clock is started. More...
 
int tc_start (volatile avr32_tc_t *tc, unsigned int channel)
 Starts a timer/counter. More...
 
int tc_stop (volatile avr32_tc_t *tc, unsigned int channel)
 Stops a timer/counter. More...
 
void tc_sync_start (volatile avr32_tc_t *tc)
 Start all TC channels simultaneously. More...
 
void tc_sync_trigger (volatile avr32_tc_t *tc)
 Asserts a SYNC signal to generate a software trigger and reset all channels. More...
 
int tc_write_ra (volatile avr32_tc_t *tc, unsigned int channel, unsigned short value)
 Writes a value to the channel's RA register. More...
 
int tc_write_rb (volatile avr32_tc_t *tc, unsigned int channel, unsigned short value)
 Writes a value to the channel's RB register. More...
 
int tc_write_rc (volatile avr32_tc_t *tc, unsigned int channel, unsigned short value)
 Writes a value to the channel's RC register. More...