Skip to content

Commit ccd7f2e

Browse files
committed
Cosmetic updates to VTOR relocation test
1 parent e10bd60 commit ccd7f2e

File tree

1 file changed

+28
-14
lines changed

1 file changed

+28
-14
lines changed

libraries/tests/mbed/vtor_reloc/main.cpp

Lines changed: 28 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,13 @@
1313
DigitalOut out(PIN_OUT);
1414
DigitalOut myled(LED1);
1515

16-
static volatile int checks;
17-
static uint32_t int_table[NUM_VECTORS];
16+
volatile int checks = 0;
17+
uint32_t int_table[NUM_VECTORS];
18+
19+
#define FALLING_EDGE_COUNT 5
1820

1921
void flipper() {
20-
for (int i = 0; i < 5; i++) {
22+
for (int i = 0; i < FALLING_EDGE_COUNT; i++) {
2123
out = 1;
2224
wait(0.2);
2325
out = 0;
@@ -38,24 +40,36 @@ static bool test_once() {
3840
in.fall(in_handler);
3941
flipper();
4042
in.fall(NULL);
41-
bool result = (checks == 5);
42-
printf(result ? "Test passed.\r\n" : "Test failed.\r\n");
43+
bool result = (checks == FALLING_EDGE_COUNT);
44+
printf("Falling edge checks counted: %d ... [%s]\r\n", checks, result ? "OK" : "FAIL");
4345
return result;
4446
}
4547

4648
int main() {
47-
printf("Starting first test (interrupts not relocated).\r\n");
48-
if (!test_once()) {
49-
notify_completion(false);
50-
return 1;
49+
50+
// First test, no table reallocation
51+
{
52+
printf("Starting first test (interrupts not relocated).\r\n");
53+
bool ret = test_once();
54+
if (ret == false) {
55+
notify_completion(false);
56+
return 1;
57+
}
5158
}
5259

5360
// Relocate interrupt table and test again
54-
memcpy(int_table, (void*)SCB->VTOR, sizeof(int_table));
55-
SCB->VTOR = (uint32_t)int_table;
56-
printf("Starting second test (interrupts relocated).\r\n");
61+
{
62+
printf("Starting second test (interrupts relocated).\r\n");
63+
memcpy(int_table, (void*)SCB->VTOR, sizeof(int_table));
64+
SCB->VTOR = (uint32_t)int_table;
5765

58-
notify_completion(test_once());
66+
bool ret = test_once();
67+
if (ret == false) {
68+
notify_completion(false);
69+
return 1;
70+
}
71+
}
72+
73+
notify_completion(true);
5974
return 0;
6075
}
61-

0 commit comments

Comments
 (0)