em_cmu.h File Reference

Clock management unit (CMU) API.

Version
5.4.0

License

Copyright 2016 Silicon Laboratories, Inc. www.silabs.com

Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions:

  1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software.
  2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
  3. This notice may not be removed or altered from any source distribution.

DISCLAIMER OF WARRANTY/LIMITATION OF REMEDIES: Silicon Labs has no obligation to support this Software. Silicon Labs is providing the Software "AS IS", with no express or implied warranties of any kind, including, but not limited to, any implied warranties of merchantability or fitness for any particular purpose or warranties against infringement of any proprietary rights of a third party.

Silicon Labs will not be liable for any consequential, incidental, or special damages, or any other relief, or for any claim by any third party, arising from your use of this Software.

Definition in file em_cmu.h .

#include " em_device.h "
#include <stdbool.h>
#include " em_assert.h "
#include " em_bus.h "

Data Structures

struct CMU_DPLLInit_TypeDef
struct CMU_HFXOInit_TypeDef
struct CMU_LFXOInit_TypeDef

Macros

#define CMU_AUXHFRCO_MAX cmuAUXHFRCOFreq_48M0Hz
#define CMU_AUXHFRCO_MIN cmuAUXHFRCOFreq_1M0Hz
#define CMU_DPLL_LFXO_TO_40MHZ
#define CMU_HFRCO_MAX cmuHFRCOFreq_48M0Hz
#define CMU_HFRCO_MIN cmuHFRCOFreq_1M0Hz
#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
typedef uint32_t CMU_ClkPresc_TypeDef

Enumerations

enum CMU_AUXHFRCOFreq_TypeDef {
cmuAUXHFRCOFreq_1M0Hz = 1000000U,
cmuAUXHFRCOFreq_2M0Hz = 2000000U,
cmuAUXHFRCOFreq_4M0Hz = 4000000U,
cmuAUXHFRCOFreq_7M0Hz = 7000000U,
cmuAUXHFRCOFreq_13M0Hz = 13000000U,
cmuAUXHFRCOFreq_16M0Hz = 16000000U,
cmuAUXHFRCOFreq_19M0Hz = 19000000U,
cmuAUXHFRCOFreq_26M0Hz = 26000000U,
cmuAUXHFRCOFreq_32M0Hz = 32000000U,
cmuAUXHFRCOFreq_38M0Hz = 38000000U,
cmuAUXHFRCOFreq_48M0Hz = 48000000U,
cmuAUXHFRCOFreq_UserDefined = 0
}
enum CMU_Clock_TypeDef {
cmuClock_HF ,
cmuClock_DBG ,
cmuClock_AUX ,
cmuClock_EXPORT ,
cmuClock_BUS ,
cmuClock_CRYPTO0 ,
cmuClock_LDMA ,
cmuClock_GPCRC ,
cmuClock_GPIO ,
cmuClock_HFLE ,
cmuClock_PRS ,
cmuClock_HFPER ,
cmuClock_USART0 ,
cmuClock_USART1 ,
cmuClock_USART2 ,
cmuClock_USART3 ,
cmuClock_UART0 ,
cmuClock_TIMER0 ,
cmuClock_TIMER1 ,
cmuClock_WTIMER0 ,
cmuClock_WTIMER1 ,
cmuClock_CRYOTIMER ,
cmuClock_ACMP0 ,
cmuClock_ACMP1 ,
cmuClock_VDAC0 ,
cmuClock_ADC0 ,
cmuClock_I2C0 ,
cmuClock_I2C1 ,
cmuClock_CSEN_HF ,
cmuClock_TRNG0 ,
cmuClock_CAN0 ,
cmuClock_CORE ,
cmuClock_LFA ,
cmuClock_LETIMER0 ,
cmuClock_LCDpre ,
cmuClock_LCD ,
cmuClock_PCNT0 ,
cmuClock_LESENSE ,
cmuClock_LFB ,
cmuClock_LEUART0 ,
cmuClock_CSEN_LF ,
cmuClock_SYSTICK ,
cmuClock_LFE ,
cmuClock_RTCC ,
cmuClock_ADC0ASYNC
}
enum CMU_DPLLClkSel_TypeDef {
cmuDPLLClkSel_Hfxo = _CMU_DPLLCTRL_REFSEL_HFXO,
cmuDPLLClkSel_Lfxo = _CMU_DPLLCTRL_REFSEL_LFXO,
cmuDPLLClkSel_Clkin0 = _CMU_DPLLCTRL_REFSEL_CLKIN0
}
enum CMU_DPLLEdgeSel_TypeDef {
cmuDPLLEdgeSel_Fall = _CMU_DPLLCTRL_EDGESEL_FALL,
cmuDPLLEdgeSel_Rise = _CMU_DPLLCTRL_EDGESEL_RISE
}
enum CMU_DPLLLockMode_TypeDef {
cmuDPLLLockMode_Freq = _CMU_DPLLCTRL_MODE_FREQLL,
cmuDPLLLockMode_Phase = _CMU_DPLLCTRL_MODE_PHASELL
}
enum CMU_HFRCOFreq_TypeDef {
cmuHFRCOFreq_1M0Hz = 1000000U,
cmuHFRCOFreq_2M0Hz = 2000000U,
cmuHFRCOFreq_4M0Hz = 4000000U,
cmuHFRCOFreq_7M0Hz = 7000000U,
cmuHFRCOFreq_13M0Hz = 13000000U,
cmuHFRCOFreq_16M0Hz = 16000000U,
cmuHFRCOFreq_19M0Hz = 19000000U,
cmuHFRCOFreq_26M0Hz = 26000000U,
cmuHFRCOFreq_32M0Hz = 32000000U,
cmuHFRCOFreq_38M0Hz = 38000000U,
cmuHFRCOFreq_48M0Hz = 48000000U,
cmuHFRCOFreq_UserDefined = 0
}
enum CMU_HFXOTuningMode_TypeDef {
cmuHFXOTuningMode_Auto = 0,
cmuHFXOTuningMode_PeakDetectCommand = CMU_CMD_HFXOPEAKDETSTART
}
enum CMU_Osc_TypeDef {
cmuOsc_LFXO ,
cmuOsc_LFRCO ,
cmuOsc_HFXO ,
cmuOsc_HFRCO ,
cmuOsc_AUXHFRCO ,
cmuOsc_ULFRCO
}
enum CMU_OscMode_TypeDef {
cmuOscMode_Crystal ,
cmuOscMode_AcCoupled ,
cmuOscMode_External
}
enum CMU_Select_TypeDef {
cmuSelect_Error ,
cmuSelect_Disabled ,
cmuSelect_LFXO ,
cmuSelect_LFRCO ,
cmuSelect_HFXO ,
cmuSelect_HFRCO ,
cmuSelect_HFCLKLE ,
cmuSelect_AUXHFRCO ,
cmuSelect_HFSRCCLK ,
cmuSelect_HFCLK ,
cmuSelect_ULFRCO
}

