Skip to content

Commit 9971ad2

Browse files
bcostmcmonr
authored andcommitted
Update system_stm32l4xx.c with latest version
1 parent fb71917 commit 9971ad2

File tree

1 file changed

+22
-22
lines changed

1 file changed

+22
-22
lines changed

targets/TARGET_STM/TARGET_STM32L4/device/system_stm32l4xx.c

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
******************************************************************************
33
* @file system_stm32l4xx.c
44
* @author MCD Application Team
5-
* @version V1.3.1
6-
* @date 21-April-2017
75
* @brief CMSIS Cortex-M4 Device Peripheral Access Layer System Source File
86
*
97
* This file provides two functions and one global variable to be called from
@@ -110,15 +108,15 @@
110108
#include "stm32l4xx.h"
111109

112110
#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 */
114112
#endif /* HSE_VALUE */
115113

116114
#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*/
118116
#endif /* MSI_VALUE */
119117

120118
#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*/
122120
#endif /* HSI_VALUE */
123121

124122
/**
@@ -167,12 +165,12 @@
167165
is no need to call the 2 first functions listed above, since SystemCoreClock
168166
variable is updated automatically.
169167
*/
170-
uint32_t SystemCoreClock = 4000000;
168+
uint32_t SystemCoreClock = 4000000U;
171169

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};
176174
/**
177175
* @}
178176
*/
@@ -189,6 +187,7 @@
189187
* @{
190188
*/
191189

190+
// Removed from MBED PR #4740
192191
/*+ MBED */
193192
#if 0
194193
/*- MBED */
@@ -205,24 +204,25 @@ void SystemInit(void)
205204
#if (__FPU_PRESENT == 1) && (__FPU_USED == 1)
206205
SCB->CPACR |= ((3UL << 10*2)|(3UL << 11*2)); /* set CP10 and CP11 Full Access */
207206
#endif
207+
208208
/* Reset the RCC clock configuration to the default reset state ------------*/
209209
/* Set MSION bit */
210210
RCC->CR |= RCC_CR_MSION;
211211

212212
/* Reset CFGR register */
213-
RCC->CFGR = 0x00000000;
213+
RCC->CFGR = 0x00000000U;
214214

215215
/* Reset HSEON, CSSON , HSION, and PLLON bits */
216-
RCC->CR &= (uint32_t)0xEAF6FFFF;
216+
RCC->CR &= 0xEAF6FFFFU;
217217

218218
/* Reset PLLCFGR register */
219-
RCC->PLLCFGR = 0x00001000;
219+
RCC->PLLCFGR = 0x00001000U;
220220

221221
/* Reset HSEBYP bit */
222-
RCC->CR &= (uint32_t)0xFFFBFFFF;
222+
RCC->CR &= 0xFFFBFFFFU;
223223

224224
/* Disable all interrupts */
225-
RCC->CIER = 0x00000000;
225+
RCC->CIER = 0x00000000U;
226226

227227
/* Configure the Vector Table location add offset address ------------------*/
228228
#ifdef VECT_TAB_SRAM
@@ -280,16 +280,16 @@ void SystemInit(void)
280280
*/
281281
void SystemCoreClockUpdate(void)
282282
{
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;
284284

285285
/* Get MSI Range frequency--------------------------------------------------*/
286286
if((RCC->CR & RCC_CR_MSIRGSEL) == RESET)
287287
{ /* MSISRANGE from RCC_CSR applies */
288-
msirange = (RCC->CSR & RCC_CSR_MSISRANGE) >> 8;
288+
msirange = (RCC->CSR & RCC_CSR_MSISRANGE) >> 8U;
289289
}
290290
else
291291
{ /* MSIRANGE from RCC_CR applies */
292-
msirange = (RCC->CR & RCC_CR_MSIRANGE) >> 4;
292+
msirange = (RCC->CR & RCC_CR_MSIRANGE) >> 4U;
293293
}
294294
/*MSI frequency range in HZ*/
295295
msirange = MSIRangeTable[msirange];
@@ -314,7 +314,7 @@ void SystemCoreClockUpdate(void)
314314
SYSCLK = PLL_VCO / PLLR
315315
*/
316316
pllsource = (RCC->PLLCFGR & RCC_PLLCFGR_PLLSRC);
317-
pllm = ((RCC->PLLCFGR & RCC_PLLCFGR_PLLM) >> 4) + 1 ;
317+
pllm = ((RCC->PLLCFGR & RCC_PLLCFGR_PLLM) >> 4U) + 1U ;
318318

319319
switch (pllsource)
320320
{
@@ -330,8 +330,8 @@ void SystemCoreClockUpdate(void)
330330
pllvco = (msirange / pllm);
331331
break;
332332
}
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;
335335
SystemCoreClock = pllvco/pllr;
336336
break;
337337

@@ -341,7 +341,7 @@ void SystemCoreClockUpdate(void)
341341
}
342342
/* Compute HCLK clock frequency --------------------------------------------*/
343343
/* Get HCLK prescaler */
344-
tmp = AHBPrescTable[((RCC->CFGR & RCC_CFGR_HPRE) >> 4)];
344+
tmp = AHBPrescTable[((RCC->CFGR & RCC_CFGR_HPRE) >> 4U)];
345345
/* HCLK clock frequency */
346346
SystemCoreClock >>= tmp;
347347
}

0 commit comments

Comments
 (0)