EFM32 Zero Gecko Software Documentation  efm32zg-doc-4.2.1

Clock management unit (CMU) Peripheral API

. More...

Macros

#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_AUXHFRCOBand_TypeDef {
  cmuAUXHFRCOBand_1MHz = _CMU_AUXHFRCOCTRL_BAND_1MHZ,
  cmuAUXHFRCOBand_7MHz = _CMU_AUXHFRCOCTRL_BAND_7MHZ,
  cmuAUXHFRCOBand_11MHz = _CMU_AUXHFRCOCTRL_BAND_11MHZ,
  cmuAUXHFRCOBand_14MHz = _CMU_AUXHFRCOCTRL_BAND_14MHZ,
  cmuAUXHFRCOBand_21MHz = _CMU_AUXHFRCOCTRL_BAND_21MHZ
}
 
enum  CMU_Clock_TypeDef {
  cmuClock_HF,
  cmuClock_DBG,
  cmuClock_AUX,
  cmuClock_HFPER,
  cmuClock_USART1,
  cmuClock_TIMER0,
  cmuClock_TIMER1,
  cmuClock_ACMP0,
  cmuClock_PRS,
  cmuClock_IDAC0,
  cmuClock_GPIO,
  cmuClock_VCMP,
  cmuClock_ADC0,
  cmuClock_I2C0,
  cmuClock_CORE,
  cmuClock_AES,
  cmuClock_DMA,
  cmuClock_CORELE,
  cmuClock_LFA,
  cmuClock_RTC,
  cmuClock_PCNT0,
  cmuClock_LFB,
  cmuClock_LEUART0
}
 
enum  CMU_Osc_TypeDef {
  cmuOsc_LFXO,
  cmuOsc_LFRCO,
  cmuOsc_HFXO,
  cmuOsc_HFRCO,
  cmuOsc_AUXHFRCO,
  cmuOsc_ULFRCO
}
 
enum  CMU_Select_TypeDef {
  cmuSelect_Error,
  cmuSelect_Disabled,
  cmuSelect_LFXO,
  cmuSelect_LFRCO,
  cmuSelect_HFXO,
  cmuSelect_HFRCO,
  cmuSelect_CORELEDIV2,
  cmuSelect_AUXHFRCO,
  cmuSelect_HFCLK,
  cmuSelect_ULFRCO
}
 

Functions

CMU_AUXHFRCOBand_TypeDef CMU_AUXHFRCOBandGet (void)
 Get AUXHFRCO band in use. More...
 
void CMU_AUXHFRCOBandSet (CMU_AUXHFRCOBand_TypeDef band)
 Set AUXHFRCO band and the tuning value based on the value in the calibration table made during production. More...
 
uint32_t CMU_Calibrate (uint32_t HFCycles, CMU_Osc_TypeDef ref)
 Calibrate clock. More...
 
void CMU_CalibrateConfig (uint32_t downCycles, CMU_Osc_TypeDef downSel, CMU_Osc_TypeDef upSel)
 Configure clock calibration. More...
 
uint32_t CMU_CalibrateCountGet (void)
 Get calibration count register. More...
 
void CMU_ClockEnable (CMU_Clock_TypeDef clock, bool enable)
 Enable/disable a clock. More...
 
CMU_ClkDiv_TypeDef CMU_ClockDivGet (CMU_Clock_TypeDef clock)
 Get clock divisor/prescaler. More...
 
void CMU_ClockDivSet (CMU_Clock_TypeDef clock, CMU_ClkDiv_TypeDef div)
 Set clock divisor/prescaler. More...
 
uint32_t CMU_ClockFreqGet (CMU_Clock_TypeDef clock)
 Get clock frequency for a clock point. More...
 
void CMU_ClockSelectSet (CMU_Clock_TypeDef clock, CMU_Select_TypeDef ref)
 Select reference clock/oscillator used for a clock branch. More...
 
CMU_Select_TypeDef CMU_ClockSelectGet (CMU_Clock_TypeDef clock)
 Get currently selected reference clock used for a clock branch. More...
 
