libopencm3
A free/libre/open-source firmware library for various ARM Cortex-M3 microcontrollers.
CMU peripheral API
Collaboration diagram for CMU peripheral API:

Macros

#define _CMU_REG(i)   MMIO32(CMU_BASE + ((i) >> 5))
 
#define _CMU_BIT(i)   (1 << ((i) & 0x1f))
 

Functions

void cmu_enable_lock (void)
 Enable CMU registers lock. More...
 
void cmu_disable_lock (void)
 Disable CMU registers lock. More...
 
bool cmu_get_lock_flag (void)
 Get CMU register lock flag. More...
 
void cmu_periph_clock_enable (enum cmu_periph_clken clken)
 Enable Peripheral Clock in running mode. More...
 
void cmu_periph_clock_disable (enum cmu_periph_clken clken)
 Disable Peripheral Clock in running mode. More...
 
void cmu_osc_on (enum cmu_osc osc)
 Turn on Oscillator. More...
 
void cmu_osc_off (enum cmu_osc osc)
 Turn off Oscillator. More...
 
bool cmu_osc_ready_flag (enum cmu_osc osc)
 Get Oscillator read flag. More...
 
void cmu_wait_for_osc_ready (enum cmu_osc osc)
 Wait till oscillator is not ready. More...
 
void cmu_set_hfclk_source (enum cmu_osc osc)
 Set HFCLK clock source. More...
 
enum cmu_osc cmu_get_hfclk_source (void)
 
void cmu_clock_setup_in_hfxo_out_48mhz (void)
 HFXO output 48Mhz and core running at 48Mhz. More...
 

Detailed Description

Macro Definition Documentation

◆ _CMU_BIT

#define _CMU_BIT (   i)    (1 << ((i) & 0x1f))

Definition at line 55 of file cmu_common.c.

◆ _CMU_REG

#define _CMU_REG (   i)    MMIO32(CMU_BASE + ((i) >> 5))

Definition at line 54 of file cmu_common.c.

Function Documentation

◆ cmu_clock_setup_in_hfxo_out_48mhz()

◆ cmu_disable_lock()

void cmu_disable_lock ( void  )

Disable CMU registers lock.

Definition at line 39 of file cmu_common.c.

References CMU_LOCK, and CMU_LOCK_LOCKKEY_UNLOCK.

◆ cmu_enable_lock()

void cmu_enable_lock ( void  )

Enable CMU registers lock.

Definition at line 31 of file cmu_common.c.

References CMU_LOCK, and CMU_LOCK_LOCKKEY_LOCK.

◆ cmu_get_hfclk_source()

enum cmu_osc cmu_get_hfclk_source ( void  )

Definition at line 232 of file cmu_common.c.

References CMU_STATUS, CMU_STATUS_HFRCOSEL, CMU_STATUS_HFXOSEL, CMU_STATUS_LFRCOSEL, CMU_STATUS_LFXOSEL, HFRCO, HFXO, LFRCO, and LFXO.

Referenced by cmu_clock_setup_in_hfxo_out_48mhz().

Here is the caller graph for this function:

◆ cmu_get_lock_flag()

bool cmu_get_lock_flag ( void  )

Get CMU register lock flag.

Return values
trueif flag is set
falseif flag is not set

Definition at line 49 of file cmu_common.c.

References CMU_LOCK, CMU_LOCK_LOCKKEY_LOCKED, and CMU_LOCK_LOCKKEY_MASK.

◆ cmu_osc_off()

void cmu_osc_off ( enum cmu_osc  osc)

Turn off Oscillator.

Parameters
[in]oscenum cmu_osc Oscillator name

Definition at line 120 of file cmu_common.c.

References AUXHFRCO, CMU_OSCENCMD, CMU_OSCENCMD_AUXHFRCODIS, CMU_OSCENCMD_HFRCODIS, CMU_OSCENCMD_HFXODIS, CMU_OSCENCMD_LFRCODIS, CMU_OSCENCMD_LFXODIS, HFRCO, HFXO, LFRCO, LFXO, and ULFRCO.

◆ cmu_osc_on()

void cmu_osc_on ( enum cmu_osc  osc)

Turn on Oscillator.

Parameters
[in]oscenum cmu_osc Oscillator name

Definition at line 92 of file cmu_common.c.

References AUXHFRCO, CMU_OSCENCMD, CMU_OSCENCMD_AUXHFRCOEN, CMU_OSCENCMD_HFRCOEN, CMU_OSCENCMD_HFXOEN, CMU_OSCENCMD_LFRCOEN, CMU_OSCENCMD_LFXOEN, HFRCO, HFXO, LFRCO, LFXO, and ULFRCO.

Referenced by cmu_clock_setup_in_hfxo_out_48mhz().

Here is the caller graph for this function:

◆ cmu_osc_ready_flag()

bool cmu_osc_ready_flag ( enum cmu_osc  osc)

Get Oscillator read flag.

Parameters
[in]oscenum cmu_osc Oscillator name
Return values
trueif flag is set
falseif flag is not set

Definition at line 150 of file cmu_common.c.

References AUXHFRCO, CMU_STATUS, CMU_STATUS_AUXHFRCORDY, CMU_STATUS_HFRCORDY, CMU_STATUS_HFXORDY, CMU_STATUS_LFRCORDY, CMU_STATUS_LFXORDY, HFRCO, HFXO, LFRCO, LFXO, and ULFRCO.

◆ cmu_periph_clock_disable()

void cmu_periph_clock_disable ( enum cmu_periph_clken  clken)

Disable Peripheral Clock in running mode.

Disable the clock on particular peripheral.

Parameters
[in]clkenPeripheral Name

For available constants, see enum::cmu_periph_clken (CMU_LEUART1 for example)

Definition at line 83 of file cmu_common.c.

References _CMU_REG.

◆ cmu_periph_clock_enable()

void cmu_periph_clock_enable ( enum cmu_periph_clken  clken)

Enable Peripheral Clock in running mode.

Enable the clock on particular peripheral.

Parameters
[in]clkenPeripheral Name

For available constants, see enum::cmu_periph_clken (CMU_LEUART1 for example)

Definition at line 68 of file cmu_common.c.

References _CMU_BIT, and _CMU_REG.

◆ cmu_set_hfclk_source()

void cmu_set_hfclk_source ( enum cmu_osc  osc)

Set HFCLK clock source.

Parameters
[in]oscenum cmu_osc Oscillator name
Note
calling cmu_set_hfclk_source() do not set source immediately, use cmu_get_hfclk_source() to verify that the source has been set.
See also
cmu_get_hfclk_source()

Definition at line 211 of file cmu_common.c.

References CMU_CMD, CMU_CMD_HFCLKSEL_HFRCO, CMU_CMD_HFCLKSEL_HFXO, CMU_CMD_HFCLKSEL_LFRCO, CMU_CMD_HFCLKSEL_LFXO, HFRCO, HFXO, LFRCO, and LFXO.

Referenced by cmu_clock_setup_in_hfxo_out_48mhz().

Here is the caller graph for this function:

◆ cmu_wait_for_osc_ready()

void cmu_wait_for_osc_ready ( enum cmu_osc  osc)

Wait till oscillator is not ready.

Parameters
[in]oscenum cmu_osc Oscillator name

Definition at line 180 of file cmu_common.c.

References AUXHFRCO, CMU_STATUS, CMU_STATUS_AUXHFRCORDY, CMU_STATUS_HFRCORDY, CMU_STATUS_HFXORDY, CMU_STATUS_LFRCORDY, CMU_STATUS_LFXORDY, HFRCO, HFXO, LFRCO, LFXO, and ULFRCO.

Referenced by cmu_clock_setup_in_hfxo_out_48mhz().

Here is the caller graph for this function: