2
2
******************************************************************************
3
3
* @file system_stm32l4xx.c
4
4
* @author MCD Application Team
5
- * @version V1.3.1
6
- * @date 21-April-2017
7
5
* @brief CMSIS Cortex-M4 Device Peripheral Access Layer System Source File
8
6
*
9
7
* This file provides two functions and one global variable to be called from
110
108
#include "stm32l4xx.h"
111
109
112
110
#if !defined (HSE_VALUE )
113
- #define HSE_VALUE ((uint32_t)8000000) /*!< Value of the External oscillator in Hz */
111
+ #define HSE_VALUE 8000000U /*!< Value of the External oscillator in Hz */
114
112
#endif /* HSE_VALUE */
115
113
116
114
#if !defined (MSI_VALUE )
117
- #define MSI_VALUE ((uint32_t)4000000) /*!< Value of the Internal oscillator in Hz*/
115
+ #define MSI_VALUE 4000000U /*!< Value of the Internal oscillator in Hz*/
118
116
#endif /* MSI_VALUE */
119
117
120
118
#if !defined (HSI_VALUE )
121
- #define HSI_VALUE ((uint32_t)16000000) /*!< Value of the Internal oscillator in Hz*/
119
+ #define HSI_VALUE 16000000U /*!< Value of the Internal oscillator in Hz*/
122
120
#endif /* HSI_VALUE */
123
121
124
122
/**
167
165
is no need to call the 2 first functions listed above, since SystemCoreClock
168
166
variable is updated automatically.
169
167
*/
170
- uint32_t SystemCoreClock = 4000000 ;
168
+ uint32_t SystemCoreClock = 4000000U ;
171
169
172
- const uint8_t AHBPrescTable [16 ] = {0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 1 , 2 , 3 , 4 , 6 , 7 , 8 , 9 };
173
- const uint8_t APBPrescTable [8 ] = {0 , 0 , 0 , 0 , 1 , 2 , 3 , 4 };
174
- const uint32_t MSIRangeTable [12 ] = {100000 , 200000 , 400000 , 800000 , 1000000 , 2000000 , \
175
- 4000000 , 8000000 , 16000000 , 24000000 , 32000000 , 48000000 };
170
+ const uint8_t AHBPrescTable [16 ] = {0U , 0U , 0U , 0U , 0U , 0U , 0U , 0U , 1U , 2U , 3U , 4U , 6U , 7U , 8U , 9U };
171
+ const uint8_t APBPrescTable [8 ] = {0U , 0U , 0U , 0U , 1U , 2U , 3U , 4U };
172
+ const uint32_t MSIRangeTable [12 ] = {100000U , 200000U , 400000U , 800000U , 1000000U , 2000000U , \
173
+ 4000000U , 8000000U , 16000000U , 24000000U , 32000000U , 48000000U };
176
174
/**
177
175
* @}
178
176
*/
189
187
* @{
190
188
*/
191
189
190
+ // Removed from MBED PR #4740
192
191
/*+ MBED */
193
192
#if 0
194
193
/*- MBED */
@@ -205,24 +204,25 @@ void SystemInit(void)
205
204
#if (__FPU_PRESENT == 1 ) && (__FPU_USED == 1 )
206
205
SCB -> CPACR |= ((3UL << 10 * 2 )|(3UL << 11 * 2 )); /* set CP10 and CP11 Full Access */
207
206
#endif
207
+
208
208
/* Reset the RCC clock configuration to the default reset state ------------*/
209
209
/* Set MSION bit */
210
210
RCC -> CR |= RCC_CR_MSION ;
211
211
212
212
/* Reset CFGR register */
213
- RCC -> CFGR = 0x00000000 ;
213
+ RCC -> CFGR = 0x00000000U ;
214
214
215
215
/* Reset HSEON, CSSON , HSION, and PLLON bits */
216
- RCC -> CR &= ( uint32_t ) 0xEAF6FFFF ;
216
+ RCC -> CR &= 0xEAF6FFFFU ;
217
217
218
218
/* Reset PLLCFGR register */
219
- RCC -> PLLCFGR = 0x00001000 ;
219
+ RCC -> PLLCFGR = 0x00001000U ;
220
220
221
221
/* Reset HSEBYP bit */
222
- RCC -> CR &= ( uint32_t ) 0xFFFBFFFF ;
222
+ RCC -> CR &= 0xFFFBFFFFU ;
223
223
224
224
/* Disable all interrupts */
225
- RCC -> CIER = 0x00000000 ;
225
+ RCC -> CIER = 0x00000000U ;
226
226
227
227
/* Configure the Vector Table location add offset address ------------------*/
228
228
#ifdef VECT_TAB_SRAM
@@ -280,16 +280,16 @@ void SystemInit(void)
280
280
*/
281
281
void SystemCoreClockUpdate (void )
282
282
{
283
- uint32_t tmp = 0 , msirange = 0 , pllvco = 0 , pllr = 2 , pllsource = 0 , pllm = 2 ;
283
+ uint32_t tmp = 0U , msirange = 0U , pllvco = 0U , pllr = 2U , pllsource = 0U , pllm = 2U ;
284
284
285
285
/* Get MSI Range frequency--------------------------------------------------*/
286
286
if ((RCC -> CR & RCC_CR_MSIRGSEL ) == RESET )
287
287
{ /* MSISRANGE from RCC_CSR applies */
288
- msirange = (RCC -> CSR & RCC_CSR_MSISRANGE ) >> 8 ;
288
+ msirange = (RCC -> CSR & RCC_CSR_MSISRANGE ) >> 8U ;
289
289
}
290
290
else
291
291
{ /* MSIRANGE from RCC_CR applies */
292
- msirange = (RCC -> CR & RCC_CR_MSIRANGE ) >> 4 ;
292
+ msirange = (RCC -> CR & RCC_CR_MSIRANGE ) >> 4U ;
293
293
}
294
294
/*MSI frequency range in HZ*/
295
295
msirange = MSIRangeTable [msirange ];
@@ -314,7 +314,7 @@ void SystemCoreClockUpdate(void)
314
314
SYSCLK = PLL_VCO / PLLR
315
315
*/
316
316
pllsource = (RCC -> PLLCFGR & RCC_PLLCFGR_PLLSRC );
317
- pllm = ((RCC -> PLLCFGR & RCC_PLLCFGR_PLLM ) >> 4 ) + 1 ;
317
+ pllm = ((RCC -> PLLCFGR & RCC_PLLCFGR_PLLM ) >> 4U ) + 1U ;
318
318
319
319
switch (pllsource )
320
320
{
@@ -330,8 +330,8 @@ void SystemCoreClockUpdate(void)
330
330
pllvco = (msirange / pllm );
331
331
break ;
332
332
}
333
- pllvco = pllvco * ((RCC -> PLLCFGR & RCC_PLLCFGR_PLLN ) >> 8 );
334
- pllr = (((RCC -> PLLCFGR & RCC_PLLCFGR_PLLR ) >> 25 ) + 1 ) * 2 ;
333
+ pllvco = pllvco * ((RCC -> PLLCFGR & RCC_PLLCFGR_PLLN ) >> 8U );
334
+ pllr = (((RCC -> PLLCFGR & RCC_PLLCFGR_PLLR ) >> 25U ) + 1U ) * 2U ;
335
335
SystemCoreClock = pllvco /pllr ;
336
336
break ;
337
337
@@ -341,7 +341,7 @@ void SystemCoreClockUpdate(void)
341
341
}
342
342
/* Compute HCLK clock frequency --------------------------------------------*/
343
343
/* Get HCLK prescaler */
344
- tmp = AHBPrescTable [((RCC -> CFGR & RCC_CFGR_HPRE ) >> 4 )];
344
+ tmp = AHBPrescTable [((RCC -> CFGR & RCC_CFGR_HPRE ) >> 4U )];
345
345
/* HCLK clock frequency */
346
346
SystemCoreClock >>= tmp ;
347
347
}
0 commit comments