void CMU_FreezeEnable (bool enable)
 CMU low frequency register synchronization freeze control. More...
 
CMU_HFRCOBand_TypeDef CMU_HFRCOBandGet (void)
 Get HFRCO band in use. More...
 
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. More...
 
uint32_t CMU_HFRCOStartupDelayGet (void)
 Get the HFRCO startup delay. More...
 
void CMU_HFRCOStartupDelaySet (uint32_t delay)
 Set the HFRCO startup delay. More...
 
uint32_t CMU_LCDClkFDIVGet (void)
 Get the LCD framerate divisor (FDIV) setting. More...
 
void CMU_LCDClkFDIVSet (uint32_t div)
 Set the LCD framerate divisor (FDIV) setting. More...
 
void CMU_OscillatorEnable (CMU_Osc_TypeDef osc, bool enable, bool wait)
 Enable/disable oscillator. More...
 
uint32_t CMU_OscillatorTuningGet (CMU_Osc_TypeDef osc)
 Get oscillator frequency tuning setting. More...
 
void CMU_OscillatorTuningSet (CMU_Osc_TypeDef osc, uint32_t val)
 Set the oscillator frequency tuning control. More...
 
bool CMU_PCNTClockExternalGet (unsigned int instance)
 Determine if currently selected PCNTn clock used is external or LFBCLK. More...
 
void CMU_PCNTClockExternalSet (unsigned int instance, bool external)
 Select PCNTn clock. More...
 
__STATIC_INLINE void CMU_CalibrateCont (bool enable)
 Configures continuous calibration mode. More...
 
__STATIC_INLINE void CMU_CalibrateStart (void)
 Starts calibration. More...
 
__STATIC_INLINE void CMU_CalibrateStop (void)
 Stop the calibration counters.
 
__STATIC_INLINE uint32_t CMU_DivToLog2 (CMU_ClkDiv_TypeDef div)
 Convert dividend to logarithmic value. Only works for even numbers equal to 2^n. More...
 
__STATIC_INLINE void CMU_IntClear (uint32_t flags)
 Clear one or more pending CMU interrupts. More...
 
__STATIC_INLINE void CMU_IntDisable (uint32_t flags)
 Disable one or more CMU interrupts. More...
 
__STATIC_INLINE void CMU_IntEnable (uint32_t flags)
 Enable one or more CMU interrupts. More...
 
__STATIC_INLINE uint32_t CMU_IntGet (void)
 Get pending CMU interrupts. More...
 
__STATIC_INLINE uint32_t CMU_IntGetEnabled (void)
 Get enabled and pending CMU interrupt flags. More...
 
__STATIC_INLINE void CMU_IntSet (uint32_t flags)
 Set one or more pending CMU interrupts. More...
 
__STATIC_INLINE void CMU_Lock (void)
 Lock the CMU in order to protect some of its registers against unintended modification. More...
 
__STATIC_INLINE uint32_t CMU_Log2ToDiv (uint32_t log2)
 Convert logarithm of 2 prescaler to division factor. More...
 
__STATIC_INLINE void CMU_Unlock (void)
 Unlock the CMU so that writing to locked registers again is possible.
 

Detailed Description

Macro Definition Documentation

#define cmuClkDiv_1   1

Clock divisors. These values are valid for prescalers. Divide clock by 1.

Definition at line 148 of file em_cmu.h.

Referenced by CAPLESENSE_setupCMU(), CMU_ClockDivGet(), CMU_ClockDivSet(), and RETARGET_SerialInit().

#define cmuClkDiv_2   2

Divide clock by 2.

Definition at line 149 of file em_cmu.h.

#define cmuClkDiv_4   4

Divide clock by 4.

Definition at line 150 of file em_cmu.h.

#define cmuClkDiv_8   8

Divide clock by 8.

Definition at line 151 of file em_cmu.h.

Referenced by CMU_ClockDivSet().

#define cmuClkDiv_16   16

Divide clock by 16.

