Skip to content

Commit c59167c

Browse files
committed
[STM32F0_all] remove the global variable and use SYSCFG register instead
1 parent 5784d29 commit c59167c

File tree

14 files changed

+7
-39
lines changed

14 files changed

+7
-39
lines changed

libraries/mbed/targets/cmsis/TARGET_STM/TARGET_STM32F0/TARGET_DISCO_F051R8/cmsis_nvic.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,19 +33,16 @@
3333
#define NVIC_RAM_VECTOR_ADDRESS (0x20000000) // Vectors positioned at start of RAM
3434
#define NVIC_FLASH_VECTOR_ADDRESS (0x08000000) // Initial vector position in flash
3535

36-
int NVIC_vtor_remap = 0; // To keep track that the vectors remap is done
37-
3836
void NVIC_SetVector(IRQn_Type IRQn, uint32_t vector) {
3937
int i;
4038

4139
// Copy and switch to dynamic vectors if first time called
42-
if (NVIC_vtor_remap == 0) {
40+
if ((SYSCFG->CFGR1 & SYSCFG_CFGR1_MEM_MODE) != SYSCFG_CFGR1_MEM_MODE) {
4341
uint32_t *old_vectors = (uint32_t *)NVIC_FLASH_VECTOR_ADDRESS;
4442
for (i = 0; i < NVIC_NUM_VECTORS; i++) {
4543
*((uint32_t *)(NVIC_RAM_VECTOR_ADDRESS + (i*4))) = old_vectors[i];
4644
}
4745
SYSCFG->CFGR1 |= SYSCFG_CFGR1_MEM_MODE; // Embedded SRAM mapped at 0x00000000
48-
NVIC_vtor_remap = 1; // The vectors remap is done
4946
}
5047

5148
// Set the vector

libraries/mbed/targets/cmsis/TARGET_STM/TARGET_STM32F0/TARGET_DISCO_F051R8/system_stm32f0xx.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,6 @@ uint8_t SetSysClock_PLL_HSI(void);
160160
* @{
161161
*/
162162

163-
extern int NVIC_vtor_remap;
164163

165164
/**
166165
* @brief Setup the microcontroller system.
@@ -229,7 +228,6 @@ void SystemInit(void)
229228

230229
/* Configure the Cube driver */
231230
SystemCoreClock = 8000000; // At this stage the HSI is used as system clock
232-
NVIC_vtor_remap = 0; // Because it is not cleared the first time we enter in NVIC_SetVector()
233231
HAL_Init();
234232

235233
/* Configure the System clock source, PLL Multiplier and Divider factors,

libraries/mbed/targets/cmsis/TARGET_STM/TARGET_STM32F0/TARGET_NUCLEO_F030R8/cmsis_nvic.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,19 +33,17 @@
3333
#define NVIC_RAM_VECTOR_ADDRESS (0x20000000) // Vectors positioned at start of RAM
3434
#define NVIC_FLASH_VECTOR_ADDRESS (0x08000000) // Initial vector position in flash
3535

36-
int NVIC_vtor_remap = 0; // To keep track that the vectors remap is done
3736

3837
void NVIC_SetVector(IRQn_Type IRQn, uint32_t vector) {
3938
int i;
4039

4140
// Copy and switch to dynamic vectors if first time called
42-
if (NVIC_vtor_remap == 0) {
41+
if ((SYSCFG->CFGR1 & SYSCFG_CFGR1_MEM_MODE) != SYSCFG_CFGR1_MEM_MODE) {
4342
uint32_t *old_vectors = (uint32_t *)NVIC_FLASH_VECTOR_ADDRESS;
4443
for (i = 0; i < NVIC_NUM_VECTORS; i++) {
4544
*((uint32_t *)(NVIC_RAM_VECTOR_ADDRESS + (i*4))) = old_vectors[i];
4645
}
4746
SYSCFG->CFGR1 |= SYSCFG_CFGR1_MEM_MODE; // Embedded SRAM mapped at 0x00000000
48-
NVIC_vtor_remap = 1; // The vectors remap is done
4947
}
5048

5149
// Set the vector

libraries/mbed/targets/cmsis/TARGET_STM/TARGET_STM32F0/TARGET_NUCLEO_F030R8/system_stm32f0xx.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,6 @@ uint8_t SetSysClock_PLL_HSI(void);
161161
* @{
162162
*/
163163

164-
extern int NVIC_vtor_remap;
165164

166165
/**
167166
* @brief Setup the microcontroller system.
@@ -230,7 +229,6 @@ void SystemInit(void)
230229

231230
/* Configure the Cube driver */
232231
SystemCoreClock = 8000000; // At this stage the HSI is used as system clock
233-
NVIC_vtor_remap = 0; // Because it is not cleared the first time we enter in NVIC_SetVector()
234232
HAL_Init();
235233

236234
/* Configure the System clock source, PLL Multiplier and Divider factors,

libraries/mbed/targets/cmsis/TARGET_STM/TARGET_STM32F0/TARGET_NUCLEO_F031K6/cmsis_nvic.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,19 +33,17 @@
3333
#define NVIC_RAM_VECTOR_ADDRESS (0x20000000) // Vectors positioned at start of RAM
3434
#define NVIC_FLASH_VECTOR_ADDRESS (0x08000000) // Initial vector position in flash
3535

36-
int NVIC_vtor_remap = 0; // To keep track that the vectors remap is done
3736

3837
void NVIC_SetVector(IRQn_Type IRQn, uint32_t vector) {
3938
int i;
4039

4140
// Copy and switch to dynamic vectors if first time called
42-
if (NVIC_vtor_remap == 0) {
41+
if ((SYSCFG->CFGR1 & SYSCFG_CFGR1_MEM_MODE) != SYSCFG_CFGR1_MEM_MODE) {
4342
uint32_t *old_vectors = (uint32_t *)NVIC_FLASH_VECTOR_ADDRESS;
4443
for (i = 0; i < NVIC_NUM_VECTORS; i++) {
4544
*((uint32_t *)(NVIC_RAM_VECTOR_ADDRESS + (i*4))) = old_vectors[i];
4645
}
4746
SYSCFG->CFGR1 |= SYSCFG_CFGR1_MEM_MODE; // Embedded SRAM mapped at 0x00000000
48-
NVIC_vtor_remap = 1; // The vectors remap is done
4947
}
5048

5149
// Set the vector

libraries/mbed/targets/cmsis/TARGET_STM/TARGET_STM32F0/TARGET_NUCLEO_F031K6/system_stm32f0xx.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,6 @@ uint8_t SetSysClock_PLL_HSI(void);
161161
* @{
162162
*/
163163

164-
extern int NVIC_vtor_remap;
165164

166165
/**
167166
* @brief Setup the microcontroller system.
@@ -230,7 +229,6 @@ void SystemInit(void)
230229

231230
/* Configure the Cube driver */
232231
SystemCoreClock = 8000000; // At this stage the HSI is used as system clock
233-
NVIC_vtor_remap = 0; // Because it is not cleared the first time we enter in NVIC_SetVector()
234232
HAL_Init();
235233

236234
/* Configure the System clock source, PLL Multiplier and Divider factors,

libraries/mbed/targets/cmsis/TARGET_STM/TARGET_STM32F0/TARGET_NUCLEO_F042K6/cmsis_nvic.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,19 +33,17 @@
3333
#define NVIC_RAM_VECTOR_ADDRESS (0x20000000) // Vectors positioned at start of RAM
3434
#define NVIC_FLASH_VECTOR_ADDRESS (0x08000000) // Initial vector position in flash
3535

36-
int NVIC_vtor_remap = 0; // To keep track that the vectors remap is done
3736

3837
void NVIC_SetVector(IRQn_Type IRQn, uint32_t vector) {
3938
int i;
4039

4140
// Copy and switch to dynamic vectors if first time called
42-
if (NVIC_vtor_remap == 0) {
41+
if ((SYSCFG->CFGR1 & SYSCFG_CFGR1_MEM_MODE) != SYSCFG_CFGR1_MEM_MODE) {
4342
uint32_t *old_vectors = (uint32_t *)NVIC_FLASH_VECTOR_ADDRESS;
4443
for (i = 0; i < NVIC_NUM_VECTORS; i++) {
4544
*((uint32_t *)(NVIC_RAM_VECTOR_ADDRESS + (i*4))) = old_vectors[i];
4645
}
4746
SYSCFG->CFGR1 |= SYSCFG_CFGR1_MEM_MODE; // Embedded SRAM mapped at 0x00000000
48-
NVIC_vtor_remap = 1; // The vectors remap is done
4947
}
5048

5149
// Set the vector

libraries/mbed/targets/cmsis/TARGET_STM/TARGET_STM32F0/TARGET_NUCLEO_F042K6/system_stm32f0xx.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,6 @@ uint8_t SetSysClock_PLL_HSI(void);
161161
* @{
162162
*/
163163

164-
extern int NVIC_vtor_remap;
165164

166165
/**
167166
* @brief Setup the microcontroller system.
@@ -230,7 +229,6 @@ void SystemInit(void)
230229

231230
/* Configure the Cube driver */
232231
SystemCoreClock = 8000000; // At this stage the HSI is used as system clock
233-
NVIC_vtor_remap = 0; // Because it is not cleared the first time we enter in NVIC_SetVector()
234232
HAL_Init();
235233

236234
/* Configure the System clock source, PLL Multiplier and Divider factors,

libraries/mbed/targets/cmsis/TARGET_STM/TARGET_STM32F0/TARGET_NUCLEO_F070RB/cmsis_nvic.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,19 +33,17 @@
3333
#define NVIC_RAM_VECTOR_ADDRESS (0x20000000) // Vectors positioned at start of RAM
3434
#define NVIC_FLASH_VECTOR_ADDRESS (0x08000000) // Initial vector position in flash
3535

36-
int NVIC_vtor_remap = 0; // To keep track that the vectors remap is done
3736

3837
void NVIC_SetVector(IRQn_Type IRQn, uint32_t vector) {
3938
int i;
4039

4140
// Copy and switch to dynamic vectors if first time called
42-
if (NVIC_vtor_remap == 0) {
41+
if ((SYSCFG->CFGR1 & SYSCFG_CFGR1_MEM_MODE) != SYSCFG_CFGR1_MEM_MODE) {
4342
uint32_t *old_vectors = (uint32_t *)NVIC_FLASH_VECTOR_ADDRESS;
4443
for (i = 0; i < NVIC_NUM_VECTORS; i++) {
4544
*((uint32_t *)(NVIC_RAM_VECTOR_ADDRESS + (i*4))) = old_vectors[i];
4645
}
4746
SYSCFG->CFGR1 |= SYSCFG_CFGR1_MEM_MODE; // Embedded SRAM mapped at 0x00000000
48-
NVIC_vtor_remap = 1; // The vectors remap is done
4947
}
5048

5149
// Set the vector

libraries/mbed/targets/cmsis/TARGET_STM/TARGET_STM32F0/TARGET_NUCLEO_F070RB/system_stm32f0xx.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,6 @@ uint8_t SetSysClock_PLL_HSI(void);
161161
* @{
162162
*/
163163

164-
extern int NVIC_vtor_remap;
165164

166165
/**
167166
* @brief Setup the microcontroller system.
@@ -230,7 +229,6 @@ void SystemInit(void)
230229

231230
/* Configure the Cube driver */
232231
SystemCoreClock = 8000000; // At this stage the HSI is used as system clock
233-
NVIC_vtor_remap = 0; // Because it is not cleared the first time we enter in NVIC_SetVector()
234232
HAL_Init();
235233

236234
/* Configure the System clock source, PLL Multiplier and Divider factors,

libraries/mbed/targets/cmsis/TARGET_STM/TARGET_STM32F0/TARGET_NUCLEO_F072RB/cmsis_nvic.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,19 +33,17 @@
3333
#define NVIC_RAM_VECTOR_ADDRESS (0x20000000) // Vectors positioned at start of RAM
3434
#define NVIC_FLASH_VECTOR_ADDRESS (0x08000000) // Initial vector position in flash
3535

36-
int NVIC_vtor_remap = 0; // To keep track that the vectors remap is done
3736

3837
void NVIC_SetVector(IRQn_Type IRQn, uint32_t vector) {
3938
int i;
4039

4140
// Copy and switch to dynamic vectors if first time called
42-
if (NVIC_vtor_remap == 0) {
41+
if ((SYSCFG->CFGR1 & SYSCFG_CFGR1_MEM_MODE) != SYSCFG_CFGR1_MEM_MODE) {
4342
uint32_t *old_vectors = (uint32_t *)NVIC_FLASH_VECTOR_ADDRESS;
4443
for (i = 0; i < NVIC_NUM_VECTORS; i++) {
4544
*((uint32_t *)(NVIC_RAM_VECTOR_ADDRESS + (i*4))) = old_vectors[i];
4645
}
4746
SYSCFG->CFGR1 |= SYSCFG_CFGR1_MEM_MODE; // Embedded SRAM mapped at 0x00000000
48-
NVIC_vtor_remap = 1; // The vectors remap is done
4947
}
5048

5149
// Set the vector

libraries/mbed/targets/cmsis/TARGET_STM/TARGET_STM32F0/TARGET_NUCLEO_F072RB/system_stm32f0xx.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -161,8 +161,6 @@ uint8_t SetSysClock_PLL_HSI(void);
161161
* @{
162162
*/
163163

164-
extern int NVIC_vtor_remap;
165-
166164
/**
167165
* @brief Setup the microcontroller system.
168166
* Initialize the default HSI clock source, vector table location and the PLL configuration is reset.
@@ -230,7 +228,6 @@ void SystemInit(void)
230228

231229
/* Configure the Cube driver */
232230
SystemCoreClock = 8000000; // At this stage the HSI is used as system clock
233-
NVIC_vtor_remap = 0; // Because it is not cleared the first time we enter in NVIC_SetVector()
234231
HAL_Init();
235232

236233
/* Configure the System clock source, PLL Multiplier and Divider factors,

libraries/mbed/targets/cmsis/TARGET_STM/TARGET_STM32F0/TARGET_NUCLEO_F091RC/cmsis_nvic.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,19 +33,16 @@
3333
#define NVIC_RAM_VECTOR_ADDRESS (0x20000000) // Vectors positioned at start of RAM
3434
#define NVIC_FLASH_VECTOR_ADDRESS (0x08000000) // Initial vector position in flash
3535

36-
int NVIC_vtor_remap = 0; // To keep track that the vectors remap is done
37-
3836
void NVIC_SetVector(IRQn_Type IRQn, uint32_t vector) {
3937
int i;
4038

4139
// Copy and switch to dynamic vectors if first time called
42-
if (NVIC_vtor_remap == 0) {
40+
if ((SYSCFG->CFGR1 & SYSCFG_CFGR1_MEM_MODE) != SYSCFG_CFGR1_MEM_MODE) {
4341
uint32_t *old_vectors = (uint32_t *)NVIC_FLASH_VECTOR_ADDRESS;
4442
for (i = 0; i < NVIC_NUM_VECTORS; i++) {
4543
*((uint32_t *)(NVIC_RAM_VECTOR_ADDRESS + (i*4))) = old_vectors[i];
4644
}
4745
SYSCFG->CFGR1 |= SYSCFG_CFGR1_MEM_MODE; // Embedded SRAM mapped at 0x00000000
48-
NVIC_vtor_remap = 1; // The vectors remap is done
4946
}
5047

5148
// Set the vector

libraries/mbed/targets/cmsis/TARGET_STM/TARGET_STM32F0/TARGET_NUCLEO_F091RC/system_stm32f0xx.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -161,8 +161,6 @@ uint8_t SetSysClock_PLL_HSI(void);
161161
* @{
162162
*/
163163

164-
extern int NVIC_vtor_remap;
165-
166164
/**
167165
* @brief Setup the microcontroller system.
168166
* Initialize the default HSI clock source, vector table location and the PLL configuration is reset.
@@ -230,7 +228,6 @@ void SystemInit(void)
230228

231229
/* Configure the Cube driver */
232230
SystemCoreClock = 8000000; // At this stage the HSI is used as system clock
233-
NVIC_vtor_remap = 0; // Because it is not cleared the first time we enter in NVIC_SetVector()
234231
HAL_Init();
235232

236233
/* Configure the System clock source, PLL Multiplier and Divider factors,

0 commit comments

Comments
 (0)