1 // Interrupt table relocation test, based on the 'interrupt_in' test
2 // It will test an interrupt pin before and after the interrupt table is relocated
3 // Works only on LPC1768
6 #include "cmsis_nvic.h"
11 #define NUM_VECTORS (16+33)
13 DigitalOut
out(PIN_OUT
);
14 DigitalOut
myled(LED1
);
16 volatile int checks
= 0;
17 uint32_t int_table
[NUM_VECTORS
] __attribute__ ((aligned(256)));
19 #define FALLING_EDGE_COUNT 5
22 for (int i
= 0; i
< FALLING_EDGE_COUNT
; i
++) {
35 static bool test_once() {
36 InterruptIn
in(PIN_IN
);
38 printf("Interrupt table location: 0x%08X\r\n", SCB
->VTOR
);
43 bool result
= (checks
== FALLING_EDGE_COUNT
);
44 printf("Falling edge checks counted: %d ... [%s]\r\n", checks
, result
? "OK" : "FAIL");
49 MBED_HOSTTEST_TIMEOUT(15);
50 MBED_HOSTTEST_SELECT(default_auto
);
51 MBED_HOSTTEST_DESCRIPTION(Interrupt vector relocation
);
52 MBED_HOSTTEST_START("MBED_A18");
54 // First test, no table reallocation
56 printf("Starting first test (interrupts not relocated).\r\n");
57 bool ret
= test_once();
59 MBED_HOSTTEST_RESULT(false);
63 // Relocate interrupt table and test again
65 printf("Starting second test (interrupts relocated).\r\n");
66 memcpy(int_table
, (void*)SCB
->VTOR
, sizeof(int_table
));
67 SCB
->VTOR
= (uint32_t)int_table
;
69 bool ret
= test_once();
71 MBED_HOSTTEST_RESULT(false);
75 MBED_HOSTTEST_RESULT(true);