Definition at line 152 of file em_cmu.h.

Referenced by CMU_ClockDivGet(), CMU_ClockDivSet(), and CMU_ClockFreqGet().

#define cmuClkDiv_32   32

Divide clock by 32.

Definition at line 153 of file em_cmu.h.

#define cmuClkDiv_64   64

Divide clock by 64.

Definition at line 154 of file em_cmu.h.

#define cmuClkDiv_128   128

Divide clock by 128.

Definition at line 155 of file em_cmu.h.

Referenced by CMU_ClockDivSet(), and CMU_LCDClkFDIVSet().

#define cmuClkDiv_256   256

Divide clock by 256.

Definition at line 156 of file em_cmu.h.

Referenced by UDELAY_Calibrate().

#define cmuClkDiv_512   512

Divide clock by 512.

Definition at line 157 of file em_cmu.h.

Referenced by CMU_ClockDivSet().

#define cmuClkDiv_1024   1024

Divide clock by 1024.

Definition at line 158 of file em_cmu.h.

#define cmuClkDiv_2048   2048

Divide clock by 2048.

Definition at line 159 of file em_cmu.h.

#define cmuClkDiv_4096   4096

Divide clock by 4096.

Definition at line 160 of file em_cmu.h.

#define cmuClkDiv_8192   8192

Divide clock by 8192.

Definition at line 161 of file em_cmu.h.

#define cmuClkDiv_16384   16384

Divide clock by 16384.

Definition at line 162 of file em_cmu.h.

#define cmuClkDiv_32768   32768

Divide clock by 32768.

Definition at line 163 of file em_cmu.h.

Referenced by CMU_ClockDivSet().

Typedef Documentation

typedef uint32_t CMU_ClkDiv_TypeDef

Clock divider configuration

Definition at line 166 of file em_cmu.h.

Enumeration Type Documentation

High frequency system RCO bands

Enumerator
cmuHFRCOBand_1MHz 

1MHz HFRCO band

cmuHFRCOBand_7MHz 

7MHz HFRCO band

cmuHFRCOBand_11MHz 

11MHz HFRCO band

cmuHFRCOBand_14MHz 

14MHz HFRCO band

cmuHFRCOBand_21MHz 

21MHz HFRCO band

Definition at line 175 of file em_cmu.h.

AUX High frequency RCO bands

Enumerator
cmuAUXHFRCOBand_1MHz 

1MHz RC band

cmuAUXHFRCOBand_7MHz 

7MHz RC band

cmuAUXHFRCOBand_11MHz 

11MHz RC band

cmuAUXHFRCOBand_14MHz 

14MHz RC band

cmuAUXHFRCOBand_21MHz 

21MHz RC band

Definition at line 190 of file em_cmu.h.

Clock points in CMU. Please refer to CMU overview in reference manual.

Enumerator
cmuClock_HF 

High frequency clock

cmuClock_DBG 

Debug clock

cmuClock_AUX 

AUX clock

cmuClock_HFPER 

High frequency peripheral clock

cmuClock_USART1 

Universal sync/async receiver/transmitter 1 clock.

cmuClock_TIMER0 

Timer 0 clock.

cmuClock_TIMER1 

Timer 1 clock.

cmuClock_ACMP0 

Analog comparator 0 clock.

cmuClock_PRS 

Peripheral reflex system clock.

cmuClock_IDAC0 

Digital to analog converter 0 clock.

cmuClock_GPIO 

General purpose input/output clock.

cmuClock_VCMP 

Voltage comparator clock.

cmuClock_ADC0 

Analog to digital converter 0 clock.

cmuClock_I2C0 

I2C 0 clock.

cmuClock_CORE 

Core clock

cmuClock_AES 

Advanced encryption standard accelerator clock.

cmuClock_DMA 

Direct memory access controller clock.

cmuClock_CORELE 

Low energy clocking module clock.

cmuClock_LFA 

Low frequency A clock

cmuClock_RTC 

Real time counter clock.

cmuClock_PCNT0 

Pulse counter 0 clock.

