mirror of https://github.com/ARMmbed/mbed-os.git
Fix for the previous "change vector table relocation check" commit.
parent
beed7117ad
commit
5655d2fc2a
|
@ -10,18 +10,18 @@
|
|||
#define NVIC_FLASH_VECTOR_ADDRESS (0x0) // Initial vector position in flash
|
||||
|
||||
void NVIC_SetVector(IRQn_Type IRQn, uint32_t vector) {
|
||||
static volatile uint32_t *vectors = (uint32_t*)NVIC_RAM_VECTOR_ADDRESS;
|
||||
uint32_t *vectors = (uint32_t*)SCB->VTOR;
|
||||
uint32_t i;
|
||||
|
||||
// Copy and switch to dynamic vectors if the first time called
|
||||
if (SCB->VTOR == NVIC_FLASH_VECTOR_ADDRESS) {
|
||||
uint32_t *old_vectors = (uint32_t*)SCB->VTOR;
|
||||
uint32_t *old_vectors = vectors;
|
||||
vectors = (uint32_t*)NVIC_RAM_VECTOR_ADDRESS;
|
||||
for (i=0; i<NVIC_NUM_VECTORS; i++) {
|
||||
vectors[i] = old_vectors[i];
|
||||
}
|
||||
SCB->VTOR = (uint32_t)vectors;
|
||||
SCB->VTOR = (uint32_t)NVIC_RAM_VECTOR_ADDRESS;
|
||||
}
|
||||
|
||||
vectors[IRQn + 16] = vector;
|
||||
}
|
||||
|
||||
|
|
|
@ -10,18 +10,18 @@
|
|||
#define NVIC_FLASH_VECTOR_ADDRESS (0x0) // Initial vector position in flash
|
||||
|
||||
void NVIC_SetVector(IRQn_Type IRQn, uint32_t vector) {
|
||||
static volatile uint32_t* vectors = (uint32_t*)NVIC_RAM_VECTOR_ADDRESS;
|
||||
int i;
|
||||
|
||||
// Copy and switch to dynamic vectors if first time called
|
||||
uint32_t *vectors = (uint32_t*)SCB->VTOR;
|
||||
uint32_t i;
|
||||
|
||||
// Copy and switch to dynamic vectors if the first time called
|
||||
if (SCB->VTOR == NVIC_FLASH_VECTOR_ADDRESS) {
|
||||
uint32_t *old_vectors = (uint32_t*)SCB->VTOR;
|
||||
uint32_t *old_vectors = vectors;
|
||||
vectors = (uint32_t*)NVIC_RAM_VECTOR_ADDRESS;
|
||||
for (i=0; i<NVIC_NUM_VECTORS; i++) {
|
||||
vectors[i] = old_vectors[i];
|
||||
}
|
||||
SCB->VTOR = (uint32_t)vectors;
|
||||
SCB->VTOR = (uint32_t)NVIC_RAM_VECTOR_ADDRESS;
|
||||
}
|
||||
|
||||
vectors[IRQn + 16] = vector;
|
||||
}
|
||||
|
||||
|
|
|
@ -10,17 +10,18 @@
|
|||
#define NVIC_FLASH_VECTOR_ADDRESS (0x0) // Initial vector position in flash
|
||||
|
||||
void NVIC_SetVector(IRQn_Type IRQn, uint32_t vector) {
|
||||
static volatile uint32_t* vectors = (uint32_t*)NVIC_RAM_VECTOR_ADDRESS;
|
||||
int i;
|
||||
// Copy and switch to dynamic vectors if first time called
|
||||
uint32_t *vectors = (uint32_t*)SCB->VTOR;
|
||||
uint32_t i;
|
||||
|
||||
// Copy and switch to dynamic vectors if the first time called
|
||||
if (SCB->VTOR == NVIC_FLASH_VECTOR_ADDRESS) {
|
||||
uint32_t *old_vectors = (uint32_t*)SCB->VTOR;
|
||||
uint32_t *old_vectors = vectors;
|
||||
vectors = (uint32_t*)NVIC_RAM_VECTOR_ADDRESS;
|
||||
for (i=0; i<NVIC_NUM_VECTORS; i++) {
|
||||
vectors[i] = old_vectors[i];
|
||||
}
|
||||
SCB->VTOR = (uint32_t)vectors;
|
||||
SCB->VTOR = (uint32_t)NVIC_RAM_VECTOR_ADDRESS;
|
||||
}
|
||||
|
||||
vectors[IRQn + 16] = vector;
|
||||
}
|
||||
|
||||
|
|
|
@ -10,17 +10,18 @@
|
|||
#define NVIC_FLASH_VECTOR_ADDRESS (0x0) // Initial vector position in flash
|
||||
|
||||
void NVIC_SetVector(IRQn_Type IRQn, uint32_t vector) {
|
||||
static volatile uint32_t* vectors = (uint32_t*)NVIC_RAM_VECTOR_ADDRESS;
|
||||
int i;
|
||||
// Copy and switch to dynamic vectors if first time called
|
||||
uint32_t *vectors = (uint32_t*)SCB->VTOR;
|
||||
uint32_t i;
|
||||
|
||||
// Copy and switch to dynamic vectors if the first time called
|
||||
if (SCB->VTOR == NVIC_FLASH_VECTOR_ADDRESS) {
|
||||
uint32_t *old_vectors = (uint32_t*)SCB->VTOR;
|
||||
uint32_t *old_vectors = vectors;
|
||||
vectors = (uint32_t*)NVIC_RAM_VECTOR_ADDRESS;
|
||||
for (i=0; i<NVIC_NUM_VECTORS; i++) {
|
||||
vectors[i] = old_vectors[i];
|
||||
}
|
||||
SCB->VTOR = (uint32_t)vectors;
|
||||
SCB->VTOR = (uint32_t)NVIC_RAM_VECTOR_ADDRESS;
|
||||
}
|
||||
|
||||
vectors[IRQn + 16] = vector;
|
||||
}
|
||||
|
||||
|
|
|
@ -10,17 +10,18 @@
|
|||
#define NVIC_FLASH_VECTOR_ADDRESS (0x0) // Initial vector position in flash
|
||||
|
||||
void NVIC_SetVector(IRQn_Type IRQn, uint32_t vector) {
|
||||
static volatile uint32_t* vectors = (uint32_t*)NVIC_RAM_VECTOR_ADDRESS;
|
||||
int i;
|
||||
// Copy and switch to dynamic vectors if first time called
|
||||
uint32_t *vectors = (uint32_t*)SCB->VTOR;
|
||||
uint32_t i;
|
||||
|
||||
// Copy and switch to dynamic vectors if the first time called
|
||||
if (SCB->VTOR == NVIC_FLASH_VECTOR_ADDRESS) {
|
||||
uint32_t *old_vectors = (uint32_t*)SCB->VTOR;
|
||||
uint32_t *old_vectors = vectors;
|
||||
vectors = (uint32_t*)NVIC_RAM_VECTOR_ADDRESS;
|
||||
for (i=0; i<NVIC_NUM_VECTORS; i++) {
|
||||
vectors[i] = old_vectors[i];
|
||||
}
|
||||
SCB->VTOR = (uint32_t)vectors;
|
||||
SCB->VTOR = (uint32_t)NVIC_RAM_VECTOR_ADDRESS;
|
||||
}
|
||||
|
||||
vectors[IRQn + 16] = vector;
|
||||
}
|
||||
|
||||
|
|
|
@ -14,18 +14,19 @@
|
|||
static unsigned char vtor_relocated;
|
||||
|
||||
void NVIC_SetVector(IRQn_Type IRQn, uint32_t vector) {
|
||||
static volatile uint32_t* vectors = (uint32_t*)NVIC_RAM_VECTOR_ADDRESS;
|
||||
int i;
|
||||
uint32_t *vectors = (uint32_t*)SCB->VTOR;
|
||||
uint32_t i;
|
||||
|
||||
// Copy and switch to dynamic vectors if first time called
|
||||
if (!vtor_relocated) {
|
||||
uint32_t *old_vectors = (uint32_t*)SCB->VTOR;
|
||||
if (!vtor_relocated) {
|
||||
uint32_t *old_vectors = vectors;
|
||||
vectors = (uint32_t*)NVIC_RAM_VECTOR_ADDRESS;
|
||||
for (i=0; i<NVIC_NUM_VECTORS; i++) {
|
||||
vectors[i] = old_vectors[i];
|
||||
}
|
||||
SCB->VTOR = (uint32_t)vectors;
|
||||
SCB->VTOR = (uint32_t)NVIC_RAM_VECTOR_ADDRESS;
|
||||
vtor_relocated = 1;
|
||||
}
|
||||
|
||||
vectors[IRQn + 16] = vector;
|
||||
}
|
||||
|
||||
|
|
|
@ -10,18 +10,18 @@
|
|||
#define NVIC_FLASH_VECTOR_ADDRESS (0x0) // Initial vector position in flash
|
||||
|
||||
void NVIC_SetVector(IRQn_Type IRQn, uint32_t vector) {
|
||||
static volatile uint32_t* vectors = (uint32_t*)NVIC_RAM_VECTOR_ADDRESS;
|
||||
int i;
|
||||
|
||||
// Copy and switch to dynamic vectors if first time called
|
||||
uint32_t *vectors = (uint32_t*)SCB->VTOR;
|
||||
uint32_t i;
|
||||
|
||||
// Copy and switch to dynamic vectors if the first time called
|
||||
if (SCB->VTOR == NVIC_FLASH_VECTOR_ADDRESS) {
|
||||
uint32_t *old_vectors = (uint32_t*)SCB->VTOR;
|
||||
uint32_t *old_vectors = vectors;
|
||||
vectors = (uint32_t*)NVIC_RAM_VECTOR_ADDRESS;
|
||||
for (i=0; i<NVIC_NUM_VECTORS; i++) {
|
||||
vectors[i] = old_vectors[i];
|
||||
}
|
||||
SCB->VTOR = (uint32_t)vectors;
|
||||
SCB->VTOR = (uint32_t)NVIC_RAM_VECTOR_ADDRESS;
|
||||
}
|
||||
|
||||
vectors[IRQn + 16] = vector;
|
||||
}
|
||||
|
||||
|
|
|
@ -10,17 +10,18 @@
|
|||
#define NVIC_FLASH_VECTOR_ADDRESS (0x0) // Initial vector position in flash
|
||||
|
||||
void NVIC_SetVector(IRQn_Type IRQn, uint32_t vector) {
|
||||
static volatile uint32_t* vectors = (uint32_t*)NVIC_RAM_VECTOR_ADDRESS;
|
||||
int i;
|
||||
// Copy and switch to dynamic vectors if first time called
|
||||
uint32_t *vectors = (uint32_t*)SCB->VTOR;
|
||||
uint32_t i;
|
||||
|
||||
// Copy and switch to dynamic vectors if the first time called
|
||||
if (SCB->VTOR == NVIC_FLASH_VECTOR_ADDRESS) {
|
||||
uint32_t *old_vectors = (uint32_t*)SCB->VTOR;
|
||||
uint32_t *old_vectors = vectors;
|
||||
vectors = (uint32_t*)NVIC_RAM_VECTOR_ADDRESS;
|
||||
for (i=0; i<NVIC_NUM_VECTORS; i++) {
|
||||
vectors[i] = old_vectors[i];
|
||||
}
|
||||
SCB->VTOR = (uint32_t)vectors;
|
||||
SCB->VTOR = (uint32_t)NVIC_RAM_VECTOR_ADDRESS;
|
||||
}
|
||||
|
||||
vectors[IRQn + 16] = vector;
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,60 @@
|
|||
// Interrupt table relocation test, based on the 'interrupt_in' test
|
||||
// It will test an interrupt pin before and after the interrupt table is relocated
|
||||
// Works only on LPC1768
|
||||
|
||||
#include "test_env.h"
|
||||
#include "cmsis_nvic.h"
|
||||
#include <string.h>
|
||||
|
||||
#define PIN_IN (p5)
|
||||
#define PIN_OUT (p25)
|
||||
#define NUM_VECTORS (16+33)
|
||||
|
||||
DigitalOut out(PIN_OUT);
|
||||
DigitalOut myled(LED1);
|
||||
|
||||
static volatile int checks;
|
||||
static uint32_t int_table[NUM_VECTORS];
|
||||
|
||||
void flipper() {
|
||||
for (int i = 0; i < 5; i++) {
|
||||
out = 1; wait(0.2);
|
||||
out = 0; wait(0.2);
|
||||
}
|
||||
}
|
||||
|
||||
void in_handler() {
|
||||
checks++;
|
||||
myled = !myled;
|
||||
}
|
||||
|
||||
static bool test_once() {
|
||||
InterruptIn in(PIN_IN);
|
||||
|
||||
checks = 0;
|
||||
printf(" Interrupt table location: 0x%08X\r\n", SCB->VTOR);
|
||||
in.rise(NULL);
|
||||
in.fall(in_handler);
|
||||
flipper();
|
||||
in.fall(NULL);
|
||||
if (checks != 5) {
|
||||
printf(" Test failed.\r\n");
|
||||
return false;
|
||||
}
|
||||
printf(" Test passed.\r\n");
|
||||
return true;
|
||||
}
|
||||
|
||||
int main() {
|
||||
printf("Starting first test (interrupts not relocated).\r\n");
|
||||
if (!test_once())
|
||||
notify_completion(false);
|
||||
|
||||
// Relocate interrupt table and test again
|
||||
memcpy(int_table, (void*)SCB->VTOR, sizeof(int_table));
|
||||
SCB->VTOR = (uint32_t)int_table;
|
||||
printf("Starting second test (interrupts relocated).\r\n");
|
||||
|
||||
notify_completion(test_once());
|
||||
}
|
||||
|
Loading…
Reference in New Issue