Aravind Vadali / mbed-src-RatRacerAV

Fork of mbed-src by mbed official

Committer:
mbed_official
Date:
Tue Apr 28 11:45:12 2015 +0100
Revision:
525:c320967f86b9
Synchronized with git revision 299385b8331142b9dc524da7a986536f60b14553

Full URL: https://github.com/mbedmicro/mbed/commit/299385b8331142b9dc524da7a986536f60b14553/

Add in Silicon Labs targets with asynchronous API support

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mbed_official 525:c320967f86b9 1 /***************************************************************************//**
mbed_official 525:c320967f86b9 2 * @file system_efm32wg.c
mbed_official 525:c320967f86b9 3 * @brief CMSIS Cortex-M4 System Layer for EFM32WG devices.
mbed_official 525:c320967f86b9 4 * @version 3.20.6
mbed_official 525:c320967f86b9 5 ******************************************************************************
mbed_official 525:c320967f86b9 6 * @section License
mbed_official 525:c320967f86b9 7 * <b>(C) Copyright 2014 Silicon Laboratories, Inc. http://www.silabs.com</b>
mbed_official 525:c320967f86b9 8 ******************************************************************************
mbed_official 525:c320967f86b9 9 *
mbed_official 525:c320967f86b9 10 * Permission is granted to anyone to use this software for any purpose,
mbed_official 525:c320967f86b9 11 * including commercial applications, and to alter it and redistribute it
mbed_official 525:c320967f86b9 12 * freely, subject to the following restrictions:
mbed_official 525:c320967f86b9 13 *
mbed_official 525:c320967f86b9 14 * 1. The origin of this software must not be misrepresented; you must not
mbed_official 525:c320967f86b9 15 * claim that you wrote the original software.@n
mbed_official 525:c320967f86b9 16 * 2. Altered source versions must be plainly marked as such, and must not be
mbed_official 525:c320967f86b9 17 * misrepresented as being the original software.@n
mbed_official 525:c320967f86b9 18 * 3. This notice may not be removed or altered from any source distribution.
mbed_official 525:c320967f86b9 19 *
mbed_official 525:c320967f86b9 20 * DISCLAIMER OF WARRANTY/LIMITATION OF REMEDIES: Silicon Laboratories, Inc.
mbed_official 525:c320967f86b9 21 * has no obligation to support this Software. Silicon Laboratories, Inc. is
mbed_official 525:c320967f86b9 22 * providing the Software "AS IS", with no express or implied warranties of any
mbed_official 525:c320967f86b9 23 * kind, including, but not limited to, any implied warranties of
mbed_official 525:c320967f86b9 24 * merchantability or fitness for any particular purpose or warranties against
mbed_official 525:c320967f86b9 25 * infringement of any proprietary rights of a third party.
mbed_official 525:c320967f86b9 26 *
mbed_official 525:c320967f86b9 27 * Silicon Laboratories, Inc. will not be liable for any consequential,
mbed_official 525:c320967f86b9 28 * incidental, or special damages, or any other relief, or for any claim by
mbed_official 525:c320967f86b9 29 * any third party, arising from your use of this Software.
mbed_official 525:c320967f86b9 30 *
mbed_official 525:c320967f86b9 31 *****************************************************************************/
mbed_official 525:c320967f86b9 32
mbed_official 525:c320967f86b9 33 #include <stdint.h>
mbed_official 525:c320967f86b9 34 #include "em_device.h"
mbed_official 525:c320967f86b9 35
mbed_official 525:c320967f86b9 36 /*******************************************************************************
mbed_official 525:c320967f86b9 37 ****************************** DEFINES ************************************
mbed_official 525:c320967f86b9 38 ******************************************************************************/
mbed_official 525:c320967f86b9 39
mbed_official 525:c320967f86b9 40 /** LFRCO frequency, tuned to below frequency during manufacturing. */
mbed_official 525:c320967f86b9 41 #define EFM32_LFRCO_FREQ (32768UL)
mbed_official 525:c320967f86b9 42 #define EFM32_ULFRCO_FREQ (1000UL)
mbed_official 525:c320967f86b9 43
mbed_official 525:c320967f86b9 44 /*******************************************************************************
mbed_official 525:c320967f86b9 45 ************************** LOCAL VARIABLES ********************************
mbed_official 525:c320967f86b9 46 ******************************************************************************/
mbed_official 525:c320967f86b9 47
mbed_official 525:c320967f86b9 48 /* System oscillator frequencies. These frequencies are normally constant */
mbed_official 525:c320967f86b9 49 /* for a target, but they are made configurable in order to allow run-time */
mbed_official 525:c320967f86b9 50 /* handling of different boards. The crystal oscillator clocks can be set */
mbed_official 525:c320967f86b9 51 /* compile time to a non-default value by defining respective EFM32_nFXO_FREQ */
mbed_official 525:c320967f86b9 52 /* values according to board design. By defining the EFM32_nFXO_FREQ to 0, */
mbed_official 525:c320967f86b9 53 /* one indicates that the oscillator is not present, in order to save some */
mbed_official 525:c320967f86b9 54 /* SW footprint. */
mbed_official 525:c320967f86b9 55
mbed_official 525:c320967f86b9 56 #ifndef EFM32_HFXO_FREQ
mbed_official 525:c320967f86b9 57 #if defined(_EFM32_GIANT_FAMILY) || defined(_EFM32_WONDER_FAMILY)
mbed_official 525:c320967f86b9 58 #define EFM32_HFXO_FREQ (48000000UL)
mbed_official 525:c320967f86b9 59 #else
mbed_official 525:c320967f86b9 60 #define EFM32_HFXO_FREQ (32000000UL)
mbed_official 525:c320967f86b9 61 #endif
mbed_official 525:c320967f86b9 62 #endif
mbed_official 525:c320967f86b9 63 /* Do not define variable if HF crystal oscillator not present */
mbed_official 525:c320967f86b9 64 #if (EFM32_HFXO_FREQ > 0)
mbed_official 525:c320967f86b9 65 /** @cond DO_NOT_INCLUDE_WITH_DOXYGEN */
mbed_official 525:c320967f86b9 66 /** System HFXO clock. */
mbed_official 525:c320967f86b9 67 static uint32_t SystemHFXOClock = EFM32_HFXO_FREQ;
mbed_official 525:c320967f86b9 68 /** @endcond (DO_NOT_INCLUDE_WITH_DOXYGEN) */
mbed_official 525:c320967f86b9 69 #endif
mbed_official 525:c320967f86b9 70
mbed_official 525:c320967f86b9 71 #ifndef EFM32_LFXO_FREQ
mbed_official 525:c320967f86b9 72 #define EFM32_LFXO_FREQ (EFM32_LFRCO_FREQ)
mbed_official 525:c320967f86b9 73 #endif
mbed_official 525:c320967f86b9 74 /* Do not define variable if LF crystal oscillator not present */
mbed_official 525:c320967f86b9 75 #if (EFM32_LFXO_FREQ > 0)
mbed_official 525:c320967f86b9 76 /** @cond DO_NOT_INCLUDE_WITH_DOXYGEN */
mbed_official 525:c320967f86b9 77 /** System LFXO clock. */
mbed_official 525:c320967f86b9 78 static uint32_t SystemLFXOClock = EFM32_LFXO_FREQ;
mbed_official 525:c320967f86b9 79 /** @endcond (DO_NOT_INCLUDE_WITH_DOXYGEN) */
mbed_official 525:c320967f86b9 80 #endif
mbed_official 525:c320967f86b9 81
mbed_official 525:c320967f86b9 82 /* Inline function to get the chip's Production Revision. */
mbed_official 525:c320967f86b9 83 __STATIC_INLINE uint8_t GetProdRev(void)
mbed_official 525:c320967f86b9 84 {
mbed_official 525:c320967f86b9 85 return ((DEVINFO->PART & _DEVINFO_PART_PROD_REV_MASK)
mbed_official 525:c320967f86b9 86 >> _DEVINFO_PART_PROD_REV_SHIFT);
mbed_official 525:c320967f86b9 87 }
mbed_official 525:c320967f86b9 88
mbed_official 525:c320967f86b9 89 /*******************************************************************************
mbed_official 525:c320967f86b9 90 ************************** GLOBAL VARIABLES *******************************
mbed_official 525:c320967f86b9 91 ******************************************************************************/
mbed_official 525:c320967f86b9 92
mbed_official 525:c320967f86b9 93 /**
mbed_official 525:c320967f86b9 94 * @brief
mbed_official 525:c320967f86b9 95 * System System Clock Frequency (Core Clock).
mbed_official 525:c320967f86b9 96 *
mbed_official 525:c320967f86b9 97 * @details
mbed_official 525:c320967f86b9 98 * Required CMSIS global variable that must be kept up-to-date.
mbed_official 525:c320967f86b9 99 */
mbed_official 525:c320967f86b9 100 uint32_t SystemCoreClock;
mbed_official 525:c320967f86b9 101
mbed_official 525:c320967f86b9 102 /*******************************************************************************
mbed_official 525:c320967f86b9 103 ************************** GLOBAL FUNCTIONS *******************************
mbed_official 525:c320967f86b9 104 ******************************************************************************/
mbed_official 525:c320967f86b9 105
mbed_official 525:c320967f86b9 106 /***************************************************************************//**
mbed_official 525:c320967f86b9 107 * @brief
mbed_official 525:c320967f86b9 108 * Get the current core clock frequency.
mbed_official 525:c320967f86b9 109 *
mbed_official 525:c320967f86b9 110 * @details
mbed_official 525:c320967f86b9 111 * Calculate and get the current core clock frequency based on the current
mbed_official 525:c320967f86b9 112 * configuration. Assuming that the SystemCoreClock global variable is
mbed_official 525:c320967f86b9 113 * maintained, the core clock frequency is stored in that variable as well.
mbed_official 525:c320967f86b9 114 * This function will however calculate the core clock based on actual HW
mbed_official 525:c320967f86b9 115 * configuration. It will also update the SystemCoreClock global variable.
mbed_official 525:c320967f86b9 116 *
mbed_official 525:c320967f86b9 117 * @note
mbed_official 525:c320967f86b9 118 * This is an EFM32 proprietary function, not part of the CMSIS definition.
mbed_official 525:c320967f86b9 119 *
mbed_official 525:c320967f86b9 120 * @return
mbed_official 525:c320967f86b9 121 * The current core clock frequency in Hz.
mbed_official 525:c320967f86b9 122 ******************************************************************************/
mbed_official 525:c320967f86b9 123 uint32_t SystemCoreClockGet(void)
mbed_official 525:c320967f86b9 124 {
mbed_official 525:c320967f86b9 125 uint32_t ret;
mbed_official 525:c320967f86b9 126
mbed_official 525:c320967f86b9 127 ret = SystemHFClockGet();
mbed_official 525:c320967f86b9 128 #if defined(_EFM32_GIANT_FAMILY) || defined(_EFM32_WONDER_FAMILY)
mbed_official 525:c320967f86b9 129 /* Leopard/Giant/Wonder Gecko has an additional divider */
mbed_official 525:c320967f86b9 130 ret = ret / (1 + ((CMU->CTRL & _CMU_CTRL_HFCLKDIV_MASK)>>_CMU_CTRL_HFCLKDIV_SHIFT));
mbed_official 525:c320967f86b9 131 #endif
mbed_official 525:c320967f86b9 132 ret >>= (CMU->HFCORECLKDIV & _CMU_HFCORECLKDIV_HFCORECLKDIV_MASK) >>
mbed_official 525:c320967f86b9 133 _CMU_HFCORECLKDIV_HFCORECLKDIV_SHIFT;
mbed_official 525:c320967f86b9 134
mbed_official 525:c320967f86b9 135 /* Keep CMSIS variable up-to-date just in case */
mbed_official 525:c320967f86b9 136 SystemCoreClock = ret;
mbed_official 525:c320967f86b9 137
mbed_official 525:c320967f86b9 138 return ret;
mbed_official 525:c320967f86b9 139 }
mbed_official 525:c320967f86b9 140
mbed_official 525:c320967f86b9 141
mbed_official 525:c320967f86b9 142 /***************************************************************************//**
mbed_official 525:c320967f86b9 143 * @brief
mbed_official 525:c320967f86b9 144 * Get the current HFCLK frequency.
mbed_official 525:c320967f86b9 145 *
mbed_official 525:c320967f86b9 146 * @note
mbed_official 525:c320967f86b9 147 * This is an EFM32 proprietary function, not part of the CMSIS definition.
mbed_official 525:c320967f86b9 148 *
mbed_official 525:c320967f86b9 149 * @return
mbed_official 525:c320967f86b9 150 * The current HFCLK frequency in Hz.
mbed_official 525:c320967f86b9 151 ******************************************************************************/
mbed_official 525:c320967f86b9 152 uint32_t SystemHFClockGet(void)
mbed_official 525:c320967f86b9 153 {
mbed_official 525:c320967f86b9 154 uint32_t ret;
mbed_official 525:c320967f86b9 155
mbed_official 525:c320967f86b9 156 switch (CMU->STATUS & (CMU_STATUS_HFRCOSEL | CMU_STATUS_HFXOSEL |
mbed_official 525:c320967f86b9 157 CMU_STATUS_LFRCOSEL | CMU_STATUS_LFXOSEL))
mbed_official 525:c320967f86b9 158 {
mbed_official 525:c320967f86b9 159 case CMU_STATUS_LFXOSEL:
mbed_official 525:c320967f86b9 160 #if (EFM32_LFXO_FREQ > 0)
mbed_official 525:c320967f86b9 161 ret = SystemLFXOClock;
mbed_official 525:c320967f86b9 162 #else
mbed_official 525:c320967f86b9 163 /* We should not get here, since core should not be clocked. May */
mbed_official 525:c320967f86b9 164 /* be caused by a misconfiguration though. */
mbed_official 525:c320967f86b9 165 ret = 0;
mbed_official 525:c320967f86b9 166 #endif
mbed_official 525:c320967f86b9 167 break;
mbed_official 525:c320967f86b9 168
mbed_official 525:c320967f86b9 169 case CMU_STATUS_LFRCOSEL:
mbed_official 525:c320967f86b9 170 ret = EFM32_LFRCO_FREQ;
mbed_official 525:c320967f86b9 171 break;
mbed_official 525:c320967f86b9 172
mbed_official 525:c320967f86b9 173 case CMU_STATUS_HFXOSEL:
mbed_official 525:c320967f86b9 174 #if (EFM32_HFXO_FREQ > 0)
mbed_official 525:c320967f86b9 175 ret = SystemHFXOClock;
mbed_official 525:c320967f86b9 176 #else
mbed_official 525:c320967f86b9 177 /* We should not get here, since core should not be clocked. May */
mbed_official 525:c320967f86b9 178 /* be caused by a misconfiguration though. */
mbed_official 525:c320967f86b9 179 ret = 0;
mbed_official 525:c320967f86b9 180 #endif
mbed_official 525:c320967f86b9 181 break;
mbed_official 525:c320967f86b9 182
mbed_official 525:c320967f86b9 183 default: /* CMU_STATUS_HFRCOSEL */
mbed_official 525:c320967f86b9 184 switch (CMU->HFRCOCTRL & _CMU_HFRCOCTRL_BAND_MASK)
mbed_official 525:c320967f86b9 185 {
mbed_official 525:c320967f86b9 186 case CMU_HFRCOCTRL_BAND_28MHZ:
mbed_official 525:c320967f86b9 187 ret = 28000000;
mbed_official 525:c320967f86b9 188 break;
mbed_official 525:c320967f86b9 189
mbed_official 525:c320967f86b9 190 case CMU_HFRCOCTRL_BAND_21MHZ:
mbed_official 525:c320967f86b9 191 ret = 21000000;
mbed_official 525:c320967f86b9 192 break;
mbed_official 525:c320967f86b9 193
mbed_official 525:c320967f86b9 194 case CMU_HFRCOCTRL_BAND_14MHZ:
mbed_official 525:c320967f86b9 195 ret = 14000000;
mbed_official 525:c320967f86b9 196 break;
mbed_official 525:c320967f86b9 197
mbed_official 525:c320967f86b9 198 case CMU_HFRCOCTRL_BAND_11MHZ:
mbed_official 525:c320967f86b9 199 ret = 11000000;
mbed_official 525:c320967f86b9 200 break;
mbed_official 525:c320967f86b9 201
mbed_official 525:c320967f86b9 202 case CMU_HFRCOCTRL_BAND_7MHZ:
mbed_official 525:c320967f86b9 203 if ( GetProdRev() >= 19 )
mbed_official 525:c320967f86b9 204 ret = 6600000;
mbed_official 525:c320967f86b9 205 else
mbed_official 525:c320967f86b9 206 ret = 7000000;
mbed_official 525:c320967f86b9 207 break;
mbed_official 525:c320967f86b9 208
mbed_official 525:c320967f86b9 209 case CMU_HFRCOCTRL_BAND_1MHZ:
mbed_official 525:c320967f86b9 210 if ( GetProdRev() >= 19 )
mbed_official 525:c320967f86b9 211 ret = 1200000;
mbed_official 525:c320967f86b9 212 else
mbed_official 525:c320967f86b9 213 ret = 1000000;
mbed_official 525:c320967f86b9 214 break;
mbed_official 525:c320967f86b9 215
mbed_official 525:c320967f86b9 216 default:
mbed_official 525:c320967f86b9 217 ret = 0;
mbed_official 525:c320967f86b9 218 break;
mbed_official 525:c320967f86b9 219 }
mbed_official 525:c320967f86b9 220 break;
mbed_official 525:c320967f86b9 221 }
mbed_official 525:c320967f86b9 222
mbed_official 525:c320967f86b9 223 return ret;
mbed_official 525:c320967f86b9 224 }
mbed_official 525:c320967f86b9 225
mbed_official 525:c320967f86b9 226
mbed_official 525:c320967f86b9 227 /**************************************************************************//**
mbed_official 525:c320967f86b9 228 * @brief
mbed_official 525:c320967f86b9 229 * Get high frequency crystal oscillator clock frequency for target system.
mbed_official 525:c320967f86b9 230 *
mbed_official 525:c320967f86b9 231 * @note
mbed_official 525:c320967f86b9 232 * This is an EFM32 proprietary function, not part of the CMSIS definition.
mbed_official 525:c320967f86b9 233 *
mbed_official 525:c320967f86b9 234 * @return
mbed_official 525:c320967f86b9 235 * HFXO frequency in Hz.
mbed_official 525:c320967f86b9 236 *****************************************************************************/
mbed_official 525:c320967f86b9 237 uint32_t SystemHFXOClockGet(void)
mbed_official 525:c320967f86b9 238 {
mbed_official 525:c320967f86b9 239 /* External crystal oscillator present? */
mbed_official 525:c320967f86b9 240 #if (EFM32_HFXO_FREQ > 0)
mbed_official 525:c320967f86b9 241 return SystemHFXOClock;
mbed_official 525:c320967f86b9 242 #else
mbed_official 525:c320967f86b9 243 return 0;
mbed_official 525:c320967f86b9 244 #endif
mbed_official 525:c320967f86b9 245 }
mbed_official 525:c320967f86b9 246
mbed_official 525:c320967f86b9 247
mbed_official 525:c320967f86b9 248 /**************************************************************************//**
mbed_official 525:c320967f86b9 249 * @brief
mbed_official 525:c320967f86b9 250 * Set high frequency crystal oscillator clock frequency for target system.
mbed_official 525:c320967f86b9 251 *
mbed_official 525:c320967f86b9 252 * @note
mbed_official 525:c320967f86b9 253 * This function is mainly provided for being able to handle target systems
mbed_official 525:c320967f86b9 254 * with different HF crystal oscillator frequencies run-time. If used, it
mbed_official 525:c320967f86b9 255 * should probably only be used once during system startup.
mbed_official 525:c320967f86b9 256 *
mbed_official 525:c320967f86b9 257 * @note
mbed_official 525:c320967f86b9 258 * This is an EFM32 proprietary function, not part of the CMSIS definition.
mbed_official 525:c320967f86b9 259 *
mbed_official 525:c320967f86b9 260 * @param[in] freq
mbed_official 525:c320967f86b9 261 * HFXO frequency in Hz used for target.
mbed_official 525:c320967f86b9 262 *****************************************************************************/
mbed_official 525:c320967f86b9 263 void SystemHFXOClockSet(uint32_t freq)
mbed_official 525:c320967f86b9 264 {
mbed_official 525:c320967f86b9 265 /* External crystal oscillator present? */
mbed_official 525:c320967f86b9 266 #if (EFM32_HFXO_FREQ > 0)
mbed_official 525:c320967f86b9 267 SystemHFXOClock = freq;
mbed_official 525:c320967f86b9 268
mbed_official 525:c320967f86b9 269 /* Update core clock frequency if HFXO is used to clock core */
mbed_official 525:c320967f86b9 270 if (CMU->STATUS & CMU_STATUS_HFXOSEL)
mbed_official 525:c320967f86b9 271 {
mbed_official 525:c320967f86b9 272 /* The function will update the global variable */
mbed_official 525:c320967f86b9 273 SystemCoreClockGet();
mbed_official 525:c320967f86b9 274 }
mbed_official 525:c320967f86b9 275 #else
mbed_official 525:c320967f86b9 276 (void)freq; /* Unused parameter */
mbed_official 525:c320967f86b9 277 #endif
mbed_official 525:c320967f86b9 278 }
mbed_official 525:c320967f86b9 279
mbed_official 525:c320967f86b9 280
mbed_official 525:c320967f86b9 281 /**************************************************************************//**
mbed_official 525:c320967f86b9 282 * @brief
mbed_official 525:c320967f86b9 283 * Initialize the system.
mbed_official 525:c320967f86b9 284 *
mbed_official 525:c320967f86b9 285 * @details
mbed_official 525:c320967f86b9 286 * Do required generic HW system init.
mbed_official 525:c320967f86b9 287 *
mbed_official 525:c320967f86b9 288 * @note
mbed_official 525:c320967f86b9 289 * This function is invoked during system init, before the main() routine
mbed_official 525:c320967f86b9 290 * and any data has been initialized. For this reason, it cannot do any
mbed_official 525:c320967f86b9 291 * initialization of variables etc.
mbed_official 525:c320967f86b9 292 *****************************************************************************/
mbed_official 525:c320967f86b9 293 void SystemInit(void)
mbed_official 525:c320967f86b9 294 {
mbed_official 525:c320967f86b9 295 /* Set floating point coprosessor access mode. */
mbed_official 525:c320967f86b9 296 SCB->CPACR |= ((3UL << 10*2) | /* set CP10 Full Access */
mbed_official 525:c320967f86b9 297 (3UL << 11*2) ); /* set CP11 Full Access */
mbed_official 525:c320967f86b9 298 }
mbed_official 525:c320967f86b9 299
mbed_official 525:c320967f86b9 300
mbed_official 525:c320967f86b9 301 /**************************************************************************//**
mbed_official 525:c320967f86b9 302 * @brief
mbed_official 525:c320967f86b9 303 * Get low frequency RC oscillator clock frequency for target system.
mbed_official 525:c320967f86b9 304 *
mbed_official 525:c320967f86b9 305 * @note
mbed_official 525:c320967f86b9 306 * This is an EFM32 proprietary function, not part of the CMSIS definition.
mbed_official 525:c320967f86b9 307 *
mbed_official 525:c320967f86b9 308 * @return
mbed_official 525:c320967f86b9 309 * LFRCO frequency in Hz.
mbed_official 525:c320967f86b9 310 *****************************************************************************/
mbed_official 525:c320967f86b9 311 uint32_t SystemLFRCOClockGet(void)
mbed_official 525:c320967f86b9 312 {
mbed_official 525:c320967f86b9 313 /* Currently we assume that this frequency is properly tuned during */
mbed_official 525:c320967f86b9 314 /* manufacturing and is not changed after reset. If future requirements */
mbed_official 525:c320967f86b9 315 /* for re-tuning by user, we can add support for that. */
mbed_official 525:c320967f86b9 316 return EFM32_LFRCO_FREQ;
mbed_official 525:c320967f86b9 317 }
mbed_official 525:c320967f86b9 318
mbed_official 525:c320967f86b9 319
mbed_official 525:c320967f86b9 320 /**************************************************************************//**
mbed_official 525:c320967f86b9 321 * @brief
mbed_official 525:c320967f86b9 322 * Get ultra low frequency RC oscillator clock frequency for target system.
mbed_official 525:c320967f86b9 323 *
mbed_official 525:c320967f86b9 324 * @note
mbed_official 525:c320967f86b9 325 * This is an EFM32 proprietary function, not part of the CMSIS definition.
mbed_official 525:c320967f86b9 326 *
mbed_official 525:c320967f86b9 327 * @return
mbed_official 525:c320967f86b9 328 * ULFRCO frequency in Hz.
mbed_official 525:c320967f86b9 329 *****************************************************************************/
mbed_official 525:c320967f86b9 330 uint32_t SystemULFRCOClockGet(void)
mbed_official 525:c320967f86b9 331 {
mbed_official 525:c320967f86b9 332 /* The ULFRCO frequency is not tuned, and can be very inaccurate */
mbed_official 525:c320967f86b9 333 return EFM32_ULFRCO_FREQ;
mbed_official 525:c320967f86b9 334 }
mbed_official 525:c320967f86b9 335
mbed_official 525:c320967f86b9 336
mbed_official 525:c320967f86b9 337 /**************************************************************************//**
mbed_official 525:c320967f86b9 338 * @brief
mbed_official 525:c320967f86b9 339 * Get low frequency crystal oscillator clock frequency for target system.
mbed_official 525:c320967f86b9 340 *
mbed_official 525:c320967f86b9 341 * @note
mbed_official 525:c320967f86b9 342 * This is an EFM32 proprietary function, not part of the CMSIS definition.
mbed_official 525:c320967f86b9 343 *
mbed_official 525:c320967f86b9 344 * @return
mbed_official 525:c320967f86b9 345 * LFXO frequency in Hz.
mbed_official 525:c320967f86b9 346 *****************************************************************************/
mbed_official 525:c320967f86b9 347 uint32_t SystemLFXOClockGet(void)
mbed_official 525:c320967f86b9 348 {
mbed_official 525:c320967f86b9 349 /* External crystal oscillator present? */
mbed_official 525:c320967f86b9 350 #if (EFM32_LFXO_FREQ > 0)
mbed_official 525:c320967f86b9 351 return SystemLFXOClock;
mbed_official 525:c320967f86b9 352 #else
mbed_official 525:c320967f86b9 353 return 0;
mbed_official 525:c320967f86b9 354 #endif
mbed_official 525:c320967f86b9 355 }
mbed_official 525:c320967f86b9 356
mbed_official 525:c320967f86b9 357
mbed_official 525:c320967f86b9 358 /**************************************************************************//**
mbed_official 525:c320967f86b9 359 * @brief
mbed_official 525:c320967f86b9 360 * Set low frequency crystal oscillator clock frequency for target system.
mbed_official 525:c320967f86b9 361 *
mbed_official 525:c320967f86b9 362 * @note
mbed_official 525:c320967f86b9 363 * This function is mainly provided for being able to handle target systems
mbed_official 525:c320967f86b9 364 * with different HF crystal oscillator frequencies run-time. If used, it
mbed_official 525:c320967f86b9 365 * should probably only be used once during system startup.
mbed_official 525:c320967f86b9 366 *
mbed_official 525:c320967f86b9 367 * @note
mbed_official 525:c320967f86b9 368 * This is an EFM32 proprietary function, not part of the CMSIS definition.
mbed_official 525:c320967f86b9 369 *
mbed_official 525:c320967f86b9 370 * @param[in] freq
mbed_official 525:c320967f86b9 371 * LFXO frequency in Hz used for target.
mbed_official 525:c320967f86b9 372 *****************************************************************************/
mbed_official 525:c320967f86b9 373 void SystemLFXOClockSet(uint32_t freq)
mbed_official 525:c320967f86b9 374 {
mbed_official 525:c320967f86b9 375 /* External crystal oscillator present? */
mbed_official 525:c320967f86b9 376 #if (EFM32_LFXO_FREQ > 0)
mbed_official 525:c320967f86b9 377 SystemLFXOClock = freq;
mbed_official 525:c320967f86b9 378
mbed_official 525:c320967f86b9 379 /* Update core clock frequency if LFXO is used to clock core */
mbed_official 525:c320967f86b9 380 if (CMU->STATUS & CMU_STATUS_LFXOSEL)
mbed_official 525:c320967f86b9 381 {
mbed_official 525:c320967f86b9 382 /* The function will update the global variable */
mbed_official 525:c320967f86b9 383 SystemCoreClockGet();
mbed_official 525:c320967f86b9 384 }
mbed_official 525:c320967f86b9 385 #else
mbed_official 525:c320967f86b9 386 (void)freq; /* Unused parameter */
mbed_official 525:c320967f86b9 387 #endif
mbed_official 525:c320967f86b9 388 }