cmuClock_LFB 

Low frequency B clock

cmuClock_LEUART0 

Low energy universal asynchronous receiver/transmitter 0 clock.

Definition at line 256 of file em_cmu.h.

Oscillator types.

Enumerator
cmuOsc_LFXO 

Low frequency crystal oscillator.

cmuOsc_LFRCO 

Low frequency RC oscillator.

cmuOsc_HFXO 

High frequency crystal oscillator.

cmuOsc_HFRCO 

High frequency RC oscillator.

cmuOsc_AUXHFRCO 

Auxiliary high frequency RC oscillator.

cmuOsc_ULFRCO 

Ultra low frequency RC oscillator.

Definition at line 933 of file em_cmu.h.

Selectable clock sources.

Enumerator
cmuSelect_Error 

Usage error.

cmuSelect_Disabled 

Clock selector disabled.

cmuSelect_LFXO 

Low frequency crystal oscillator.

cmuSelect_LFRCO 

Low frequency RC oscillator.

cmuSelect_HFXO 

High frequency crystal oscillator.

cmuSelect_HFRCO 

High frequency RC oscillator.

cmuSelect_CORELEDIV2 

Core low energy clock divided by 2.

cmuSelect_AUXHFRCO 

Auxilliary clock source can be used for debug clock

cmuSelect_HFCLK 

Divided HFCLK on Giant for debug clock, undivided on Tiny Gecko and for USBC (not used on Gecko)

cmuSelect_ULFRCO 

Ultra low frequency RC oscillator.

Definition at line 950 of file em_cmu.h.

Function Documentation

CMU_AUXHFRCOBand_TypeDef CMU_AUXHFRCOBandGet ( void  )
Returns
AUXHFRCO band in use.

Definition at line 595 of file em_cmu.c.

References _CMU_AUXHFRCOCTRL_BAND_MASK, _CMU_AUXHFRCOCTRL_BAND_SHIFT, and CMU.

uint32_t CMU_Calibrate ( uint32_t  HFCycles,
CMU_Osc_TypeDef  ref 
)

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]HFCyclesThe number of HFCLK cycles to run calibration. Increasing this number increases precision, but the calibration will take more time.
[in]refThe 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 801 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.

void CMU_CalibrateConfig ( uint32_t  downCycles,
CMU_Osc_TypeDef  downSel,
CMU_Osc_TypeDef  upSel 
)

Configure a calibration for a selectable clock source against another selectable reference clock. Refer to the reference manual, CMU chapter, for further details.

Note
After configuration, a call to CMU_CalibrateStart() is required, and the resulting calibration value can be read out with the CMU_CalibrateCountGet() function call.
Parameters
[in]downCyclesThe number of downSel clock cycles to run calibration. Increasing this number increases precision, but the calibration will take more time.
[in]downSelThe clock which will be counted down downCycles
[in]upSelThe reference clock, the number of cycles generated by this clock will be counted and added up, the result can be given with the CMU_CalibrateCountGet() function call.

Definition at line 882 of file em_cmu.c.

References _CMU_CALCNT_CALCNT_MASK, _CMU_CALCNT_CALCNT_SHIFT, _CMU_CALCTRL_DOWNSEL_MASK, _CMU_CALCTRL_UPSEL_MASK, CMU, CMU_CALCTRL_DOWNSEL_AUXHFRCO, CMU_CALCTRL_DOWNSEL_HFRCO, CMU_CALCTRL_DOWNSEL_HFXO, CMU_CALCTRL_DOWNSEL_LFRCO, CMU_CALCTRL_DOWNSEL_LFXO, CMU_CALCTRL_UPSEL_AUXHFRCO, CMU_CALCTRL_UPSEL_HFRCO, CMU_CALCTRL_UPSEL_HFXO, CMU_CALCTRL_UPSEL_LFRCO, CMU_CALCTRL_UPSEL_LFXO, cmuOsc_AUXHFRCO, cmuOsc_HFRCO, cmuOsc_HFXO, cmuOsc_LFRCO, and cmuOsc_LFXO.

