Cosmetic updates to VTOR relocation test

pull/236/head
Przemek Wirkus 2014-03-26 15:07:42 +00:00
parent e10bd60385
commit ccd7f2e757
1 changed files with 28 additions and 14 deletions

View File

@ -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() {
printf("Starting first test (interrupts not relocated).\r\n");
if (!test_once()) { // First test, no table reallocation
notify_completion(false); {
return 1; printf("Starting first test (interrupts not relocated).\r\n");
bool ret = test_once();
if (ret == false) {
notify_completion(false);
return 1;
}
} }
// Relocate interrupt table and test again // 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");
printf("Starting second test (interrupts relocated).\r\n"); memcpy(int_table, (void*)SCB->VTOR, sizeof(int_table));
SCB->VTOR = (uint32_t)int_table;
notify_completion(test_once()); bool ret = test_once();
if (ret == false) {
notify_completion(false);
return 1;
}
}
notify_completion(true);
return 0; return 0;
} }