6060 ******************************************************************************
6161 * @attention
6262 *
63- * <h2><center>© Copyright (c) 2019 STMicroelectronics.
64- * All rights reserved.</center></h2>
63+ * Copyright (c) 2019-2021 STMicroelectronics.
64+ * All rights reserved.
6565 *
6666 * This software component is licensed by ST under Apache License, Version 2.0,
6767 * the "License"; You may not use this file except in compliance with the
142142/** @addtogroup STM32WBxx_System_Private_Variables
143143 * @{
144144 */
145- /* The SystemCoreClock variable is updated in three ways:
146- 1) by calling CMSIS function SystemCoreClockUpdate()
147- 2) by calling HAL API function HAL_RCC_GetHCLKFreq()
148- 3) each time HAL_RCC_ClockConfig() is called to configure the system clock frequency
149- Note: If you use this function to configure the system clock; then there
150- is no need to call the 2 first functions listed above, since SystemCoreClock
151- variable is updated automatically.
152- */
153- uint32_t SystemCoreClock = 4000000UL ; /*CPU1: M4 on MSI clock after startup (4MHz)*/
145+ /* The SystemCoreClock variable is updated in three ways:
146+ 1) by calling CMSIS function SystemCoreClockUpdate()
147+ 2) by calling HAL API function HAL_RCC_GetHCLKFreq()
148+ 3) each time HAL_RCC_ClockConfig() is called to configure the system clock frequency
149+ Note: If you use this function to configure the system clock; then there
150+ is no need to call the 2 first functions listed above, since SystemCoreClock
151+ variable is updated automatically.
152+ */
153+ uint32_t SystemCoreClock = 4000000UL ; /*CPU1: M4 on MSI clock after startup (4MHz)*/
154154
155155 const uint32_t AHBPrescTable [16UL ] = {1UL , 3UL , 5UL , 1UL , 1UL , 6UL , 10UL , 32UL , 2UL , 4UL , 8UL , 16UL , 64UL , 128UL , 256UL , 512UL };
156156
159159 const uint32_t MSIRangeTable [16UL ] = {100000UL , 200000UL , 400000UL , 800000UL , 1000000UL , 2000000UL , \
160160 4000000UL , 8000000UL , 16000000UL , 24000000UL , 32000000UL , 48000000UL , 0UL , 0UL , 0UL , 0UL }; /* 0UL values are incorrect cases */
161161
162- #if defined(STM32WB55xx ) || defined(STM32WB5Mxx ) || defined(STM32WB35xx ) || defined (STM32WB15xx )
162+ #if defined(STM32WB55xx ) || defined(STM32WB5Mxx ) || defined(STM32WB35xx ) || defined (STM32WB15xx ) || defined ( STM32WB1Mxx )
163163 const uint32_t SmpsPrescalerTable [4UL ][6UL ]= {{1UL ,3UL ,2UL ,2UL ,1UL ,2UL }, \
164164 {2UL ,6UL ,4UL ,3UL ,2UL ,4UL }, \
165165 {4UL ,12UL ,8UL ,6UL ,4UL ,8UL }, \
166166 {4UL ,12UL ,8UL ,6UL ,4UL ,8UL }};
167- #endif
167+ #endif /* STM32WB55xx || STM32WB5Mxx || STM32WB35xx || STM32WB15xx || STM32WB1Mxx */
168168
169169/**
170170 * @}
@@ -192,10 +192,10 @@ void SystemInit(void)
192192 SCB -> VTOR = VECT_TAB_BASE_ADDRESS | VECT_TAB_OFFSET ;
193193
194194 /* FPU settings ------------------------------------------------------------*/
195- #if (__FPU_PRESENT == 1 ) && (__FPU_USED == 1 )
196- SCB -> CPACR |= ((3UL << (10UL * 2UL ))| (3UL << (11UL * 2UL ))); /* set CP10 and CP11 Full Access */
197- #endif
198-
195+ #if (__FPU_PRESENT == 1 ) && (__FPU_USED == 1 )
196+ SCB -> CPACR |= ((3UL << (10UL * 2UL )) | (3UL << (11UL * 2UL ))); /* set CP10 and CP11 Full Access */
197+ #endif /* FPU */
198+
199199 /* Reset the RCC clock configuration to the default reset state ------------*/
200200 /* Set MSION bit */
201201 RCC -> CR |= RCC_CR_MSION ;
@@ -204,21 +204,21 @@ void SystemInit(void)
204204 RCC -> CFGR = 0x00070000U ;
205205
206206 /* Reset PLLSAI1ON, PLLON, HSECSSON, HSEON, HSION, and MSIPLLON bits */
207- RCC -> CR &= 0xFAF6FEFBU ;
207+ RCC -> CR &= ( uint32_t ) 0xFAF6FEFBU ;
208208
209209 /*!< Reset LSI1 and LSI2 bits */
210- RCC -> CSR &= 0xFFFFFFFAU ;
211-
210+ RCC -> CSR &= ( uint32_t ) 0xFFFFFFFAU ;
211+
212212 /*!< Reset HSI48ON bit */
213- RCC -> CRRCR &= 0xFFFFFFFEU ;
214-
213+ RCC -> CRRCR &= ( uint32_t ) 0xFFFFFFFEU ;
214+
215215 /* Reset PLLCFGR register */
216216 RCC -> PLLCFGR = 0x22041000U ;
217217
218218#if defined(STM32WB55xx ) || defined(STM32WB5Mxx )
219219 /* Reset PLLSAI1CFGR register */
220220 RCC -> PLLSAI1CFGR = 0x22041000U ;
221- #endif
221+ #endif /* STM32WB55xx || STM32WB5Mxx */
222222
223223 /* Reset HSEBYP bit */
224224 RCC -> CR &= 0xFFFBFFFFU ;
@@ -280,7 +280,7 @@ void SystemInit(void)
280280 */
281281void SystemCoreClockUpdate (void )
282282{
283- uint32_t tmp , msirange , pllvco , pllr , pllsource , pllm ;
283+ uint32_t tmp , msirange , pllvco , pllr , pllsource , pllm ;
284284
285285 /* Get MSI Range frequency--------------------------------------------------*/
286286
@@ -290,13 +290,13 @@ void SystemCoreClockUpdate(void)
290290 /* Get SYSCLK source -------------------------------------------------------*/
291291 switch (RCC -> CFGR & RCC_CFGR_SWS )
292292 {
293- case 0x00 : /* MSI used as system clock source */
293+ case 0x00 : /* MSI used as system clock source */
294294 SystemCoreClock = msirange ;
295295 break ;
296296
297- case 0x04 : /* HSI used as system clock source */
297+ case 0x04 : /* HSI used as system clock source */
298298 /* HSI used as system clock source */
299- SystemCoreClock = HSI_VALUE ;
299+ SystemCoreClock = HSI_VALUE ;
300300 break ;
301301
302302 case 0x08 : /* HSE used as system clock source */
@@ -310,36 +310,36 @@ void SystemCoreClockUpdate(void)
310310 pllsource = (RCC -> PLLCFGR & RCC_PLLCFGR_PLLSRC );
311311 pllm = ((RCC -> PLLCFGR & RCC_PLLCFGR_PLLM ) >> RCC_PLLCFGR_PLLM_Pos ) + 1UL ;
312312
313- if (pllsource == 0x02UL ) /* HSI used as PLL clock source */
313+ if (pllsource == 0x02UL ) /* HSI used as PLL clock source */
314314 {
315315 pllvco = (HSI_VALUE / pllm );
316316 }
317- else if (pllsource == 0x03UL ) /* HSE used as PLL clock source */
317+ else if (pllsource == 0x03UL ) /* HSE used as PLL clock source */
318318 {
319319 pllvco = (HSE_VALUE / pllm );
320320 }
321321 else /* MSI used as PLL clock source */
322322 {
323323 pllvco = (msirange / pllm );
324324 }
325-
325+
326326 pllvco = pllvco * ((RCC -> PLLCFGR & RCC_PLLCFGR_PLLN ) >> RCC_PLLCFGR_PLLN_Pos );
327327 pllr = (((RCC -> PLLCFGR & RCC_PLLCFGR_PLLR ) >> RCC_PLLCFGR_PLLR_Pos ) + 1UL );
328-
329- SystemCoreClock = pllvco / pllr ;
328+
329+ SystemCoreClock = pllvco / pllr ;
330330 break ;
331331
332332 default :
333333 SystemCoreClock = msirange ;
334334 break ;
335335 }
336-
336+
337337 /* Compute HCLK clock frequency --------------------------------------------*/
338338 /* Get HCLK1 prescaler */
339339 tmp = AHBPrescTable [((RCC -> CFGR & RCC_CFGR_HPRE ) >> RCC_CFGR_HPRE_Pos )];
340+
340341 /* HCLK clock frequency */
341342 SystemCoreClock = SystemCoreClock / tmp ;
342-
343343}
344344
345345
0 commit comments