optical/NxFuncs/stdebug/stdebug.c

85 lines
1.7 KiB
C
Raw Normal View History

2025-09-04 01:45:08 +00:00
#include "stdebug.h"
#include "shell.h"
#include "inout.h"
#include "trigger.h"
#include "delay.h"
//------------------------------------------------------------------------------------------------------------------------------------------------------------
void OutStackInfo(int type, u32 stackaddr)
{
typedef struct
{
u32 R0;
u32 R1;
u32 R2;
u32 R3;
u32 R12;
u32 LR;
u32 PC;
u32 xPSR;
} StackData;
#ifndef SetLedOn
#define SetLedOn()
#endif
#ifndef SetLedOff
#define SetLedOff()
#endif
#if (1)
StackData * pStack = (StackData *)(stackaddr); // <20><><EFBFBD>̣߳<DFB3>ʹ<EFBFBD><CAB9> MSP<53><50>ջ
SetConsoleOutType(0); // <20>Ƕ<EFBFBD><C7B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
while (1)
{
printf("\r\n-----------------------------------------\r\n");
if (type == 0)
{
printf("In HardFault_Handler\r\n");
}
else if (type == 1)
{
printf("In MemManage_Handler\r\n");
}
else if (type == 2)
{
printf("In BusFault_Handler\r\n");
}
else if (type == 3)
{
printf("In UsageFault_Handler\r\n");
}
else if (type == 4)
{
printf("In NMI_Handler\r\n");
}
printf("Regs In stack\r\n");
printf ("R0 = 0x%lx\r\n", pStack->R0);
printf ("R1 = 0x%lx\r\n", pStack->R1);
printf ("R2 = 0x%lx\r\n", pStack->R2);
printf ("R3 = 0x%lx\r\n", pStack->R3);
printf ("R12 = 0x%lx\r\n",pStack->R12);
printf ("R14[LR] = 0x%lx\r\n", pStack->LR);
printf ("R15[PC] = 0x%lx\r\n", pStack->PC);
printf ("xPSR = 0x%lx\r\n", pStack->xPSR);
for (int i = 0; i < 10; i++)
{
SetLedOn();
DelayMs(50);
SetLedOff();
DelayMs(100);
}
}
#endif
}
//------------------------------------------------------------------------------------------------------------------------------------------------------------