Atmel Software Framework

 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
XMEGA Custom Logic (XCL) Timer/Counter (TC) sub-module

This group provides functions to configure Timer/Counter (TC) sub-module.

Modules

 XMEGA Custom Logic (XCL) T/C interrupt management
 This group provides functions to manage XCL TC interrupt Enable/Disable and interrupt flags acknowledgement.
 
 XMEGA Custom Logic (XCL) T/C in Single Slope PWM mode
 This group provides functions that can be used only when XCL TC sub-module is in SINGLE SLOPE PWM mode.
 
 XMEGA Custom Logic (XCL) T/C in Capture mode
 This group provides functions that can be used only when XCL TC sub-module is in CAPTURE mode.
 
 XMEGA Custom Logic (XCL) T/C in Normal mode
 This group provides functions that can be used only when XCL TC sub-module is in NORMAL mode.
 

Data Structures

struct  xcl_tc_config_t
 

Typedefs

typedef void(* xcl_callback_t )(void)
 

Enumerations

enum  xcl_int_level_t {
  XCL_INT_LVL_OFF = 0x00,
  XCL_INT_LVL_LO = 0x01,
  XCL_INT_LVL_MED = 0x02,
  XCL_INT_LVL_HI = 0x03
}
 
enum  xcl_tc_clk_source_t {
  OFF = XCL_CLKSEL_OFF_gc,
  DIV1 = XCL_CLKSEL_DIV1_gc,
  DIV2 = XCL_CLKSEL_DIV2_gc,
  DIV4 = XCL_CLKSEL_DIV4_gc,
  DIV8 = XCL_CLKSEL_DIV8_gc,
  DIV64 = XCL_CLKSEL_DIV64_gc,
  DIV256 = XCL_CLKSEL_DIV256_gc,
  DIV1024 = XCL_CLKSEL_DIV1024_gc,
  EVCH0 = XCL_CLKSEL_EVCH0_gc,
  EVCH1 = XCL_CLKSEL_EVCH1_gc,
  EVCH2 = XCL_CLKSEL_EVCH2_gc,
  EVCH3 = XCL_CLKSEL_EVCH3_gc,
  EVCH4 = XCL_CLKSEL_EVCH4_gc,
  EVCH5 = XCL_CLKSEL_EVCH5_gc,
  EVCH6 = XCL_CLKSEL_EVCH6_gc,
  EVCH7 = XCL_CLKSEL_EVCH7_gc
}
 
enum  xcl_tc_cmd_restart_type {
  NO_CMD = XCL_CMDEN_DISABLE_gc,
  RESTART_TIMER0 = XCL_CMDEN_CMD0_gc,
  RESTART_TIMER1 = XCL_CMDEN_CMD1_gc,
  RESTART_TIMER01 = XCL_CMDEN_CMD01_gc
}
 
enum  xcl_tc_mode_t {
  NORMAL = XCL_TCMODE_NORMAL_gc,
  CAPT = XCL_TCMODE_CAPT_gc,
  PWM = XCL_TCMODE_PWM_gc
}
 
enum  xcl_tc_sel_t {
  TC16 = XCL_TCSEL_TC16_gc,
  BTC0 = XCL_TCSEL_BTC0_gc,
  BTC01 = XCL_TCSEL_BTC01_gc,
  BTC0PEC1 = XCL_TCSEL_BTC0PEC1_gc,
  PEC0BTC1 = XCL_TCSEL_PEC0BTC1_gc,
  PEC01 = XCL_TCSEL_PEC01_gc,
  BTC0PEC2 = XCL_TCSEL_BTC0PEC2_gc
}
 

Functions

static void xcl_btc0_set_count (uint8_t count)
 Set XCL BTC0 timer count value. More...
 
static void xcl_btc1_set_count (uint8_t count)
 Set XCL BTC1 timer count value. More...
 
static void xcl_disable_oc0 (void)
 Disable XCL timer output compare 0 output (CC0). More...
 
