mirror of https://github.com/ARMmbed/mbed-os.git
Cosmetic updates to VTOR relocation test
parent
e10bd60385
commit
ccd7f2e757
|
@ -13,11 +13,13 @@
|
||||||
DigitalOut out(PIN_OUT);
|
DigitalOut out(PIN_OUT);
|
||||||
DigitalOut myled(LED1);
|
DigitalOut myled(LED1);
|
||||||
|
|
||||||
static volatile int checks;
|
volatile int checks = 0;
|
||||||
static uint32_t int_table[NUM_VECTORS];
|
uint32_t int_table[NUM_VECTORS];
|
||||||
|
|
||||||
|
#define FALLING_EDGE_COUNT 5
|
||||||
|
|
||||||
void flipper() {
|
void flipper() {
|
||||||
for (int i = 0; i < 5; i++) {
|
for (int i = 0; i < FALLING_EDGE_COUNT; i++) {
|
||||||
out = 1;
|
out = 1;
|
||||||
wait(0.2);
|
wait(0.2);
|
||||||
out = 0;
|
out = 0;
|
||||||
|
@ -38,24 +40,36 @@ static bool test_once() {
|
||||||
in.fall(in_handler);
|
in.fall(in_handler);
|
||||||
flipper();
|
flipper();
|
||||||
in.fall(NULL);
|
in.fall(NULL);
|
||||||
bool result = (checks == 5);
|
bool result = (checks == FALLING_EDGE_COUNT);
|
||||||
printf(result ? "Test passed.\r\n" : "Test failed.\r\n");
|
printf("Falling edge checks counted: %d ... [%s]\r\n", checks, result ? "OK" : "FAIL");
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
|
|
||||||
|
// First test, no table reallocation
|
||||||
|
{
|
||||||
printf("Starting first test (interrupts not relocated).\r\n");
|
printf("Starting first test (interrupts not relocated).\r\n");
|
||||||
if (!test_once()) {
|
bool ret = test_once();
|
||||||
|
if (ret == false) {
|
||||||
notify_completion(false);
|
notify_completion(false);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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());
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Relocate interrupt table and test again
|
||||||
|
{
|
||||||
|
printf("Starting second test (interrupts relocated).\r\n");
|
||||||
|
memcpy(int_table, (void*)SCB->VTOR, sizeof(int_table));
|
||||||
|
SCB->VTOR = (uint32_t)int_table;
|
||||||
|
|
||||||
|
bool ret = test_once();
|
||||||
|
if (ret == false) {
|
||||||
|
notify_completion(false);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
notify_completion(true);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue