Clock management unit (CMU) Peripheral API. More...
![]() |
Defines | |
#define | cmuClkDiv_1 1 |
#define | cmuClkDiv_2 2 |
#define | cmuClkDiv_4 4 |
#define | cmuClkDiv_8 8 |
#define | cmuClkDiv_16 16 |
#define | cmuClkDiv_32 32 |
#define | cmuClkDiv_64 64 |
#define | cmuClkDiv_128 128 |
#define | cmuClkDiv_256 256 |
#define | cmuClkDiv_512 512 |
#define | cmuClkDiv_1024 1024 |
#define | cmuClkDiv_2048 2048 |
#define | cmuClkDiv_4096 4096 |
#define | cmuClkDiv_8192 8192 |
#define | cmuClkDiv_16384 16384 |
#define | cmuClkDiv_32768 32768 |
Typedefs | |
typedef uint32_t | CMU_ClkDiv_TypeDef |
Enumerations | |
enum | CMU_HFRCOBand_TypeDef { cmuHFRCOBand_1MHz = _CMU_HFRCOCTRL_BAND_1MHZ, cmuHFRCOBand_7MHz = _CMU_HFRCOCTRL_BAND_7MHZ, cmuHFRCOBand_11MHz = _CMU_HFRCOCTRL_BAND_11MHZ, cmuHFRCOBand_14MHz = _CMU_HFRCOCTRL_BAND_14MHZ, cmuHFRCOBand_21MHz = _CMU_HFRCOCTRL_BAND_21MHZ } |
enum | CMU_Clock_TypeDef { cmuClock_HF, cmuClock_DBG, cmuClock_AUX, cmuClock_HFPER, cmuClock_USART0, cmuClock_USART1, cmuClock_USART2, cmuClock_UART0, cmuClock_UART1, cmuClock_TIMER0, cmuClock_TIMER1, cmuClock_TIMER2, cmuClock_TIMER3, cmuClock_ACMP0, cmuClock_ACMP1, cmuClock_PRS, cmuClock_DAC0, cmuClock_GPIO, cmuClock_VCMP, cmuClock_ADC0, cmuClock_I2C0, cmuClock_I2C1, cmuClock_CORE, cmuClock_AES, cmuClock_DMA, cmuClock_CORELE, cmuClock_EBI, cmuClock_USBC, cmuClock_USB, cmuClock_LFA, cmuClock_RTC, cmuClock_LETIMER0, cmuClock_LCDpre, cmuClock_LCD, cmuClock_PCNT0, cmuClock_PCNT1, cmuClock_PCNT2, cmuClock_LESENSE, cmuClock_LFB, cmuClock_LEUART0, cmuClock_LEUART1 } |
enum | CMU_Osc_TypeDef { cmuOsc_LFXO, cmuOsc_LFRCO, cmuOsc_HFXO, cmuOsc_HFRCO, cmuOsc_AUXHFRCO } |
enum | CMU_Select_TypeDef { cmuSelect_Error, cmuSelect_Disabled, cmuSelect_LFXO, cmuSelect_LFRCO, cmuSelect_HFXO, cmuSelect_HFRCO, cmuSelect_CORELEDIV2, cmuSelect_AUXHFRCO, cmuSelect_HFCLK } |
Functions | |
void | CMU_ClockEnable (CMU_Clock_TypeDef clock, bool enable) |
Enable/disable a clock. | |
uint32_t | CMU_ClockFreqGet (CMU_Clock_TypeDef clock) |
Get clock frequency for a clock point. | |
CMU_ClkDiv_TypeDef | CMU_ClockDivGet (CMU_Clock_TypeDef clock) |
Get clock divisor/prescaler. | |
CMU_Select_TypeDef | CMU_ClockSelectGet (CMU_Clock_TypeDef clock) |
Get currently selected reference clock used for a clock branch. | |
void | CMU_ClockDivSet (CMU_Clock_TypeDef clock, CMU_ClkDiv_TypeDef div) |
Set clock divisor/prescaler. | |
void | CMU_ClockSelectSet (CMU_Clock_TypeDef clock, CMU_Select_TypeDef ref) |
Select reference clock/oscillator used for a clock branch. | |
CMU_HFRCOBand_TypeDef | CMU_HFRCOBandGet (void) |
Get HFRCO band in use. | |
void | CMU_HFRCOBandSet (CMU_HFRCOBand_TypeDef band) |
Set HFRCO band and the tuning value based on the value in the calibration table made during production. | |
void | CMU_HFRCOStartupDelaySet (uint32_t delay) |
Set the HFRCO startup delay. | |
uint32_t | CMU_HFRCOStartupDelayGet (void) |
Get the HFRCO startup delay. | |
void | CMU_OscillatorEnable (CMU_Osc_TypeDef osc, bool enable, bool wait) |
Enable/disable oscillator. | |
uint32_t | CMU_OscillatorTuningGet (CMU_Osc_TypeDef osc) |
Get oscillator frequency tuning setting. | |
void | CMU_OscillatorTuningSet (CMU_Osc_TypeDef osc, uint32_t val) |
Set the oscillator frequency tuning control. | |
bool | CMU_PCNTClockExternalGet (unsigned int inst) |
Determine if currently selected PCNTn clock used is external or LFBCLK. | |
void | CMU_PCNTClockExternalSet (unsigned int inst, bool external) |
Select PCNTn clock. | |
uint32_t | CMU_LCDClkFDIVGet (void) |
Get the LCD framerate divisor (FDIV) setting. | |
void | CMU_LCDClkFDIVSet (uint32_t div) |
Set the LCD framerate divisor (FDIV) setting. | |
void | CMU_FreezeEnable (bool enable) |
CMU low frequency register synchronization freeze control. | |
uint32_t | CMU_Calibrate (uint32_t HFCycles, CMU_Osc_TypeDef ref) |
Calibrate clock. | |
__STATIC_INLINE void | CMU_IntClear (uint32_t flags) |
Clear one or more pending CMU interrupts. | |
__STATIC_INLINE void | CMU_IntDisable (uint32_t flags) |
Disable one or more CMU interrupts. | |
__STATIC_INLINE void | CMU_IntEnable (uint32_t flags) |
Enable one or more CMU interrupts. | |
__STATIC_INLINE uint32_t | CMU_IntGet (void) |
Get pending CMU interrupts. | |
__STATIC_INLINE uint32_t | CMU_IntGetEnabled (void) |
Get enabled and pending CMU interrupt flags. | |
__STATIC_INLINE void | CMU_IntSet (uint32_t flags) |
Set one or more pending CMU interrupts from SW. | |
__STATIC_INLINE void | CMU_Lock (void) |
Lock the CMU in order to protect some of its registers against unintended modification. | |
__STATIC_INLINE void | CMU_Unlock (void) |
Unlock the CMU so that writing to locked registers again is possible. | |
__STATIC_INLINE uint32_t | CMU_CalibrateCountGet (void) |
Get calibration count register. | |
__STATIC_INLINE void | CMU_CalibrateStart (void) |
Starts calibration. |
Clock management unit (CMU) Peripheral API.
#define cmuClkDiv_1 1 |
Clock divisors. These values are valid for prescalers. Divide clock by 1.
Definition at line 135 of file em_cmu.h.
Referenced by CMU_ClockDivGet(), and CMU_ClockDivSet().
#define cmuClkDiv_128 128 |
Divide clock by 128.
Definition at line 142 of file em_cmu.h.
Referenced by CMU_ClockDivSet(), and CMU_LCDClkFDIVSet().
#define cmuClkDiv_16 16 |
Divide clock by 16.
Definition at line 139 of file em_cmu.h.
Referenced by CMU_ClockDivGet(), CMU_ClockDivSet(), and CMU_ClockFreqGet().
#define cmuClkDiv_32768 32768 |
#define cmuClkDiv_512 512 |
#define cmuClkDiv_8 8 |
typedef uint32_t CMU_ClkDiv_TypeDef |
enum CMU_Clock_TypeDef |
Clock points in CMU. Please refer to CMU overview in reference manual.
enum CMU_Osc_TypeDef |
enum CMU_Select_TypeDef |
Selectable clock sources.
uint32_t CMU_Calibrate | ( | uint32_t | HFCycles, | |
CMU_Osc_TypeDef | ref | |||
) |
Calibrate clock.
Run a calibration for HFCLK against a selectable reference clock. Please refer to the EFM32 reference manual, CMU chapter, for further details.
[in] | HFCycles | The number of HFCLK cycles to run calibration. Increasing this number increases precision, but the calibration will take more time. |
[in] | ref | The reference clock used to compare HFCLK with. |
Definition at line 533 of file em_cmu.c.
References cmuOsc_AUXHFRCO, cmuOsc_HFRCO, cmuOsc_HFXO, cmuOsc_LFRCO, and cmuOsc_LFXO.
__STATIC_INLINE uint32_t CMU_CalibrateCountGet | ( | void | ) |
Get calibration count register.
__STATIC_INLINE void CMU_CalibrateStart | ( | void | ) |
CMU_ClkDiv_TypeDef CMU_ClockDivGet | ( | CMU_Clock_TypeDef | clock | ) |
Get clock divisor/prescaler.
[in] | clock | Clock point to get divisor/prescaler for. Notice that not all clock points have a divisor/prescaler. Please refer to CMU overview in reference manual. |
clock
specifies a clock point without a divisor/prescaler. Definition at line 691 of file em_cmu.c.
References cmuClkDiv_1, cmuClkDiv_16, cmuClock_LCDpre, cmuClock_LESENSE, cmuClock_LETIMER0, cmuClock_LEUART0, cmuClock_LEUART1, and cmuClock_RTC.
void CMU_ClockDivSet | ( | CMU_Clock_TypeDef | clock, | |
CMU_ClkDiv_TypeDef | div | |||
) |
Set clock divisor/prescaler.
[in] | clock | Clock point to set divisor/prescaler for. Notice that not all clock points have a divisor/prescaler, please refer to CMU overview in the reference manual. |
[in] | div | The clock divisor to use (<= cmuClkDiv_512). |
Definition at line 817 of file em_cmu.c.
References BITBAND_Peripheral(), CMU_ClockFreqGet(), cmuClkDiv_1, cmuClkDiv_128, cmuClkDiv_16, cmuClkDiv_32768, cmuClkDiv_512, cmuClkDiv_8, cmuClock_HF, cmuClock_LCDpre, cmuClock_LESENSE, cmuClock_LETIMER0, cmuClock_LEUART0, cmuClock_LEUART1, and cmuClock_RTC.
void CMU_ClockEnable | ( | CMU_Clock_TypeDef | clock, | |
bool | enable | |||
) |
Enable/disable a clock.
In general, module clocking is disabled after a reset. If a module clock is disabled, the registers of that module are not accessible and reading from such registers may return undefined values. Writing to registers of clock disabled modules have no effect. One should normally avoid accessing module registers of a module with a disabled clock.
[in] | clock | The clock to enable/disable. Notice that not all defined clock points have separate enable/disable control, please refer to CMU overview in reference manual. |
[in] | enable |
|
Definition at line 1038 of file em_cmu.c.
References BITBAND_Peripheral(), CMU_ClockFreqGet(), and cmuClock_CORE.
Referenced by DMA_Init().
uint32_t CMU_ClockFreqGet | ( | CMU_Clock_TypeDef | clock | ) |
Get clock frequency for a clock point.
[in] | clock | Clock point to fetch frequency for. |
Definition at line 1123 of file em_cmu.c.
References cmuClkDiv_16.
Referenced by ADC_PrescaleCalc(), ADC_TimebaseCalc(), CMU_ClockDivSet(), CMU_ClockEnable(), DAC_PrescaleCalc(), I2C_BusFreqGet(), I2C_BusFreqSet(), LESENSE_ScanFreqSet(), LEUART_BaudrateGet(), LEUART_BaudrateSet(), MSC_Init(), USART_BaudrateAsyncSet(), USART_BaudrateGet(), and USART_BaudrateSyncSet().
CMU_Select_TypeDef CMU_ClockSelectGet | ( | CMU_Clock_TypeDef | clock | ) |
Get currently selected reference clock used for a clock branch.
[in] | clock | Clock branch to fetch selected ref. clock for. One of: |
clock
provided. Definition at line 1290 of file em_cmu.c.
References cmuSelect_AUXHFRCO, cmuSelect_CORELEDIV2, cmuSelect_Disabled, cmuSelect_Error, cmuSelect_HFCLK, cmuSelect_HFRCO, cmuSelect_HFXO, cmuSelect_LFRCO, and cmuSelect_LFXO.
Referenced by CMU_HFRCOBandSet().
void CMU_ClockSelectSet | ( | CMU_Clock_TypeDef | clock, | |
CMU_Select_TypeDef | ref | |||
) |
Select reference clock/oscillator used for a clock branch.
Notice that if a selected reference is not enabled prior to selecting its use, it will be enabled, and this function will wait for the selected oscillator to be stable. It will however NOT be disabled if another reference clock is selected later.
This feature is particularly important if selecting a new reference clock for the clock branch clocking the core, otherwise the system may halt.
[in] | clock | Clock branch to select reference clock for. One of: |
[in] | ref | Reference selected for clocking, please refer to reference manual for for details on which reference is available for a specific clock branch. |
Definition at line 1534 of file em_cmu.c.
References BITBAND_Peripheral(), CMU_OscillatorEnable(), cmuOsc_HFRCO, cmuOsc_HFXO, cmuOsc_LFRCO, cmuOsc_LFXO, cmuSelect_AUXHFRCO, cmuSelect_CORELEDIV2, cmuSelect_Disabled, cmuSelect_HFCLK, cmuSelect_HFRCO, cmuSelect_HFXO, cmuSelect_LFRCO, cmuSelect_LFXO, and EMU_UpdateOscConfig().
void CMU_FreezeEnable | ( | bool | enable | ) |
CMU low frequency register synchronization freeze control.
Some CMU registers requires synchronization into the low frequency (LF) domain. The freeze feature allows for several such registers to be modified before passing them to the LF domain simultaneously (which takes place when the freeze mode is disabled).
Another usage scenario of this feature, is when using an API (such as the CMU API) for modifying several bit fields consecutively in the same register. If freeze mode is enabled during this sequence, stalling can be avoided.
[in] | enable |
|
CMU_HFRCOBand_TypeDef CMU_HFRCOBandGet | ( | void | ) |
void CMU_HFRCOBandSet | ( | CMU_HFRCOBand_TypeDef | band | ) |
Set HFRCO band and the tuning value based on the value in the calibration table made during production.
[in] | band | HFRCO band to activate. |
Definition at line 2054 of file em_cmu.c.
References CMU_ClockSelectGet(), cmuClock_HF, cmuHFRCOBand_11MHz, cmuHFRCOBand_14MHz, cmuHFRCOBand_1MHz, cmuHFRCOBand_21MHz, cmuHFRCOBand_7MHz, and cmuSelect_HFRCO.
uint32_t CMU_HFRCOStartupDelayGet | ( | void | ) |
void CMU_HFRCOStartupDelaySet | ( | uint32_t | delay | ) |
__STATIC_INLINE void CMU_IntClear | ( | uint32_t | flags | ) |
__STATIC_INLINE void CMU_IntDisable | ( | uint32_t | flags | ) |
__STATIC_INLINE void CMU_IntEnable | ( | uint32_t | flags | ) |
Enable one or more CMU interrupts.
[in] | flags | CMU interrupt sources to enable. |
__STATIC_INLINE uint32_t CMU_IntGet | ( | void | ) |
__STATIC_INLINE uint32_t CMU_IntGetEnabled | ( | void | ) |
Get enabled and pending CMU interrupt flags.
Useful for handling more interrupt sources in the same interrupt handler.
__STATIC_INLINE void CMU_IntSet | ( | uint32_t | flags | ) |
uint32_t CMU_LCDClkFDIVGet | ( | void | ) |
void CMU_LCDClkFDIVSet | ( | uint32_t | div | ) |
Set the LCD framerate divisor (FDIV) setting.
[in] | div | The FDIV setting to use. |
Definition at line 2196 of file em_cmu.c.
References cmuClkDiv_128.
__STATIC_INLINE void CMU_Lock | ( | void | ) |
Lock the CMU in order to protect some of its registers against unintended modification.
Please refer to the reference manual for CMU registers that will be locked.
Definition at line 834 of file em_cmu.h.
Referenced by EMU_EnterEM3().
void CMU_OscillatorEnable | ( | CMU_Osc_TypeDef | osc, | |
bool | enable, | |||
bool | wait | |||
) |
Enable/disable oscillator.
[in] | osc | The oscillator to enable/disable. |
[in] | enable |
|
[in] | wait | Only used if enable is true.
|
Definition at line 2240 of file em_cmu.c.
References cmuOsc_AUXHFRCO, cmuOsc_HFRCO, cmuOsc_HFXO, cmuOsc_LFRCO, cmuOsc_LFXO, and EMU_UpdateOscConfig().
Referenced by CMU_ClockSelectSet().
uint32_t CMU_OscillatorTuningGet | ( | CMU_Osc_TypeDef | osc | ) |
Get oscillator frequency tuning setting.
[in] | osc | Oscillator to get tuning value for, one of: |
Definition at line 2332 of file em_cmu.c.
References cmuOsc_AUXHFRCO, cmuOsc_HFRCO, and cmuOsc_LFRCO.
void CMU_OscillatorTuningSet | ( | CMU_Osc_TypeDef | osc, | |
uint32_t | val | |||
) |
Set the oscillator frequency tuning control.
[in] | osc | Oscillator to set tuning value for, one of: |
[in] | val | The oscillator frequency tuning setting to use. |
Definition at line 2381 of file em_cmu.c.
References cmuOsc_AUXHFRCO, cmuOsc_HFRCO, and cmuOsc_LFRCO.
bool CMU_PCNTClockExternalGet | ( | unsigned int | inst | ) |
void CMU_PCNTClockExternalSet | ( | unsigned int | inst, | |
bool | external | |||
) |
Select PCNTn clock.
[in] | inst | PCNT instance number to set selected clock source for. |
[in] | external | Set to true to select external clock, false to select LFBCLK. |
Definition at line 2479 of file em_cmu.c.
References BITBAND_Peripheral().
Referenced by PCNT_Init(), and PCNT_Reset().
__STATIC_INLINE void CMU_Unlock | ( | void | ) |
Unlock the CMU so that writing to locked registers again is possible.
Definition at line 844 of file em_cmu.h.
Referenced by EMU_EnterEM3().