AVR XMEGA TC

Defines

#define tc_get_regs(id)   ((void *) (TC##id##_BASE))
 Get a pointer to the TC registers.

Functions

static uint8_t tc_select_clock (uint8_t tc_id, uint32_t resolution)
 Select clock for a specified TC and resolution.
static uint32_t tc_get_resolution (uint8_t tc_id, uint8_t clksel)
 Get the resolution for a specified TC and clock selection.



static uint8_t tc_get_sysclk_port (uint8_t tc_id)
 Get the SYSCLK port for a specified tc_id.
static uint8_t tc_get_sysclk_id (uint8_t tc_id)
 Get the SYSCLK ID for a specified tc_id.
static void tc_enable_pclk (uint8_t tc_id)
 Enable the peripheral clock for a specified tc_id.
static void tc_disable_pclk (uint8_t tc_id)
 Disable the peripheral clock for a specified tc_id.
static bool tc_pclk_is_enabled (uint8_t tc_id)
 Return whether peripheral clock is enabled for a specified tc_id.
static uint32_t tc_get_pclk_hz (uint8_t tc_id)
 Get the clock frequency for a specified tc_id.

Detailed Description

Definitions for getting a TC's register base address at compile time, and clock selection and frequency at runtime.


Define Documentation

#define tc_get_regs ( id   )     ((void *) (TC##id##_BASE))

Get a pointer to the TC registers.

Parameters:
id The ID of the TC module. This must be a constant value. The first ID is 0 and it refers to the first TC in the peripheral module address map. The other TCs that follow get increasing IDs 1, 2, 3 ...
Returns:
A pointer to a virtual address corresponding to the base address of the selected TC peripheral.

Definition at line 66 of file tc_xmega.h.


Function Documentation

static void tc_disable_pclk ( uint8_t  tc_id  )  [inline, static]

Disable the peripheral clock for a specified tc_id.

Definition at line 118 of file tc.h.

References sysclk_disable_module(), tc_get_sysclk_id(), and tc_get_sysclk_port().

Referenced by tc_timer_init(), tc_timer_set_alarm(), and tc_timer_stop().

static void tc_enable_pclk ( uint8_t  tc_id  )  [inline, static]

Enable the peripheral clock for a specified tc_id.

Definition at line 109 of file tc.h.

References sysclk_enable_module(), tc_get_sysclk_id(), and tc_get_sysclk_port().

Referenced by tc_timer_init(), tc_timer_set_alarm(), and tc_timer_start().

static uint32_t tc_get_pclk_hz ( uint8_t  tc_id  )  [inline, static]

Get the clock frequency for a specified tc_id.

All TCs in this chip are connected to CLKper, which is the same frequency as CLKcpu. tc_id is therefore only defined as a parameter for code consistency across devices.

Todo:
Revisit, remove dependence on CONFIG_CPU_HZ.

Definition at line 142 of file tc.h.

Referenced by tc_get_resolution(), and tc_select_clock().

static uint32_t tc_get_resolution ( uint8_t  tc_id,
uint8_t  clksel 
) [inline, static]

Get the resolution for a specified TC and clock selection.

This function returns the resolution which the specified clock selection and TC will result in. The resolution of a TC is synonymous with its clock frequency.

Note:
This function does not handle event channel clock selections.
Parameters:
tc_id ID of TC to get resolution for.
clksel Clock selection, as prescaled CLKper.
Returns:
The resolution of tc_id with the clock selection clksel.

Definition at line 118 of file tc_xmega.h.

References TC_CLKSEL_DIV1, TC_CLKSEL_DIV1024, TC_CLKSEL_DIV2, TC_CLKSEL_DIV256, TC_CLKSEL_DIV4, TC_CLKSEL_DIV64, TC_CLKSEL_DIV8, TC_CLKSEL_OFF, tc_get_pclk_hz(), and unhandled_case.

Referenced by tc_timer_get_resolution().

static uint8_t tc_get_sysclk_id ( uint8_t  tc_id  )  [inline, static]

Get the SYSCLK ID for a specified tc_id.

Definition at line 85 of file tc.h.

References SYSCLK_TC0, SYSCLK_TC1, and unhandled_case.

Referenced by tc_disable_pclk(), tc_enable_pclk(), and tc_pclk_is_enabled().

static uint8_t tc_get_sysclk_port ( uint8_t  tc_id  )  [inline, static]

Get the SYSCLK port for a specified tc_id.

chip-specific TC definitions

Definition at line 57 of file tc.h.

References SYSCLK_PORT_C, SYSCLK_PORT_D, SYSCLK_PORT_E, SYSCLK_PORT_F, and unhandled_case.

Referenced by tc_disable_pclk(), tc_enable_pclk(), and tc_pclk_is_enabled().

static bool tc_pclk_is_enabled ( uint8_t  tc_id  )  [inline, static]

Return whether peripheral clock is enabled for a specified tc_id.

Definition at line 127 of file tc.h.

References sysclk_module_is_enabled(), tc_get_sysclk_id(), and tc_get_sysclk_port().

Referenced by tc_timer_get_time(), and tc_timer_set_alarm().

static uint8_t tc_select_clock ( uint8_t  tc_id,
uint32_t  resolution 
) [inline, static]

Select clock for a specified TC and resolution.

This function returns the clock selection, as prescaled CLKper, for a specified TC that gives a resolution at least as high as the one specified. The resolution of a TC is synonymous with its clock frequency.

Note:
It is also possible to clock TCs with event channels. This is not handled by this implementation.
Parameters:
tc_id ID of TC to get clock selection for.
resolution Desired resolution for the TC.
Returns:
The clock selection (prescaled CLKper) that gives a resolution at least as high as resolution for tc_id.

Definition at line 84 of file tc_xmega.h.

References TC_CLKSEL_DIV1, TC_CLKSEL_DIV1024, TC_CLKSEL_DIV2, TC_CLKSEL_DIV256, TC_CLKSEL_DIV4, TC_CLKSEL_DIV64, TC_CLKSEL_DIV8, and tc_get_pclk_hz().

Referenced by tc_timer_init(), and tc_timer_set_resolution().

Generated on Thu Apr 29 14:10:01 2010 for display-demo by  doxygen 1.6.3