static void xcl_disable_oc1 (void)
 Disable XCL timer output compare 1 output (CC1). More...
 
static void xcl_enable_oc0 (void)
 Enable XCL timer output compare 0 output (CC0). More...
 
static void xcl_enable_oc1 (void)
 Enable XCL timer output compare 1 output (CC1). More...
 
static void xcl_force_oc0 (bool value)
 Force XCL Timer output compare 0 output (CC0). More...
 
static void xcl_force_oc1 (bool value)
 Force XCL Timer output compare 1 output (CC1). More...
 
static void xcl_pec0_set_count (uint8_t count)
 Set XCL PEC0 timer count value. More...
 
static void xcl_pec1_set_count (uint8_t count)
 Set XCL PEC1 timer count value. More...
 
static void xcl_pec_set_lenght (uint8_t lenght)
 Set XCL PEC lenght. More...
 
void xcl_set_cc_interrupt_callback (xcl_callback_t callback)
 
void xcl_set_unf_interrupt_callback (xcl_callback_t callback)
 Set interrupt XCL underflow callback function. More...
 
static void xcl_tc16_set_count (uint16_t count)
 Set XCL TC16 timer count value. More...
 
static void xcl_tc_mode (enum xcl_tc_mode_t mode)
 Configure the XCL Timer mode. More...
 
static void xcl_tc_restart (enum xcl_tc_cmd_restart_type restart_type)
 Generate a restart command on the selected XCL timer. More...
 
uint32_t xcl_tc_set_resolution (uint32_t resolution)
 Configure the XCL TC source clock to achieve a requested resolution. More...
 
static void xcl_tc_source_clock (enum xcl_tc_clk_source_t src)
 Configure the XCL Timer module source clock. More...
 
static void xcl_tc_type (enum xcl_tc_sel_t tc_sel)
 Configure the XCL Timer module type. More...
 

typedef void(* xcl_callback_t)(void)

Enumerator
XCL_INT_LVL_OFF 
XCL_INT_LVL_LO 
XCL_INT_LVL_MED 
XCL_INT_LVL_HI 
Enumerator
OFF 
DIV1 
DIV2 
DIV4 
DIV8 
DIV64 
DIV256 
DIV1024 
EVCH0 
EVCH1 
EVCH2 
EVCH3 
EVCH4 
EVCH5 
EVCH6 
EVCH7 
Enumerator
NO_CMD 
RESTART_TIMER0 
RESTART_TIMER1 
RESTART_TIMER01 
Enumerator
NORMAL 
CAPT 
PWM 
Enumerator
TC16 
BTC0 
BTC01 
BTC0PEC1 
PEC0BTC1 
PEC01 
BTC0PEC2 

static void xcl_btc0_set_count ( uint8_t  count)
inlinestatic

Set XCL BTC0 timer count value.

This function loads the XCL BTC0 count to a specific value.

Parameters
countThe count value
static void xcl_btc1_set_count ( uint8_t  count)
inlinestatic

Set XCL BTC1 timer count value.

This function loads the XCL BTC1 count to a specific value.

Parameters
countThe count value
static void xcl_disable_oc0 ( void  )
inlinestatic

Disable XCL timer output compare 0 output (CC0).

This function Disable the output compare 0 output of XCL BTCO timer.

static void xcl_disable_oc1 ( void  )
inlinestatic

Disable XCL timer output compare 1 output (CC1).

This function Disable the output compare 1 output of XCL BTCO timer.

static void xcl_enable_oc0 ( void  )
inlinestatic

Enable XCL timer output compare 0 output (CC0).

This function enable the output compare 0 output of XCL BTCO timer.

Referenced by main().

static void xcl_enable_oc1 ( void  )
inlinestatic

Enable XCL timer output compare 1 output (CC1).

This function enable the output compare 1 output of XCL BTC1 timer.

Referenced by main().