uint32_t CMU_CalibrateCountGet ( void  )
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 969 of file em_cmu.c.

References _CMU_CALCTRL_CONT_SHIFT, _CMU_STATUS_CALBSY_SHIFT, BUS_RegBitRead(), and CMU.

void CMU_ClockEnable ( CMU_Clock_TypeDef  clock,
bool  enable 
)

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]clockThe 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 1369 of file em_cmu.c.

References _CMU_HFCORECLKDIV_HFCORECLKLEDIV_SHIFT, BUS_RegBitWrite(), CMU, CMU_ClockFreqGet(), CMU_SYNCBUSY_LFACLKEN0, CMU_SYNCBUSY_LFBCLKEN0, and cmuClock_CORE.

Referenced by BSP_BccDeInit(), BSP_BccInit(), BSP_EbiInit(), BSP_McuBoard_Init(), CAPLESENSE_setupCMU(), CAPSENSE_Init(), DMA_Init(), DMADRV_DeInit(), ezradio_hal_GpioInit(), I2CSPM_Init(), MICROSD_Init(), MICROSD_PowerOff(), MICROSD_PowerOn(), MSDD_Init(), RETARGET_SerialInit(), RTCDRV_DeInit(), RTCDRV_Init(), SegmentLCD_Disable(), SegmentLCD_Init(), SPI_TFT_Init(), SPIDRV_DeInit(), SPIDRV_Init(), TOUCH_Init(), UARTDRV_DeInit(), UARTDRV_Init(), UDELAY_Calibrate(), USTIMER_DeInit(), USTIMER_Init(), VDDCHECK_Disable(), and VDDCHECK_Init().

CMU_ClkDiv_TypeDef CMU_ClockDivGet ( CMU_Clock_TypeDef  clock)
Parameters
[in]clockClock 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 1009 of file em_cmu.c.

References _CMU_HFCORECLKDIV_HFCORECLKDIV_MASK, _CMU_HFCORECLKDIV_HFCORECLKDIV_SHIFT, _CMU_HFPERCLKDIV_HFPERCLKDIV_MASK, _CMU_HFPERCLKDIV_HFPERCLKDIV_SHIFT, _CMU_LFAPRESC0_RTC_MASK, _CMU_LFAPRESC0_RTC_SHIFT, _CMU_LFBPRESC0_LEUART0_MASK, _CMU_LFBPRESC0_LEUART0_SHIFT, CMU, CMU_DivToLog2(), CMU_Log2ToDiv(), cmuClkDiv_1, cmuClkDiv_16, cmuClock_LEUART0, and cmuClock_RTC.

Referenced by UDELAY_Calibrate().

void CMU_ClockDivSet ( CMU_Clock_TypeDef  clock,
CMU_ClkDiv_TypeDef  div 
)
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]clockClock 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]divThe clock divisor to use (<= cmuClkDiv_512).

Definition at line 1141 of file em_cmu.c.

References _CMU_HFCORECLKDIV_HFCORECLKDIV_MASK, _CMU_HFCORECLKDIV_HFCORECLKDIV_SHIFT, _CMU_HFCORECLKDIV_HFCORECLKLEDIV_SHIFT, _CMU_HFPERCLKDIV_HFPERCLKDIV_MASK, _CMU_HFPERCLKDIV_HFPERCLKDIV_SHIFT, _CMU_LFAPRESC0_RTC_MASK, _CMU_LFAPRESC0_RTC_SHIFT, _CMU_LFBPRESC0_LEUART0_MASK, _CMU_LFBPRESC0_LEUART0_SHIFT, BUS_RegBitWrite(), CMU, CMU_ClockFreqGet(), CMU_DivToLog2(), CMU_SYNCBUSY_LFAPRESC0, CMU_SYNCBUSY_LFBPRESC0, cmuClkDiv_1, cmuClkDiv_128, cmuClkDiv_16, cmuClkDiv_32768, cmuClkDiv_512, cmuClkDiv_8, cmuClock_HF, cmuClock_LEUART0, cmuClock_RTC, and SystemCoreClockGet().

