-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathFault.cpp
44 lines (34 loc) · 1.36 KB
/
Fault.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#include "Fault.h"
#include "CoreDump.h"
#include <stdio.h>
void FaultHandler(const char* file, unsigned short line)
{
// Store software assertion core dump data
CoreDumpStore(0, file, line, 0);
printf("Fault at file %s line %d.\n", file, line);
printf("The _coreDumpData structure has crash results.\n");
printf("Use a debugger to view the structure or store somewhere.\n");
// TODO: Reboot CPU here! After reboot, the core dump data is used.
// If you hit this line, it means one of the ASSERT macros failed.
//while (true);
}
void HardFaultHandler(void)
{
// TODO: Called if a hardware exception is generated. Platform
// specific detail. Connect exceptions to call this function.
INTEGER_TYPE* stackPointer = nullptr; // TODO: Store the current stack pointer here
uint32_t vectorNum = 0; // TODO: Store the exception vector number here
#ifdef USE_HARDWARE
// Determine if main stack or process stack is being used. Bit 2 of the
// LR (link register) indicates if MSP or PSP stack is used.
if ((LR & 0x4) == 0)
stackPointer = (unsigned int*)MSP;
else
stackPointer = (unsigned int*)PSP;
#endif
// Store hardware exception core dump data
CoreDumpStore(stackPointer, __FILE__, __LINE__, vectorNum);
// TODO: Reboot CPU here! After reboot, the core dump data is used.
// If you hit this line, it means a hardware exception occurred.
while (true);
}