static void xcl_force_oc0 ( bool  value)
inlinestatic

Force XCL Timer output compare 0 output (CC0).

This function force the XCL Timer output compare 0 output pin to the specified logic level.

Note
The XCL timer shold be turned off to force the output compare pin.
Parameters
valueThe logic value to be forced on CC0 pin
static void xcl_force_oc1 ( bool  value)
inlinestatic

Force XCL Timer output compare 1 output (CC1).

This function force the XCL Timer output compare 1 output pin to the specified logic level.

Note
The XCL timer shold be turned off to force the output compare pin.
Parameters
valueThe logic value to be forced on CC1 pin
static void xcl_pec0_set_count ( uint8_t  count)
inlinestatic

Set XCL PEC0 timer count value.

This function loads the XCL PEC0 count to a specific value.

Parameters
countThe count value
static void xcl_pec1_set_count ( uint8_t  count)
inlinestatic

Set XCL PEC1 timer count value.

This function loads the XCL PEC1 count to a specific value.

Parameters
countThe count value
static void xcl_pec_set_lenght ( uint8_t  lenght)
inlinestatic

Set XCL PEC lenght.

This function configures the frame lenght when XCL in PEC mode is used with USART or SPI module to generate extended variable frame lenght.

Parameters
lenghtThe PEC frame lenght (in bit number)

Referenced by usart_xmegae_init_rs232(), and usart_xmegae_init_spi().

void xcl_set_cc_interrupt_callback ( xcl_callback_t  callback)
void xcl_set_unf_interrupt_callback ( xcl_callback_t  callback)

Set interrupt XCL underflow callback function.

This function allows the caller to set and change the interrupt callback function. Without setting a callback function the interrupt handler in the driver will only clear the interrupt flags.

Note
This function is available only when CONFIG_XCL_CALLBACK_ENABLE is active in conf_xcl.h.
Parameters
callbackReference to a callback function

References xcl_unf_callback.

Referenced by main().

static void xcl_tc16_set_count ( uint16_t  count)
inlinestatic

Set XCL TC16 timer count value.

This function loads the XCL TC16 count to a specific value.

Parameters
countThe count value

References LSB, and MSB.

Referenced by main().

static void xcl_tc_mode ( enum xcl_tc_mode_t  mode)
inlinestatic

Configure the XCL Timer mode.

This function will configure the XCL timer mode acording to the selected mode passed as parameter.

Parameters
modeThe timer selection

Referenced by main().

static void xcl_tc_restart ( enum xcl_tc_cmd_restart_type  restart_type)
inlinestatic

Generate a restart command on the selected XCL timer.

This function will initiate a restart command for the XCL timer passed as parameter.

Parameters
restart_typeThe restart type command
uint32_t xcl_tc_set_resolution ( uint32_t  resolution)

Configure the XCL TC source clock to achieve a requested resolution.

This function will configure the XCL TC clock selection register in order to achieve a resolution equal or higher than the one passed as an argument. This function returns the real resulting resolution that has been configured.

Parameters
resolutionthe requested resolution
Returns
The resulting real configured resolution

References DIV1, DIV1024, DIV2, DIV256, DIV4, DIV64, DIV8, sysclk_get_peripheral_bus_hz(), and xcl_tc_source_clock().

Referenced by main().

static void xcl_tc_source_clock ( enum xcl_tc_clk_source_t  src)
inlinestatic

Configure the XCL Timer module source clock.

This function will configure the XCL timer source clock acording to the selected source clock passed as parameter.

Parameters
srcThe selected soruce clock.

Referenced by xcl_tc_set_resolution().

static void xcl_tc_type ( enum xcl_tc_sel_t  tc_sel)
inlinestatic

Configure the XCL Timer module type.

This function will configure the XCL timer mode acording to the selected mode passed as parameter.

Parameters
tc_selThe timer selection

Referenced by main(), usart_xmegae_init_rs232(), and usart_xmegae_init_spi().