-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.c
executable file
·57 lines (39 loc) · 910 Bytes
/
main.c
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
45
46
47
48
49
50
51
52
53
54
55
56
#include <stdio.h>
#include "main.h"
#include "HC_SR04.h"
#if !defined(__SOFT_FP__) && defined(__ARM_FP)
#warning "FPU is not initialized, but the project is compiling for an FPU. Please initialize the FPU before use."
#endif
#define SEMIHOSTING 0
#ifdef SEMIHOSTING
extern void initialise_monitor_handles(void);
#endif
void enable_processor_faults(void);
int main(void){
enable_processor_faults();
#ifdef SEMIHOSTING
initialise_monitor_handles();
#endif
}
void enable_processor_faults(void)
{
uint32_t *pSHCSR = (uint32_t*)0xE000ED24;
*pSHCSR |= ( 1 << 16); //mem manage
*pSHCSR |= ( 1 << 17); //bus fault
*pSHCSR |= ( 1 << 18); //usage fault
}
void HardFault_Handler(void)
{
printf("Exception : Hardfault\n");
while(1);
}
void MemManage_Handler(void)
{
printf("Exception : MemManage\n");
while(1);
}
void BusFault_Handler(void)
{
printf("Exception : BusFault\n");
while(1);
}