Referenced by CAPLESENSE_setupCMU(), RETARGET_SerialInit(), RTCDRV_Init(), SegmentLCD_Init(), and UDELAY_Calibrate().

void CMU_ClockSelectSet ( CMU_Clock_TypeDef  clock,
CMU_Select_TypeDef  ref 
)

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]clockClock branch to select reference clock for. One of:
[in]refReference selected for clocking, please refer to reference manual for for details on which reference is available for a specific clock branch.

Definition at line 2406 of file em_cmu.c.

References _CMU_CTRL_HFXOBUFCUR_MASK, _CMU_HFCORECLKDIV_HFCORECLKLEDIV_SHIFT, _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_LFAE_MASK, _CMU_LFCLKSEL_LFAE_SHIFT, _CMU_LFCLKSEL_LFB_MASK, _CMU_LFCLKSEL_LFB_SHIFT, _CMU_LFCLKSEL_LFBE_MASK, _CMU_LFCLKSEL_LFBE_SHIFT, BUS_RegBitWrite(), CMU, CMU_CMD_HFCLKSEL_HFRCO, CMU_CMD_HFCLKSEL_HFXO, CMU_CMD_HFCLKSEL_LFRCO, CMU_CMD_HFCLKSEL_LFXO, CMU_HFCORECLKEN0_LE, 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, cmuSelect_ULFRCO, EMU_UpdateOscConfig(), SystemCoreClockGet(), and SystemHFXOClockGet().

Referenced by BSP_BccInit(), CAPLESENSE_setupCMU(), RETARGET_SerialInit(), RTCDRV_Init(), SegmentLCD_Init(), and UDELAY_Calibrate().

void CMU_FreezeEnable ( bool  enable)

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 2857 of file em_cmu.c.

References CMU, and CMU_FREEZE_REGFREEZE.

CMU_HFRCOBand_TypeDef CMU_HFRCOBandGet ( void  )
Returns
HFRCO band in use.

Definition at line 2889 of file em_cmu.c.

References _CMU_HFRCOCTRL_BAND_MASK, _CMU_HFRCOCTRL_BAND_SHIFT, and CMU.

uint32_t CMU_HFRCOStartupDelayGet ( void  )

Please refer to the reference manual for further details.

Returns
The startup delay in use.

Definition at line 3115 of file em_cmu.c.

References _CMU_HFRCOCTRL_SUDELAY_MASK, _CMU_HFRCOCTRL_SUDELAY_SHIFT, and CMU.

void CMU_HFRCOStartupDelaySet ( uint32_t  delay)

Please refer to the reference manual for further details.

Parameters
[in]delayThe startup delay to set (<= 31).

Definition at line 3132 of file em_cmu.c.

References _CMU_HFRCOCTRL_SUDELAY_MASK, _CMU_HFRCOCTRL_SUDELAY_SHIFT, and CMU.

uint32_t CMU_LCDClkFDIVGet ( void  )
Returns
The LCD framerate divisor.

Definition at line 3295 of file em_cmu.c.

References CMU.

void CMU_LCDClkFDIVSet ( uint32_t  div)
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]divThe FDIV setting to use.

Definition at line 3318 of file em_cmu.c.

References CMU, and cmuClkDiv_128.

Referenced by SegmentLCD_Init().

void CMU_OscillatorEnable ( CMU_Osc_TypeDef  osc,
bool  enable,
bool  wait 
)
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]oscThe oscillator to enable/disable.
[in]enable
  • true - enable specified oscillator.
  • false - disable specified oscillator.
[in]waitOnly 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 3394 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(), BUS_RegMaskedRead(), 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, cmuOsc_AUXHFRCO, cmuOsc_HFRCO, cmuOsc_HFXO, cmuOsc_LFRCO, cmuOsc_LFXO, cmuOsc_ULFRCO, and EMU_UpdateOscConfig().

