2
2
******************************************************************************
3
3
* @file system_stm32f1xx.c
4
4
* @author MCD Application Team
5
- * @version V4.1 .0
6
- * @date 29-April-2016
5
+ * @version V4.2 .0
6
+ * @date 31-March-2017
7
7
* @brief CMSIS Cortex-M3 Device Peripheral Access Layer System Source File.
8
8
*
9
9
* 1. This file provides two functions and one global variable to be called from
52
52
******************************************************************************
53
53
* @attention
54
54
*
55
- * <h2><center>© COPYRIGHT(c) 2016 STMicroelectronics</center></h2>
55
+ * <h2><center>© COPYRIGHT(c) 2017 STMicroelectronics</center></h2>
56
56
*
57
57
* Redistribution and use in source and binary forms, with or without modification,
58
58
* are permitted provided that the following conditions are met:
111
111
*/
112
112
113
113
#if !defined (HSE_VALUE )
114
- #define HSE_VALUE ((uint32_t)8000000) /*!< Default value of the External oscillator in Hz.
114
+ #define HSE_VALUE 8000000U /*!< Default value of the External oscillator in Hz.
115
115
This value can be provided and adapted by the user application. */
116
116
#endif /* HSE_VALUE */
117
117
118
118
#if !defined (HSI_VALUE )
119
- #define HSI_VALUE ((uint32_t)8000000) /*!< Default value of the Internal oscillator in Hz.
119
+ #define HSI_VALUE 8000000U /*!< Default value of the Internal oscillator in Hz.
120
120
This value can be provided and adapted by the user application. */
121
121
#endif /* HSI_VALUE */
122
122
128
128
/*!< Uncomment the following line if you need to relocate your vector Table in
129
129
Internal SRAM. */
130
130
/* #define VECT_TAB_SRAM */
131
- #define VECT_TAB_OFFSET 0x0 /*!< Vector Table base offset field.
131
+ #define VECT_TAB_OFFSET 0x00000000U /*!< Vector Table base offset field.
132
132
This value must be a multiple of 0x200. */
133
133
134
134
156
156
* Clock Definitions
157
157
*******************************************************************************/
158
158
#if defined(STM32F100xB ) || defined(STM32F100xE )
159
- uint32_t SystemCoreClock = 24000000 ; /*!< System Clock Frequency (Core Clock) */
159
+ uint32_t SystemCoreClock = 24000000U ; /*!< System Clock Frequency (Core Clock) */
160
160
#else /*!< HSI Selected as System Clock source */
161
- uint32_t SystemCoreClock = 72000000 ; /*!< System Clock Frequency (Core Clock) */
161
+ uint32_t SystemCoreClock = 72000000U ; /*!< System Clock Frequency (Core Clock) */
162
162
#endif
163
163
164
- const uint8_t AHBPrescTable [16 ] = {0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 1 , 2 , 3 , 4 , 6 , 7 , 8 , 9 };
165
- const uint8_t APBPrescTable [8 ] = {0 , 0 , 0 , 0 , 1 , 2 , 3 , 4 };
164
+ const uint8_t AHBPrescTable [16U ] = {0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 1 , 2 , 3 , 4 , 6 , 7 , 8 , 9 };
165
+ const uint8_t APBPrescTable [8U ] = {0 , 0 , 0 , 0 , 1 , 2 , 3 , 4 };
166
166
167
167
/**
168
168
* @}
@@ -204,42 +204,42 @@ void SystemInit (void)
204
204
{
205
205
/* Reset the RCC clock configuration to the default reset state(for debug purpose) */
206
206
/* Set HSION bit */
207
- RCC -> CR |= ( uint32_t ) 0x00000001 ;
207
+ RCC -> CR |= 0x00000001U ;
208
208
209
209
/* Reset SW, HPRE, PPRE1, PPRE2, ADCPRE and MCO bits */
210
210
#if !defined(STM32F105xC ) && !defined(STM32F107xC )
211
- RCC -> CFGR &= ( uint32_t ) 0xF8FF0000 ;
211
+ RCC -> CFGR &= 0xF8FF0000U ;
212
212
#else
213
- RCC -> CFGR &= ( uint32_t ) 0xF0FF0000 ;
213
+ RCC -> CFGR &= 0xF0FF0000U ;
214
214
#endif /* STM32F105xC */
215
215
216
216
/* Reset HSEON, CSSON and PLLON bits */
217
- RCC -> CR &= ( uint32_t ) 0xFEF6FFFF ;
217
+ RCC -> CR &= 0xFEF6FFFFU ;
218
218
219
219
/* Reset HSEBYP bit */
220
- RCC -> CR &= ( uint32_t ) 0xFFFBFFFF ;
220
+ RCC -> CR &= 0xFFFBFFFFU ;
221
221
222
222
/* Reset PLLSRC, PLLXTPRE, PLLMUL and USBPRE/OTGFSPRE bits */
223
- RCC -> CFGR &= ( uint32_t ) 0xFF80FFFF ;
223
+ RCC -> CFGR &= 0xFF80FFFFU ;
224
224
225
225
#if defined(STM32F105xC ) || defined(STM32F107xC )
226
226
/* Reset PLL2ON and PLL3ON bits */
227
- RCC -> CR &= ( uint32_t ) 0xEBFFFFFF ;
227
+ RCC -> CR &= 0xEBFFFFFFU ;
228
228
229
229
/* Disable all interrupts and clear pending bits */
230
- RCC -> CIR = 0x00FF0000 ;
230
+ RCC -> CIR = 0x00FF0000U ;
231
231
232
232
/* Reset CFGR2 register */
233
- RCC -> CFGR2 = 0x00000000 ;
233
+ RCC -> CFGR2 = 0x00000000U ;
234
234
#elif defined(STM32F100xB ) || defined(STM32F100xE )
235
235
/* Disable all interrupts and clear pending bits */
236
- RCC -> CIR = 0x009F0000 ;
236
+ RCC -> CIR = 0x009F0000U ;
237
237
238
238
/* Reset CFGR2 register */
239
- RCC -> CFGR2 = 0x00000000 ;
239
+ RCC -> CFGR2 = 0x00000000U ;
240
240
#else
241
241
/* Disable all interrupts and clear pending bits */
242
- RCC -> CIR = 0x009F0000 ;
242
+ RCC -> CIR = 0x009F0000U ;
243
243
#endif /* STM32F105xC */
244
244
245
245
#if defined(STM32F100xE ) || defined(STM32F101xE ) || defined(STM32F101xG ) || defined(STM32F103xE ) || defined(STM32F103xG )
@@ -304,52 +304,52 @@ void SystemInit (void)
304
304
*/
305
305
void SystemCoreClockUpdate (void )
306
306
{
307
- uint32_t tmp = 0 , pllmull = 0 , pllsource = 0 ;
307
+ uint32_t tmp = 0U , pllmull = 0U , pllsource = 0U ;
308
308
309
309
#if defined(STM32F105xC ) || defined(STM32F107xC )
310
- uint32_t prediv1source = 0 , prediv1factor = 0 , prediv2factor = 0 , pll2mull = 0 ;
310
+ uint32_t prediv1source = 0U , prediv1factor = 0U , prediv2factor = 0U , pll2mull = 0U ;
311
311
#endif /* STM32F105xC */
312
312
313
313
#if defined(STM32F100xB ) || defined(STM32F100xE )
314
- uint32_t prediv1factor = 0 ;
314
+ uint32_t prediv1factor = 0U ;
315
315
#endif /* STM32F100xB or STM32F100xE */
316
316
317
317
/* Get SYSCLK source -------------------------------------------------------*/
318
318
tmp = RCC -> CFGR & RCC_CFGR_SWS ;
319
319
320
320
switch (tmp )
321
321
{
322
- case 0x00 : /* HSI used as system clock */
322
+ case 0x00U : /* HSI used as system clock */
323
323
SystemCoreClock = HSI_VALUE ;
324
324
break ;
325
- case 0x04 : /* HSE used as system clock */
325
+ case 0x04U : /* HSE used as system clock */
326
326
SystemCoreClock = HSE_VALUE ;
327
327
break ;
328
- case 0x08 : /* PLL used as system clock */
328
+ case 0x08U : /* PLL used as system clock */
329
329
330
330
/* Get PLL clock source and multiplication factor ----------------------*/
331
331
pllmull = RCC -> CFGR & RCC_CFGR_PLLMULL ;
332
332
pllsource = RCC -> CFGR & RCC_CFGR_PLLSRC ;
333
333
334
334
#if !defined(STM32F105xC ) && !defined(STM32F107xC )
335
- pllmull = ( pllmull >> 18 ) + 2 ;
335
+ pllmull = ( pllmull >> 18U ) + 2U ;
336
336
337
- if (pllsource == 0x00 )
337
+ if (pllsource == 0x00U )
338
338
{
339
339
/* HSI oscillator clock divided by 2 selected as PLL clock entry */
340
- SystemCoreClock = (HSI_VALUE >> 1 ) * pllmull ;
340
+ SystemCoreClock = (HSI_VALUE >> 1U ) * pllmull ;
341
341
}
342
342
else
343
343
{
344
344
#if defined(STM32F100xB ) || defined(STM32F100xE )
345
- prediv1factor = (RCC -> CFGR2 & RCC_CFGR2_PREDIV1 ) + 1 ;
345
+ prediv1factor = (RCC -> CFGR2 & RCC_CFGR2_PREDIV1 ) + 1U ;
346
346
/* HSE oscillator clock selected as PREDIV1 clock entry */
347
347
SystemCoreClock = (HSE_VALUE / prediv1factor ) * pllmull ;
348
348
#else
349
349
/* HSE selected as PLL clock entry */
350
350
if ((RCC -> CFGR & RCC_CFGR_PLLXTPRE ) != (uint32_t )RESET )
351
351
{/* HSE oscillator clock divided by 2 */
352
- SystemCoreClock = (HSE_VALUE >> 1 ) * pllmull ;
352
+ SystemCoreClock = (HSE_VALUE >> 1U ) * pllmull ;
353
353
}
354
354
else
355
355
{
@@ -358,30 +358,30 @@ void SystemCoreClockUpdate (void)
358
358
#endif
359
359
}
360
360
#else
361
- pllmull = pllmull >> 18 ;
361
+ pllmull = pllmull >> 18U ;
362
362
363
- if (pllmull != 0x0D )
363
+ if (pllmull != 0x0DU )
364
364
{
365
- pllmull += 2 ;
365
+ pllmull += 2U ;
366
366
}
367
367
else
368
368
{ /* PLL multiplication factor = PLL input clock * 6.5 */
369
- pllmull = 13 / 2 ;
369
+ pllmull = 13U / 2U ;
370
370
}
371
371
372
- if (pllsource == 0x00 )
372
+ if (pllsource == 0x00U )
373
373
{
374
374
/* HSI oscillator clock divided by 2 selected as PLL clock entry */
375
- SystemCoreClock = (HSI_VALUE >> 1 ) * pllmull ;
375
+ SystemCoreClock = (HSI_VALUE >> 1U ) * pllmull ;
376
376
}
377
377
else
378
378
{/* PREDIV1 selected as PLL clock entry */
379
379
380
380
/* Get PREDIV1 clock source and division factor */
381
381
prediv1source = RCC -> CFGR2 & RCC_CFGR2_PREDIV1SRC ;
382
- prediv1factor = (RCC -> CFGR2 & RCC_CFGR2_PREDIV1 ) + 1 ;
382
+ prediv1factor = (RCC -> CFGR2 & RCC_CFGR2_PREDIV1 ) + 1U ;
383
383
384
- if (prediv1source == 0 )
384
+ if (prediv1source == 0U )
385
385
{
386
386
/* HSE oscillator clock selected as PREDIV1 clock entry */
387
387
SystemCoreClock = (HSE_VALUE / prediv1factor ) * pllmull ;
@@ -390,8 +390,8 @@ void SystemCoreClockUpdate (void)
390
390
{/* PLL2 clock selected as PREDIV1 clock entry */
391
391
392
392
/* Get PREDIV2 division factor and PLL2 multiplication factor */
393
- prediv2factor = ((RCC -> CFGR2 & RCC_CFGR2_PREDIV2 ) >> 4 ) + 1 ;
394
- pll2mull = ((RCC -> CFGR2 & RCC_CFGR2_PLL2MUL ) >> 8 ) + 2 ;
393
+ prediv2factor = ((RCC -> CFGR2 & RCC_CFGR2_PREDIV2 ) >> 4U ) + 1U ;
394
+ pll2mull = ((RCC -> CFGR2 & RCC_CFGR2_PLL2MUL ) >> 8U ) + 2U ;
395
395
SystemCoreClock = (((HSE_VALUE / prediv2factor ) * pll2mull ) / prediv1factor ) * pllmull ;
396
396
}
397
397
}
@@ -405,7 +405,7 @@ void SystemCoreClockUpdate (void)
405
405
406
406
/* Compute HCLK clock frequency ----------------*/
407
407
/* Get HCLK prescaler */
408
- tmp = AHBPrescTable [((RCC -> CFGR & RCC_CFGR_HPRE ) >> 4 )];
408
+ tmp = AHBPrescTable [((RCC -> CFGR & RCC_CFGR_HPRE ) >> 4U )];
409
409
/* HCLK clock frequency */
410
410
SystemCoreClock >>= tmp ;
411
411
}
@@ -434,13 +434,13 @@ void SystemInit_ExtMemCtl(void)
434
434
required, then adjust the Register Addresses */
435
435
436
436
/* Enable FSMC clock */
437
- RCC -> AHBENR = 0x00000114 ;
437
+ RCC -> AHBENR = 0x00000114U ;
438
438
439
439
/* Delay after an RCC peripheral clock enabling */
440
440
tmpreg = READ_BIT (RCC -> AHBENR , RCC_AHBENR_FSMCEN );
441
441
442
442
/* Enable GPIOD, GPIOE, GPIOF and GPIOG clocks */
443
- RCC -> APB2ENR = 0x000001E0 ;
443
+ RCC -> APB2ENR = 0x000001E0U ;
444
444
445
445
/* Delay after an RCC peripheral clock enabling */
446
446
tmpreg = READ_BIT (RCC -> APB2ENR , RCC_APB2ENR_IOPDEN );
@@ -453,23 +453,23 @@ void SystemInit_ExtMemCtl(void)
453
453
/*---------------- NE3 configuration ----------------------------------------*/
454
454
/*---------------- NBL0, NBL1 configuration ---------------------------------*/
455
455
456
- GPIOD -> CRL = 0x44BB44BB ;
457
- GPIOD -> CRH = 0xBBBBBBBB ;
456
+ GPIOD -> CRL = 0x44BB44BBU ;
457
+ GPIOD -> CRH = 0xBBBBBBBBU ;
458
458
459
- GPIOE -> CRL = 0xB44444BB ;
460
- GPIOE -> CRH = 0xBBBBBBBB ;
459
+ GPIOE -> CRL = 0xB44444BBU ;
460
+ GPIOE -> CRH = 0xBBBBBBBBU ;
461
461
462
- GPIOF -> CRL = 0x44BBBBBB ;
463
- GPIOF -> CRH = 0xBBBB4444 ;
462
+ GPIOF -> CRL = 0x44BBBBBBU ;
463
+ GPIOF -> CRH = 0xBBBB4444U ;
464
464
465
- GPIOG -> CRL = 0x44BBBBBB ;
466
- GPIOG -> CRH = 0x444B4B44 ;
465
+ GPIOG -> CRL = 0x44BBBBBBU ;
466
+ GPIOG -> CRH = 0x444B4B44U ;
467
467
468
468
/*---------------- FSMC Configuration ---------------------------------------*/
469
469
/*---------------- Enable FSMC Bank1_SRAM Bank ------------------------------*/
470
470
471
- FSMC_Bank1 -> BTCR [4 ] = 0x00001091 ;
472
- FSMC_Bank1 -> BTCR [5 ] = 0x00110212 ;
471
+ FSMC_Bank1 -> BTCR [4U ] = 0x00001091U ;
472
+ FSMC_Bank1 -> BTCR [5U ] = 0x00110212U ;
473
473
}
474
474
#endif /* DATA_IN_ExtSRAM */
475
475
#endif /* STM32F100xE || STM32F101xE || STM32F101xG || STM32F103xE || STM32F103xG */
0 commit comments