File tree Expand file tree Collapse file tree 8 files changed +21
-8
lines changed
libraries/mbed/targets/cmsis
TARGET_STM/TARGET_STM32F4XX Expand file tree Collapse file tree 8 files changed +21
-8
lines changed Original file line number Diff line number Diff line change 7
7
8
8
#define NVIC_NUM_VECTORS (16 + 32) // CORE + MCU Peripherals
9
9
#define NVIC_RAM_VECTOR_ADDRESS (0x1FFFFC00) // Vectors positioned at start of RAM
10
+ #define NVIC_FLASH_VECTOR_ADDRESS (0x0) // Initial vector position in flash
10
11
11
12
void NVIC_SetVector (IRQn_Type IRQn , uint32_t vector ) {
12
13
static volatile uint32_t * vectors = (uint32_t * )NVIC_RAM_VECTOR_ADDRESS ;
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_RAM_VECTOR_ADDRESS ) {
17
+ if (SCB -> VTOR == NVIC_FLASH_VECTOR_ADDRESS ) {
17
18
uint32_t * old_vectors = (uint32_t * )SCB -> VTOR ;
18
19
for (i = 0 ; i < NVIC_NUM_VECTORS ; i ++ ) {
19
20
vectors [i ] = old_vectors [i ];
Original file line number Diff line number Diff line change 7
7
8
8
#define NVIC_NUM_VECTORS (16 + 32) // CORE + MCU Peripherals
9
9
#define NVIC_RAM_VECTOR_ADDRESS (0x1FFFF000) // Vectors positioned at start of RAM
10
+ #define NVIC_FLASH_VECTOR_ADDRESS (0x0) // Initial vector position in flash
10
11
11
12
void NVIC_SetVector (IRQn_Type IRQn , uint32_t vector ) {
12
13
static volatile uint32_t * vectors = (uint32_t * )NVIC_RAM_VECTOR_ADDRESS ;
13
14
int i ;
14
15
15
16
// Copy and switch to dynamic vectors if first time called
16
- if (SCB -> VTOR != NVIC_RAM_VECTOR_ADDRESS ) {
17
+ if (SCB -> VTOR == NVIC_FLASH_VECTOR_ADDRESS ) {
17
18
uint32_t * old_vectors = (uint32_t * )SCB -> VTOR ;
18
19
for (i = 0 ; i < NVIC_NUM_VECTORS ; i ++ ) {
19
20
vectors [i ] = old_vectors [i ];
Original file line number Diff line number Diff line change 7
7
8
8
#define NVIC_NUM_VECTORS (16 + 32) // CORE + MCU Peripherals
9
9
#define NVIC_RAM_VECTOR_ADDRESS (0x10000000) // Location of vectors in RAM
10
+ #define NVIC_FLASH_VECTOR_ADDRESS (0x0) // Initial vector position in flash
10
11
11
12
void NVIC_SetVector (IRQn_Type IRQn , uint32_t vector ) {
12
13
static volatile uint32_t * vectors = (uint32_t * )NVIC_RAM_VECTOR_ADDRESS ;
13
14
int i ;
14
15
// Copy and switch to dynamic vectors if first time called
15
- if (SCB -> VTOR != NVIC_RAM_VECTOR_ADDRESS ) {
16
+ if (SCB -> VTOR == NVIC_FLASH_VECTOR_ADDRESS ) {
16
17
uint32_t * old_vectors = (uint32_t * )SCB -> VTOR ;
17
18
for (i = 0 ; i < NVIC_NUM_VECTORS ; i ++ ) {
18
19
vectors [i ] = old_vectors [i ];
Original file line number Diff line number Diff line change 7
7
8
8
#define NVIC_NUM_VECTORS (16 + 33) // CORE + MCU Peripherals
9
9
#define NVIC_RAM_VECTOR_ADDRESS (0x10000000) // Location of vectors in RAM
10
+ #define NVIC_FLASH_VECTOR_ADDRESS (0x0) // Initial vector position in flash
10
11
11
12
void NVIC_SetVector (IRQn_Type IRQn , uint32_t vector ) {
12
13
static volatile uint32_t * vectors = (uint32_t * )NVIC_RAM_VECTOR_ADDRESS ;
13
14
int i ;
14
15
// Copy and switch to dynamic vectors if first time called
15
- if (SCB -> VTOR != NVIC_RAM_VECTOR_ADDRESS ) {
16
+ if (SCB -> VTOR == NVIC_FLASH_VECTOR_ADDRESS ) {
16
17
uint32_t * old_vectors = (uint32_t * )SCB -> VTOR ;
17
18
for (i = 0 ; i < NVIC_NUM_VECTORS ; i ++ ) {
18
19
vectors [i ] = old_vectors [i ];
Original file line number Diff line number Diff line change 7
7
8
8
#define NVIC_NUM_VECTORS (16 + 41) // CORE + MCU Peripherals
9
9
#define NVIC_RAM_VECTOR_ADDRESS (0x10000000) // Location of vectors in RAM
10
+ #define NVIC_FLASH_VECTOR_ADDRESS (0x0) // Initial vector position in flash
10
11
11
12
void NVIC_SetVector (IRQn_Type IRQn , uint32_t vector ) {
12
13
static volatile uint32_t * vectors = (uint32_t * )NVIC_RAM_VECTOR_ADDRESS ;
13
14
int i ;
14
15
// Copy and switch to dynamic vectors if first time called
15
- if (SCB -> VTOR != NVIC_RAM_VECTOR_ADDRESS ) {
16
+ if (SCB -> VTOR == NVIC_FLASH_VECTOR_ADDRESS ) {
16
17
uint32_t * old_vectors = (uint32_t * )SCB -> VTOR ;
17
18
for (i = 0 ; i < NVIC_NUM_VECTORS ; i ++ ) {
18
19
vectors [i ] = old_vectors [i ];
Original file line number Diff line number Diff line change 8
8
#define NVIC_NUM_VECTORS (16 + 53) // CORE + MCU Peripherals
9
9
#define NVIC_RAM_VECTOR_ADDRESS (0x10000000) // Location of vectors in RAM
10
10
11
+ // The LPC43xx can boot from multiple memories (internal Flash, external NOR,
12
+ // external SPIFI) so we don't know the initial value of VTOR. Thus we use
13
+ // a variable to keep track if the vector table was relocated or not
14
+ static unsigned char vtor_relocated ;
15
+
11
16
void NVIC_SetVector (IRQn_Type IRQn , uint32_t vector ) {
12
17
static volatile uint32_t * vectors = (uint32_t * )NVIC_RAM_VECTOR_ADDRESS ;
13
18
int i ;
14
19
// Copy and switch to dynamic vectors if first time called
15
- if (SCB -> VTOR != NVIC_RAM_VECTOR_ADDRESS ) {
20
+ if (! vtor_relocated ) {
16
21
uint32_t * old_vectors = (uint32_t * )SCB -> VTOR ;
17
22
for (i = 0 ; i < NVIC_NUM_VECTORS ; i ++ ) {
18
23
vectors [i ] = old_vectors [i ];
19
24
}
20
25
SCB -> VTOR = (uint32_t )vectors ;
26
+ vtor_relocated = 1 ;
21
27
}
22
28
23
29
vectors [IRQn + 16 ] = vector ;
Original file line number Diff line number Diff line change 7
7
8
8
#define NVIC_NUM_VECTORS (16 + 32) // CORE + MCU Peripherals
9
9
#define NVIC_RAM_VECTOR_ADDRESS (0x10000000) // Vectors positioned at start of RAM
10
+ #define NVIC_FLASH_VECTOR_ADDRESS (0x0) // Initial vector position in flash
10
11
11
12
void NVIC_SetVector (IRQn_Type IRQn , uint32_t vector ) {
12
13
static volatile uint32_t * vectors = (uint32_t * )NVIC_RAM_VECTOR_ADDRESS ;
13
14
int i ;
14
15
15
16
// Copy and switch to dynamic vectors if first time called
16
- if (SCB -> VTOR != NVIC_RAM_VECTOR_ADDRESS ) {
17
+ if (SCB -> VTOR == NVIC_FLASH_VECTOR_ADDRESS ) {
17
18
uint32_t * old_vectors = (uint32_t * )SCB -> VTOR ;
18
19
for (i = 0 ; i < NVIC_NUM_VECTORS ; i ++ ) {
19
20
vectors [i ] = old_vectors [i ];
Original file line number Diff line number Diff line change 7
7
8
8
#define NVIC_NUM_VECTORS (16 + 81) // CORE + MCU Peripherals
9
9
#define NVIC_RAM_VECTOR_ADDRESS (0x20000000) // Location of vectors in RAM
10
+ #define NVIC_FLASH_VECTOR_ADDRESS (0x0) // Initial vector position in flash
10
11
11
12
void NVIC_SetVector (IRQn_Type IRQn , uint32_t vector ) {
12
13
static volatile uint32_t * vectors = (uint32_t * )NVIC_RAM_VECTOR_ADDRESS ;
13
14
int i ;
14
15
// Copy and switch to dynamic vectors if first time called
15
- if (SCB -> VTOR != NVIC_RAM_VECTOR_ADDRESS ) {
16
+ if (SCB -> VTOR == NVIC_FLASH_VECTOR_ADDRESS ) {
16
17
uint32_t * old_vectors = (uint32_t * )SCB -> VTOR ;
17
18
for (i = 0 ; i < NVIC_NUM_VECTORS ; i ++ ) {
18
19
vectors [i ] = old_vectors [i ];
You can’t perform that action at this time.
0 commit comments