Functions

CMU_AUXHFRCOFreq_TypeDef CMU_AUXHFRCOBandGet (void)
Get current AUXHFRCO frequency.
void CMU_AUXHFRCOBandSet ( CMU_AUXHFRCOFreq_TypeDef setFreq)
Set AUXHFRCO calibration for the selected target frequency.
__STATIC_INLINE CMU_AUXHFRCOFreq_TypeDef CMU_AUXHFRCOFreqGet (void)
Get current AUXHFRCO frequency.
__STATIC_INLINE void CMU_AUXHFRCOFreqSet ( CMU_AUXHFRCOFreq_TypeDef setFreq)
Set AUXHFRCO calibration for the selected target frequency.
uint32_t CMU_Calibrate (uint32_t HFCycles, CMU_Osc_TypeDef reference)
Calibrate clock.
void CMU_CalibrateConfig (uint32_t downCycles, CMU_Osc_TypeDef downSel, CMU_Osc_TypeDef upSel)
Configure clock calibration.
__STATIC_INLINE void CMU_CalibrateCont (bool enable)
Configures continuous calibration mode.
uint32_t CMU_CalibrateCountGet (void)
Get calibration count register.
__STATIC_INLINE void CMU_CalibrateStart (void)
Starts calibration.
__STATIC_INLINE void CMU_CalibrateStop (void)
Stop the calibration counters.
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.
uint32_t CMU_ClockPrescGet ( CMU_Clock_TypeDef clock)
Get clock prescaler.
void CMU_ClockPrescSet ( CMU_Clock_TypeDef clock, CMU_ClkPresc_TypeDef presc)
Set clock prescaler.
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.
bool CMU_DPLLLock ( CMU_DPLLInit_TypeDef *init)
Lock the DPLL to a given frequency.
__STATIC_INLINE void CMU_DPLLUnlock (void)
Unlock the DPLL.
void CMU_FreezeEnable (bool enable)
CMU low frequency register synchronization freeze control.
CMU_HFRCOFreq_TypeDef CMU_HFRCOBandGet (void)
Get current HFRCO frequency.
void CMU_HFRCOBandSet ( CMU_HFRCOFreq_TypeDef setFreq)
Set HFRCO calibration for the selected target frequency.
__STATIC_INLINE CMU_HFRCOFreq_TypeDef CMU_HFRCOFreqGet (void)
Get current HFRCO frequency.
__STATIC_INLINE void CMU_HFRCOFreqSet ( CMU_HFRCOFreq_TypeDef setFreq)
Set HFRCO calibration for the selected target frequency.
void CMU_HFXOAutostartEnable (uint32_t userSel, bool enEM0EM1Start, bool enEM0EM1StartSel)
Enable or disable HFXO autostart.
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.
bool CMU_OscillatorTuningOptimize ( CMU_Osc_TypeDef osc, CMU_HFXOTuningMode_TypeDef mode, bool wait)
Start and optionally wait for oscillator tuning optimization.
void CMU_OscillatorTuningSet ( CMU_Osc_TypeDef osc, uint32_t val)
Set the oscillator frequency tuning control.
bool CMU_OscillatorTuningWait ( CMU_Osc_TypeDef osc, CMU_HFXOTuningMode_TypeDef mode)
Wait for oscillator tuning optimization.
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 uint32_t CMU_PrescToLog2 ( CMU_ClkPresc_TypeDef presc)
Convert prescaler dividend to logarithmic value. Only works for even numbers equal to 2^n.
__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)