File tree Expand file tree Collapse file tree 1 file changed +4
-2
lines changed
libraries/mbed/targets/cmsis/TARGET_STM/TARGET_STM32F4XX Expand file tree Collapse file tree 1 file changed +4
-2
lines changed Original file line number Diff line number Diff line change 6
6
#include "cmsis_nvic.h"
7
7
8
8
#define NVIC_RAM_VECTOR_ADDRESS (0x20000000) // Location of vectors in RAM
9
- #define NVIC_FLASH_VECTOR_ADDRESS (0x0) // Initial vector position in flash
9
+
10
+ static unsigned char vtor_relocated ;
10
11
11
12
void NVIC_SetVector (IRQn_Type IRQn , uint32_t vector ) {
12
13
uint32_t * vectors = (uint32_t * )SCB -> VTOR ;
13
14
uint32_t i ;
14
15
15
16
// Copy and switch to dynamic vectors if the first time called
16
- if (SCB -> VTOR == NVIC_FLASH_VECTOR_ADDRESS ) {
17
+ if (! vtor_relocated ) {
17
18
uint32_t * old_vectors = vectors ;
18
19
vectors = (uint32_t * )NVIC_RAM_VECTOR_ADDRESS ;
19
20
for (i = 0 ; i < NVIC_NUM_VECTORS ; i ++ ) {
20
21
vectors [i ] = old_vectors [i ];
21
22
}
22
23
SCB -> VTOR = (uint32_t )NVIC_RAM_VECTOR_ADDRESS ;
24
+ vtor_relocated = 1 ;
23
25
}
24
26
vectors [IRQn + 16 ] = vector ;
25
27
}
You can’t perform that action at this time.
0 commit comments