这段查找硬件中断原因的代码,下面子函数获取的代码变量各是什么意思呢?(stacked_r0 这些等)
HardFault_Handler
PROC
IMPORT hard_fault_handler_c
TST LR, #4
ITE EQ
MRSEQ R0, MSP
MRSNE R0, PSP
B hard_fault_handler_c
ENDP
// hard fault handler in C,
// with stack frame location as input parameter
void hard_fault_handler_c(unsigned int * hardfault_args)
{
unsigned int stacked_r0;
unsigned int stacked_r1;
unsigned int stacked_r2;
unsigned int stacked_r3;
unsigned int stacked_r12;
unsigned int stacked_lr;
unsigned int stacked_pc;
unsigned int stacked_psr;
stacked_r0 = ((unsigned long) hardfault_args[0]);
stacked_r1 = ((unsigned long) hardfault_args[1]);
stacked_r2 = ((unsigned long) hardfault_args[2]);
stacked_r3 = ((unsigned long) hardfault_args[3]);
stacked_r12 = ((unsigned long) hardfault_args[4]);
stacked_lr = ((unsigned long) hardfault_args[5]);
stacked_pc = ((unsigned long) hardfault_args[6]);
stacked_psr = ((unsigned long) hardfault_args[7]);
printf ("[Hard fault handler]
");
printf ("R0 = %x
", stacked_r0);
printf ("R1 = %x
", stacked_r1);
printf ("R2 = %x
", stacked_r2);
printf ("R3 = %x
", stacked_r3);
printf ("R12 = %x
", stacked_r12);
printf ("LR = %x
", stacked_lr);
printf ("PC = %x
", stacked_pc);
printf ("PSR = %x
", stacked_psr);
printf ("BFAR = %x
", (*((volatile unsigned long *)(0xE000ED38))));
printf ("CFSR = %x
", (*((volatile unsigned long *)(0xE000ED28))));
printf ("HFSR = %x
", (*((volatile unsigned long *)(0xE000ED2C))));
printf ("DFSR = %x
", (*((volatile unsigned long *)(0xE000ED30))));
printf ("AFSR = %x
", (*((volatile unsigned long *)(0xE000ED3C))));
while(1)
{
;
}
}
一周热门 更多>