system_efr32bg21.c File Reference

CMSIS Cortex-M33 system support for EFR32BG21 devices.

Version
5.8.0

License

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

SPDX-License-Identifier: Zlib

The licensor of this software is Silicon Laboratories Inc.

This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software.

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. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
  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.

Definition in file system_efr32bg21.c.

#include <stdint.h>
#include "em_device.h"

Macros

#define CLKIN0_FREQ   (0UL)
 
#define FSRCO_FREQ   (20000000UL)
 
#define HFRCODPLL_MAX_FREQ   (80000000UL)
 
#define HFRCODPLL_STARTUP_FREQ   (19000000UL)
 
#define HFXO_FREQ   (38400000UL)
 
#define LFRCO_FREQ   (32768UL)
 
#define LFXO_FREQ   (LFRCO_FREQ)
 
#define ULFRCO_FREQ   (1000UL)
 

Functions

uint32_t SystemCLKIN0Get (void)
 Get current CLKIN0 frequency.
 
uint32_t SystemFSRCOClockGet (void)
 Get FSRCO frequency.
 
uint32_t SystemHCLKGet (void)
 Get the current system core clock frequency (HCLK).
 
uint32_t SystemHFRCODPLLClockGet (void)
 Get current HFRCODPLL frequency.
 
void SystemHFRCODPLLClockSet (uint32_t freq)
 Set HFRCODPLL frequency value.
 
uint32_t SystemHFRCOEM23ClockGet (void)
 Get current HFRCOEM23 frequency.
 
uint32_t SystemHFXOClockGet (void)
 Get high frequency crystal oscillator clock frequency for target system.
 
void SystemHFXOClockSet (uint32_t freq)
 Set high frequency crystal oscillator clock frequency for target system.
 
void SystemInit (void)
 Initialize the system.
 
uint32_t SystemLFRCOClockGet (void)
 Get low frequency RC oscillator clock frequency for target system.
 
uint32_t SystemLFXOClockGet (void)
 Get low frequency crystal oscillator clock frequency for target system.
 
void SystemLFXOClockSet (uint32_t freq)
 Set low frequency crystal oscillator clock frequency for target system.
 
uint32_t SystemMaxCoreClockGet (void)
 Get the maximum core clock frequency.
 
uint32_t SystemSYSCLKGet (void)
 Get the current system clock frequency (SYSCLK).
 
uint32_t SystemULFRCOClockGet (void)
 Get ultra low frequency RC oscillator clock frequency for target system.
 

Variables

uint32_t __Vectors
 
uint32_t SystemCoreClock = HFRCODPLL_STARTUP_FREQ
 System System Clock Frequency (Core Clock).
 
static uint32_t SystemHFRCODPLLClock = HFRCODPLL_STARTUP_FREQ
 
static uint32_t SystemHFXOClock = HFXO_FREQ
 
static uint32_t SystemLFXOClock = LFXO_FREQ
 

Function Documentation

uint32_t SystemCLKIN0Get ( void  )

Get current CLKIN0 frequency.

Note
This is a EFR32BG21 specific function, not part of the CMSIS definition.
Returns
CLKIN0 frequency in Hz.

Definition at line 450 of file system_efr32bg21.c.

Referenced by dpllRefClkGet().

uint32_t SystemFSRCOClockGet ( void  )

Get FSRCO frequency.

Note
This is a EFR32BG21 specific function, not part of the CMSIS definition.
Returns
FSRCO frequency in Hz.

Definition at line 466 of file system_efr32bg21.c.

Referenced by em01GrpaClkGet(), and iadcClkGet().

uint32_t SystemHCLKGet ( void  )

Get the current system core clock frequency (HCLK).

Calculate and get the current core clock frequency based on the current configuration. Assuming that the SystemCoreClock global variable is maintained, the core clock frequency is stored in that variable as well. This function will however calculate the core clock based on actual HW configuration. It will also update the SystemCoreClock global variable.

Note
This is a EFR32BG21 specific function, not part of the CMSIS definition.
Returns
The current core clock (HCLK) frequency in Hz.

Definition at line 233 of file system_efr32bg21.c.

References _CMU_SYSCLKCTRL_HCLKPRESC_MASK, _CMU_SYSCLKCTRL_HCLKPRESC_SHIFT, CMU, SystemCoreClock, and SystemSYSCLKGet().

Referenced by CMU_ClockFreqGet(), SystemCoreClockGet(), SystemCoreClockUpdate(), SystemHFXOClockSet(), and wdog0ClkGet().

uint32_t SystemHFRCODPLLClockGet ( void  )

Get current HFRCODPLL frequency.

Note
This is a EFR32BG21 specific function, not part of the CMSIS definition.
Returns
HFRCODPLL frequency in Hz.

Definition at line 338 of file system_efr32bg21.c.

References _HFRCO_CAL_CLKDIV_MASK, _HFRCO_CAL_FREQRANGE_MASK, _HFRCO_CAL_FREQRANGE_SHIFT, HFRCO0, HFRCO_CAL_CLKDIV_DIV1, HFRCO_CAL_CLKDIV_DIV2, and HFRCO_CAL_CLKDIV_DIV4.

Referenced by CMU_DPLLLock(), CMU_HFRCODPLLBandGet(), em01GrpaClkGet(), and SystemSYSCLKGet().

void SystemHFRCODPLLClockSet ( uint32_t  freq)

Set HFRCODPLL frequency value.

Note
This is a EFR32BG21 specific function, not part of the CMSIS definition.
Parameters
[in]freqHFRCODPLL frequency in Hz.

