# chip/at32uc3a3/include/chip/clk.h File Reference

AT32UC3A3 clock control. More...

`#include <app/clk-config.h>`
`#include <board/clk.h>`
`#include <flash/flashc.h>`
`#include <pm/pm_v2.h>`

Include dependency graph for clk.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

## Enumerations
enum | pm_mainclk_src
| Main clock source. More...
enum | pm_pll_src
| PLL clock source. More...
enum | pm_genclk_src
| Generic clock source. More...
## Functions
static uint32_t | pm_priv_osc_startup (unsigned long us)
| Get the OSCCTRL startup value corresponding to a given number of microseconds.
static unsigned long | get_main_clock_rate (void)
| Get the main synchronous clock rate in Hz.
static unsigned long | get_cpu_clock_rate (void)
| Get the CPU clock rate in Hz.
static unsigned long | get_hsb_clock_rate (void)
| Get the HSB clock rate in Hz.
static unsigned long | get_pba_clock_rate (void)
| Get the PBA clock rate in Hz.
static unsigned long | get_pbb_clock_rate (void)
| Get the PBB clock rate in Hz.
static unsigned long | get_smc_hclk_rate (void)
| Get the rate of the bus clock connected to the SMC.
static unsigned long | get_usart_pclk_rate (unsigned int id)
| Get the rate of the bus clock connected to a USART.
static unsigned long | get_spi_pclk_rate (unsigned int id)
| Get the rate of the bus clock connected to a SPI controller.
static unsigned long | get_mci_pclk_rate (unsigned int id)
| Get the rate of the bus clock connected to a MMC controller.
static void | pm_init_osc (unsigned int id)
| Enable an on-chip oscillator.
static int | clk_enable_usbb (void)
| Enable the USBB clock.
## Variables
unsigned long | main_clock_rate
| The main clock rate in Hz, if not constant.

## Detailed Description

AT32UC3A3 clock control.

- Compiler: IAR EWAVR32 and GNU GCC for AVR32
- Supported devices: AT32UC3A3
- AppNote:

Author:
  Atmel Corporation: http://www.atmel.com
  Support and FAQ: http://support.atmel.no/

Definition in file clk.h.

## Enumeration Type Documentation

enum pm_genclk_src

Generic clock source.

Each generic clock must be generated from a different clock. These are the available alternatives provided by the chip.

Definition at line 78 of file clk.h.

enum pm_mainclk_src

Main clock source.

Definition at line 58 of file clk.h.

enum pm_pll_src

PLL clock source.

Definition at line 67 of file clk.h.

## Function Documentation

static int clk_enable_usbb | ( | void |  | ) | `[inline, static]`

Enable the USBB clock.

Returns:
  0 if successful, or a negative error code otherwise.

Todo:
  We should probably distinguish between the UTMI clock and the peripheral bus/HSB clocks.

Definition at line 328 of file clk.h.

Referenced by usbb_init().

static unsigned long get_cpu_clock_rate | ( | void |  | ) | `[inline, static]`

Get the CPU clock rate in Hz.

Definition at line 214 of file clk.h.

Referenced by udelay().

static unsigned long get_hsb_clock_rate | ( | void |  | ) | `[inline, static]`

Get the HSB clock rate in Hz.

Definition at line 220 of file clk.h.

Referenced by get_smc_hclk_rate().

static unsigned long get_main_clock_rate | ( | void |  | ) | `[inline, static]`

Get the main synchronous clock rate in Hz.

The main clock is the base clock from which the CPU clock and all the bus clocks are derived.

Returns:
  The main clock rate in Hz

Definition at line 184 of file clk.h.

static unsigned long get_mci_pclk_rate | ( | unsigned int | id | ) | `[inline, static]`

Get the rate of the bus clock connected to a MMC controller.

Parameters:

  | id | The ID of the MMC controller of which to query the bus clock rate.

Returns:
  The MMC bus clock rate in Hz.

Definition at line 275 of file clk.h.

References get_pba_clock_rate().

Referenced by sdmmc_mcihost_init().

Here is the call graph for this function:

static unsigned long get_pba_clock_rate | ( | void |  | ) | `[inline, static]`

Get the PBA clock rate in Hz.

Definition at line 226 of file clk.h.

Referenced by get_mci_pclk_rate(), and timer_init().

static unsigned long get_pbb_clock_rate | ( | void |  | ) | `[inline, static]`

Get the PBB clock rate in Hz.

Definition at line 232 of file clk.h.

Referenced by get_spi_pclk_rate(), and get_usart_pclk_rate().

static unsigned long get_smc_hclk_rate | ( | void |  | ) | `[inline, static]`

Get the rate of the bus clock connected to the SMC.

Definition at line 239 of file clk.h.

References get_hsb_clock_rate().

Here is the call graph for this function:

static unsigned long get_spi_pclk_rate | ( | unsigned int | id | ) | `[inline, static]`

Get the rate of the bus clock connected to a SPI controller.

Parameters:

  | id | The ID of the SPI controller of which to query the bus clock rate.

Returns:
  The SPI bus clock rate in Hz.

Definition at line 263 of file clk.h.

References get_pbb_clock_rate().

Here is the call graph for this function:

static unsigned long get_usart_pclk_rate | ( | unsigned int | id | ) | `[inline, static]`

Get the rate of the bus clock connected to a USART.

Parameters:

  | id | The ID of the USART of which to query the bus clock rate.

Returns:
  The USART bus clock rate in Hz.

Definition at line 251 of file clk.h.

References get_pbb_clock_rate().

Here is the call graph for this function:

static void pm_init_osc | ( | unsigned int | id | ) | `[inline, static]`

Enable an on-chip oscillator.

Parameters:

  | id | The ID of the oscillator to enable (0 or 1).

Return values:

  | STATUS_OK | The oscillator was successfully started
  | -STATUS_TIMEOUT | Timed out waiting for the oscillator to start

Definition at line 288 of file clk.h.

References assert, BOARD_OSC0_STARTUP_US, BOARD_OSC0_XTAL, BOARD_OSC1_STARTUP_US, BOARD_OSC1_XTAL, pm_priv_osc_startup(), and unhandled_case.

Here is the call graph for this function:

static uint32_t pm_priv_osc_startup | ( | unsigned long | us | ) | `[inline, static]`

Get the OSCCTRL startup value corresponding to a given number of microseconds.

For internal use only.

Parameters:

  | us | The startup time in microseconds

Returns:
  The value to write to the STARTUP field in OSCCTRL.

Definition at line 95 of file clk.h.

References build_assert, and is_constant.

Referenced by pm_init_osc().

## Variable Documentation

unsigned long main_clock_rate

The main clock rate in Hz, if not constant.

Definition at line 60 of file pm.c.

Referenced by pm_priv_set_main_clock().