chip/atxmega128a1/include/chip/sysclk.h File Reference

Chip-specific system clock management functions. More...

#include <compiler.h>
#include <clk/pll.h>
#include <regs/xmega_pr.h>
#include <regs/xmega_clk.h>
#include <stdint.h>
#include <stdbool.h>
#include <assert.h>
#include <chip/memory-map.h>
#include <io.h>

Go to the source code of this file.

Defines

System Clock Sources

#define SYSCLK_SRC_RC2MHZ   0x00
#define SYSCLK_SRC_RC32MHZ   0x01
#define SYSCLK_SRC_RC32KHZ   0x02
#define SYSCLK_SRC_XOSC   0x03
#define SYSCLK_SRC_PLL   0x04
System Clock Port Numbers

#define SYSCLK_PORT_GEN   XMEGA_PR_PRGEN
 No particular port.
#define SYSCLK_PORT_A   XMEGA_PR_PRPA
 Devices on PORTA.
#define SYSCLK_PORT_B   XMEGA_PR_PRPB
 Devices on PORTB.
#define SYSCLK_PORT_C   XMEGA_PR_PRPC
 Devices on PORTC.
#define SYSCLK_PORT_D   XMEGA_PR_PRPD
 Devices on PORTD.
#define SYSCLK_PORT_E   XMEGA_PR_PRPE
 Devices on PORTE.
#define SYSCLK_PORT_F   XMEGA_PR_PRPF
 Devices on PORTF.
Clocks not associated with any port

#define SYSCLK_DMA   (1U << PR_DMA_BIT)
 DMA Controller.
#define SYSCLK_EVSYS   (1U << PR_EVSYS_BIT)
 Event System.
#define SYSCLK_RTC   (1U << PR_RTC_BIT)
 Real-Time Counter.
#define SYSCLK_EBI   (1U << PR_EBI_BIT)
 Ext Bus Interface.
#define SYSCLK_AES   (1U << PR_AES_BIT)
 AES Module.
Clocks on PORTA and PORTB

#define SYSCLK_AC   (1U << PR_AC_BIT)
 Analog Comparator.
#define SYSCLK_ADC   (1U << PR_ADC_BIT)
 A/D Converter.
#define SYSCLK_DAC   (1U << PR_DAC_BIT)
 D/A Converter.
Clocks on PORTC, PORTD, PORTE and PORTF

#define SYSCLK_TC0   (1U << PR_TC0_BIT)
 Timer/Counter 0.
#define SYSCLK_TC1   (1U << PR_TC1_BIT)
 Timer/Counter 1.
#define SYSCLK_HIRES   (1U << PR_HIRES_BIT)
 Hi-Res Extension.
#define SYSCLK_SPI   (1U << PR_SPI_BIT)
 SPI controller.
#define SYSCLK_USART0   (1U << PR_USART0_BIT)
 USART 0.
#define SYSCLK_USART1   (1U << PR_USART1_BIT)
 USART 1.
#define SYSCLK_TWI   (1U << PR_TWI_BIT)
 TWI controller.

Functions

static __always_inline bool sysclk_module_is_enabled (uint8_t port, uint8_t id)
 Check if the synchronous clock is enabled for a module.
Querying the system clock and its derived clocks

The following functions may be used to query the current frequency of the system clock and the CPU and bus clocks derived from it. sysclk_get_main_hz() and sysclk_get_cpu_hz() can be assumed to be available on all platforms, although some platforms may define additional accessors for various chip-internal bus clocks. These are usually not intended to be queried directly by generic code.

static uint32_t sysclk_get_main_hz (void)
 Return the current rate in Hz of the main system clock.
static uint32_t sysclk_get_per4_hz (void)
 Return the current rate in Hz of clk_PER4.
static uint32_t sysclk_get_per2_hz (void)
 Return the current rate in Hz of clk_PER2.
