SAM D21/R21/DA/HA Clock Driver.
Copyright (c) 2013-2018 Microchip Technology Inc. and its subsidiaries.
Data Structures | |
struct | _system_clock_dfll_config |
DFLL-specific data container. More... | |
struct | _system_clock_dpll_config |
DPLL-specific data container. More... | |
struct | _system_clock_module |
System clock module data container. More... | |
struct | _system_clock_xosc_config |
XOSC-specific data container. More... | |
Macros | |
#define | SYSCTRL_FUSES_OSC32K_ADDR FUSES_OSC32K_CAL_ADDR |
#define | SYSCTRL_FUSES_OSC32K_Pos FUSES_OSC32K_CAL_Pos |
Functions | |
static void | _switch_peripheral_gclk (void) |
static void | _system_clock_source_dfll_set_config_errata_9905 (void) |
static void | _system_dfll_wait_for_sync (void) |
Wait for sync to the DFLL control registers. More... | |
static void | _system_osc32k_wait_for_sync (void) |
Wait for sync to the OSC32K control registers. More... | |
void | system_clock_init (void) |
Initialize clock system based on the configuration in conf_clocks.h. More... | |
void | system_clock_source_dfll_set_config (struct system_clock_source_dfll_config *const config) |
Configure the DFLL clock source. More... | |
enum status_code | system_clock_source_disable (const enum system_clock_source clock_source) |
Disables a clock source. More... | |
enum status_code | system_clock_source_enable (const enum system_clock_source clock_source) |
Enables a clock source. More... | |
uint32_t | system_clock_source_get_hz (const enum system_clock_source clock_source) |
Retrieve the frequency of a clock source. More... | |
bool | system_clock_source_is_ready (const enum system_clock_source clock_source) |
Checks if a clock source is ready. More... | |
void | system_clock_source_osc32k_set_config (struct system_clock_source_osc32k_config *const config) |
Configure the internal OSC32K oscillator clock source. More... | |
void | system_clock_source_osc8m_set_config (struct system_clock_source_osc8m_config *const config) |
Configure the internal OSC8M oscillator clock source. More... | |
enum status_code | system_clock_source_write_calibration (const enum system_clock_source clock_source, const uint16_t calibration_value, const uint8_t freq_range) |
Writes the calibration values for a given oscillator clock source. More... | |
void | system_clock_source_xosc32k_set_config (struct system_clock_source_xosc32k_config *const config) |
Configure the XOSC32K external 32KHz oscillator clock source. More... | |
void | system_clock_source_xosc_set_config (struct system_clock_source_xosc_config *const config) |
Configure the external oscillator clock source. More... | |
Variables | |
static struct _system_clock_module | _system_clock_inst |
Internal module instance to cache configuration values. More... | |
#define SYSCTRL_FUSES_OSC32K_ADDR FUSES_OSC32K_CAL_ADDR |
Referenced by system_clock_init().
#define SYSCTRL_FUSES_OSC32K_Pos FUSES_OSC32K_CAL_Pos |
Referenced by system_clock_init().
|
static |
Switch all peripheral clock to a not enabled general clock to save power.
References GCLK_GENERATOR_1, GCLK_GENERATOR_2, GCLK_GENERATOR_3, GCLK_GENERATOR_4, GCLK_GENERATOR_5, GCLK_GENERATOR_6, GCLK_GENERATOR_7, system_gclk_chan_config::source_generator, and system_gclk_chan_set_config().
Referenced by system_clock_init().
|
inlinestatic |
|
inlinestatic |
Wait for sync to the DFLL control registers.
Referenced by _system_clock_source_dfll_set_config_errata_9905(), and system_clock_source_get_hz().
|
inlinestatic |
Wait for sync to the OSC32K control registers.
Referenced by system_clock_source_write_calibration().
enum status_code system_clock_source_enable | ( | const enum system_clock_source | clock_source | ) |
Enables a clock source.
Enables a clock source which has been previously configured.
[in] | clock_source | Clock source to enable |
STATUS_OK | Clock source was enabled successfully and is ready |
STATUS_ERR_INVALID_ARG | The clock source is not available on this device |
References _system_clock_source_dfll_set_config_errata_9905(), Assert, _system_clock_dfll_config::control, _system_clock_module::dfll, STATUS_ERR_INVALID_ARG, STATUS_OK, SYSTEM_CLOCK_SOURCE_DFLL, SYSTEM_CLOCK_SOURCE_OSC32K, SYSTEM_CLOCK_SOURCE_OSC8M, SYSTEM_CLOCK_SOURCE_ULP32K, SYSTEM_CLOCK_SOURCE_XOSC, and SYSTEM_CLOCK_SOURCE_XOSC32K.
Referenced by system_clock_init().
enum status_code system_clock_source_write_calibration | ( | const enum system_clock_source | clock_source, |
const uint16_t | calibration_value, | ||
const uint8_t | freq_range | ||
) |
Writes the calibration values for a given oscillator clock source.
Writes an oscillator calibration value to the given oscillator control registers. The acceptable ranges are:
For OSC32K:
[in] | clock_source | Clock source to calibrate |
[in] | calibration_value | Calibration value to write |
[in] | freq_range | Frequency range (8MHz oscillator only) |
STATUS_OK | The calibration value was written successfully. |
STATUS_ERR_INVALID_ARG | The setting is not valid for selected clock source. |
References _system_osc32k_wait_for_sync(), Assert, STATUS_ERR_INVALID_ARG, STATUS_OK, SYSTEM_CLOCK_SOURCE_OSC32K, SYSTEM_CLOCK_SOURCE_OSC8M, and SYSTEM_CLOCK_SOURCE_ULP32K.
|
static |
Internal module instance to cache configuration values.