Pedro Correia / mbed-dev

Fork of mbed-dev by mbed official

Committer:
Kojto
Date:
Thu Aug 03 13:13:39 2017 +0100
Revision:
170:19eb464bc2be
Child:
180:96ed750bd169
This updates the lib to the mbed lib v 148

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