4 * Created on: Apr 24, 2011
9 #include "inc/dcc_stdio.h"
11 # include <stm32f4xx.h>
14 # include <stm32f2xx.h>
17 #define FAULT_TRAMPOLINE(_vec) \
18 __attribute__((naked, no_instrument_function)) \
20 _vec##_Handler(void) \
22 __asm(".syntax unified\n" \
28 "B " #_vec "_Handler2 \n" \
31 "B " #_vec "_Handler2 \n" \
32 ".syntax divided\n"); \
47 FAULT_TRAMPOLINE(HardFault
);
48 FAULT_TRAMPOLINE(BusFault
);
49 FAULT_TRAMPOLINE(UsageFault
);
51 /* this is a hackaround to avoid an issue where dereferencing SCB seems to result in bad codegen and a link error */
52 #define SCB_REG(_reg) (*(uint32_t *)&(SCB->_reg))
54 void HardFault_Handler2(struct cm3_frame
*frame
)
56 dbg_write_str("\nHARD FAULT");
57 dbg_write_hex32(frame
->pc
);
59 dbg_write_hex32(SCB_REG(HFSR
));
66 void BusFault_Handler2(struct cm3_frame
*frame
)
68 dbg_write_str("\nBUS FAULT");
69 dbg_write_hex32(frame
->pc
);
71 dbg_write_hex32(SCB_REG(CFSR
));
73 dbg_write_hex32(SCB_REG(BFAR
));
80 void UsageFault_Handler2(struct cm3_frame
*frame
)
82 dbg_write_str("\nUSAGE FAULT");
83 dbg_write_hex32(frame
->pc
);
85 dbg_write_hex32(SCB_REG(CFSR
));