|
31 | 31 | using namespace utest::v1;
|
32 | 32 |
|
33 | 33 | #define HARDFAULT_IRQn ((IRQn_Type)-13)
|
| 34 | +#define MEMFAULT_IRQn ((IRQn_Type)-12) |
34 | 35 |
|
35 | 36 | // Assembly return instruction: bx lr
|
36 | 37 | #define ASM_BX_LR 0x4770
|
37 | 38 |
|
38 | 39 | volatile uint32_t fault_count;
|
39 | 40 | uint32_t real_hard_fault_handler;
|
| 41 | +uint32_t real_mem_fault_handler; |
40 | 42 |
|
41 | 43 | static volatile uint16_t data_function = ASM_BX_LR;
|
42 | 44 | static volatile uint16_t bss_function;
|
@@ -154,18 +156,21 @@ void mpu_fault_test_heap()
|
154 | 156 |
|
155 | 157 | utest::v1::status_t fault_override_setup(const Case *const source, const size_t index_of_case)
|
156 | 158 | {
|
157 |
| - // Save old hard fault handler and replace it with a new one |
| 159 | + // Save old fault handlers and replace it with a new one |
158 | 160 | real_hard_fault_handler = NVIC_GetVector(HARDFAULT_IRQn);
|
| 161 | + real_mem_fault_handler = NVIC_GetVector(MEMFAULT_IRQn); |
159 | 162 | NVIC_SetVector(HARDFAULT_IRQn, (uint32_t)&hard_fault_handler_test);
|
| 163 | + NVIC_SetVector(MEMFAULT_IRQn, (uint32_t)&hard_fault_handler_test); |
160 | 164 |
|
161 | 165 | return greentea_case_setup_handler(source, index_of_case);
|
162 | 166 | }
|
163 | 167 |
|
164 | 168 | utest::v1::status_t fault_override_teardown(const Case *const source, const size_t passed, const size_t failed,
|
165 | 169 | const failure_t reason)
|
166 | 170 | {
|
167 |
| - // Restore real hard fault handler |
| 171 | + // Restore real fault handlers |
168 | 172 | NVIC_SetVector(HARDFAULT_IRQn, real_hard_fault_handler);
|
| 173 | + NVIC_SetVector(MEMFAULT_IRQn, real_mem_fault_handler); |
169 | 174 |
|
170 | 175 | return greentea_case_teardown_handler(source, passed, failed, reason);
|
171 | 176 | }
|
|
0 commit comments