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_DPLLInit_TypeDef |
struct | CMU_HFXOInit_TypeDef |
struct | CMU_LFXOInit_TypeDef |
Macros |
|
#define | CMU_DPLL_HFXO_TO_80MHZ |
#define | CMU_DPLL_LFXO_TO_40MHZ |
#define | CMU_DPLLINIT_DEFAULT |
#define | CMU_HFRCODPLL_MAX cmuHFRCODPLLFreq_80M0Hz |
#define | CMU_HFRCODPLL_MIN cmuHFRCODPLLFreq_1M0Hz |
#define | CMU_HFRCOEM23_MAX cmuHFRCOEM23Freq_40M0Hz |
#define | CMU_HFRCOEM23_MIN cmuHFRCOEM23Freq_1M0Hz |
#define | CMU_HFXOINIT_DEFAULT |
#define | CMU_HFXOINIT_EXTERNAL_SINE |
#define | CMU_LFXOINIT_DEFAULT |
#define | CMU_LFXOINIT_EXTERNAL_CLOCK |
#define | CMU_LFXOINIT_EXTERNAL_SINE |
Typedefs |
|
typedef uint32_t | CMU_ClkDiv_TypeDef |
Functions |
|
uint32_t | CMU_Calibrate (uint32_t cycles, CMU_Select_TypeDef ref) |
Calibrate an oscillator.
|
|
void | CMU_CalibrateConfig (uint32_t downCycles, CMU_Select_TypeDef downSel, CMU_Select_TypeDef upSel) |
Configure clock calibration.
|
|
__STATIC_INLINE void | CMU_CalibrateCont (bool enable) |
Configures continuous calibration mode.
|
|
uint32_t | CMU_CalibrateCountGet (void) |
Get calibration count value.
|
|
__STATIC_INLINE void | CMU_CalibrateStart (void) |
Starts calibration.
|
|
__STATIC_INLINE void | CMU_CalibrateStop (void) |
Stop calibration counters.
|
|
void | CMU_ClkOutPinConfig (uint32_t clkNo, CMU_Select_TypeDef sel, CMU_ClkDiv_TypeDef clkDiv, GPIO_Port_TypeDef port, unsigned int pin) |
Direct a clock to a GPIO pin.
|
|
CMU_ClkDiv_TypeDef | CMU_ClockDivGet ( CMU_Clock_TypeDef clock) |
Get clock divisor.
|
|
void | CMU_ClockDivSet ( CMU_Clock_TypeDef clock, CMU_ClkDiv_TypeDef div) |
Set clock divisor.
|
|
__STATIC_INLINE 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.
|
|
bool | CMU_DPLLLock (const CMU_DPLLInit_TypeDef *init) |
Lock the DPLL to a given frequency. The frequency is given by: Fout = Fref * (N+1) / (M+1).
|
|
__STATIC_INLINE void | CMU_DPLLUnlock (void) |
Unlock the DPLL.
|
|
CMU_HFRCODPLLFreq_TypeDef | CMU_HFRCODPLLBandGet (void) |
Get HFRCODPLL band in use.
|
|
void | CMU_HFRCODPLLBandSet ( CMU_HFRCODPLLFreq_TypeDef freq) |
Set HFRCODPLL band and the tuning value based on the value in the calibration table made during production.
|
|
CMU_HFRCOEM23Freq_TypeDef | CMU_HFRCOEM23BandGet (void) |
Get HFRCOEM23 band in use.
|
|
void | CMU_HFRCOEM23BandSet ( CMU_HFRCOEM23Freq_TypeDef freq) |
Set HFRCOEM23 band and the tuning value based on the value in the calibration table made during production.
|
|
void | CMU_HFXOInit (const CMU_HFXOInit_TypeDef *hfxoInit) |
Initialize all HFXO control registers.
|
|
__STATIC_INLINE void | CMU_IntClear (uint32_t flags) |
Clear one or more pending CMU interrupt flags.
|
|
__STATIC_INLINE void | CMU_IntDisable (uint32_t flags) |
Disable one or more CMU interrupt sources.
|
|
__STATIC_INLINE void | CMU_IntEnable (uint32_t flags) |
Enable one or more CMU interrupt sources.
|
|
__STATIC_INLINE uint32_t | CMU_IntGet (void) |
Get pending CMU interrupt sources.
|
|
__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 interrupt sources.
|
|
void | CMU_LFXOInit (const CMU_LFXOInit_TypeDef *lfxoInit) |
Initialize LFXO control registers.
|
|
__STATIC_INLINE void | CMU_Lock (void) |
Lock CMU register access in order to protect registers contents against unintended modification.
|
|
__STATIC_INLINE 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.
|
|
__STATIC_INLINE void | CMU_Unlock (void) |
Unlock CMU register access so that writing to registers is possible.
|
|
void | CMU_UpdateWaitStates (uint32_t freq, int vscale) |
Configure wait state settings necessary to switch to a given core clock frequency.
|
|
__STATIC_INLINE void | CMU_WdogLock (void) |
Lock WDOG register access in order to protect registers contents against unintended modification.
|
|
__STATIC_INLINE void | CMU_WdogUnlock (void) |
Unlock WDOG register access so that writing to registers is possible.
|
|
Macro Definition Documentation
#define CMU_DPLL_HFXO_TO_80MHZ |
DPLL initialization values for 80,000,000 Hz using HFXO as reference clock, M = 1919, N = 3999.
Definition at line
455
of file
em_cmu.h
.
Referenced by BSP_initClocks() .
#define CMU_DPLL_LFXO_TO_40MHZ |
DPLL initialization values for 39,998,805 Hz using LFXO as reference clock, M=2 and N=3661.
Definition at line
439
of file
em_cmu.h
.
Referenced by BSP_initClocks() .
#define CMU_DPLLINIT_DEFAULT |
Default configurations for DPLL initialization. When using this macro you need to modify the N and M factor and the desired frequency to match the components placed on the board.
Definition at line
472
of file
em_cmu.h
.
#define CMU_HFRCODPLL_MAX cmuHFRCODPLLFreq_80M0Hz |
HFRCODPLL minimum frequency
Definition at line
87
of file
em_cmu.h
.
#define CMU_HFRCODPLL_MIN cmuHFRCODPLLFreq_1M0Hz |
HFRCODPLL maximum frequency
Definition at line
85
of file
em_cmu.h
.
#define CMU_HFRCOEM23_MAX cmuHFRCOEM23Freq_40M0Hz |
HFRCOEM23 minimum frequency
Definition at line
106
of file
em_cmu.h
.
#define CMU_HFRCOEM23_MIN cmuHFRCOEM23Freq_1M0Hz |
HFRCOEM23 maximum frequency
Definition at line
104
of file
em_cmu.h
.
#define CMU_HFXOINIT_DEFAULT |
Default HFXO initialization values for XTAL mode.
Definition at line
376
of file
em_cmu.h
.
#define CMU_HFXOINIT_EXTERNAL_SINE |
em_cmu.h:269
em_cmu.h:224
em_cmu.h:277
Default HFXO initialization values for external sine mode.
Definition at line
400
of file
em_cmu.h
.
#define CMU_LFXOINIT_DEFAULT |
Default LFXO initialization values for XTAL mode.
Definition at line
304
of file
em_cmu.h
.
#define CMU_LFXOINIT_EXTERNAL_CLOCK |
Default LFXO initialization values for external clock mode.
Definition at line
320
of file
em_cmu.h
.
#define CMU_LFXOINIT_EXTERNAL_SINE |
Default LFXO initialization values for external sine mode.
Definition at line
336
of file
em_cmu.h
.
Typedef Documentation
typedef uint32_t CMU_ClkDiv_TypeDef |
Clock divider configuration
Definition at line
63
of file
em_cmu.h
.
Enumeration Type Documentation
enum CMU_Clock_TypeDef |
Clock points in CMU clock-tree.
Definition at line
109
of file
em_cmu.h
.
HFRCODPLL frequency bands
Definition at line
66
of file
em_cmu.h
.
HFRCOEM23 frequency bands
Definition at line
90
of file
em_cmu.h
.
HFXO core bias LSB change timeout.
Definition at line
228
of file
em_cmu.h
.
HFXO steady state timeout.
Definition at line
248
of file
em_cmu.h
.
LFXO start-up timeout delay.
Definition at line
210
of file
em_cmu.h
.
enum CMU_Osc_TypeDef |
Oscillator types.
Definition at line
160
of file
em_cmu.h
.
enum CMU_Select_TypeDef |
Selectable clock sources.
Definition at line
171
of file
em_cmu.h
.
Function Documentation
uint32_t CMU_Calibrate | ( | uint32_t |
cycles,
|
CMU_Select_TypeDef |
ref
|
||
) |
Calibrate an oscillator.
Run a calibration of a selectable reference clock againt HCLK. Please refer to the reference manual, CMU chapter, for further details.
- Note
- This function will not return until calibration measurement is completed.
- Parameters
-
[in] cycles
The number of HCLK cycles to run calibration. Increasing this number increases precision, but the calibration will take more time. [in] ref
The reference clock used to compare against HCLK.
- Returns
- The number of ticks the selected reference clock ticked while running cycles ticks of the HCLK clock.
Definition at line
173
of file
em_cmu.c
.
References _CMU_CALCTRL_CALTOP_MASK , _CMU_CALCTRL_CALTOP_SHIFT , CMU_CalibrateConfig() , CMU_CalibrateCountGet() , CMU_CalibrateStart() , and cmuSelect_HCLK .
void CMU_CalibrateConfig | ( | uint32_t |
downCycles,
|
CMU_Select_TypeDef |
downSel,
|
||
CMU_Select_TypeDef |
upSel
|
||
) |
Configure clock calibration.
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 with the CMU_CalibrateCountGet() function call.
- Parameters
-
[in] downCycles
The number of downSel clock cycles to run calibration. Increasing this number increases precision, but the calibration will take more time. [in] downSel
The clock which will be counted down downCycles cycles. [in] upSel
The 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
210
of file
em_cmu.c
.
References _CMU_CALCTRL_CALTOP_MASK , _CMU_CALCTRL_CALTOP_SHIFT , _CMU_CALCTRL_DOWNSEL_MASK , _CMU_CALCTRL_UPSEL_MASK , CMU , CMU_CALCTRL_DOWNSEL_FSRCO , CMU_CALCTRL_DOWNSEL_HCLK , CMU_CALCTRL_DOWNSEL_HFRCODPLL , CMU_CALCTRL_DOWNSEL_HFRCOEM23 , CMU_CALCTRL_DOWNSEL_HFXO , CMU_CALCTRL_DOWNSEL_LFRCO , CMU_CALCTRL_DOWNSEL_LFXO , CMU_CALCTRL_DOWNSEL_PRS , CMU_CALCTRL_DOWNSEL_ULFRCO , CMU_CALCTRL_UPSEL_FSRCO , CMU_CALCTRL_UPSEL_HFRCODPLL , CMU_CALCTRL_UPSEL_HFRCOEM23 , CMU_CALCTRL_UPSEL_HFXO , CMU_CALCTRL_UPSEL_LFRCO , CMU_CALCTRL_UPSEL_LFXO , CMU_CALCTRL_UPSEL_PRS , CMU_CALCTRL_UPSEL_ULFRCO , cmuSelect_Disabled , cmuSelect_FSRCO , cmuSelect_HCLK , cmuSelect_HFRCODPLL , cmuSelect_HFRCOEM23 , cmuSelect_HFXO , cmuSelect_LFRCO , cmuSelect_LFXO , cmuSelect_PRS , and cmuSelect_ULFRCO .
Referenced by CMU_Calibrate() .
__STATIC_INLINE void CMU_CalibrateCont | ( | bool |
enable
|
) |
Configures continuous calibration mode.
- Parameters
-
[in] enable
If true, enables continuous calibration, if false disables continuous calibration.
Definition at line
524
of file
em_cmu.h
.
References _CMU_CALCTRL_CONT_SHIFT , BUS_RegBitWrite() , and CMU .
uint32_t CMU_CalibrateCountGet | ( | void |
|
) |
Get calibration count value.
- 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
330
of file
em_cmu.c
.
References CMU , CMU_CALCTRL_CONT , and CMU_STATUS_CALRDY .
Referenced by CMU_Calibrate() .
__STATIC_INLINE void CMU_CalibrateStart | ( | void |
|
) |
Starts calibration.
- Note
- This call is usually invoked after CMU_CalibrateConfig() and possibly CMU_CalibrateCont() .
Definition at line
536
of file
em_cmu.h
.
References CMU , and CMU_CALCMD_CALSTART .
Referenced by CMU_Calibrate() .
void CMU_ClkOutPinConfig | ( | uint32_t |
clkNo,
|
CMU_Select_TypeDef |
sel,
|
||
CMU_ClkDiv_TypeDef |
clkDiv,
|
||
GPIO_Port_TypeDef |
port,
|
||
unsigned int |
pin
|
||
) |
Direct a clock to a GPIO pin.
- Parameters
-
[in] clkNo
Selects between CLKOUT0, CLKOUT1 or CLKOUT2 outputs. Use values 0,1or 2. [in] sel
Select clock source. [in] clkDiv
Select a clock divisor (1..32). Only applicable when cmuSelect_EXPCLK is slexted as clock source. [in] port
GPIO port. [in] pin
GPIO pin.
- Note
- Refer to the reference manual and the datasheet for details on which GPIO port/pins that are available.
Definition at line
365
of file
em_cmu.c
.
References _CMU_EXPORTCLKCTRL_CLKOUTSEL0_MASK , _CMU_EXPORTCLKCTRL_CLKOUTSEL1_SHIFT , _CMU_EXPORTCLKCTRL_PRESC_MASK , _CMU_EXPORTCLKCTRL_PRESC_SHIFT , _GPIO_CMU_CLKOUT0ROUTE_PIN_SHIFT , _GPIO_CMU_CLKOUT0ROUTE_PORT_SHIFT , _GPIO_CMU_CLKOUT1ROUTE_PIN_SHIFT , _GPIO_CMU_CLKOUT1ROUTE_PORT_SHIFT , _GPIO_CMU_CLKOUT2ROUTE_PIN_SHIFT , _GPIO_CMU_CLKOUT2ROUTE_PORT_SHIFT , CMU , CMU_EXPORTCLKCTRL_CLKOUTSEL0_DISABLED , CMU_EXPORTCLKCTRL_CLKOUTSEL0_FSRCO , CMU_EXPORTCLKCTRL_CLKOUTSEL0_HCLK , CMU_EXPORTCLKCTRL_CLKOUTSEL0_HFEXPCLK , CMU_EXPORTCLKCTRL_CLKOUTSEL0_HFRCODPLL , CMU_EXPORTCLKCTRL_CLKOUTSEL0_HFRCOEM23 , CMU_EXPORTCLKCTRL_CLKOUTSEL0_HFXO , CMU_EXPORTCLKCTRL_CLKOUTSEL0_LFRCO , CMU_EXPORTCLKCTRL_CLKOUTSEL0_LFXO , CMU_EXPORTCLKCTRL_CLKOUTSEL0_ULFRCO , cmuSelect_Disabled , cmuSelect_EXPCLK , cmuSelect_FSRCO , cmuSelect_HCLK , cmuSelect_HFRCODPLL , cmuSelect_HFRCOEM23 , cmuSelect_HFXO , cmuSelect_LFRCO , cmuSelect_LFXO , cmuSelect_ULFRCO , GPIO , GPIO_CMU_ROUTEEN_CLKOUT0PEN , GPIO_PinModeSet() , gpioModeDisabled , and gpioModePushPull .
CMU_ClkDiv_TypeDef CMU_ClockDivGet | ( | CMU_Clock_TypeDef |
clock
|
) |
Get clock divisor.
- Parameters
-
[in] clock
Clock point to get divisor for. Notice that not all clock points have a divisors. Please refer to CMU overview in reference manual.
- Returns
-
The current clock point divisor. 1 is returned if
clock
specifies a clock point without divisor.
Definition at line
466
of file
em_cmu.c
.
References _CMU_EXPORTCLKCTRL_PRESC_MASK , _CMU_EXPORTCLKCTRL_PRESC_SHIFT , _CMU_SYSCLKCTRL_HCLKPRESC_MASK , _CMU_SYSCLKCTRL_HCLKPRESC_SHIFT , _CMU_SYSCLKCTRL_PCLKPRESC_MASK , _CMU_SYSCLKCTRL_PCLKPRESC_SHIFT , CMU , cmuClock_CORE , cmuClock_EXPCLK , cmuClock_HCLK , and cmuClock_PCLK .
Referenced by CMU_ClockFreqGet() , CMU_DPLLLock() , and UDELAY_Calibrate() .
void CMU_ClockDivSet | ( | CMU_Clock_TypeDef |
clock,
|
CMU_ClkDiv_TypeDef |
div
|
||
) |
Set clock divisor.
- Parameters
-
[in] clock
Clock point to set divisor for. Notice that not all clock points have a divisor, please refer to CMU overview in the reference manual. [in] div
The clock divisor to use.
Definition at line
509
of file
em_cmu.c
.
References
_CMU_EXPORTCLKCTRL_PRESC_MASK
,
_CMU_EXPORTCLKCTRL_PRESC_SHIFT
,
_CMU_SYSCLKCTRL_HCLKPRESC_MASK
,
_CMU_SYSCLKCTRL_HCLKPRESC_SHIFT
,
_CMU_SYSCLKCTRL_PCLKPRESC_MASK
,
_CMU_SYSCLKCTRL_PCLKPRESC_SHIFT
,
CMU
,
CMU_UpdateWaitStates()
,
cmuClock_CORE
,
cmuClock_EXPCLK
,
cmuClock_HCLK
,
cmuClock_PCLK
, and
SystemCoreClockGet()
.
Referenced by CAPLESENSE_setupCMU() , CMU_DPLLLock() , RETARGET_SerialInit() , RTCDRV_Init() , SegmentLCD_Init() , and UDELAY_Calibrate() .
__STATIC_INLINE void CMU_ClockEnable | ( | CMU_Clock_TypeDef |
clock,
|
bool |
enable
|
||
) |
Enable/disable a clock.
- Note
- This is a dummy function to solve backward compatibility issues.
- Parameters
-
[in] clock
The clock to enable/disable. [in] enable
- true - enable specified clock.
- false - disable specified clock.
Definition at line
564
of file
em_cmu.h
.
Referenced by adcInit() , BOARD_init() , BSP_BccDeInit() , BSP_BccInit() , BSP_BusControlModeSet() , BSP_EbiInit() , BSP_initBoard() , BSP_McuBoard_Init() , CAPLESENSE_setupCMU() , CAPSENSE_Init() , DMADRV_DeInit() , ezradio_hal_GpioInit() , gpioInit() , I2CSPM_Init() , ICM20648_spiInit() , initEbiCommon() , initGpio() , LDMA_DeInit() , LDMA_Init() , MIC_init() , MICROSD_Init() , MICROSD_PowerOff() , MICROSD_PowerOn() , mscEccReadWriteExistingDma() , MSDD_Init() , RETARGET_SerialInit() , RTCDRV_DeInit() , RTCDRV_Init() , SegmentLCD_Disable() , SegmentLCD_Init() , SPI_TFT_Init() , SPIDRV_DeInit() , SPIDRV_Init() , TOUCH_Init() , UARTDRV_DeInit() , 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
559
of file
em_cmu.c
.
References CMU_ClockDivGet() , cmuClock_BURTC , cmuClock_CORE , cmuClock_DPLLREFCLK , cmuClock_EM01GRPACLK , cmuClock_EM23GRPACLK , cmuClock_EM4GRPACLK , cmuClock_EXPCLK , cmuClock_GPCRC , cmuClock_GPIO , cmuClock_HCLK , cmuClock_I2C0 , cmuClock_I2C1 , cmuClock_IADC0 , cmuClock_IADCCLK , cmuClock_LDMA , cmuClock_LETIMER0 , cmuClock_LSPCLK , cmuClock_PCLK , cmuClock_PRS , cmuClock_RTCC , cmuClock_RTCCCLK , cmuClock_SYSCLK , cmuClock_SYSTICK , cmuClock_TIMER0 , cmuClock_TIMER1 , cmuClock_TIMER2 , cmuClock_TIMER3 , cmuClock_TRACECLK , cmuClock_USART0 , cmuClock_USART1 , cmuClock_USART2 , cmuClock_WDOG0 , cmuClock_WDOG0CLK , cmuClock_WDOG1 , cmuClock_WDOG1CLK , SystemHCLKGet() , and SystemSYSCLKGet() .
Referenced by BSP_TraceProfilerSetup() , I2C_BusFreqGet() , I2C_BusFreqSet() , IADC_calcAdcClkPrescale() , IADC_calcSrcClkPrescale() , IADC_calcTimebase() , MIC_init() , 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.
- Returns
-
Reference clock used for clocking selected branch,
cmuSelect_Error
if invalid
clock
provided.
Definition at line
659
of file
em_cmu.c
.
References _CMU_SYSCLKCTRL_CLKSEL_CLKIN0 , _CMU_SYSCLKCTRL_CLKSEL_FSRCO , _CMU_SYSCLKCTRL_CLKSEL_HFRCODPLL , _CMU_SYSCLKCTRL_CLKSEL_HFXO , _CMU_SYSCLKCTRL_CLKSEL_MASK , CMU , cmuClock_BURTC , cmuClock_DPLLREFCLK , cmuClock_EM01GRPACLK , cmuClock_EM23GRPACLK , cmuClock_EM4GRPACLK , cmuClock_IADC0 , cmuClock_IADCCLK , cmuClock_LETIMER0 , cmuClock_RTCC , cmuClock_RTCCCLK , cmuClock_SYSCLK , cmuClock_SYSTICK , cmuClock_TIMER0 , cmuClock_TIMER1 , cmuClock_TIMER2 , cmuClock_TIMER3 , cmuClock_TRACECLK , cmuClock_WDOG0 , cmuClock_WDOG0CLK , cmuClock_WDOG1 , cmuClock_WDOG1CLK , cmuSelect_CLKIN0 , cmuSelect_Error , cmuSelect_FSRCO , cmuSelect_HFRCODPLL , and cmuSelect_HFXO .
Referenced by CMU_DPLLLock() , CMU_HFRCODPLLBandSet() , CMU_HFXOInit() , and UDELAY_Calibrate() .
void CMU_ClockSelectSet | ( | CMU_Clock_TypeDef |
clock,
|
CMU_Select_TypeDef |
ref
|
||
) |
Select reference clock/oscillator used for a clock branch.
- Parameters
-
[in] clock
Clock branch to select reference clock for. [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
765
of file
em_cmu.c
.
References
_CMU_DPLLREFCLKCTRL_CLKSEL_MASK
,
_CMU_EM01GRPACLKCTRL_CLKSEL_MASK
,
_CMU_EM23GRPACLKCTRL_CLKSEL_MASK
,
_CMU_EM4GRPACLKCTRL_CLKSEL_MASK
,
_CMU_IADCCLKCTRL_CLKSEL_MASK
,
_CMU_RTCCCLKCTRL_CLKSEL_MASK
,
_CMU_SYSCLKCTRL_CLKSEL_MASK
,
_CMU_TRACECLKCTRL_CLKSEL_MASK
,
_CMU_WDOG0CLKCTRL_CLKSEL_MASK
,
_CMU_WDOG1CLKCTRL_CLKSEL_MASK
,
CMU
,
CMU_DPLLREFCLKCTRL_CLKSEL_CLKIN0
,
CMU_DPLLREFCLKCTRL_CLKSEL_DISABLED
,
CMU_DPLLREFCLKCTRL_CLKSEL_HFXO
,
CMU_DPLLREFCLKCTRL_CLKSEL_LFXO
,
CMU_EM01GRPACLKCTRL_CLKSEL_FSRCO
,
CMU_EM01GRPACLKCTRL_CLKSEL_HFRCODPLL
,
CMU_EM01GRPACLKCTRL_CLKSEL_HFRCOEM23
,
CMU_EM01GRPACLKCTRL_CLKSEL_HFXO
,
CMU_EM23GRPACLKCTRL_CLKSEL_LFRCO
,
CMU_EM23GRPACLKCTRL_CLKSEL_LFXO
,
CMU_EM23GRPACLKCTRL_CLKSEL_ULFRCO
,
CMU_EM4GRPACLKCTRL_CLKSEL_LFRCO
,
CMU_EM4GRPACLKCTRL_CLKSEL_LFXO
,
CMU_EM4GRPACLKCTRL_CLKSEL_ULFRCO
,
CMU_IADCCLKCTRL_CLKSEL_EM01GRPACLK
,
CMU_IADCCLKCTRL_CLKSEL_FSRCO
,
CMU_IADCCLKCTRL_CLKSEL_HFRCOEM23
,
CMU_RTCCCLKCTRL_CLKSEL_LFRCO
,
CMU_RTCCCLKCTRL_CLKSEL_LFXO
,
CMU_RTCCCLKCTRL_CLKSEL_ULFRCO
,
CMU_SYSCLKCTRL_CLKSEL_CLKIN0
,
CMU_SYSCLKCTRL_CLKSEL_FSRCO
,
CMU_SYSCLKCTRL_CLKSEL_HFRCODPLL
,
CMU_SYSCLKCTRL_CLKSEL_HFXO
,
CMU_TRACECLKCTRL_CLKSEL_HCLK
,
CMU_TRACECLKCTRL_CLKSEL_HFRCOEM23
,
CMU_UpdateWaitStates()
,
CMU_WDOG0CLKCTRL_CLKSEL_HCLKDIV1024
,
CMU_WDOG0CLKCTRL_CLKSEL_LFRCO
,
CMU_WDOG0CLKCTRL_CLKSEL_LFXO
,
CMU_WDOG0CLKCTRL_CLKSEL_ULFRCO
,
CMU_WDOG1CLKCTRL_CLKSEL_HCLKDIV1024
,
CMU_WDOG1CLKCTRL_CLKSEL_LFRCO
,
CMU_WDOG1CLKCTRL_CLKSEL_LFXO
,
CMU_WDOG1CLKCTRL_CLKSEL_ULFRCO
,
cmuClock_BURTC
,
cmuClock_DPLLREFCLK
,
cmuClock_EM01GRPACLK
,
cmuClock_EM23GRPACLK
,
cmuClock_EM4GRPACLK
,
cmuClock_IADC0
,
cmuClock_IADCCLK
,
cmuClock_LETIMER0
,
cmuClock_RTCC
,
cmuClock_RTCCCLK
,
cmuClock_SYSCLK
,
cmuClock_SYSTICK
,
cmuClock_TIMER0
,
cmuClock_TIMER1
,
cmuClock_TIMER2
,
cmuClock_TIMER3
,
cmuClock_TRACECLK
,
cmuClock_WDOG0
,
cmuClock_WDOG0CLK
,
cmuClock_WDOG1
,
cmuClock_WDOG1CLK
,
cmuSelect_CLKIN0
,
cmuSelect_Disabled
,
cmuSelect_EM01GRPACLK
,
cmuSelect_FSRCO
,
cmuSelect_HCLK
,
cmuSelect_HCLKDIV1024
,
cmuSelect_HFRCODPLL
,
cmuSelect_HFRCOEM23
,
cmuSelect_HFXO
,
cmuSelect_LFRCO
,
cmuSelect_LFXO
,
cmuSelect_ULFRCO
,
HFXO0
,
HFXO_CTRL_DISONDEMAND
,
HFXO_CTRL_FORCEEN
, and
SystemCoreClockGet()
.
Referenced by BSP_BccInit() , BSP_initClocks() , CAPLESENSE_setupCMU() , CMU_DPLLLock() , MIC_init() , RETARGET_SerialInit() , RTCDRV_Init() , SegmentLCD_Init() , and UDELAY_Calibrate() .
bool CMU_DPLLLock | ( | const CMU_DPLLInit_TypeDef * |
init
|
) |
Lock the DPLL to a given frequency. The frequency is given by: Fout = Fref * (N+1) / (M+1).
- Note
-
This function does not check if the given N & M values will actually produce the desired target frequency.
N & M limitations:
300 < N <= 4095
0 <= M <= 4095
Any peripheral running off HFRCODPLL should be switched to a lower frequency clock (if possible) prior to calling this function to avoid over-clocking.
- Parameters
-
[in] init
DPLL setup parameter struct.
- Returns
- Returns false on invalid target frequency or DPLL locking error.
Definition at line
1081
of file
em_cmu.c
.
References
_DPLL_CFG1_M_MASK
,
_DPLL_CFG1_M_SHIFT
,
_DPLL_CFG1_N_MASK
,
_DPLL_CFG1_N_SHIFT
,
_DPLL_CFG_AUTORECOVER_SHIFT
,
_DPLL_CFG_DITHEN_SHIFT
,
_DPLL_CFG_EDGESEL_SHIFT
,
_DPLL_CFG_MODE_SHIFT
,
_HFRCO_CAL_TUNING_MASK
,
_HFRCO_CAL_TUNING_SHIFT
,
CMU_DPLLInit_TypeDef::autoRecover
,
CMU_ClockDivGet()
,
CMU_ClockDivSet()
,
CMU_ClockSelectGet()
,
CMU_ClockSelectSet()
,
CMU_UpdateWaitStates()
,
cmuClock_DPLLREFCLK
,
cmuClock_HCLK
,
cmuClock_SYSCLK
,
cmuSelect_HFRCODPLL
,
CMU_DPLLInit_TypeDef::ditherEn
,
DPLL0
,
DPLL_EN_EN
,
DPLL_IF_LOCK
,
DPLL_IF_LOCKFAILHIGH
,
DPLL_IF_LOCKFAILLOW
,
DPLL_STATUS_ENS
,
DPLL_STATUS_RDY
,
CMU_DPLLInit_TypeDef::edgeSel
,
CMU_DPLLInit_TypeDef::frequency
,
HFRCO0
,
CMU_DPLLInit_TypeDef::lockMode
,
CMU_DPLLInit_TypeDef::m
,
CMU_DPLLInit_TypeDef::n
,
CMU_DPLLInit_TypeDef::refClk
,
SystemCoreClockGet()
,
SystemHFRCODPLLClockGet()
, and
SystemHFRCODPLLClockSet()
.
Referenced by BSP_initClocks() .
__STATIC_INLINE void CMU_DPLLUnlock | ( | void |
|
) |
Unlock the DPLL.
- Note
- The HFRCODPLL oscillator is not turned off.
Definition at line
576
of file
em_cmu.h
.
References DPLL0 , and DPLL_EN_EN .
CMU_HFRCODPLLFreq_TypeDef CMU_HFRCODPLLBandGet | ( | void |
|
) |
Get HFRCODPLL band in use.
- Returns
- HFRCODPLL band in use.
Definition at line
1191
of file
em_cmu.c
.
References SystemHFRCODPLLClockGet() .
void CMU_HFRCODPLLBandSet | ( | CMU_HFRCODPLLFreq_TypeDef |
freq
|
) |
Set HFRCODPLL band and the tuning value based on the value in the calibration table made during production.
- Parameters
-
[in] freq
HFRCODPLL frequency band to activate.
Definition at line
1204
of file
em_cmu.c
.
References
_HFRCO_CAL_CLKDIV_MASK
,
CMU_ClockSelectGet()
,
CMU_UpdateWaitStates()
,
cmuClock_SYSCLK
,
cmuHFRCODPLLFreq_1M0Hz
,
cmuHFRCODPLLFreq_2M0Hz
,
cmuSelect_HFRCODPLL
,
DPLL0
,
DPLL_EN_EN
,
DPLL_STATUS_ENS
,
DPLL_STATUS_RDY
,
HFRCO0
,
HFRCO_CAL_CLKDIV_DIV2
,
HFRCO_CAL_CLKDIV_DIV4
,
SystemCoreClockGet()
, and
SystemHFRCODPLLClockSet()
.
CMU_HFRCOEM23Freq_TypeDef CMU_HFRCOEM23BandGet | ( | void |
|
) |
Get HFRCOEM23 band in use.
- Returns
- HFRCOEM23 band in use.
Definition at line
1264
of file
em_cmu.c
.
References SystemHFRCOEM23ClockGet() .
void CMU_HFRCOEM23BandSet | ( | CMU_HFRCOEM23Freq_TypeDef |
freq
|
) |
Set HFRCOEM23 band and the tuning value based on the value in the calibration table made during production.
- Parameters
-
[in] freq
HFRCOEM23 frequency band to activate.
Definition at line
1277
of file
em_cmu.c
.
References _HFRCO_CAL_CLKDIV_MASK , cmuHFRCOEM23Freq_1M0Hz , cmuHFRCOEM23Freq_2M0Hz , HFRCO_CAL_CLKDIV_DIV2 , HFRCO_CAL_CLKDIV_DIV4 , and HFRCOEM23 .
void CMU_HFXOInit | ( | const CMU_HFXOInit_TypeDef * |
hfxoInit
|
) |
Initialize all HFXO control registers.
- Note
- HFXO configuration should be obtained from a configuration tool, app note or xtal datasheet. This function returns early if HFXO is already selected as SYSCLK.
- Parameters
-
[in] hfxoInit
HFXO setup parameters.
Definition at line
1316
of file
em_cmu.c
.
References _HFXO_CFG_ENXIDCBIASANA_MASK , _HFXO_CFG_ENXIDCBIASANA_SHIFT , _HFXO_CFG_MODE_MASK , _HFXO_CFG_MODE_SHIFT , _HFXO_CFG_SQBUFSCHTRGANA_MASK , _HFXO_CTRL_DISONDEMAND_MASK , _HFXO_CTRL_DISONDEMAND_SHIFT , _HFXO_CTRL_FORCEEN_MASK , _HFXO_CTRL_FORCEEN_SHIFT , _HFXO_CTRL_FORCEXI2GNDANA_MASK , _HFXO_CTRL_FORCEXI2GNDANA_SHIFT , _HFXO_CTRL_FORCEXO2GNDANA_MASK , _HFXO_CTRL_FORCEXO2GNDANA_SHIFT , _HFXO_STATUS_ENS_MASK , _HFXO_XTALCFG_COREBIASSTARTUP_MASK , _HFXO_XTALCFG_COREBIASSTARTUP_SHIFT , _HFXO_XTALCFG_COREBIASSTARTUPI_MASK , _HFXO_XTALCFG_COREBIASSTARTUPI_SHIFT , _HFXO_XTALCFG_CTUNEXISTARTUP_MASK , _HFXO_XTALCFG_CTUNEXISTARTUP_SHIFT , _HFXO_XTALCFG_CTUNEXOSTARTUP_MASK , _HFXO_XTALCFG_CTUNEXOSTARTUP_SHIFT , _HFXO_XTALCFG_TIMEOUTCBLSB_MASK , _HFXO_XTALCFG_TIMEOUTCBLSB_SHIFT , _HFXO_XTALCFG_TIMEOUTSTEADY_MASK , _HFXO_XTALCFG_TIMEOUTSTEADY_SHIFT , _HFXO_XTALCTRL_COREBIASANA_SHIFT , _HFXO_XTALCTRL_COREDGENANA_MASK , _HFXO_XTALCTRL_COREDGENANA_SHIFT , _HFXO_XTALCTRL_CTUNEFIXANA_MASK , _HFXO_XTALCTRL_CTUNEFIXANA_SHIFT , _HFXO_XTALCTRL_CTUNEXIANA_SHIFT , _HFXO_XTALCTRL_CTUNEXOANA_SHIFT , CMU_ClockSelectGet() , cmuClock_SYSCLK , cmuHfxoOscMode_Crystal , cmuSelect_HFXO , CMU_HFXOInit_TypeDef::coreBiasAna , CMU_HFXOInit_TypeDef::coreBiasStartup , CMU_HFXOInit_TypeDef::coreDegenAna , CMU_HFXOInit_TypeDef::ctuneFixAna , CMU_HFXOInit_TypeDef::ctuneXiAna , CMU_HFXOInit_TypeDef::ctuneXiStartup , CMU_HFXOInit_TypeDef::ctuneXoAna , CMU_HFXOInit_TypeDef::ctuneXoStartup , CMU_HFXOInit_TypeDef::disOnDemand , CMU_HFXOInit_TypeDef::enXiDcBiasAna , CMU_HFXOInit_TypeDef::forceEn , CMU_HFXOInit_TypeDef::forceXi2GndAna , CMU_HFXOInit_TypeDef::forceXo2GndAna , HFXO0 , HFXO_CFG_SQBUFSCHTRGANA , HFXO_CTRL_DISONDEMAND , HFXO_CTRL_FORCEEN , HFXO_LOCK_LOCKKEY_UNLOCK , HFXO_STATUS_COREBIASOPTRDY , HFXO_STATUS_ENS , HFXO_STATUS_FSMLOCK , HFXO_STATUS_RDY , HFXO_XTALCTRL_SKIPCOREBIASOPT , CMU_HFXOInit_TypeDef::imCoreBiasStartup , CMU_HFXOInit_TypeDef::mode , CMU_HFXOInit_TypeDef::regLock , CMU_HFXOInit_TypeDef::timeoutCbLsb , CMU_HFXOInit_TypeDef::timeoutSteady , and CMU_HFXOInit_TypeDef::timeoutSteadyFirstLock .
Referenced by BSP_initClocks() .
__STATIC_INLINE void CMU_IntClear | ( | uint32_t |
flags
|
) |
Clear one or more pending CMU interrupt flags.
- Parameters
-
[in] flags
CMU interrupt sources to clear.
Definition at line
588
of file
em_cmu.h
.
References CMU .
__STATIC_INLINE void CMU_IntDisable | ( | uint32_t |
flags
|
) |
Disable one or more CMU interrupt sources.
- Parameters
-
[in] flags
CMU interrupt sources to disable.
Definition at line
600
of file
em_cmu.h
.
References CMU .
__STATIC_INLINE void CMU_IntEnable | ( | uint32_t |
flags
|
) |
Enable one or more CMU interrupt sources.
- 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
617
of file
em_cmu.h
.
References CMU .
__STATIC_INLINE uint32_t CMU_IntGet | ( | void |
|
) |
Get pending CMU interrupt sources.
- Returns
- CMU interrupt sources pending.
Definition at line
629
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
650
of file
em_cmu.h
.
References CMU .
__STATIC_INLINE void CMU_IntSet | ( | uint32_t |
flags
|
) |
Set one or more pending CMU interrupt sources.
- Parameters
-
[in] flags
CMU interrupt sources to set to pending.
Definition at line
665
of file
em_cmu.h
.
References CMU .
void CMU_LFXOInit | ( | const CMU_LFXOInit_TypeDef * |
lfxoInit
|
) |
Initialize 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
1457
of file
em_cmu.c
.
References _LFXO_CAL_CAPTUNE_MASK , _LFXO_CAL_CAPTUNE_SHIFT , _LFXO_CAL_GAIN_MASK , _LFXO_CAL_GAIN_SHIFT , _LFXO_CFG_AGC_SHIFT , _LFXO_CFG_HIGHAMPL_SHIFT , _LFXO_CFG_MODE_MASK , _LFXO_CFG_MODE_SHIFT , _LFXO_CFG_TIMEOUT_MASK , _LFXO_CFG_TIMEOUT_SHIFT , _LFXO_CTRL_DISONDEMAND_SHIFT , _LFXO_CTRL_FAILDETEM4WUEN_SHIFT , _LFXO_CTRL_FAILDETEN_SHIFT , _LFXO_CTRL_FORCEEN_SHIFT , _LFXO_STATUS_ENS_MASK , CMU_LFXOInit_TypeDef::agcEn , CMU_LFXOInit_TypeDef::capTune , CMU_LFXOInit_TypeDef::disOnDemand , CMU_LFXOInit_TypeDef::failDetEM4WUEn , CMU_LFXOInit_TypeDef::failDetEn , CMU_LFXOInit_TypeDef::forceEn , CMU_LFXOInit_TypeDef::gain , CMU_LFXOInit_TypeDef::highAmplitudeEn , LFXO , LFXO_CTRL_DISONDEMAND , LFXO_CTRL_FORCEEN , LFXO_LOCK_LOCKKEY_UNLOCK , CMU_LFXOInit_TypeDef::mode , CMU_LFXOInit_TypeDef::regLock , SL_MIN , and CMU_LFXOInit_TypeDef::timeout .
Referenced by BSP_initClocks() .
__STATIC_INLINE void CMU_Lock | ( | void |
|
) |
Lock CMU register access in order to protect registers contents 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
683
of file
em_cmu.h
.
References CMU , and CMU_LOCK_LOCKKEY_UNLOCK .
Referenced by EMU_EnterEM3() .
__STATIC_INLINE void CMU_OscillatorEnable | ( | CMU_Osc_TypeDef |
osc,
|
bool |
enable,
|
||
bool |
wait
|
||
) |
Enable/disable oscillator.
- Note
- This is a dummy function to solve backward compatibility issues.
- 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
708
of file
em_cmu.h
.
Referenced by BSP_initClocks() , DBG_SWOEnable() , 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.
- Returns
- The oscillator frequency tuning setting in use.
Definition at line
1509
of file
em_cmu.c
.
References _HFRCO_CAL_TUNING_MASK , _HFRCO_CAL_TUNING_SHIFT , _LFRCO_CAL_FREQTRIM_MASK , _LFRCO_CAL_FREQTRIM_SHIFT , cmuOsc_HFRCODPLL , cmuOsc_HFRCOEM23 , cmuOsc_LFRCO , HFRCO0 , HFRCOEM23 , and LFRCO .
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. [in] val
The oscillator frequency tuning setting to use.
Definition at line
1552
of file
em_cmu.c
.
References _HFRCO_CAL_TUNING_MASK , _HFRCO_CAL_TUNING_SHIFT , _LFRCO_CAL_FREQTRIM_MASK , _LFRCO_CAL_FREQTRIM_SHIFT , cmuOsc_HFRCODPLL , cmuOsc_HFRCOEM23 , cmuOsc_LFRCO , HFRCO0 , HFRCO_STATUS_SYNCBUSY , HFRCOEM23 , and LFRCO .
void CMU_UpdateWaitStates | ( | uint32_t |
freq,
|
int |
vscale
|
||
) |
Configure wait state settings necessary to switch to a given core clock frequency.
This function will setup the necessary flash and RAM wait states. Updating the wait state configuration must be done before increasing the clock frequency, and it must be done after decreasing the clock frequency.
- Parameters
-
[in] freq
Core clock frequency to configure wait-states for.
Definition at line
1601
of file
em_cmu.c
.
Referenced by CMU_ClockDivSet() , CMU_ClockSelectSet() , CMU_DPLLLock() , and CMU_HFRCODPLLBandSet() .
__STATIC_INLINE void CMU_WdogLock | ( | void |
|
) |
Lock WDOG register access in order to protect registers contents against unintended modification.
- Note
- If locking the WDOG registers, they must be unlocked prior to using any emlib API functions modifying registers protected by the lock.
Definition at line
735
of file
em_cmu.h
.
References CMU , and CMU_WDOGLOCK_LOCKKEY_UNLOCK .