The clock to the MCU is sourced from either an on-chip RC oscillator or an external crystal oscillator. This module contains functions for selecting clock source and clock frequency.
Enumerations | |
enum | hal_clk_input_t { HAL_CLK_XOSC16_OR_RCOSC16 = 0, HAL_CLK_PAD_XC1 = 1 } |
enum | hal_clk_source_t { HAL_CLK_XOSC16M_AND_RCOSC16M = 0, HAL_CLK_RCOSC16M = 1, HAL_CLK_XOSC16M = 2 } |
enum | hal_clk_freq_t { HAL_CLK_16MHZ = 0, HAL_CLK_8MHZ = 1, HAL_CLK_4MHZ = 2, HAL_CLK_2MHZ = 3, HAL_CLK_1MHZ = 4, HAL_CLK_500KHZ = 5, HAL_CLK_250KHZ = 6, HAL_CLK_125KHZ = 7 } |
enum | hal_clklf_source_t { HAL_CLKLF_XOSC32K = 0, HAL_CLKLF_RCOSC32K = 1, HAL_CLKLF_XOSC16M_SYNTH = 2, HAL_CLKLF_PAD_XC1 = 3, HAL_CLKLF_DIG_IO_RAIL = 4, HAL_CLKLF_NONE = 7 } |
Functions | |
void | hal_clk_regret_xosc16m_on (_Bool on) |
void | hal_clk_set_input (hal_clk_input_t input) |
void | hal_clk_set_16m_source (hal_clk_source_t source) |
hal_clk_source_t | hal_clk_get_16m_source (void) |
void | hal_clk_set_freq (hal_clk_freq_t freq) |
_Bool | hal_clklf_phase (void) |
_Bool | hal_clklf_ready (void) |
void | hal_clklf_set_source (hal_clklf_source_t source) |
enum hal_clk_input_t |
An enum describing the possible system clock inputs.
Definition at line 34 of file hal_clk.h.
{ HAL_CLK_XOSC16_OR_RCOSC16 = 0, HAL_CLK_PAD_XC1 = 1 } hal_clk_input_t;
enum hal_clk_source_t |
An enum used for selecting which 16MHz clocks to run.
Definition at line 43 of file hal_clk.h.
{ HAL_CLK_XOSC16M_AND_RCOSC16M = 0, HAL_CLK_RCOSC16M = 1, HAL_CLK_XOSC16M = 2 } hal_clk_source_t;
enum hal_clk_freq_t |
An enum describing the possible internal (system) clock frequencies.
HAL_CLK_16MHZ | |
HAL_CLK_8MHZ | |
HAL_CLK_4MHZ | |
HAL_CLK_2MHZ | |
HAL_CLK_1MHZ | |
HAL_CLK_500KHZ | |
HAL_CLK_250KHZ | |
HAL_CLK_125KHZ |
Definition at line 53 of file hal_clk.h.
{ HAL_CLK_16MHZ = 0, HAL_CLK_8MHZ = 1, HAL_CLK_4MHZ = 2, HAL_CLK_2MHZ = 3, HAL_CLK_1MHZ = 4, HAL_CLK_500KHZ = 5, HAL_CLK_250KHZ = 6, HAL_CLK_125KHZ = 7 } hal_clk_freq_t;
enum hal_clklf_source_t |
An enum describing the possible 32khz clock (clklf) sources.
HAL_CLKLF_XOSC32K | |
HAL_CLKLF_RCOSC32K | |
HAL_CLKLF_XOSC16M_SYNTH | |
HAL_CLKLF_PAD_XC1 | |
HAL_CLKLF_DIG_IO_RAIL | |
HAL_CLKLF_NONE |
Definition at line 68 of file hal_clk.h.
{ HAL_CLKLF_XOSC32K = 0, HAL_CLKLF_RCOSC32K = 1, HAL_CLKLF_XOSC16M_SYNTH = 2, HAL_CLKLF_PAD_XC1 = 3, HAL_CLKLF_DIG_IO_RAIL = 4, HAL_CLKLF_NONE = 7 } hal_clklf_source_t;
void hal_clk_regret_xosc16m_on | ( | _Bool | on ) |
Function selecting whether XOSC16 should run during register retention power down mode.
on | Boolean value. True = on, false = off. |
void hal_clk_set_input | ( | hal_clk_input_t | input ) |
void hal_clk_set_16m_source | ( | hal_clk_source_t | source ) |
Function selecting the 16Mhz clock to be used. For this function to have any effect the main source for the 16MHz clock must be either XOSC16 or RCOSC16. See hal_clk_set_input().
source | selects the 16M clock to be used.
|
hal_clk_source_t hal_clk_get_16m_source | ( | void | ) |
Function returning the source for the 16MHz clock. For this function to have any effect the main source for the 16MHz clock must be either XOSC16 or RCOSC16. See hal_clk_set_input().
Definition at line 44 of file hal_clk.c.
{ hal_clk_source_t clock_source; if(CLKLFCTRL & (uint8_t)0x08U) { clock_source = HAL_CLK_XOSC16M; } else { clock_source = HAL_CLK_RCOSC16M; } return clock_source; }
void hal_clk_set_freq | ( | hal_clk_freq_t | freq ) |
Function for setting the internal system clock frequency. The system clock source is always 16MHz. This function configures the system clock prescaler.
freq | selects the internal clock to be used.
|
_Bool hal_clklf_phase | ( | void | ) |
_Bool hal_clklf_ready | ( | void | ) |
void hal_clklf_set_source | ( | hal_clklf_source_t | source ) |
Function for setting the source for the 32KHz clock (clklf / RTC).
source | selects the 32KHz clock source.
|