Macros | |
#define | CONFIG_USBCLK_DIV 1 |
Configuration symbol for the USB generic clock divider setting. More... | |
#define | CONFIG_USBCLK_SOURCE USBCLK_SRC_UPLL |
Configuration symbol for the USB generic clock source. More... | |
Functions | |
void | sysclk_disable_usb (void) |
void | sysclk_enable_usb (void) |
Configuration Symbols | |
#define | CONFIG_SYSCLK_SOURCE SYSCLK_SRC_MAINCK_4M_RC |
Initial/static main system clock source. More... | |
#define | CONFIG_SYSCLK_PRES 0 |
Initial CPU clock divider (mck) More... | |
Master Clock Sources (MCK) | |
#define | SYSCLK_SRC_SLCK_RC 0 |
Internal 32kHz RC oscillator as master source clock. More... | |
#define | SYSCLK_SRC_SLCK_XTAL 1 |
External 32kHz crystal oscillator as master source clock. More... | |
#define | SYSCLK_SRC_SLCK_BYPASS 2 |
External 32kHz bypass oscillator as master source clock. More... | |
#define | SYSCLK_SRC_MAINCK_4M_RC 3 |
Internal 4MHz RC oscillator as master source clock. More... | |
#define | SYSCLK_SRC_MAINCK_8M_RC 4 |
Internal 8MHz RC oscillator as master source clock. More... | |
#define | SYSCLK_SRC_MAINCK_12M_RC 5 |
Internal 12MHz RC oscillator as master source clock. More... | |
#define | SYSCLK_SRC_MAINCK_XTAL 6 |
External crystal oscillator as master source clock. More... | |
#define | SYSCLK_SRC_MAINCK_BYPASS 7 |
External bypass oscillator as master source clock. More... | |
#define | SYSCLK_SRC_PLLACK 8 |
Use PLLACK as master source clock. More... | |
#define | SYSCLK_SRC_UPLLCK 9 |
Use UPLLCK as master source clock. More... | |
Master Clock Prescalers (MCK) | |
#define | SYSCLK_PRES_1 PMC_MCKR_PRES_CLK_1 |
Set master clock prescaler to 1. More... | |
#define | SYSCLK_PRES_2 PMC_MCKR_PRES_CLK_2 |
Set master clock prescaler to 2. More... | |
#define | SYSCLK_PRES_4 PMC_MCKR_PRES_CLK_4 |
Set master clock prescaler to 4. More... | |
#define | SYSCLK_PRES_8 PMC_MCKR_PRES_CLK_8 |
Set master clock prescaler to 8. More... | |
#define | SYSCLK_PRES_16 PMC_MCKR_PRES_CLK_16 |
Set master clock prescaler to 16. More... | |
#define | SYSCLK_PRES_32 PMC_MCKR_PRES_CLK_32 |
Set master clock prescaler to 32. More... | |
#define | SYSCLK_PRES_64 PMC_MCKR_PRES_CLK_64 |
Set master clock prescaler to 64. More... | |
#define | SYSCLK_PRES_3 PMC_MCKR_PRES_CLK_3 |
Set master clock prescaler to 3. More... | |
Master Clock Division (MCK) | |
#define | SYSCLK_DIV_1 PMC_MCKR_MDIV_EQ_PCK |
Set master clock division to 1. More... | |
#define | SYSCLK_DIV_2 PMC_MCKR_MDIV_PCK_DIV2 |
Set master clock division to 2. More... | |
#define | SYSCLK_DIV_4 PMC_MCKR_MDIV_PCK_DIV4 |
Set master clock division to 4. More... | |
#define | SYSCLK_DIV_3 PMC_MCKR_MDIV_PCK_DIV3 |
Set master clock division to 3. More... | |
USB Clock Sources | |
#define | USBCLK_SRC_PLL0 0 |
Use PLLA. More... | |
#define | USBCLK_SRC_UPLL 1 |
Use UPLL. More... | |
Querying the system clock | |
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. More... | |
static uint32_t | sysclk_get_cpu_hz (void) |
Return the current rate in Hz of the CPU clock. More... | |
static uint32_t | sysclk_get_peripheral_hz (void) |
Retrieves the current rate in Hz of the peripheral clocks. More... | |
static uint32_t | sysclk_get_peripheral_bus_hz (const volatile void *module) |
Retrieves the current rate in Hz of the Peripheral Bus clock attached to the specified peripheral. More... | |
Enabling and disabling synchronous clocks | |
static void | sysclk_enable_peripheral_clock (uint32_t ul_id) |
Enable a peripheral's clock. More... | |
static void | sysclk_disable_peripheral_clock (uint32_t ul_id) |
Disable a peripheral's clock. More... | |
System Clock Source and Prescaler configuration | |
void | sysclk_set_prescalers (uint32_t ul_pres) |
Set system clock prescaler configuration. More... | |
void | sysclk_set_source (uint32_t ul_src) |
Change the source of the main system clock. More... | |
System Clock Initialization | |
void | sysclk_init (void) |
Initialize the synchronous clock system. More... | |
See Quick Start Guide for the System Clock Management.
The sysclk API covers the system clock and all clocks derived from it. The system clock is a chip-internal clock on which all synchronous clocks, i.e. CPU and bus/peripheral clocks, are based. The system clock is typically generated from one of a variety of sources, which may include crystal and RC oscillators as well as PLLs. The clocks derived from the system clock are sometimes also known as synchronous clocks, since they always run synchronously with respect to each other, as opposed to generic clocks which may run from different oscillators or PLLs.
Most applications should simply call sysclk_init() to initialize everything related to the system clock and its source (oscillator, PLL or DFLL), and leave it at that. More advanced applications, and platform-specific drivers, may require additional services from the clock system, some of which may be platform-specific.
The sysclk API is partially chip- or platform-specific. While all platforms provide mostly the same functionality, there are some variations around how different bus types and clock tree structures are handled.
The following functions are available on all platforms with the same parameters and functionality. These functions may be called freely by portable applications, drivers and services:
The following functions are available on all platforms, but there may be variations in the function signature (i.e. parameters) and behavior. These functions are typically called by platform-specific parts of drivers, and applications that aren't intended to be portable:
All other functions should be considered platform-specific. Enabling/disabling clocks to specific peripherals as well as determining the speed of these clocks should be done by calling functions provided by the driver for that peripheral.
#define CONFIG_SYSCLK_PRES 0 |
Initial CPU clock divider (mck)
The MCK will run at
after initialization.
Definition at line 228 of file same70/sysclk.h.
#define CONFIG_SYSCLK_SOURCE SYSCLK_SRC_MAINCK_4M_RC |
Initial/static main system clock source.
The main system clock will be configured to use this clock during initialization.
Definition at line 215 of file same70/sysclk.h.
#define CONFIG_USBCLK_DIV 1 |
Configuration symbol for the USB generic clock divider setting.
Sets the clock division for the USB generic clock. If a USB clock source is selected with CONFIG_USBCLK_SOURCE, this configuration symbol must also be defined.
Definition at line 87 of file conf_clock.h.
#define CONFIG_USBCLK_SOURCE USBCLK_SRC_UPLL |
Configuration symbol for the USB generic clock source.
Sets the clock source to use for the USB. The source must also be properly configured.
Define this to one of the USBCLK_SRC_xxx
settings. Leave it undefined if USB is not required.
Definition at line 86 of file conf_clock.h.
#define SYSCLK_DIV_1 PMC_MCKR_MDIV_EQ_PCK |
Set master clock division to 1.
Definition at line 261 of file same70/sysclk.h.
#define SYSCLK_DIV_2 PMC_MCKR_MDIV_PCK_DIV2 |
Set master clock division to 2.
Definition at line 262 of file same70/sysclk.h.
#define SYSCLK_DIV_3 PMC_MCKR_MDIV_PCK_DIV3 |
Set master clock division to 3.
Definition at line 264 of file same70/sysclk.h.
#define SYSCLK_DIV_4 PMC_MCKR_MDIV_PCK_DIV4 |
Set master clock division to 4.
Definition at line 263 of file same70/sysclk.h.
#define SYSCLK_PRES_1 PMC_MCKR_PRES_CLK_1 |
Set master clock prescaler to 1.
Definition at line 249 of file same70/sysclk.h.
#define SYSCLK_PRES_16 PMC_MCKR_PRES_CLK_16 |
Set master clock prescaler to 16.
Definition at line 253 of file same70/sysclk.h.
#define SYSCLK_PRES_2 PMC_MCKR_PRES_CLK_2 |
Set master clock prescaler to 2.
Definition at line 250 of file same70/sysclk.h.
#define SYSCLK_PRES_3 PMC_MCKR_PRES_CLK_3 |
Set master clock prescaler to 3.
Definition at line 256 of file same70/sysclk.h.
#define SYSCLK_PRES_32 PMC_MCKR_PRES_CLK_32 |
Set master clock prescaler to 32.
Definition at line 254 of file same70/sysclk.h.
#define SYSCLK_PRES_4 PMC_MCKR_PRES_CLK_4 |
Set master clock prescaler to 4.
Definition at line 251 of file same70/sysclk.h.
#define SYSCLK_PRES_64 PMC_MCKR_PRES_CLK_64 |
Set master clock prescaler to 64.
Definition at line 255 of file same70/sysclk.h.
#define SYSCLK_PRES_8 PMC_MCKR_PRES_CLK_8 |
Set master clock prescaler to 8.
Definition at line 252 of file same70/sysclk.h.
#define SYSCLK_SRC_MAINCK_12M_RC 5 |
Internal 12MHz RC oscillator as master source clock.
Definition at line 240 of file same70/sysclk.h.
#define SYSCLK_SRC_MAINCK_4M_RC 3 |
Internal 4MHz RC oscillator as master source clock.
Definition at line 238 of file same70/sysclk.h.
#define SYSCLK_SRC_MAINCK_8M_RC 4 |
Internal 8MHz RC oscillator as master source clock.
Definition at line 239 of file same70/sysclk.h.
#define SYSCLK_SRC_MAINCK_BYPASS 7 |
External bypass oscillator as master source clock.
Definition at line 242 of file same70/sysclk.h.
#define SYSCLK_SRC_MAINCK_XTAL 6 |
External crystal oscillator as master source clock.
Definition at line 241 of file same70/sysclk.h.
#define SYSCLK_SRC_PLLACK 8 |
Use PLLACK as master source clock.
Definition at line 243 of file same70/sysclk.h.
#define SYSCLK_SRC_SLCK_BYPASS 2 |
External 32kHz bypass oscillator as master source clock.
Definition at line 237 of file same70/sysclk.h.
#define SYSCLK_SRC_SLCK_RC 0 |
Internal 32kHz RC oscillator as master source clock.
Definition at line 235 of file same70/sysclk.h.
#define SYSCLK_SRC_SLCK_XTAL 1 |
External 32kHz crystal oscillator as master source clock.
Definition at line 236 of file same70/sysclk.h.
#define SYSCLK_SRC_UPLLCK 9 |
Use UPLLCK as master source clock.
Definition at line 244 of file same70/sysclk.h.
#define USBCLK_SRC_PLL0 0 |
Use PLLA.
Definition at line 269 of file same70/sysclk.h.
#define USBCLK_SRC_UPLL 1 |
Use UPLL.
Definition at line 270 of file same70/sysclk.h.
|
inlinestatic |
Disable a peripheral's clock.
ul_id | Id (number) of the peripheral clock. |
Definition at line 433 of file same70/sysclk.h.
void sysclk_disable_usb | ( | void | ) |
|
inlinestatic |
Enable a peripheral's clock.
ul_id | Id (number) of the peripheral clock. |
Definition at line 423 of file same70/sysclk.h.
void sysclk_enable_usb | ( | void | ) |
|
inlinestatic |
Return the current rate in Hz of the CPU clock.
Definition at line 378 of file same70/sysclk.h.
|
inlinestatic |
Return the current rate in Hz of the main system clock.
Definition at line 324 of file same70/sysclk.h.
|
inlinestatic |
Retrieves the current rate in Hz of the Peripheral Bus clock attached to the specified peripheral.
module | Pointer to the module's base address. |
Definition at line 408 of file same70/sysclk.h.
|
inlinestatic |
Retrieves the current rate in Hz of the peripheral clocks.
Definition at line 392 of file same70/sysclk.h.
void sysclk_init | ( | void | ) |
Initialize the synchronous clock system.
This function will initialize the system clock and its source. This includes:
Since all non-essential peripheral clocks are initially disabled, it is the responsibility of the peripheral driver to re-enable any clocks that are needed for normal operation.
void sysclk_set_prescalers | ( | uint32_t | ul_pres | ) |