mbed library sources. Supersedes mbed-src.

Dependents:   Nucleo_Hello_Encoder BLE_iBeaconScan AM1805_DEMO DISCO-F429ZI_ExportTemplate1 ... more

Committer:
AnnaBridge
Date:
Wed Feb 20 22:31:08 2019 +0000
Revision:
189:f392fc9709a3
Parent:
180:96ed750bd169
mbed library release version 165

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Kojto 170:19eb464bc2be 1 /**
Kojto 170:19eb464bc2be 2 ******************************************************************************
Kojto 170:19eb464bc2be 3 * @file system_stm32f0xx.c
Kojto 170:19eb464bc2be 4 * @author MCD Application Team
Kojto 170:19eb464bc2be 5 * @brief CMSIS Cortex-M0 Device Peripheral Access Layer System Source File.
Kojto 170:19eb464bc2be 6 *
Kojto 170:19eb464bc2be 7 * This file provides two functions and one global variable to be called from
Kojto 170:19eb464bc2be 8 * user application:
Kojto 170:19eb464bc2be 9 * - SystemInit(): This function is called at startup just after reset and
Kojto 170:19eb464bc2be 10 * before branch to main program. This call is made inside
Kojto 170:19eb464bc2be 11 * the "startup_stm32f0xx.s" file.
Kojto 170:19eb464bc2be 12 *
Kojto 170:19eb464bc2be 13 * - SystemCoreClock variable: Contains the core clock (HCLK), it can be used
Kojto 170:19eb464bc2be 14 * by the user application to setup the SysTick
Kojto 170:19eb464bc2be 15 * timer or configure other parameters.
Kojto 170:19eb464bc2be 16 *
Kojto 170:19eb464bc2be 17 * - SystemCoreClockUpdate(): Updates the variable SystemCoreClock and must
Kojto 170:19eb464bc2be 18 * be called whenever the core clock is changed
Kojto 170:19eb464bc2be 19 * during program execution.
Kojto 170:19eb464bc2be 20 *
Kojto 170:19eb464bc2be 21 ******************************************************************************
Kojto 170:19eb464bc2be 22 * @attention
Kojto 170:19eb464bc2be 23 *
Kojto 170:19eb464bc2be 24 * <h2><center>&copy; COPYRIGHT(c) 2016 STMicroelectronics</center></h2>
Kojto 170:19eb464bc2be 25 *
Kojto 170:19eb464bc2be 26 * Redistribution and use in source and binary forms, with or without modification,
Kojto 170:19eb464bc2be 27 * are permitted provided that the following conditions are met:
Kojto 170:19eb464bc2be 28 * 1. Redistributions of source code must retain the above copyright notice,
Kojto 170:19eb464bc2be 29 * this list of conditions and the following disclaimer.
Kojto 170:19eb464bc2be 30 * 2. Redistributions in binary form must reproduce the above copyright notice,
Kojto 170:19eb464bc2be 31 * this list of conditions and the following disclaimer in the documentation
Kojto 170:19eb464bc2be 32 * and/or other materials provided with the distribution.
Kojto 170:19eb464bc2be 33 * 3. Neither the name of STMicroelectronics nor the names of its contributors
Kojto 170:19eb464bc2be 34 * may be used to endorse or promote products derived from this software
Kojto 170:19eb464bc2be 35 * without specific prior written permission.
Kojto 170:19eb464bc2be 36 *
Kojto 170:19eb464bc2be 37 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
Kojto 170:19eb464bc2be 38 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
Kojto 170:19eb464bc2be 39 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
Kojto 170:19eb464bc2be 40 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
Kojto 170:19eb464bc2be 41 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
Kojto 170:19eb464bc2be 42 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
Kojto 170:19eb464bc2be 43 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
Kojto 170:19eb464bc2be 44 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
Kojto 170:19eb464bc2be 45 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
Kojto 170:19eb464bc2be 46 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Kojto 170:19eb464bc2be 47 *
Kojto 170:19eb464bc2be 48 ******************************************************************************
Kojto 170:19eb464bc2be 49 */
Kojto 170:19eb464bc2be 50
Kojto 170:19eb464bc2be 51 /** @addtogroup CMSIS
Kojto 170:19eb464bc2be 52 * @{
Kojto 170:19eb464bc2be 53 */
Kojto 170:19eb464bc2be 54
Kojto 170:19eb464bc2be 55 /** @addtogroup stm32f0xx_system
Kojto 170:19eb464bc2be 56 * @{
Kojto 170:19eb464bc2be 57 */
Kojto 170:19eb464bc2be 58
Kojto 170:19eb464bc2be 59 /** @addtogroup STM32F0xx_System_Private_Includes
Kojto 170:19eb464bc2be 60 * @{
Kojto 170:19eb464bc2be 61 */
Kojto 170:19eb464bc2be 62
Kojto 170:19eb464bc2be 63 #include "stm32f0xx.h"
Kojto 170:19eb464bc2be 64
Kojto 170:19eb464bc2be 65 /**
Kojto 170:19eb464bc2be 66 * @}
Kojto 170:19eb464bc2be 67 */
Kojto 170:19eb464bc2be 68
Kojto 170:19eb464bc2be 69 /** @addtogroup STM32F0xx_System_Private_TypesDefinitions
Kojto 170:19eb464bc2be 70 * @{
Kojto 170:19eb464bc2be 71 */
Kojto 170:19eb464bc2be 72
Kojto 170:19eb464bc2be 73 /**
Kojto 170:19eb464bc2be 74 * @}
Kojto 170:19eb464bc2be 75 */
Kojto 170:19eb464bc2be 76
Kojto 170:19eb464bc2be 77 /** @addtogroup STM32F0xx_System_Private_Defines
Kojto 170:19eb464bc2be 78 * @{
Kojto 170:19eb464bc2be 79 */
Kojto 170:19eb464bc2be 80 #if !defined (HSE_VALUE)
Kojto 170:19eb464bc2be 81 #define HSE_VALUE ((uint32_t)8000000) /*!< Default value of the External oscillator in Hz.
Kojto 170:19eb464bc2be 82 This value can be provided and adapted by the user application. */
Kojto 170:19eb464bc2be 83 #endif /* HSE_VALUE */
Kojto 170:19eb464bc2be 84
Kojto 170:19eb464bc2be 85 #if !defined (HSI_VALUE)
Kojto 170:19eb464bc2be 86 #define HSI_VALUE ((uint32_t)8000000) /*!< Default value of the Internal oscillator in Hz.
Kojto 170:19eb464bc2be 87 This value can be provided and adapted by the user application. */
Kojto 170:19eb464bc2be 88 #endif /* HSI_VALUE */
Kojto 170:19eb464bc2be 89
Kojto 170:19eb464bc2be 90 #if !defined (HSI48_VALUE)
Kojto 170:19eb464bc2be 91 #define HSI48_VALUE ((uint32_t)48000000) /*!< Default value of the HSI48 Internal oscillator in Hz.
Kojto 170:19eb464bc2be 92 This value can be provided and adapted by the user application. */
Kojto 170:19eb464bc2be 93 #endif /* HSI48_VALUE */
Kojto 170:19eb464bc2be 94 /**
Kojto 170:19eb464bc2be 95 * @}
Kojto 170:19eb464bc2be 96 */
Kojto 170:19eb464bc2be 97
Kojto 170:19eb464bc2be 98 /** @addtogroup STM32F0xx_System_Private_Macros
Kojto 170:19eb464bc2be 99 * @{
Kojto 170:19eb464bc2be 100 */
Kojto 170:19eb464bc2be 101
Kojto 170:19eb464bc2be 102 /**
Kojto 170:19eb464bc2be 103 * @}
Kojto 170:19eb464bc2be 104 */
Kojto 170:19eb464bc2be 105
Kojto 170:19eb464bc2be 106 /** @addtogroup STM32F0xx_System_Private_Variables
Kojto 170:19eb464bc2be 107 * @{
Kojto 170:19eb464bc2be 108 */
Kojto 170:19eb464bc2be 109 /* This variable is updated in three ways:
Kojto 170:19eb464bc2be 110 1) by calling CMSIS function SystemCoreClockUpdate()
Kojto 170:19eb464bc2be 111 2) by calling HAL API function HAL_RCC_GetHCLKFreq()
Kojto 170:19eb464bc2be 112 3) each time HAL_RCC_ClockConfig() is called to configure the system clock frequency
Kojto 170:19eb464bc2be 113 Note: If you use this function to configure the system clock there is no need to
Kojto 170:19eb464bc2be 114 call the 2 first functions listed above, since SystemCoreClock variable is
Kojto 170:19eb464bc2be 115 updated automatically.
Kojto 170:19eb464bc2be 116 */
Kojto 170:19eb464bc2be 117 uint32_t SystemCoreClock = 8000000;
Kojto 170:19eb464bc2be 118
Kojto 170:19eb464bc2be 119 const uint8_t AHBPrescTable[16] = {0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 6, 7, 8, 9};
Kojto 170:19eb464bc2be 120 const uint8_t APBPrescTable[8] = {0, 0, 0, 0, 1, 2, 3, 4};
Kojto 170:19eb464bc2be 121
Kojto 170:19eb464bc2be 122 /**
Kojto 170:19eb464bc2be 123 * @}
Kojto 170:19eb464bc2be 124 */
Kojto 170:19eb464bc2be 125
Kojto 170:19eb464bc2be 126 /** @addtogroup STM32F0xx_System_Private_FunctionPrototypes
Kojto 170:19eb464bc2be 127 * @{
Kojto 170:19eb464bc2be 128 */
Kojto 170:19eb464bc2be 129
Kojto 170:19eb464bc2be 130 /**
Kojto 170:19eb464bc2be 131 * @}
Kojto 170:19eb464bc2be 132 */
Kojto 170:19eb464bc2be 133
Kojto 170:19eb464bc2be 134 /** @addtogroup STM32F0xx_System_Private_Functions
Kojto 170:19eb464bc2be 135 * @{
Kojto 170:19eb464bc2be 136 */
Kojto 170:19eb464bc2be 137
Kojto 170:19eb464bc2be 138 /*+ MBED */
Kojto 170:19eb464bc2be 139 #if 0
Kojto 170:19eb464bc2be 140 /*- MBED */
Kojto 170:19eb464bc2be 141
Kojto 170:19eb464bc2be 142 /**
Kojto 170:19eb464bc2be 143 * @brief Setup the microcontroller system.
Kojto 170:19eb464bc2be 144 * Initialize the default HSI clock source, vector table location and the PLL configuration is reset.
Kojto 170:19eb464bc2be 145 * @param None
Kojto 170:19eb464bc2be 146 * @retval None
Kojto 170:19eb464bc2be 147 */
Kojto 170:19eb464bc2be 148 void SystemInit(void)
Kojto 170:19eb464bc2be 149 {
Kojto 170:19eb464bc2be 150 /* Reset the RCC clock configuration to the default reset state ------------*/
Kojto 170:19eb464bc2be 151 /* Set HSION bit */
Kojto 170:19eb464bc2be 152 RCC->CR |= (uint32_t)0x00000001U;
Kojto 170:19eb464bc2be 153
Kojto 170:19eb464bc2be 154 #if defined (STM32F051x8) || defined (STM32F058x8)
Kojto 170:19eb464bc2be 155 /* Reset SW[1:0], HPRE[3:0], PPRE[2:0], ADCPRE and MCOSEL[2:0] bits */
Kojto 170:19eb464bc2be 156 RCC->CFGR &= (uint32_t)0xF8FFB80CU;
Kojto 170:19eb464bc2be 157 #else
Kojto 170:19eb464bc2be 158 /* Reset SW[1:0], HPRE[3:0], PPRE[2:0], ADCPRE, MCOSEL[2:0], MCOPRE[2:0] and PLLNODIV bits */
Kojto 170:19eb464bc2be 159 RCC->CFGR &= (uint32_t)0x08FFB80CU;
Kojto 170:19eb464bc2be 160 #endif /* STM32F051x8 or STM32F058x8 */
Kojto 170:19eb464bc2be 161
Kojto 170:19eb464bc2be 162 /* Reset HSEON, CSSON and PLLON bits */
Kojto 170:19eb464bc2be 163 RCC->CR &= (uint32_t)0xFEF6FFFFU;
Kojto 170:19eb464bc2be 164
Kojto 170:19eb464bc2be 165 /* Reset HSEBYP bit */
Kojto 170:19eb464bc2be 166 RCC->CR &= (uint32_t)0xFFFBFFFFU;
Kojto 170:19eb464bc2be 167
Kojto 170:19eb464bc2be 168 /* Reset PLLSRC, PLLXTPRE and PLLMUL[3:0] bits */
Kojto 170:19eb464bc2be 169 RCC->CFGR &= (uint32_t)0xFFC0FFFFU;
Kojto 170:19eb464bc2be 170
Kojto 170:19eb464bc2be 171 /* Reset PREDIV[3:0] bits */
Kojto 170:19eb464bc2be 172 RCC->CFGR2 &= (uint32_t)0xFFFFFFF0U;
Kojto 170:19eb464bc2be 173
Kojto 170:19eb464bc2be 174 #if defined (STM32F072xB) || defined (STM32F078xx)
Kojto 170:19eb464bc2be 175 /* Reset USART2SW[1:0], USART1SW[1:0], I2C1SW, CECSW, USBSW and ADCSW bits */
Kojto 170:19eb464bc2be 176 RCC->CFGR3 &= (uint32_t)0xFFFCFE2CU;
Kojto 170:19eb464bc2be 177 #elif defined (STM32F071xB)
Kojto 170:19eb464bc2be 178 /* Reset USART2SW[1:0], USART1SW[1:0], I2C1SW, CECSW and ADCSW bits */
Kojto 170:19eb464bc2be 179 RCC->CFGR3 &= (uint32_t)0xFFFFCEACU;
Kojto 170:19eb464bc2be 180 #elif defined (STM32F091xC) || defined (STM32F098xx)
Kojto 170:19eb464bc2be 181 /* Reset USART3SW[1:0], USART2SW[1:0], USART1SW[1:0], I2C1SW, CECSW and ADCSW bits */
Kojto 170:19eb464bc2be 182 RCC->CFGR3 &= (uint32_t)0xFFF0FEACU;
Kojto 170:19eb464bc2be 183 #elif defined (STM32F030x6) || defined (STM32F030x8) || defined (STM32F031x6) || defined (STM32F038xx) || defined (STM32F030xC)
Kojto 170:19eb464bc2be 184 /* Reset USART1SW[1:0], I2C1SW and ADCSW bits */
Kojto 170:19eb464bc2be 185 RCC->CFGR3 &= (uint32_t)0xFFFFFEECU;
Kojto 170:19eb464bc2be 186 #elif defined (STM32F051x8) || defined (STM32F058xx)
Kojto 170:19eb464bc2be 187 /* Reset USART1SW[1:0], I2C1SW, CECSW and ADCSW bits */
Kojto 170:19eb464bc2be 188 RCC->CFGR3 &= (uint32_t)0xFFFFFEACU;
Kojto 170:19eb464bc2be 189 #elif defined (STM32F042x6) || defined (STM32F048xx)
Kojto 170:19eb464bc2be 190 /* Reset USART1SW[1:0], I2C1SW, CECSW, USBSW and ADCSW bits */
Kojto 170:19eb464bc2be 191 RCC->CFGR3 &= (uint32_t)0xFFFFFE2CU;
Kojto 170:19eb464bc2be 192 #elif defined (STM32F070x6) || defined (STM32F070xB)
Kojto 170:19eb464bc2be 193 /* Reset USART1SW[1:0], I2C1SW, USBSW and ADCSW bits */
Kojto 170:19eb464bc2be 194 RCC->CFGR3 &= (uint32_t)0xFFFFFE6CU;
Kojto 170:19eb464bc2be 195 /* Set default USB clock to PLLCLK, since there is no HSI48 */
Kojto 170:19eb464bc2be 196 RCC->CFGR3 |= (uint32_t)0x00000080U;
Kojto 170:19eb464bc2be 197 #else
Kojto 170:19eb464bc2be 198 #warning "No target selected"
Kojto 170:19eb464bc2be 199 #endif
Kojto 170:19eb464bc2be 200
Kojto 170:19eb464bc2be 201 /* Reset HSI14 bit */
Kojto 170:19eb464bc2be 202 RCC->CR2 &= (uint32_t)0xFFFFFFFEU;
Kojto 170:19eb464bc2be 203
Kojto 170:19eb464bc2be 204 /* Disable all interrupts */
Kojto 170:19eb464bc2be 205 RCC->CIR = 0x00000000U;
Kojto 170:19eb464bc2be 206
Kojto 170:19eb464bc2be 207 }
Kojto 170:19eb464bc2be 208
Kojto 170:19eb464bc2be 209 /*+ MBED */
Kojto 170:19eb464bc2be 210 #endif
Kojto 170:19eb464bc2be 211 /*- MBED */
Kojto 170:19eb464bc2be 212
Kojto 170:19eb464bc2be 213 /**
Kojto 170:19eb464bc2be 214 * @brief Update SystemCoreClock variable according to Clock Register Values.
Kojto 170:19eb464bc2be 215 * The SystemCoreClock variable contains the core clock (HCLK), it can
Kojto 170:19eb464bc2be 216 * be used by the user application to setup the SysTick timer or configure
Kojto 170:19eb464bc2be 217 * other parameters.
Kojto 170:19eb464bc2be 218 *
Kojto 170:19eb464bc2be 219 * @note Each time the core clock (HCLK) changes, this function must be called
Kojto 170:19eb464bc2be 220 * to update SystemCoreClock variable value. Otherwise, any configuration
Kojto 170:19eb464bc2be 221 * based on this variable will be incorrect.
Kojto 170:19eb464bc2be 222 *
Kojto 170:19eb464bc2be 223 * @note - The system frequency computed by this function is not the real
Kojto 170:19eb464bc2be 224 * frequency in the chip. It is calculated based on the predefined
Kojto 170:19eb464bc2be 225 * constant and the selected clock source:
Kojto 170:19eb464bc2be 226 *
Kojto 170:19eb464bc2be 227 * - If SYSCLK source is HSI, SystemCoreClock will contain the HSI_VALUE(*)
Kojto 170:19eb464bc2be 228 *
Kojto 170:19eb464bc2be 229 * - If SYSCLK source is HSE, SystemCoreClock will contain the HSE_VALUE(**)
Kojto 170:19eb464bc2be 230 *
Kojto 170:19eb464bc2be 231 * - If SYSCLK source is PLL, SystemCoreClock will contain the HSE_VALUE(**)
Kojto 170:19eb464bc2be 232 * or HSI_VALUE(*) multiplied/divided by the PLL factors.
Kojto 170:19eb464bc2be 233 *
Kojto 170:19eb464bc2be 234 * (*) HSI_VALUE is a constant defined in stm32f0xx_hal.h file (default value
Kojto 170:19eb464bc2be 235 * 8 MHz) but the real value may vary depending on the variations
Kojto 170:19eb464bc2be 236 * in voltage and temperature.
Kojto 170:19eb464bc2be 237 *
Kojto 170:19eb464bc2be 238 * (**) HSE_VALUE is a constant defined in stm32f0xx_hal.h file (default value
Kojto 170:19eb464bc2be 239 * 8 MHz), user has to ensure that HSE_VALUE is same as the real
Kojto 170:19eb464bc2be 240 * frequency of the crystal used. Otherwise, this function may
Kojto 170:19eb464bc2be 241 * have wrong result.
Kojto 170:19eb464bc2be 242 *
Kojto 170:19eb464bc2be 243 * - The result of this function could be not correct when using fractional
Kojto 170:19eb464bc2be 244 * value for HSE crystal.
Kojto 170:19eb464bc2be 245 *
Kojto 170:19eb464bc2be 246 * @param None
Kojto 170:19eb464bc2be 247 * @retval None
Kojto 170:19eb464bc2be 248 */
Kojto 170:19eb464bc2be 249 void SystemCoreClockUpdate (void)
Kojto 170:19eb464bc2be 250 {
Kojto 170:19eb464bc2be 251 uint32_t tmp = 0, pllmull = 0, pllsource = 0, predivfactor = 0;
Kojto 170:19eb464bc2be 252
Kojto 170:19eb464bc2be 253 /* Get SYSCLK source -------------------------------------------------------*/
Kojto 170:19eb464bc2be 254 tmp = RCC->CFGR & RCC_CFGR_SWS;
Kojto 170:19eb464bc2be 255
Kojto 170:19eb464bc2be 256 switch (tmp)
Kojto 170:19eb464bc2be 257 {
Kojto 170:19eb464bc2be 258 case RCC_CFGR_SWS_HSI: /* HSI used as system clock */
Kojto 170:19eb464bc2be 259 SystemCoreClock = HSI_VALUE;
Kojto 170:19eb464bc2be 260 break;
Kojto 170:19eb464bc2be 261 case RCC_CFGR_SWS_HSE: /* HSE used as system clock */
Kojto 170:19eb464bc2be 262 SystemCoreClock = HSE_VALUE;
Kojto 170:19eb464bc2be 263 break;
Kojto 170:19eb464bc2be 264 case RCC_CFGR_SWS_PLL: /* PLL used as system clock */
Kojto 170:19eb464bc2be 265 /* Get PLL clock source and multiplication factor ----------------------*/
Kojto 170:19eb464bc2be 266 pllmull = RCC->CFGR & RCC_CFGR_PLLMUL;
Kojto 170:19eb464bc2be 267 pllsource = RCC->CFGR & RCC_CFGR_PLLSRC;
Kojto 170:19eb464bc2be 268 pllmull = ( pllmull >> 18) + 2;
Kojto 170:19eb464bc2be 269 predivfactor = (RCC->CFGR2 & RCC_CFGR2_PREDIV) + 1;
Kojto 170:19eb464bc2be 270
Kojto 170:19eb464bc2be 271 if (pllsource == RCC_CFGR_PLLSRC_HSE_PREDIV)
Kojto 170:19eb464bc2be 272 {
Kojto 170:19eb464bc2be 273 /* HSE used as PLL clock source : SystemCoreClock = HSE/PREDIV * PLLMUL */
Kojto 170:19eb464bc2be 274 SystemCoreClock = (HSE_VALUE/predivfactor) * pllmull;
Kojto 170:19eb464bc2be 275 }
Kojto 170:19eb464bc2be 276 #if defined(STM32F042x6) || defined(STM32F048xx) || defined(STM32F072xB) || defined(STM32F078xx) || defined(STM32F091xC) || defined(STM32F098xx)
Kojto 170:19eb464bc2be 277 else if (pllsource == RCC_CFGR_PLLSRC_HSI48_PREDIV)
Kojto 170:19eb464bc2be 278 {
Kojto 170:19eb464bc2be 279 /* HSI48 used as PLL clock source : SystemCoreClock = HSI48/PREDIV * PLLMUL */
Kojto 170:19eb464bc2be 280 SystemCoreClock = (HSI48_VALUE/predivfactor) * pllmull;
Kojto 170:19eb464bc2be 281 }
Kojto 170:19eb464bc2be 282 #endif /* STM32F042x6 || STM32F048xx || STM32F072xB || STM32F078xx || STM32F091xC || STM32F098xx */
Kojto 170:19eb464bc2be 283 else
Kojto 170:19eb464bc2be 284 {
Kojto 170:19eb464bc2be 285 #if defined(STM32F042x6) || defined(STM32F048xx) || defined(STM32F070x6) \
Kojto 170:19eb464bc2be 286 || defined(STM32F078xx) || defined(STM32F071xB) || defined(STM32F072xB) \
Kojto 170:19eb464bc2be 287 || defined(STM32F070xB) || defined(STM32F091xC) || defined(STM32F098xx) || defined(STM32F030xC)
Kojto 170:19eb464bc2be 288 /* HSI used as PLL clock source : SystemCoreClock = HSI/PREDIV * PLLMUL */
Kojto 170:19eb464bc2be 289 SystemCoreClock = (HSI_VALUE/predivfactor) * pllmull;
Kojto 170:19eb464bc2be 290 #else
Kojto 170:19eb464bc2be 291 /* HSI used as PLL clock source : SystemCoreClock = HSI/2 * PLLMUL */
Kojto 170:19eb464bc2be 292 SystemCoreClock = (HSI_VALUE >> 1) * pllmull;
Kojto 170:19eb464bc2be 293 #endif /* STM32F042x6 || STM32F048xx || STM32F070x6 ||
Kojto 170:19eb464bc2be 294 STM32F071xB || STM32F072xB || STM32F078xx || STM32F070xB ||
Kojto 170:19eb464bc2be 295 STM32F091xC || STM32F098xx || STM32F030xC */
Kojto 170:19eb464bc2be 296 }
Kojto 170:19eb464bc2be 297 break;
Kojto 170:19eb464bc2be 298 default: /* HSI used as system clock */
Kojto 170:19eb464bc2be 299 SystemCoreClock = HSI_VALUE;
Kojto 170:19eb464bc2be 300 break;
Kojto 170:19eb464bc2be 301 }
Kojto 170:19eb464bc2be 302 /* Compute HCLK clock frequency ----------------*/
Kojto 170:19eb464bc2be 303 /* Get HCLK prescaler */
Kojto 170:19eb464bc2be 304 tmp = AHBPrescTable[((RCC->CFGR & RCC_CFGR_HPRE) >> 4)];
Kojto 170:19eb464bc2be 305 /* HCLK clock frequency */
Kojto 170:19eb464bc2be 306 SystemCoreClock >>= tmp;
Kojto 170:19eb464bc2be 307 }
Kojto 170:19eb464bc2be 308
Kojto 170:19eb464bc2be 309 /**
Kojto 170:19eb464bc2be 310 * @}
Kojto 170:19eb464bc2be 311 */
Kojto 170:19eb464bc2be 312
Kojto 170:19eb464bc2be 313 /**
Kojto 170:19eb464bc2be 314 * @}
Kojto 170:19eb464bc2be 315 */
Kojto 170:19eb464bc2be 316
Kojto 170:19eb464bc2be 317 /**
Kojto 170:19eb464bc2be 318 * @}
Kojto 170:19eb464bc2be 319 */
Kojto 170:19eb464bc2be 320
Kojto 170:19eb464bc2be 321 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
Kojto 170:19eb464bc2be 322