static uint32_t sysclk_get_per_hz (void)
 Return the current rate in Hz of clk_PER.
static uint32_t sysclk_get_cpu_hz (void)
 Return the current rate in Hz of the CPU clock.
Enabling and disabling synchronous clocks

void sysclk_enable_module (uint8_t port, uint8_t id)
 Enable the clock to peripheral id on port port.
void sysclk_disable_module (uint8_t port, uint8_t id)
 Disable the clock to peripheral id on port port.
System Clock Initialization

void sysclk_init (void)
 Initialize the synchronous clock system.

Detailed Description

Chip-specific system clock management functions.

Copyright (C) 2009 - 2010 Atmel Corporation. All rights reserved.

Definition in file sysclk.h.


Define Documentation

#define SYSCLK_AC   (1U << PR_AC_BIT)

Analog Comparator.

Definition at line 82 of file sysclk.h.

#define SYSCLK_ADC   (1U << PR_ADC_BIT)

A/D Converter.

Definition at line 83 of file sysclk.h.

#define SYSCLK_AES   (1U << PR_AES_BIT)

AES Module.

Definition at line 74 of file sysclk.h.

#define SYSCLK_DAC   (1U << PR_DAC_BIT)

D/A Converter.

Definition at line 84 of file sysclk.h.

#define SYSCLK_DMA   (1U << PR_DMA_BIT)

DMA Controller.

Definition at line 70 of file sysclk.h.

#define SYSCLK_EBI   (1U << PR_EBI_BIT)

Ext Bus Interface.

Definition at line 73 of file sysclk.h.

#define SYSCLK_EVSYS   (1U << PR_EVSYS_BIT)

Event System.

Definition at line 71 of file sysclk.h.

#define SYSCLK_HIRES   (1U << PR_HIRES_BIT)

Hi-Res Extension.

Definition at line 91 of file sysclk.h.

#define SYSCLK_PORT_A   XMEGA_PR_PRPA

Devices on PORTA.

Definition at line 60 of file sysclk.h.

#define SYSCLK_PORT_B   XMEGA_PR_PRPB

Devices on PORTB.

Definition at line 61 of file sysclk.h.

#define SYSCLK_PORT_C   XMEGA_PR_PRPC

Devices on PORTC.

Definition at line 62 of file sysclk.h.

#define SYSCLK_PORT_D   XMEGA_PR_PRPD

Devices on PORTD.

Definition at line 63 of file sysclk.h.

#define SYSCLK_PORT_E   XMEGA_PR_PRPE

Devices on PORTE.

Definition at line 64 of file sysclk.h.

#define SYSCLK_PORT_F   XMEGA_PR_PRPF

Devices on PORTF.

Definition at line 65 of file sysclk.h.

#define SYSCLK_PORT_GEN   XMEGA_PR_PRGEN

No particular port.

Definition at line 59 of file sysclk.h.

#define SYSCLK_RTC   (1U << PR_RTC_BIT)

Real-Time Counter.

Definition at line 72 of file sysclk.h.

#define SYSCLK_SPI   (1U << PR_SPI_BIT)

SPI controller.

Definition at line 92 of file sysclk.h.

#define SYSCLK_TC0   (1U << PR_TC0_BIT)

Timer/Counter 0.

Definition at line 89 of file sysclk.h.

#define SYSCLK_TC1   (1U << PR_TC1_BIT)

Timer/Counter 1.

Definition at line 90 of file sysclk.h.

#define SYSCLK_TWI   (1U << PR_TWI_BIT)

TWI controller.

Definition at line 95 of file sysclk.h.

#define SYSCLK_USART0   (1U << PR_USART0_BIT)

USART 0.

Definition at line 93 of file sysclk.h.

#define SYSCLK_USART1   (1U << PR_USART1_BIT)

USART 1.

Definition at line 94 of file sysclk.h.

Generated on Thu Apr 29 14:09:42 2010 for uart-loopback by  doxygen 1.6.3