Referenced by CMU_ClockSelectSet(), and UDELAY_Calibrate().

uint32_t CMU_OscillatorTuningGet ( CMU_Osc_TypeDef  osc)
Parameters
[in]oscOscillator to get tuning value for, one of:
Returns
The oscillator frequency tuning setting in use.

Definition at line 3535 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, and cmuOsc_LFRCO.

void CMU_OscillatorTuningSet ( CMU_Osc_TypeDef  osc,
uint32_t  val 
)
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.
Parameters
[in]oscOscillator to set tuning value for, one of:
[in]valThe oscillator frequency tuning setting to use.

Definition at line 3584 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, cmuOsc_AUXHFRCO, cmuOsc_HFRCO, and cmuOsc_LFRCO.

bool CMU_PCNTClockExternalGet ( unsigned int  instance)
Parameters
[in]instancePCNT instance number to get currently selected clock source for.
Returns
  • true - selected clock is external clock.
  • false - selected clock is LFBCLK.

Definition at line 3643 of file em_cmu.c.

References CMU, and CMU_PCNTCTRL_PCNT0CLKSEL_PCNT0S0.

void CMU_PCNTClockExternalSet ( unsigned int  instance,
bool  external 
)
Parameters
[in]instancePCNT instance number to set selected clock source for.
[in]externalSet to true to select external clock, false to select LFBCLK.

Definition at line 3685 of file em_cmu.c.

References BUS_RegBitWrite(), CMU, and PCNT_COUNT.

Referenced by PCNT_Init(), and PCNT_Reset().

__STATIC_INLINE void CMU_CalibrateCont ( bool  enable)
Parameters
[in]enableIf true, enables continuous calibration, if false disables continuous calibrartion

Definition at line 1153 of file em_cmu.h.

References _CMU_CALCTRL_CONT_SHIFT, BUS_RegBitWrite(), and CMU.

__STATIC_INLINE void CMU_CalibrateStart ( void  )
Note
This call is usually invoked after CMU_CalibrateConfig() and possibly CMU_CalibrateCont()

Definition at line 1167 of file em_cmu.h.

References CMU, and CMU_CMD_CALSTART.

__STATIC_INLINE uint32_t CMU_DivToLog2 ( CMU_ClkDiv_TypeDef  div)
Parameters
[in]divUnscaled dividend.
Returns
Logarithm of 2, as used by fixed prescalers.

Definition at line 1196 of file em_cmu.h.

Referenced by CMU_ClockDivGet(), CMU_ClockDivSet(), CMU_ClockFreqGet(), and RTCDRV_Init().

__STATIC_INLINE void CMU_IntClear ( uint32_t  flags)
Parameters
[in]flagsCMU interrupt sources to clear.

Definition at line 1217 of file em_cmu.h.

References CMU.

__STATIC_INLINE void CMU_IntDisable ( uint32_t  flags)
Parameters
[in]flagsCMU interrupt sources to disable.

Definition at line 1230 of file em_cmu.h.

References CMU.

__STATIC_INLINE void CMU_IntEnable ( uint32_t  flags)
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]flagsCMU interrupt sources to enable.

Definition at line 1248 of file em_cmu.h.

References CMU.

__STATIC_INLINE uint32_t CMU_IntGet ( void  )
Returns
CMU interrupt sources pending.

Definition at line 1261 of file em_cmu.h.

References CMU.

__STATIC_INLINE uint32_t CMU_IntGetEnabled ( void  )

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 1283 of file em_cmu.h.

References CMU.

__STATIC_INLINE void CMU_IntSet ( uint32_t  flags)
Parameters
[in]flagsCMU interrupt sources to set to pending.

Definition at line 1299 of file em_cmu.h.

References CMU.

__STATIC_INLINE void CMU_Lock ( void  )

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 1318 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)
Parameters
[in]log2Logarithm of 2, as used by fixed prescalers.
Returns
Dividend.

Definition at line 1334 of file em_cmu.h.

Referenced by CMU_ClockDivGet(), and CMU_ClockFreqGet().