CMUEMLIB
Detailed Description
Clock management unit (CMU) Peripheral API.
This module contains functions to control the CMU peripheral of Silicon Labs 32-bit MCUs and SoCs. The CMU controls oscillators and clocks.
Data Structures |
|
struct | CMU_HFXOInit_TypeDef |
struct | CMU_LFXOInit_TypeDef |
Macros |
|
#define | CMU_HFXOINIT_DEFAULT |
#define | CMU_HFXOINIT_EXTERNAL_CLOCK |
#define | CMU_LFXOINIT_DEFAULT |
#define | CMU_LFXOINIT_EXTERNAL_CLOCK |
#define | cmuClkDiv_1 1 |
#define | cmuClkDiv_1024 1024 |
#define | cmuClkDiv_128 128 |
#define | cmuClkDiv_16 16 |
#define | cmuClkDiv_16384 16384 |
#define | cmuClkDiv_2 2 |
#define | cmuClkDiv_2048 2048 |
#define | cmuClkDiv_256 256 |
#define | cmuClkDiv_32 32 |
#define | cmuClkDiv_32768 32768 |
#define | cmuClkDiv_4 4 |
#define | cmuClkDiv_4096 4096 |
#define | cmuClkDiv_512 512 |
#define | cmuClkDiv_64 64 |
#define | cmuClkDiv_8 8 |
#define | cmuClkDiv_8192 8192 |
Typedefs |
|
typedef uint32_t | CMU_ClkDiv_TypeDef |
Functions |
|
uint32_t | CMU_Calibrate (uint32_t HFCycles, CMU_Osc_TypeDef reference) |
Calibrate clock.
|
|
uint32_t | CMU_CalibrateCountGet (void) |
Get calibration count register.
|
|
__STATIC_INLINE void | CMU_CalibrateStart (void) |
Starts calibration.
|
|
CMU_ClkDiv_TypeDef | CMU_ClockDivGet ( CMU_Clock_TypeDef clock) |
Get clock divisor/prescaler.
|
|
void | CMU_ClockDivSet ( CMU_Clock_TypeDef clock, CMU_ClkDiv_TypeDef div) |
Set clock divisor/prescaler.
|
|
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_Select_TypeDef | CMU_ClockSelectGet ( CMU_Clock_TypeDef clock) |
Get currently selected reference clock used for a clock branch.
|
|
void | CMU_ClockSelectSet ( CMU_Clock_TypeDef clock, CMU_Select_TypeDef ref) |
Select reference clock/oscillator used for a clock branch.
|
|
__STATIC_INLINE uint32_t | CMU_DivToLog2 ( CMU_ClkDiv_TypeDef div) |
Convert dividend to logarithmic value. Only works for even numbers equal to 2^n.
|
|
void | CMU_FreezeEnable (bool enable) |
CMU low frequency register synchronization freeze control.
|
|
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.
|
|
uint32_t | CMU_HFRCOStartupDelayGet (void) |
Get the HFRCO startup delay.
|
|
void | CMU_HFRCOStartupDelaySet (uint32_t delay) |
Set the HFRCO startup delay.
|
|
void | CMU_HFXOInit (const CMU_HFXOInit_TypeDef *hfxoInit) |
Set HFXO control registers.
|
|
__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.
|
|
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_LFXOInit (const CMU_LFXOInit_TypeDef *lfxoInit) |
Set LFXO control registers.
|
|
__STATIC_INLINE void | CMU_Lock (void) |
Lock the CMU in order to protect some of its registers against unintended modification.
|
|
__STATIC_INLINE uint32_t | CMU_Log2ToDiv (uint32_t log2) |
Convert logarithm of 2 prescaler to division factor.
|
|
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 instance) |
Determine if currently selected PCNTn clock used is external or LFBCLK.
|
|
void | CMU_PCNTClockExternalSet (unsigned int instance, bool external) |
Select PCNTn clock.
|
|
__STATIC_INLINE void | CMU_Unlock (void) |
Unlock the CMU so that writing to locked registers again is possible.
|
|
void | CMU_UpdateWaitStates (uint32_t freq, int vscale) |
Macro Definition Documentation
#define CMU_HFXOINIT_DEFAULT |
Default HFXO initialization values for Platform 1 devices.
Definition at line
1516
of file
em_cmu.h
.
#define CMU_HFXOINIT_EXTERNAL_CLOCK |
Definition at line
1523
of file
em_cmu.h
.
#define CMU_LFXOINIT_DEFAULT |
Default LFXO initialization values for platform 1 devices.
Definition at line
1379
of file
em_cmu.h
.
#define CMU_LFXOINIT_EXTERNAL_CLOCK |
Definition at line
1385
of file
em_cmu.h
.
#define cmuClkDiv_1Â Â Â 1 |
Clock divisors. These values are valid for prescalers. Divide clock by 1.
Definition at line
177
of file
em_cmu.h
.
Referenced by CAPLESENSE_setupCMU() , CMU_ClockDivGet() , CMU_ClockDivSet() , and RETARGET_SerialInit() .
#define cmuClkDiv_1024Â Â Â 1024 |
Divide clock by 1024.
Definition at line
187
of file
em_cmu.h
.
#define cmuClkDiv_128Â Â Â 128 |
Divide clock by 128.
Definition at line
184
of file
em_cmu.h
.
Referenced by CMU_ClockDivSet() , and CMU_LCDClkFDIVSet() .
#define cmuClkDiv_16Â Â Â 16 |
Divide clock by 16.
Definition at line
181
of file
em_cmu.h
.
Referenced by CMU_ClockDivGet() , CMU_ClockDivSet() , and CMU_ClockFreqGet() .
#define cmuClkDiv_16384Â Â Â 16384 |
Divide clock by 16384.
Definition at line
191
of file
em_cmu.h
.
#define cmuClkDiv_2Â Â Â 2 |
Divide clock by 2.
Definition at line
178
of file
em_cmu.h
.
#define cmuClkDiv_2048Â Â Â 2048 |
Divide clock by 2048.
Definition at line
188
of file
em_cmu.h
.
#define cmuClkDiv_256Â Â Â 256 |
#define cmuClkDiv_32Â Â Â 32 |
Divide clock by 32.
Definition at line
182
of file
em_cmu.h
.
#define cmuClkDiv_32768Â Â Â 32768 |
#define cmuClkDiv_4Â Â Â 4 |
Divide clock by 4.
Definition at line
179
of file
em_cmu.h
.
#define cmuClkDiv_4096Â Â Â 4096 |
Divide clock by 4096.
Definition at line
189
of file
em_cmu.h
.
#define cmuClkDiv_512Â Â Â 512 |
#define cmuClkDiv_64Â Â Â 64 |
Divide clock by 64.
Definition at line
183
of file
em_cmu.h
.
#define cmuClkDiv_8Â Â Â 8 |
#define cmuClkDiv_8192Â Â Â 8192 |
Divide clock by 8192.
Definition at line
190
of file
em_cmu.h
.
Typedef Documentation
typedef uint32_t CMU_ClkDiv_TypeDef |
Clock divider configuration
Definition at line
195
of file
em_cmu.h
.
Enumeration Type Documentation
enum CMU_Clock_TypeDef |
Clock points in CMU. Please refer to CMU overview in reference manual.
Definition at line
326
of file
em_cmu.h
.
LFXO Boost values.
Definition at line
1312
of file
em_cmu.h
.
enum CMU_Osc_TypeDef |
Oscillator types.
Definition at line
1236
of file
em_cmu.h
.
enum CMU_OscMode_TypeDef |
enum CMU_Select_TypeDef |
Selectable clock sources.
Definition at line
1261
of file
em_cmu.h
.
Function Documentation
uint32_t CMU_Calibrate | ( | uint32_t |
HFCycles,
|
CMU_Osc_TypeDef |
reference
|
||
) |
Calibrate clock.
Run a calibration for HFCLK against a selectable reference clock. Please refer to the reference manual, CMU chapter, for further details.
- Note
- This function will not return until calibration measurement is completed.
- Parameters
-
[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.
- Returns
- The number of ticks the reference clock after HFCycles ticks on the HF clock.
Definition at line
1451
of file
em_cmu.c
.
References _CMU_CALCNT_CALCNT_MASK , _CMU_CALCNT_CALCNT_SHIFT , _CMU_STATUS_CALBSY_SHIFT , BUS_RegBitRead() , CMU , CMU_CALCTRL_UPSEL_AUXHFRCO , CMU_CALCTRL_UPSEL_HFRCO , CMU_CALCTRL_UPSEL_HFXO , CMU_CALCTRL_UPSEL_LFRCO , CMU_CALCTRL_UPSEL_LFXO , CMU_CMD_CALSTART , cmuOsc_AUXHFRCO , cmuOsc_HFRCO , cmuOsc_HFXO , cmuOsc_LFRCO , and cmuOsc_LFXO .
uint32_t CMU_CalibrateCountGet | ( | void |
|
) |
Get calibration count register.
- Note
- If continuous calibrartion mode is active, calibration busy will almost always be off, and we just need to read the value, where the normal case would be that this function call has been triggered by the CALRDY interrupt flag.
- Returns
- Calibration count, the number of UPSEL clocks (see CMU_CalibrateConfig()) in the period of DOWNSEL oscillator clock cycles configured by a previous write operation to CMU->CALCNT
Definition at line
1630
of file
em_cmu.c
.
References _CMU_STATUS_CALBSY_SHIFT , BUS_RegBitRead() , and CMU .
__STATIC_INLINE void CMU_CalibrateStart | ( | void |
|
) |
Starts calibration.
- Note
- This call is usually invoked after CMU_CalibrateConfig() and possibly CMU_CalibrateCont()
Definition at line
1675
of file
em_cmu.h
.
References CMU , and CMU_CMD_CALSTART .
CMU_ClkDiv_TypeDef CMU_ClockDivGet | ( | CMU_Clock_TypeDef |
clock
|
) |
Get clock divisor/prescaler.
- Parameters
-
[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.
- Returns
-
The current clock point divisor/prescaler. 1 is returned if
clock
specifies a clock point without a divisor/prescaler.
Definition at line
1665
of file
em_cmu.c
.
References _CMU_HFCORECLKDIV_HFCORECLKDIV_MASK , _CMU_HFCORECLKDIV_HFCORECLKDIV_SHIFT , _CMU_HFPERCLKDIV_HFPERCLKDIV_MASK , _CMU_HFPERCLKDIV_HFPERCLKDIV_SHIFT , _CMU_LFAPRESC0_LCD_MASK , _CMU_LFAPRESC0_LCD_SHIFT , _CMU_LFAPRESC0_LETIMER0_MASK , _CMU_LFAPRESC0_LETIMER0_SHIFT , _CMU_LFAPRESC0_RTC_MASK , _CMU_LFAPRESC0_RTC_SHIFT , _CMU_LFBPRESC0_LEUART0_MASK , _CMU_LFBPRESC0_LEUART0_SHIFT , _CMU_LFBPRESC0_LEUART1_MASK , _CMU_LFBPRESC0_LEUART1_SHIFT , CMU , CMU_DivToLog2() , CMU_Log2ToDiv() , cmuClkDiv_1 , cmuClkDiv_16 , cmuClock_LCDpre , cmuClock_LETIMER0 , cmuClock_LEUART0 , cmuClock_LEUART1 , and cmuClock_RTC .
Referenced by UDELAY_Calibrate() .
void CMU_ClockDivSet | ( | CMU_Clock_TypeDef |
clock,
|
CMU_ClkDiv_TypeDef |
div
|
||
) |
Set clock divisor/prescaler.
- Note
- If setting a LF clock prescaler, synchronization into the low frequency domain is required. If the same register is modified before a previous update has completed, this function will stall until the previous synchronization has completed. Please refer to CMU_FreezeEnable() for a suggestion on how to reduce stalling time in some use cases.
- Parameters
-
[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
1793
of file
em_cmu.c
.
References _CMU_HFCORECLKDIV_HFCORECLKDIV_MASK , _CMU_HFCORECLKDIV_HFCORECLKDIV_SHIFT , _CMU_HFPERCLKDIV_HFPERCLKDIV_MASK , _CMU_HFPERCLKDIV_HFPERCLKDIV_SHIFT , _CMU_LFAPRESC0_LCD_MASK , _CMU_LFAPRESC0_LCD_SHIFT , _CMU_LFAPRESC0_LETIMER0_MASK , _CMU_LFAPRESC0_LETIMER0_SHIFT , _CMU_LFAPRESC0_RTC_MASK , _CMU_LFAPRESC0_RTC_SHIFT , _CMU_LFBPRESC0_LEUART0_MASK , _CMU_LFBPRESC0_LEUART0_SHIFT , _CMU_LFBPRESC0_LEUART1_MASK , _CMU_LFBPRESC0_LEUART1_SHIFT , CMU , CMU_DivToLog2() , CMU_SYNCBUSY_LFAPRESC0 , CMU_SYNCBUSY_LFBPRESC0 , cmuClkDiv_1 , cmuClkDiv_128 , cmuClkDiv_16 , cmuClkDiv_32768 , cmuClkDiv_512 , cmuClkDiv_8 , cmuClock_LCDpre , cmuClock_LETIMER0 , cmuClock_LEUART0 , cmuClock_LEUART1 , cmuClock_RTC , SystemCoreClockGet() , and SystemHFClockGet() .
Referenced by CAPLESENSE_setupCMU() , RETARGET_SerialInit() , RTCDRV_Init() , SegmentLCD_Init() , UARTDRV_InitLeuart() , and UDELAY_Calibrate() .
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.
- Note
- If enabling/disabling a LF clock, synchronization into the low frequency domain is required. If the same register is modified before a previous update has completed, this function will stall until the previous synchronization has completed. Please refer to CMU_FreezeEnable() for a suggestion on how to reduce stalling time in some use cases.
- Parameters
-
[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
- true - enable specified clock.
- false - disable specified clock.
Definition at line
1998
of file
em_cmu.c
.
References BUS_RegBitWrite() , CMU , CMU_ClockFreqGet() , CMU_SYNCBUSY_LFACLKEN0 , CMU_SYNCBUSY_LFBCLKEN0 , and cmuClock_HFLE .
Referenced by adcInit() , BOARD_init() , BSP_BccDeInit() , BSP_BccInit() , BSP_BusControlModeSet() , BSP_EbiInit() , BSP_initBoard() , BSP_McuBoard_Init() , CAPLESENSE_setupCMU() , CAPSENSE_Init() , DMA_Init() , DMADRV_DeInit() , ezradio_hal_GpioInit() , I2CSPM_Init() , ICM20648_spiInit() , MIC_init() , MICROSD_Init() , MICROSD_PowerOff() , MICROSD_PowerOn() , MSDD_Init() , RETARGET_SerialInit() , RTCDRV_DeInit() , RTCDRV_Init() , SegmentLCD_Disable() , SegmentLCD_Init() , setupOscillators() , SPI_TFT_Init() , SPIDRV_DeInit() , SPIDRV_Init() , TOUCH_Init() , UARTDRV_DeInit() , UARTDRV_InitLeuart() , UARTDRV_InitUart() , UDELAY_Calibrate() , USTIMER_DeInit() , USTIMER_Init() , VDDCHECK_Disable() , and VDDCHECK_Init() .
uint32_t CMU_ClockFreqGet | ( | CMU_Clock_TypeDef |
clock
|
) |
Get clock frequency for a clock point.
- Parameters
-
[in] clock
Clock point to fetch frequency for.
- Returns
- The current frequency in Hz.
Definition at line
2117
of file
em_cmu.c
.
References _CMU_HFPERCLKDIV_HFPERCLKDIV_MASK , _CMU_HFPERCLKDIV_HFPERCLKDIV_SHIFT , _CMU_LCDCTRL_FDIV_MASK , _CMU_LCDCTRL_FDIV_SHIFT , _CMU_LFAPRESC0_LCD_MASK , _CMU_LFAPRESC0_LCD_SHIFT , _CMU_LFAPRESC0_LETIMER0_MASK , _CMU_LFAPRESC0_LETIMER0_SHIFT , _CMU_LFAPRESC0_RTC_MASK , _CMU_LFAPRESC0_RTC_SHIFT , _CMU_LFBPRESC0_LEUART0_MASK , _CMU_LFBPRESC0_LEUART0_SHIFT , _CMU_LFBPRESC0_LEUART1_MASK , _CMU_LFBPRESC0_LEUART1_SHIFT , CMU , CMU_DivToLog2() , CMU_Log2ToDiv() , cmuClkDiv_16 , cmuClock_LFA , cmuClock_LFB , SystemCoreClockGet() , and SystemHFClockGet() .
Referenced by ADC_PrescaleCalc() , ADC_TimebaseCalc() , BSP_TraceProfilerSetup() , CMU_ClockEnable() , CMU_ClockSelectSet() , CMU_HFRCOBandSet() , DAC_PrescaleCalc() , I2C_BusFreqGet() , I2C_BusFreqSet() , LEUART_BaudrateGet() , LEUART_BaudrateSet() , MIC_init() , MSC_Init() , UARTDRV_InitLeuart() , USART_BaudrateAsyncSet() , USART_BaudrateGet() , USART_BaudrateSyncSet() , USTIMER_Init() , and UTIL_init() .
CMU_Select_TypeDef CMU_ClockSelectGet | ( | CMU_Clock_TypeDef |
clock
|
) |
Get currently selected reference clock used for a clock branch.
- Parameters
-
[in] clock
Clock branch to fetch selected ref. clock for. One of:
- Returns
-
Reference clock used for clocking selected branch,
cmuSelect_Error
if invalid
clock
provided.
Definition at line
2843
of file
em_cmu.c
.
References _CMU_LFCLKSEL_LFA_MASK , _CMU_LFCLKSEL_LFB_MASK , CMU , CMU_LFCLKSEL_LFA_HFCORECLKLEDIV2 , CMU_LFCLKSEL_LFA_LFRCO , CMU_LFCLKSEL_LFA_LFXO , CMU_LFCLKSEL_LFB_HFCORECLKLEDIV2 , CMU_LFCLKSEL_LFB_LFRCO , CMU_LFCLKSEL_LFB_LFXO , CMU_STATUS_HFRCOSEL , CMU_STATUS_HFXOSEL , CMU_STATUS_LFRCOSEL , CMU_STATUS_LFXOSEL , cmuSelect_AUXHFRCO , cmuSelect_Disabled , cmuSelect_Error , cmuSelect_HFCLK , cmuSelect_HFCLKLE , cmuSelect_HFRCO , cmuSelect_HFSRCCLK , cmuSelect_HFXO , cmuSelect_LFRCO , and cmuSelect_LFXO .
Referenced by CMU_HFRCOBandSet() , CMU_HFXOInit() , CMU_LFXOInit() , and UDELAY_Calibrate() .
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.
- Parameters
-
[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
3341
of file
em_cmu.c
.
References _CMU_CTRL_HFXOBUFCUR_MASK , _CMU_HFCORECLKEN0_LE_SHIFT , _CMU_LFCLKSEL_LFA_DISABLED , _CMU_LFCLKSEL_LFA_HFCORECLKLEDIV2 , _CMU_LFCLKSEL_LFA_LFRCO , _CMU_LFCLKSEL_LFA_LFXO , _CMU_LFCLKSEL_LFA_MASK , _CMU_LFCLKSEL_LFA_SHIFT , _CMU_LFCLKSEL_LFB_MASK , _CMU_LFCLKSEL_LFB_SHIFT , BUS_RegBitWrite() , CMU , CMU_ClockFreqGet() , CMU_CMD_HFCLKSEL_HFRCO , CMU_CMD_HFCLKSEL_HFXO , CMU_CMD_HFCLKSEL_LFRCO , CMU_CMD_HFCLKSEL_LFXO , CMU_HFRCOBandGet() , CMU_OscillatorEnable() , cmuClock_HF , cmuClock_HFLE , cmuOsc_AUXHFRCO , cmuOsc_HFRCO , cmuOsc_HFXO , cmuOsc_LFRCO , cmuOsc_LFXO , cmuSelect_AUXHFRCO , cmuSelect_Disabled , cmuSelect_HFCLK , cmuSelect_HFCLKLE , cmuSelect_HFRCO , cmuSelect_HFSRCCLK , cmuSelect_HFXO , cmuSelect_LFRCO , cmuSelect_LFXO , SL_FALLTHROUGH , SystemCoreClockGet() , and SystemHFXOClockGet() .
Referenced by BSP_BccInit() , BSP_initClocks() , CAPLESENSE_setupCMU() , MIC_init() , RETARGET_SerialInit() , RTCDRV_Init() , SegmentLCD_Init() , setupOscillators() , UARTDRV_InitLeuart() , and UDELAY_Calibrate() .
__STATIC_INLINE uint32_t CMU_DivToLog2 | ( | CMU_ClkDiv_TypeDef |
div
|
) |
Convert dividend to logarithmic value. Only works for even numbers equal to 2^n.
- Parameters
-
[in] div
Unscaled dividend.
- Returns
- Logarithm of 2, as used by fixed prescalers.
Definition at line
1702
of file
em_cmu.h
.
Referenced by CMU_ClockDivGet() , CMU_ClockDivSet() , CMU_ClockFreqGet() , and RTCDRV_Init() .
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.
- Note
- When enabling freeze mode, this function will wait for all current ongoing CMU synchronization to LF domain to complete (Normally synchronization will not be in progress.) However for this reason, when using freeze mode, modifications of registers requiring LF synchronization should be done within one freeze enable/disable block to avoid unecessary stalling.
- Parameters
-
[in] enable
- true - enable freeze, modified registers are not propagated to the LF domain
- false - disable freeze, modified registers are propagated to LF domain
Definition at line
4160
of file
em_cmu.c
.
References CMU , and CMU_FREEZE_REGFREEZE .
CMU_HFRCOBand_TypeDef CMU_HFRCOBandGet | ( | void |
|
) |
Get HFRCO band in use.
- Returns
- HFRCO band in use.
Definition at line
4187
of file
em_cmu.c
.
References _CMU_HFRCOCTRL_BAND_MASK , _CMU_HFRCOCTRL_BAND_SHIFT , and CMU .
Referenced by CMU_ClockSelectSet() .
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.
- Parameters
-
[in] band
HFRCO band to activate.
Definition at line
4203
of file
em_cmu.c
.
References _CMU_HFRCOCTRL_BAND_MASK , _CMU_HFRCOCTRL_BAND_SHIFT , _CMU_HFRCOCTRL_TUNING_MASK , _CMU_HFRCOCTRL_TUNING_SHIFT , _DEVINFO_HFRCOCAL0_BAND11_MASK , _DEVINFO_HFRCOCAL0_BAND11_SHIFT , _DEVINFO_HFRCOCAL0_BAND14_MASK , _DEVINFO_HFRCOCAL0_BAND14_SHIFT , _DEVINFO_HFRCOCAL0_BAND1_MASK , _DEVINFO_HFRCOCAL0_BAND1_SHIFT , _DEVINFO_HFRCOCAL0_BAND7_MASK , _DEVINFO_HFRCOCAL0_BAND7_SHIFT , _DEVINFO_HFRCOCAL1_BAND21_MASK , _DEVINFO_HFRCOCAL1_BAND21_SHIFT , _DEVINFO_HFRCOCAL1_BAND28_MASK , _DEVINFO_HFRCOCAL1_BAND28_SHIFT , CMU , CMU_ClockFreqGet() , CMU_ClockSelectGet() , cmuClock_HF , cmuClock_HFLE , cmuHFRCOBand_11MHz , cmuHFRCOBand_14MHz , cmuHFRCOBand_1MHz , cmuHFRCOBand_21MHz , cmuHFRCOBand_28MHz , cmuHFRCOBand_7MHz , cmuSelect_HFRCO , DEVINFO , and SystemCoreClockGet() .
uint32_t CMU_HFRCOStartupDelayGet | ( | void |
|
) |
Get the HFRCO startup delay.
Please refer to the reference manual for further details.
- Returns
- The startup delay in use.
Definition at line
4456
of file
em_cmu.c
.
References _CMU_HFRCOCTRL_SUDELAY_MASK , _CMU_HFRCOCTRL_SUDELAY_SHIFT , and CMU .
void CMU_HFRCOStartupDelaySet | ( | uint32_t |
delay
|
) |
Set the HFRCO startup delay.
Please refer to the reference manual for further details.
- Parameters
-
[in] delay
The startup delay to set (<= 31).
Definition at line
4472
of file
em_cmu.c
.
References _CMU_HFRCOCTRL_SUDELAY_MASK , _CMU_HFRCOCTRL_SUDELAY_SHIFT , and CMU .
void CMU_HFXOInit | ( | const CMU_HFXOInit_TypeDef * |
hfxoInit
|
) |
Set HFXO control registers.
- Note
- HFXO configuration should be obtained from a configuration tool, app note or xtal datasheet. This function disables the HFXO to ensure a valid state before update.
- Parameters
-
[in] hfxoInit
HFXO setup parameters
Definition at line
4616
of file
em_cmu.c
.
References _CMU_CTRL_HFXOBOOST_MASK , _CMU_CTRL_HFXOBOOST_SHIFT , _CMU_CTRL_HFXOGLITCHDETEN_MASK , _CMU_CTRL_HFXOMODE_MASK , _CMU_CTRL_HFXOMODE_SHIFT , _CMU_CTRL_HFXOTIMEOUT_MASK , _CMU_CTRL_HFXOTIMEOUT_SHIFT , CMU_HFXOInit_TypeDef::boost , BUS_RegBitWrite() , CMU , CMU_ClockSelectGet() , CMU_CTRL_HFXOGLITCHDETEN , CMU_OscillatorEnable() , cmuClock_HF , cmuOsc_HFXO , cmuOscMode_AcCoupled , cmuOscMode_Crystal , cmuOscMode_External , cmuSelect_HFXO , CMU_HFXOInit_TypeDef::glitchDetector , CMU_HFXOInit_TypeDef::mode , SystemHFXOClockGet() , and CMU_HFXOInit_TypeDef::timeout .
Referenced by BSP_initClocks() .
__STATIC_INLINE void CMU_IntClear | ( | uint32_t |
flags
|
) |
Clear one or more pending CMU interrupts.
- Parameters
-
[in] flags
CMU interrupt sources to clear.
Definition at line
1735
of file
em_cmu.h
.
References CMU .
__STATIC_INLINE void CMU_IntDisable | ( | uint32_t |
flags
|
) |
Disable one or more CMU interrupts.
- Parameters
-
[in] flags
CMU interrupt sources to disable.
Definition at line
1747
of file
em_cmu.h
.
References CMU .
__STATIC_INLINE void CMU_IntEnable | ( | uint32_t |
flags
|
) |
Enable one or more CMU interrupts.
- Note
- Depending on the use, a pending interrupt may already be set prior to enabling the interrupt. Consider using CMU_IntClear() prior to enabling if such a pending interrupt should be ignored.
- Parameters
-
[in] flags
CMU interrupt sources to enable.
Definition at line
1764
of file
em_cmu.h
.
References CMU .
__STATIC_INLINE uint32_t CMU_IntGet | ( | void |
|
) |
Get pending CMU interrupts.
- Returns
- CMU interrupt sources pending.
Definition at line
1776
of file
em_cmu.h
.
References CMU .
__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.
- Note
- The event bits are not cleared by the use of this function.
- Returns
-
Pending and enabled CMU interrupt sources The return value is the bitwise AND of
- the enabled interrupt sources in CMU_IEN and
- the pending interrupt flags CMU_IF
Definition at line
1797
of file
em_cmu.h
.
References CMU .
__STATIC_INLINE void CMU_IntSet | ( | uint32_t |
flags
|
) |
Set one or more pending CMU interrupts.
- Parameters
-
[in] flags
CMU interrupt sources to set to pending.
Definition at line
1812
of file
em_cmu.h
.
References CMU .
uint32_t CMU_LCDClkFDIVGet | ( | void |
|
) |
Get the LCD framerate divisor (FDIV) setting.
- Returns
- The LCD framerate divisor.
Definition at line
4754
of file
em_cmu.c
.
References _CMU_LCDCTRL_FDIV_MASK , _CMU_LCDCTRL_FDIV_SHIFT , and CMU .
void CMU_LCDClkFDIVSet | ( | uint32_t |
div
|
) |
Set the LCD framerate divisor (FDIV) setting.
- Note
- The FDIV field (CMU LCDCTRL register) should only be modified while the LCD module is clock disabled (CMU LFACLKEN0.LCD bit is 0). This function will NOT modify FDIV if the LCD module clock is enabled. Please refer to CMU_ClockEnable() for disabling/enabling LCD clock.
- Parameters
-
[in] div
The FDIV setting to use.
Definition at line
4776
of file
em_cmu.c
.
References _CMU_LCDCTRL_FDIV_MASK , _CMU_LCDCTRL_FDIV_SHIFT , CMU , CMU_LFACLKEN0_LCD , and cmuClkDiv_128 .
Referenced by SegmentLCD_Init() .
void CMU_LFXOInit | ( | const CMU_LFXOInit_TypeDef * |
lfxoInit
|
) |
Set LFXO control registers.
- Note
- LFXO configuration should be obtained from a configuration tool, app note or xtal datasheet. This function disables the LFXO to ensure a valid state before update.
- Parameters
-
[in] lfxoInit
LFXO setup parameters
Definition at line
4806
of file
em_cmu.c
.
References _CMU_CTRL_LFXOBOOST_MASK , _CMU_CTRL_LFXOBOOST_SHIFT , _CMU_CTRL_LFXOMODE_MASK , _CMU_CTRL_LFXOMODE_SHIFT , _CMU_CTRL_LFXOTIMEOUT_MASK , _CMU_CTRL_LFXOTIMEOUT_SHIFT , CMU_LFXOInit_TypeDef::boost , BUS_RegBitWrite() , BUS_RegMaskedWrite() , CMU , CMU_ClockSelectGet() , CMU_OscillatorEnable() , cmuClock_HF , cmuOsc_LFXO , cmuSelect_LFXO , EMU , CMU_LFXOInit_TypeDef::mode , and CMU_LFXOInit_TypeDef::timeout .
Referenced by BSP_initClocks() .
__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.
- Note
- If locking the CMU registers, they must be unlocked prior to using any CMU API functions modifying CMU registers protected by the lock.
Definition at line
1830
of file
em_cmu.h
.
References CMU , and CMU_LOCK_LOCKKEY_LOCK .
Referenced by EMU_EnterEM3() .
__STATIC_INLINE uint32_t CMU_Log2ToDiv | ( | uint32_t |
log2
|
) |
Convert logarithm of 2 prescaler to division factor.
- Parameters
-
[in] log2
Logarithm of 2, as used by fixed prescalers.
- Returns
- Dividend.
Definition at line
1845
of file
em_cmu.h
.
Referenced by CMU_ClockDivGet() , and CMU_ClockFreqGet() .
void CMU_OscillatorEnable | ( | CMU_Osc_TypeDef |
osc,
|
bool |
enable,
|
||
bool |
wait
|
||
) |
Enable/disable oscillator.
- Note
- WARNING: When this function is called to disable either cmuOsc_LFXO or cmuOsc_HFXO the LFXOMODE or HFXOMODE fields of the CMU_CTRL register are reset to the reset value. I.e. if external clock sources are selected in either LFXOMODE or HFXOMODE fields, the configuration will be cleared and needs to be reconfigured if needed later.
- Parameters
-
[in] osc
The oscillator to enable/disable. [in] enable
- true - enable specified oscillator.
- false - disable specified oscillator.
[in] wait
Only used if enable
is true.- true - wait for oscillator start-up time to timeout before returning.
- false - do not wait for oscillator start-up time to timeout before returning.
Definition at line
4867
of file
em_cmu.c
.
References _CMU_STATUS_AUXHFRCOENS_SHIFT , _CMU_STATUS_AUXHFRCORDY_SHIFT , _CMU_STATUS_HFRCOENS_SHIFT , _CMU_STATUS_HFRCORDY_SHIFT , _CMU_STATUS_HFXOENS_SHIFT , _CMU_STATUS_HFXORDY_SHIFT , _CMU_STATUS_LFRCOENS_SHIFT , _CMU_STATUS_LFRCORDY_SHIFT , _CMU_STATUS_LFXOENS_SHIFT , _CMU_STATUS_LFXORDY_SHIFT , BUS_RegBitRead() , CMU , CMU_OSCENCMD_AUXHFRCODIS , CMU_OSCENCMD_AUXHFRCOEN , CMU_OSCENCMD_HFRCODIS , CMU_OSCENCMD_HFRCOEN , CMU_OSCENCMD_HFXODIS , CMU_OSCENCMD_HFXOEN , CMU_OSCENCMD_LFRCODIS , CMU_OSCENCMD_LFRCOEN , CMU_OSCENCMD_LFXODIS , CMU_OSCENCMD_LFXOEN , CMU_OscillatorTuningGet() , CMU_OscillatorTuningSet() , cmuOsc_AUXHFRCO , cmuOsc_HFRCO , cmuOsc_HFXO , cmuOsc_LFRCO , cmuOsc_LFXO , and EMU .
Referenced by BSP_initClocks() , CMU_ClockSelectSet() , CMU_HFXOInit() , CMU_LFXOInit() , DBG_SWOEnable() , setupOscillators() , and UDELAY_Calibrate() .
uint32_t CMU_OscillatorTuningGet | ( | CMU_Osc_TypeDef |
osc
|
) |
Get oscillator frequency tuning setting.
- Parameters
-
[in] osc
Oscillator to get tuning value for, one of: - cmuOsc_LFRCO
- cmuOsc_HFRCO
- cmuOsc_AUXHFRCO
- cmuOsc_HFXO if CMU_HFXOCTRL_PEAKDETSHUNTOPTMODE is defined
- Returns
- The oscillator frequency tuning setting in use.
Definition at line
5045
of file
em_cmu.c
.
References _CMU_AUXHFRCOCTRL_TUNING_MASK , _CMU_AUXHFRCOCTRL_TUNING_SHIFT , _CMU_HFRCOCTRL_TUNING_MASK , _CMU_HFRCOCTRL_TUNING_SHIFT , _CMU_LFRCOCTRL_TUNING_MASK , _CMU_LFRCOCTRL_TUNING_SHIFT , CMU , cmuOsc_AUXHFRCO , cmuOsc_HFRCO , cmuOsc_HFXO , and cmuOsc_LFRCO .
Referenced by CMU_OscillatorEnable() .
void CMU_OscillatorTuningSet | ( | CMU_Osc_TypeDef |
osc,
|
uint32_t |
val
|
||
) |
Set the oscillator frequency tuning control.
- Note
- Oscillator tuning is done during production, and the tuning value is automatically loaded after a reset. Changing the tuning value from the calibrated value is for more advanced use. Certain oscillators also have build-in tuning optimization.
- Parameters
-
[in] osc
Oscillator to set tuning value for, one of: - cmuOsc_LFRCO
- cmuOsc_HFRCO
- cmuOsc_AUXHFRCO
- cmuOsc_HFXO if PEAKDETSHUNTOPTMODE is available. Note that CMD mode is set.
[in] val
The oscillator frequency tuning setting to use.
Definition at line
5113
of file
em_cmu.c
.
References _CMU_AUXHFRCOCTRL_TUNING_MASK , _CMU_AUXHFRCOCTRL_TUNING_SHIFT , _CMU_HFRCOCTRL_TUNING_MASK , _CMU_HFRCOCTRL_TUNING_SHIFT , _CMU_LFRCOCTRL_TUNING_MASK , _CMU_LFRCOCTRL_TUNING_SHIFT , BUS_RegBitRead() , CMU , CMU_STATUS_HFXOENS , cmuOsc_AUXHFRCO , cmuOsc_HFRCO , cmuOsc_HFXO , and cmuOsc_LFRCO .
Referenced by CMU_OscillatorEnable() .
bool CMU_PCNTClockExternalGet | ( | unsigned int |
instance
|
) |
Determine if currently selected PCNTn clock used is external or LFBCLK.
- Parameters
-
[in] instance
PCNT instance number to get currently selected clock source for.
- Returns
-
- true - selected clock is external clock.
- false - selected clock is LFBCLK.
Definition at line
5326
of file
em_cmu.c
.
References CMU , CMU_PCNTCTRL_PCNT0CLKSEL_PCNT0S0 , CMU_PCNTCTRL_PCNT1CLKSEL_PCNT1S0 , and CMU_PCNTCTRL_PCNT2CLKSEL_PCNT2S0 .
void CMU_PCNTClockExternalSet | ( | unsigned int |
instance,
|
bool |
external
|
||
) |
Select PCNTn clock.
- Parameters
-
[in] instance
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
5366
of file
em_cmu.c
.
References BUS_RegBitWrite() , CMU , and PCNT_COUNT .
Referenced by PCNT_Init() , and PCNT_Reset() .