Skip to content

Commit

Permalink
add hard_fault handler
Browse files Browse the repository at this point in the history
  • Loading branch information
edy555 committed Jan 22, 2017
1 parent 373e56f commit 79d1060
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gdbinit
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
target extended-remote :4242
b hard_fault_handler_c
19 changes: 19 additions & 0 deletions main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1485,3 +1485,22 @@ int main(void)
chThdSleepMilliseconds(1000);
}
}

/* The prototype shows it is a naked function - in effect this is just an
assembly function. */
void HardFault_Handler( void );

void hard_fault_handler_c(uint32_t *sp) __attribute__( ( naked ) );;

void HardFault_Handler(void)
{
uint32_t* sp;
//__asm volatile ("mrs %0, msp \n\t": "=r" (sp) );
__asm volatile ("mrs %0, psp \n\t": "=r" (sp) );
hard_fault_handler_c(sp);
}

void hard_fault_handler_c(uint32_t* sp)
{
while (true) {}
}

0 comments on commit 79d1060

Please sign in to comment.