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_efm32hg.c
mbed_official 525:c320967f86b9 3 * @brief CMSIS Cortex-M0+ System Layer for EFM32HG devices.
mbed_official 525:c320967f86b9 4 * @version 3.20.12
mbed_official 525:c320967f86b9 5 ******************************************************************************
mbed_official 525:c320967f86b9 6 * @section License
mbed_official 525:c320967f86b9 7 * <b>(C) Copyright 2015 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 #define EFM32_HFXO_FREQ (24000000UL)
mbed_official 525:c320967f86b9 58 #define EFM32_HFRCO_MAX_FREQ (21000000UL)
mbed_official 525:c320967f86b9 59 #endif
mbed_official 525:c320967f86b9 60 /* Do not define variable if HF crystal oscillator not present */
mbed_official 525:c320967f86b9 61 #if (EFM32_HFXO_FREQ > 0)
mbed_official 525:c320967f86b9 62 /** @cond DO_NOT_INCLUDE_WITH_DOXYGEN */
mbed_official 525:c320967f86b9 63 /** System HFXO clock. */
mbed_official 525:c320967f86b9 64 static uint32_t SystemHFXOClock = EFM32_HFXO_FREQ;
mbed_official 525:c320967f86b9 65 /** @endcond (DO_NOT_INCLUDE_WITH_DOXYGEN) */
mbed_official 525:c320967f86b9 66 #endif
mbed_official 525:c320967f86b9 67
mbed_official 525:c320967f86b9 68 #ifndef EFM32_LFXO_FREQ
mbed_official 525:c320967f86b9 69 #define EFM32_LFXO_FREQ (EFM32_LFRCO_FREQ)
mbed_official 525:c320967f86b9 70 #endif
mbed_official 525:c320967f86b9 71 /* Do not define variable if LF crystal oscillator not present */
mbed_official 525:c320967f86b9 72 #if (EFM32_LFXO_FREQ > 0)
mbed_official 525:c320967f86b9 73 /** @cond DO_NOT_INCLUDE_WITH_DOXYGEN */
mbed_official 525:c320967f86b9 74 /** System LFXO clock. */
mbed_official 525:c320967f86b9 75 static uint32_t SystemLFXOClock = EFM32_LFXO_FREQ;
mbed_official 525:c320967f86b9 76 /** @endcond (DO_NOT_INCLUDE_WITH_DOXYGEN) */
mbed_official 525:c320967f86b9 77 #endif
mbed_official 525:c320967f86b9 78
mbed_official 525:c320967f86b9 79 /*******************************************************************************
mbed_official 525:c320967f86b9 80 ************************** GLOBAL VARIABLES *******************************
mbed_official 525:c320967f86b9 81 ******************************************************************************/
mbed_official 525:c320967f86b9 82
mbed_official 525:c320967f86b9 83 /**
mbed_official 525:c320967f86b9 84 * @brief
mbed_official 525:c320967f86b9 85 * System System Clock Frequency (Core Clock).
mbed_official 525:c320967f86b9 86 *
mbed_official 525:c320967f86b9 87 * @details
mbed_official 525:c320967f86b9 88 * Required CMSIS global variable that must be kept up-to-date.
mbed_official 525:c320967f86b9 89 */
mbed_official 525:c320967f86b9 90 uint32_t SystemCoreClock;
mbed_official 525:c320967f86b9 91
mbed_official 525:c320967f86b9 92 /*******************************************************************************
mbed_official 525:c320967f86b9 93 ************************** GLOBAL FUNCTIONS *******************************
mbed_official 525:c320967f86b9 94 ******************************************************************************/
mbed_official 525:c320967f86b9 95
mbed_official 525:c320967f86b9 96 /***************************************************************************//**
mbed_official 525:c320967f86b9 97 * @brief
mbed_official 525:c320967f86b9 98 * Get the current core clock frequency.
mbed_official 525:c320967f86b9 99 *
mbed_official 525:c320967f86b9 100 * @details
mbed_official 525:c320967f86b9 101 * Calculate and get the current core clock frequency based on the current
mbed_official 525:c320967f86b9 102 * configuration. Assuming that the SystemCoreClock global variable is
mbed_official 525:c320967f86b9 103 * maintained, the core clock frequency is stored in that variable as well.
mbed_official 525:c320967f86b9 104 * This function will however calculate the core clock based on actual HW
mbed_official 525:c320967f86b9 105 * configuration. It will also update the SystemCoreClock global variable.
mbed_official 525:c320967f86b9 106 *
mbed_official 525:c320967f86b9 107 * @note
mbed_official 525:c320967f86b9 108 * This is an EFM32 proprietary function, not part of the CMSIS definition.
mbed_official 525:c320967f86b9 109 *
mbed_official 525:c320967f86b9 110 * @return
mbed_official 525:c320967f86b9 111 * The current core clock frequency in Hz.
mbed_official 525:c320967f86b9 112 ******************************************************************************/
mbed_official 525:c320967f86b9 113 uint32_t SystemCoreClockGet(void)
mbed_official 525:c320967f86b9 114 {
mbed_official 525:c320967f86b9 115 uint32_t ret;
mbed_official 525:c320967f86b9 116
mbed_official 525:c320967f86b9 117 ret = SystemHFClockGet();
mbed_official 525:c320967f86b9 118 ret >>= (CMU->HFCORECLKDIV & _CMU_HFCORECLKDIV_HFCORECLKDIV_MASK) >>
mbed_official 525:c320967f86b9 119 _CMU_HFCORECLKDIV_HFCORECLKDIV_SHIFT;
mbed_official 525:c320967f86b9 120
mbed_official 525:c320967f86b9 121 /* Keep CMSIS variable up-to-date just in case */
mbed_official 525:c320967f86b9 122 SystemCoreClock = ret;
mbed_official 525:c320967f86b9 123
mbed_official 525:c320967f86b9 124 return ret;
mbed_official 525:c320967f86b9 125 }
mbed_official 525:c320967f86b9 126
mbed_official 525:c320967f86b9 127
mbed_official 525:c320967f86b9 128 /***************************************************************************//**
mbed_official 525:c320967f86b9 129 * @brief
mbed_official 525:c320967f86b9 130 * Get the maximum core clock frequency.
mbed_official 525:c320967f86b9 131 *
mbed_official 525:c320967f86b9 132 * @note
mbed_official 525:c320967f86b9 133 * This is an EFR32 proprietary function, not part of the CMSIS definition.
mbed_official 525:c320967f86b9 134 *
mbed_official 525:c320967f86b9 135 * @return
mbed_official 525:c320967f86b9 136 * The maximum core clock frequency in Hz.
mbed_official 525:c320967f86b9 137 ******************************************************************************/
mbed_official 525:c320967f86b9 138 uint32_t SystemMaxCoreClockGet(void)
mbed_official 525:c320967f86b9 139 {
mbed_official 525:c320967f86b9 140 return (EFM32_HFRCO_MAX_FREQ > EFM32_HFXO_FREQ ? \
mbed_official 525:c320967f86b9 141 EFM32_HFRCO_MAX_FREQ : EFM32_HFXO_FREQ);
mbed_official 525:c320967f86b9 142 }
mbed_official 525:c320967f86b9 143
mbed_official 525:c320967f86b9 144
mbed_official 525:c320967f86b9 145 /***************************************************************************//**
mbed_official 525:c320967f86b9 146 * @brief
mbed_official 525:c320967f86b9 147 * Get the current HFCLK frequency.
mbed_official 525:c320967f86b9 148 *
mbed_official 525:c320967f86b9 149 * @note
mbed_official 525:c320967f86b9 150 * This is an EFM32 proprietary function, not part of the CMSIS definition.
mbed_official 525:c320967f86b9 151 *
mbed_official 525:c320967f86b9 152 * @return
mbed_official 525:c320967f86b9 153 * The current HFCLK frequency in Hz.
mbed_official 525:c320967f86b9 154 ******************************************************************************/
mbed_official 525:c320967f86b9 155 uint32_t SystemHFClockGet(void)
mbed_official 525:c320967f86b9 156 {
mbed_official 525:c320967f86b9 157 uint32_t ret;
mbed_official 525:c320967f86b9 158
mbed_official 525:c320967f86b9 159 switch (CMU->STATUS & (CMU_STATUS_HFRCOSEL | CMU_STATUS_HFXOSEL |
mbed_official 525:c320967f86b9 160 CMU_STATUS_LFRCOSEL | CMU_STATUS_LFXOSEL |
mbed_official 525:c320967f86b9 161 CMU_STATUS_USHFRCODIV2SEL))
mbed_official 525:c320967f86b9 162 {
mbed_official 525:c320967f86b9 163 case CMU_STATUS_LFXOSEL:
mbed_official 525:c320967f86b9 164 #if (EFM32_LFXO_FREQ > 0)
mbed_official 525:c320967f86b9 165 ret = SystemLFXOClock;
mbed_official 525:c320967f86b9 166 #else
mbed_official 525:c320967f86b9 167 /* We should not get here, since core should not be clocked. May */
mbed_official 525:c320967f86b9 168 /* be caused by a misconfiguration though. */
mbed_official 525:c320967f86b9 169 ret = 0;
mbed_official 525:c320967f86b9 170 #endif
mbed_official 525:c320967f86b9 171 break;
mbed_official 525:c320967f86b9 172
mbed_official 525:c320967f86b9 173 case CMU_STATUS_LFRCOSEL:
mbed_official 525:c320967f86b9 174 ret = EFM32_LFRCO_FREQ;
mbed_official 525:c320967f86b9 175 break;
mbed_official 525:c320967f86b9 176
mbed_official 525:c320967f86b9 177 case CMU_STATUS_HFXOSEL:
mbed_official 525:c320967f86b9 178 #if (EFM32_HFXO_FREQ > 0)
mbed_official 525:c320967f86b9 179 ret = SystemHFXOClock;
mbed_official 525:c320967f86b9 180 #else
mbed_official 525:c320967f86b9 181 /* We should not get here, since core should not be clocked. May */
mbed_official 525:c320967f86b9 182 /* be caused by a misconfiguration though. */
mbed_official 525:c320967f86b9 183 ret = 0;
mbed_official 525:c320967f86b9 184 #endif
mbed_official 525:c320967f86b9 185 break;
mbed_official 525:c320967f86b9 186
mbed_official 525:c320967f86b9 187 case CMU_STATUS_USHFRCODIV2SEL:
mbed_official 525:c320967f86b9 188 ret = 24000000;
mbed_official 525:c320967f86b9 189 break;
mbed_official 525:c320967f86b9 190
mbed_official 525:c320967f86b9 191 default: /* CMU_STATUS_HFRCOSEL */
mbed_official 525:c320967f86b9 192 switch (CMU->HFRCOCTRL & _CMU_HFRCOCTRL_BAND_MASK)
mbed_official 525:c320967f86b9 193 {
mbed_official 525:c320967f86b9 194 case CMU_HFRCOCTRL_BAND_21MHZ:
mbed_official 525:c320967f86b9 195 ret = 21000000;
mbed_official 525:c320967f86b9 196 break;
mbed_official 525:c320967f86b9 197
mbed_official 525:c320967f86b9 198 case CMU_HFRCOCTRL_BAND_14MHZ:
mbed_official 525:c320967f86b9 199 ret = 14000000;
mbed_official 525:c320967f86b9 200 break;
mbed_official 525:c320967f86b9 201
mbed_official 525:c320967f86b9 202 case CMU_HFRCOCTRL_BAND_11MHZ:
mbed_official 525:c320967f86b9 203 ret = 11000000;
mbed_official 525:c320967f86b9 204 break;
mbed_official 525:c320967f86b9 205
mbed_official 525:c320967f86b9 206 case CMU_HFRCOCTRL_BAND_7MHZ:
mbed_official 525:c320967f86b9 207 ret = 6600000;
mbed_official 525:c320967f86b9 208 break;
mbed_official 525:c320967f86b9 209
mbed_official 525:c320967f86b9 210 case CMU_HFRCOCTRL_BAND_1MHZ:
mbed_official 525:c320967f86b9 211 ret = 1200000;
mbed_official 525:c320967f86b9 212 break;
mbed_official 525:c320967f86b9 213
mbed_official 525:c320967f86b9 214 default:
mbed_official 525:c320967f86b9 215 ret = 0;
mbed_official 525:c320967f86b9 216 break;
mbed_official 525:c320967f86b9 217 }
mbed_official 525:c320967f86b9 218 break;
mbed_official 525:c320967f86b9 219 }
mbed_official 525:c320967f86b9 220
mbed_official 525:c320967f86b9 221 return ret;
mbed_official 525:c320967f86b9 222 }
mbed_official 525:c320967f86b9 223
mbed_official 525:c320967f86b9 224
mbed_official 525:c320967f86b9 225 /**************************************************************************//**
mbed_official 525:c320967f86b9 226 * @brief
mbed_official 525:c320967f86b9 227 * Get high frequency crystal oscillator clock frequency for target system.
mbed_official 525:c320967f86b9 228 *
mbed_official 525:c320967f86b9 229 * @note
mbed_official 525:c320967f86b9 230 * This is an EFM32 proprietary function, not part of the CMSIS definition.
mbed_official 525:c320967f86b9 231 *
mbed_official 525:c320967f86b9 232 * @return
mbed_official 525:c320967f86b9 233 * HFXO frequency in Hz.
mbed_official 525:c320967f86b9 234 *****************************************************************************/
mbed_official 525:c320967f86b9 235 uint32_t SystemHFXOClockGet(void)
mbed_official 525:c320967f86b9 236 {
mbed_official 525:c320967f86b9 237 /* External crystal oscillator present? */
mbed_official 525:c320967f86b9 238 #if (EFM32_HFXO_FREQ > 0)
mbed_official 525:c320967f86b9 239 return SystemHFXOClock;
mbed_official 525:c320967f86b9 240 #else
mbed_official 525:c320967f86b9 241 return 0;
mbed_official 525:c320967f86b9 242 #endif
mbed_official 525:c320967f86b9 243 }
mbed_official 525:c320967f86b9 244
mbed_official 525:c320967f86b9 245
mbed_official 525:c320967f86b9 246 /**************************************************************************//**
mbed_official 525:c320967f86b9 247 * @brief
mbed_official 525:c320967f86b9 248 * Set high frequency crystal oscillator clock frequency for target system.
mbed_official 525:c320967f86b9 249 *
mbed_official 525:c320967f86b9 250 * @note
mbed_official 525:c320967f86b9 251 * This function is mainly provided for being able to handle target systems
mbed_official 525:c320967f86b9 252 * with different HF crystal oscillator frequencies run-time. If used, it
mbed_official 525:c320967f86b9 253 * should probably only be used once during system startup.
mbed_official 525:c320967f86b9 254 *
mbed_official 525:c320967f86b9 255 * @note
mbed_official 525:c320967f86b9 256 * This is an EFM32 proprietary function, not part of the CMSIS definition.
mbed_official 525:c320967f86b9 257 *
mbed_official 525:c320967f86b9 258 * @param[in] freq
mbed_official 525:c320967f86b9 259 * HFXO frequency in Hz used for target.
mbed_official 525:c320967f86b9 260 *****************************************************************************/
mbed_official 525:c320967f86b9 261 void SystemHFXOClockSet(uint32_t freq)
mbed_official 525:c320967f86b9 262 {
mbed_official 525:c320967f86b9 263 /* External crystal oscillator present? */
mbed_official 525:c320967f86b9 264 #if (EFM32_HFXO_FREQ > 0)
mbed_official 525:c320967f86b9 265 SystemHFXOClock = freq;
mbed_official 525:c320967f86b9 266
mbed_official 525:c320967f86b9 267 /* Update core clock frequency if HFXO is used to clock core */
mbed_official 525:c320967f86b9 268 if (CMU->STATUS & CMU_STATUS_HFXOSEL)
mbed_official 525:c320967f86b9 269 {
mbed_official 525:c320967f86b9 270 /* The function will update the global variable */
mbed_official 525:c320967f86b9 271 SystemCoreClockGet();
mbed_official 525:c320967f86b9 272 }
mbed_official 525:c320967f86b9 273 #else
mbed_official 525:c320967f86b9 274 (void)freq; /* Unused parameter */
mbed_official 525:c320967f86b9 275 #endif
mbed_official 525:c320967f86b9 276 }
mbed_official 525:c320967f86b9 277
mbed_official 525:c320967f86b9 278
mbed_official 525:c320967f86b9 279 /**************************************************************************//**
mbed_official 525:c320967f86b9 280 * @brief
mbed_official 525:c320967f86b9 281 * Initialize the system.
mbed_official 525:c320967f86b9 282 *
mbed_official 525:c320967f86b9 283 * @details
mbed_official 525:c320967f86b9 284 * Do required generic HW system init.
mbed_official 525:c320967f86b9 285 *
mbed_official 525:c320967f86b9 286 * @note
mbed_official 525:c320967f86b9 287 * This function is invoked during system init, before the main() routine
mbed_official 525:c320967f86b9 288 * and any data has been initialized. For this reason, it cannot do any
mbed_official 525:c320967f86b9 289 * initialization of variables etc.
mbed_official 525:c320967f86b9 290 *****************************************************************************/
mbed_official 525:c320967f86b9 291 void SystemInit(void)
mbed_official 525:c320967f86b9 292 {
mbed_official 525:c320967f86b9 293 }
mbed_official 525:c320967f86b9 294
mbed_official 525:c320967f86b9 295
mbed_official 525:c320967f86b9 296 /**************************************************************************//**
mbed_official 525:c320967f86b9 297 * @brief
mbed_official 525:c320967f86b9 298 * Get low frequency RC oscillator clock frequency for target system.
mbed_official 525:c320967f86b9 299 *
mbed_official 525:c320967f86b9 300 * @note
mbed_official 525:c320967f86b9 301 * This is an EFM32 proprietary function, not part of the CMSIS definition.
mbed_official 525:c320967f86b9 302 *
mbed_official 525:c320967f86b9 303 * @return
mbed_official 525:c320967f86b9 304 * LFRCO frequency in Hz.
mbed_official 525:c320967f86b9 305 *****************************************************************************/
mbed_official 525:c320967f86b9 306 uint32_t SystemLFRCOClockGet(void)
mbed_official 525:c320967f86b9 307 {
mbed_official 525:c320967f86b9 308 /* Currently we assume that this frequency is properly tuned during */
mbed_official 525:c320967f86b9 309 /* manufacturing and is not changed after reset. If future requirements */
mbed_official 525:c320967f86b9 310 /* for re-tuning by user, we can add support for that. */
mbed_official 525:c320967f86b9 311 return EFM32_LFRCO_FREQ;
mbed_official 525:c320967f86b9 312 }
mbed_official 525:c320967f86b9 313
mbed_official 525:c320967f86b9 314
mbed_official 525:c320967f86b9 315 /**************************************************************************//**
mbed_official 525:c320967f86b9 316 * @brief
mbed_official 525:c320967f86b9 317 * Get ultra low frequency RC oscillator clock frequency for target system.
mbed_official 525:c320967f86b9 318 *
mbed_official 525:c320967f86b9 319 * @note
mbed_official 525:c320967f86b9 320 * This is an EFM32 proprietary function, not part of the CMSIS definition.
mbed_official 525:c320967f86b9 321 *
mbed_official 525:c320967f86b9 322 * @return
mbed_official 525:c320967f86b9 323 * ULFRCO frequency in Hz.
mbed_official 525:c320967f86b9 324 *****************************************************************************/
mbed_official 525:c320967f86b9 325 uint32_t SystemULFRCOClockGet(void)
mbed_official 525:c320967f86b9 326 {
mbed_official 525:c320967f86b9 327 /* The ULFRCO frequency is not tuned, and can be very inaccurate */
mbed_official 525:c320967f86b9 328 return EFM32_ULFRCO_FREQ;
mbed_official 525:c320967f86b9 329 }
mbed_official 525:c320967f86b9 330
mbed_official 525:c320967f86b9 331
mbed_official 525:c320967f86b9 332 /**************************************************************************//**
mbed_official 525:c320967f86b9 333 * @brief
mbed_official 525:c320967f86b9 334 * Get low frequency crystal oscillator clock frequency for target system.
mbed_official 525:c320967f86b9 335 *
mbed_official 525:c320967f86b9 336 * @note
mbed_official 525:c320967f86b9 337 * This is an EFM32 proprietary function, not part of the CMSIS definition.
mbed_official 525:c320967f86b9 338 *
mbed_official 525:c320967f86b9 339 * @return
mbed_official 525:c320967f86b9 340 * LFXO frequency in Hz.
mbed_official 525:c320967f86b9 341 *****************************************************************************/
mbed_official 525:c320967f86b9 342 uint32_t SystemLFXOClockGet(void)
mbed_official 525:c320967f86b9 343 {
mbed_official 525:c320967f86b9 344 /* External crystal oscillator present? */
mbed_official 525:c320967f86b9 345 #if (EFM32_LFXO_FREQ > 0)
mbed_official 525:c320967f86b9 346 return SystemLFXOClock;
mbed_official 525:c320967f86b9 347 #else
mbed_official 525:c320967f86b9 348 return 0;
mbed_official 525:c320967f86b9 349 #endif
mbed_official 525:c320967f86b9 350 }
mbed_official 525:c320967f86b9 351
mbed_official 525:c320967f86b9 352
mbed_official 525:c320967f86b9 353 /**************************************************************************//**
mbed_official 525:c320967f86b9 354 * @brief
mbed_official 525:c320967f86b9 355 * Set low frequency crystal oscillator clock frequency for target system.
mbed_official 525:c320967f86b9 356 *
mbed_official 525:c320967f86b9 357 * @note
mbed_official 525:c320967f86b9 358 * This function is mainly provided for being able to handle target systems
mbed_official 525:c320967f86b9 359 * with different HF crystal oscillator frequencies run-time. If used, it
mbed_official 525:c320967f86b9 360 * should probably only be used once during system startup.
mbed_official 525:c320967f86b9 361 *
mbed_official 525:c320967f86b9 362 * @note
mbed_official 525:c320967f86b9 363 * This is an EFM32 proprietary function, not part of the CMSIS definition.
mbed_official 525:c320967f86b9 364 *
mbed_official 525:c320967f86b9 365 * @param[in] freq
mbed_official 525:c320967f86b9 366 * LFXO frequency in Hz used for target.
mbed_official 525:c320967f86b9 367 *****************************************************************************/
mbed_official 525:c320967f86b9 368 void SystemLFXOClockSet(uint32_t freq)
mbed_official 525:c320967f86b9 369 {
mbed_official 525:c320967f86b9 370 /* External crystal oscillator present? */
mbed_official 525:c320967f86b9 371 #if (EFM32_LFXO_FREQ > 0)
mbed_official 525:c320967f86b9 372 SystemLFXOClock = freq;
mbed_official 525:c320967f86b9 373
mbed_official 525:c320967f86b9 374 /* Update core clock frequency if LFXO is used to clock core */
mbed_official 525:c320967f86b9 375 if (CMU->STATUS & CMU_STATUS_LFXOSEL)
mbed_official 525:c320967f86b9 376 {
mbed_official 525:c320967f86b9 377 /* The function will update the global variable */
mbed_official 525:c320967f86b9 378 SystemCoreClockGet();
mbed_official 525:c320967f86b9 379 }
mbed_official 525:c320967f86b9 380 #else
mbed_official 525:c320967f86b9 381 (void)freq; /* Unused parameter */
mbed_official 525:c320967f86b9 382 #endif
mbed_official 525:c320967f86b9 383 }