4 * Created on: Apr 24, 2011
9 #include "inc/dcc_stdio.h"
11 # include <stm32f4xx.h>
14 # include <stm32f30x.h>
17 # include <stm32f2xx.h>
20 # include <stm32f10x.h>
23 #define FAULT_TRAMPOLINE(_vec) \
24 __attribute__((naked, no_instrument_function)) \
26 _vec##_Handler(void) \
28 __asm(".syntax unified\n" \
34 "B " #_vec "_Handler2 \n" \
37 "B " #_vec "_Handler2 \n" \
38 ".syntax divided\n"); \
53 FAULT_TRAMPOLINE(HardFault
);
54 FAULT_TRAMPOLINE(BusFault
);
55 FAULT_TRAMPOLINE(UsageFault
);
57 /* this is a hackaround to avoid an issue where dereferencing SCB seems to result in bad codegen and a link error */
58 #define SCB_REG(_reg) (*(uint32_t *)&(SCB->_reg))
60 void HardFault_Handler2(struct cm3_frame
*frame
)
62 dbg_write_str("\nHARD FAULT");
63 dbg_write_hex32(frame
->pc
);
65 dbg_write_hex32(SCB_REG(HFSR
));
72 void BusFault_Handler2(struct cm3_frame
*frame
)
74 dbg_write_str("\nBUS FAULT");
75 dbg_write_hex32(frame
->pc
);
77 dbg_write_hex32(SCB_REG(CFSR
));
79 dbg_write_hex32(SCB_REG(BFAR
));
86 void UsageFault_Handler2(struct cm3_frame
*frame
)
88 dbg_write_str("\nUSAGE FAULT");
89 dbg_write_hex32(frame
->pc
);
91 dbg_write_hex32(SCB_REG(CFSR
));