Skip to content

Commit 645ad72

Browse files
committed
[F3] Update CMSIS Cortex-Mx Device Peripheral Access Layer System Source File
Signed-off-by: Frederic Pillon <[email protected]>
1 parent 5f97d14 commit 645ad72

File tree

1 file changed

+36
-43
lines changed

1 file changed

+36
-43
lines changed

system/STM32F3xx/system_stm32f3xx.c

Lines changed: 36 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*
77
* 1. This file provides two functions and one global variable to be called from
88
* user application:
9-
* - SystemInit(): This function is called at startup just after reset and
9+
* - SystemInit(): This function is called at startup just after reset and
1010
* before branch to main program. This call is made inside
1111
* the "startup_stm32f3xx.s" file.
1212
*
@@ -84,14 +84,34 @@
8484
/** @addtogroup STM32F3xx_System_Private_Defines
8585
* @{
8686
*/
87-
88-
/*!< Uncomment the following line if you need to relocate your vector Table in
89-
Internal SRAM. */
90-
/* #define VECT_TAB_SRAM */
9187
#ifndef VECT_TAB_OFFSET
92-
#define VECT_TAB_OFFSET 0x0 /*!< Vector Table base offset field.
93-
This value must be a multiple of 0x200. */
88+
#define VECT_TAB_OFFSET 0x00000000U /*!< Vector Table base offset field.
89+
This value must be a multiple of 0x200. */
90+
#else
91+
#define USER_VECT_TAB_ADDRESS
9492
#endif
93+
94+
/* Note: Following vector table addresses must be defined in line with linker
95+
configuration. */
96+
/*!< Uncomment the following line if you need to relocate the vector table
97+
anywhere in Flash or Sram, else the vector table is kept at the automatic
98+
remap of boot address selected */
99+
/* #define USER_VECT_TAB_ADDRESS */
100+
101+
#if defined(USER_VECT_TAB_ADDRESS)
102+
/*!< Uncomment the following line if you need to relocate your vector Table
103+
in Sram else user remap will be done in Flash. */
104+
/* #define VECT_TAB_SRAM */
105+
#if defined(VECT_TAB_SRAM)
106+
#define VECT_TAB_BASE_ADDRESS SRAM_BASE /*!< Vector Table base address field.
107+
This value must be a multiple of 0x200. */
108+
#else
109+
#define VECT_TAB_BASE_ADDRESS FLASH_BASE /*!< Vector Table base address field.
110+
This value must be a multiple of 0x200. */
111+
#endif /* VECT_TAB_SRAM */
112+
#endif /* USER_VECT_TAB_ADDRESS */
113+
114+
/******************************************************************************/
95115
/**
96116
* @}
97117
*/
@@ -112,7 +132,7 @@
112132
2) by calling HAL API function HAL_RCC_GetHCLKFreq()
113133
3) each time HAL_RCC_ClockConfig() is called to configure the system clock frequency
114134
Note: If you use this function to configure the system clock there is no need to
115-
call the 2 first functions listed above, since SystemCoreClock variable is
135+
call the 2 first functions listed above, since SystemCoreClock variable is
116136
updated automatically.
117137
*/
118138
uint32_t SystemCoreClock = 8000000;
@@ -138,47 +158,20 @@ const uint8_t APBPrescTable[8] = {0, 0, 0, 0, 1, 2, 3, 4};
138158

139159
/**
140160
* @brief Setup the microcontroller system
141-
* Initialize the FPU setting, vector table location and the PLL configuration is reset.
142161
* @param None
143162
* @retval None
144163
*/
145164
void SystemInit(void)
146165
{
147166
/* FPU settings --------------------------------------------------------------*/
148-
#if (__FPU_PRESENT == 1) && (__FPU_USED == 1)
149-
SCB->CPACR |= ((3UL << 10*2)|(3UL << 11*2)); /* set CP10 and CP11 Full Access */
150-
#endif
151-
152-
/* Reset the RCC clock configuration to the default reset state ------------*/
153-
/* Set HSION bit */
154-
RCC->CR |= 0x00000001U;
155-
156-
/* Reset CFGR register */
157-
RCC->CFGR &= 0xF87FC00CU;
158-
159-
/* Reset HSEON, CSSON and PLLON bits */
160-
RCC->CR &= 0xFEF6FFFFU;
161-
162-
/* Reset HSEBYP bit */
163-
RCC->CR &= 0xFFFBFFFFU;
164-
165-
/* Reset PLLSRC, PLLXTPRE, PLLMUL and USBPRE bits */
166-
RCC->CFGR &= 0xFF80FFFFU;
167-
168-
/* Reset PREDIV1[3:0] bits */
169-
RCC->CFGR2 &= 0xFFFFFFF0U;
170-
171-
/* Reset USARTSW[1:0], I2CSW and TIMs bits */
172-
RCC->CFGR3 &= 0xFF00FCCCU;
173-
174-
/* Disable all interrupts */
175-
RCC->CIR = 0x00000000U;
176-
177-
#ifdef VECT_TAB_SRAM
178-
SCB->VTOR = SRAM_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal SRAM */
179-
#else
180-
SCB->VTOR = FLASH_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal FLASH */
167+
#if (__FPU_PRESENT == 1) && (__FPU_USED == 1)
168+
SCB->CPACR |= ((3UL << 10*2)|(3UL << 11*2)); /* set CP10 and CP11 Full Access */
181169
#endif
170+
171+
/* Configure the Vector Table location -------------------------------------*/
172+
#if defined(USER_VECT_TAB_ADDRESS)
173+
SCB->VTOR = VECT_TAB_BASE_ADDRESS | VECT_TAB_OFFSET; /* Vector Table Relocation */
174+
#endif /* USER_VECT_TAB_ADDRESS */
182175
}
183176

184177
/**
@@ -250,7 +243,7 @@ void SystemCoreClockUpdate (void)
250243
/* HSI oscillator clock selected as PREDIV1 clock entry */
251244
SystemCoreClock = (HSI_VALUE / predivfactor) * pllmull;
252245
}
253-
#else
246+
#else
254247
if (pllsource == RCC_CFGR_PLLSRC_HSI_DIV2)
255248
{
256249
/* HSI oscillator clock divided by 2 selected as PLL clock entry */

0 commit comments

Comments
 (0)