Definition at line 430 of file system_efr32bg21.c.

Referenced by CMU_DPLLLock(), and CMU_HFRCODPLLBandSet().

uint32_t SystemHFRCOEM23ClockGet ( void  )

Get current HFRCOEM23 frequency.

Note
This is a EFR32BG21 specific function, not part of the CMSIS definition.
Returns
HFRCOEM23 frequency in Hz.

Definition at line 482 of file system_efr32bg21.c.

References _HFRCO_CAL_CLKDIV_MASK, _HFRCO_CAL_FREQRANGE_MASK, _HFRCO_CAL_FREQRANGE_SHIFT, HFRCO_CAL_CLKDIV_DIV1, HFRCO_CAL_CLKDIV_DIV2, HFRCO_CAL_CLKDIV_DIV4, and HFRCOEM23.

Referenced by CMU_HFRCOEM23BandGet(), em01GrpaClkGet(), and iadcClkGet().

uint32_t SystemHFXOClockGet ( void  )

Get high frequency crystal oscillator clock frequency for target system.

Note
This is a EFR32BG21 specific function, not part of the CMSIS definition.
Returns
HFXO frequency in Hz. 0 if the external crystal oscillator is not present.

Definition at line 280 of file system_efr32bg21.c.

Referenced by CMU_LFRCOSetPrecision(), dpllRefClkGet(), and em01GrpaClkGet().

void SystemHFXOClockSet ( uint32_t  freq)

Set high frequency crystal oscillator clock frequency for target system.

Note
This function is mainly provided for being able to handle target systems with different HF crystal oscillator frequencies run-time. If used, it should probably only be used once during system startup.
This is a EFR32BG21 specific function, not part of the CMSIS definition.
Parameters
[in]freqHFXO frequency in Hz used for target.

Definition at line 310 of file system_efr32bg21.c.

References _CMU_SYSCLKCTRL_CLKSEL_HFXO, _CMU_SYSCLKCTRL_CLKSEL_MASK, CMU, and SystemHCLKGet().

Referenced by BSP_initClocks().

void SystemInit ( void  )

Initialize the system.

Do required generic HW system init.

Note
This function is invoked during system init, before the main() routine and any data has been initialized. For this reason, it cannot do any initialization of variables etc.

Definition at line 146 of file system_efr32bg21.c.

uint32_t SystemLFRCOClockGet ( void  )

Get low frequency RC oscillator clock frequency for target system.

Note
This is a EFR32BG21 specific function, not part of the CMSIS definition.
Returns
LFRCO frequency in Hz.

Definition at line 549 of file system_efr32bg21.c.

Referenced by em23GrpaClkGet(), em4GrpaClkGet(), rtccClkGet(), and wdog0ClkGet().

uint32_t SystemLFXOClockGet ( void  )

Get low frequency crystal oscillator clock frequency for target system.

Note
This is a EFR32BG21 specific function, not part of the CMSIS definition.
Returns
LFXO frequency in Hz.

Definition at line 582 of file system_efr32bg21.c.

Referenced by dpllRefClkGet(), em23GrpaClkGet(), em4GrpaClkGet(), rtccClkGet(), and wdog0ClkGet().

void SystemLFXOClockSet ( uint32_t  freq)

Set low frequency crystal oscillator clock frequency for target system.

Note
This function is mainly provided for being able to handle target systems with different HF crystal oscillator frequencies run-time. If used, it should probably only be used once during system startup.
This is a EFR32BG21 specific function, not part of the CMSIS definition.
Parameters
[in]freqLFXO frequency in Hz used for target.

Definition at line 612 of file system_efr32bg21.c.

Referenced by BSP_initClocks().

uint32_t SystemMaxCoreClockGet ( void  )

Get the maximum core clock frequency.

Note
This is a EFR32BG21 specific function, not part of the CMSIS definition.
Returns
The maximum core clock frequency in Hz.

Definition at line 263 of file system_efr32bg21.c.

Referenced by waitStateMax().

uint32_t SystemSYSCLKGet ( void  )

Get the current system clock frequency (SYSCLK).

Calculate and get the current core clock frequency based on the current hardware configuration.

Note
This is an EFR32BG21 specific function, not part of the CMSIS definition.
Returns
Current system clock (SYSCLK) frequency in Hz.

Definition at line 177 of file system_efr32bg21.c.

References _CMU_SYSCLKCTRL_CLKSEL_CLKIN0, _CMU_SYSCLKCTRL_CLKSEL_FSRCO, _CMU_SYSCLKCTRL_CLKSEL_HFRCODPLL, _CMU_SYSCLKCTRL_CLKSEL_HFXO, _CMU_SYSCLKCTRL_CLKSEL_MASK, CMU, and SystemHFRCODPLLClockGet().

Referenced by CMU_ClockFreqGet(), and SystemHCLKGet().

uint32_t SystemULFRCOClockGet ( void  )

Get ultra low frequency RC oscillator clock frequency for target system.

Note
This is a EFR32BG21 specific function, not part of the CMSIS definition.
Returns
ULFRCO frequency in Hz.

Definition at line 565 of file system_efr32bg21.c.

Referenced by em23GrpaClkGet(), em4GrpaClkGet(), rtccClkGet(), and wdog0ClkGet().

Variable Documentation

uint32_t SystemCoreClock = HFRCODPLL_STARTUP_FREQ

System System Clock Frequency (Core Clock).

Required CMSIS global variable that must be kept up-to-date.

Definition at line 127 of file system_efr32bg21.c.

Referenced by SystemHCLKGet().