15#if defined ( __CC_ARM )
16#if (__ARMCC_VERSION < 400000)
19#pragma import _printf_widthprec
23#ifdef DEBUG_ENABLE_UART1
24#define DEBUG_PORT UART1
26#define DEBUG_PORT UART0
32#if defined(DEBUG_ENABLE_SEMIHOST)
42#if (defined(__ARMCC_VERSION) && (__ARMCC_VERSION < 6040000)) || (defined(__ICCARM__) && (__VER__ >= 8000000))
43struct __FILE {
int handle; };
52 printf(
"r0 = 0x%x\n", stack[
r0]);
53 printf(
"r1 = 0x%x\n", stack[
r1]);
54 printf(
"r2 = 0x%x\n", stack[
r2]);
55 printf(
"r3 = 0x%x\n", stack[
r3]);
56 printf(
"r12 = 0x%x\n", stack[
r12]);
57 printf(
"lr = 0x%x\n", stack[
lr]);
58 printf(
"pc = 0x%x\n", stack[
pc]);
59 printf(
"psr = 0x%x\n", stack[
psr]);
64 printf(
"In Hard Fault Handler\n");
76#if defined(DEBUG_ENABLE_SEMIHOST)
79static char g_buf_len = 0;
83# if defined ( __GNUC__ ) && !(__CC_ARM) && !(__ICCARM__)
85# elif defined(__ICCARM__)
108 "LDR R1, [R0, #24] \n"
110 "LDR R2, [pc, #8] \n"
112 "BNE HardFault_Handler_Ret\n"
114 "STR R1, [R0, #24] \n"
117 "HardFault_Handler_Ret:\n"
121 "BEQ Stack_Use_MSP \n"
123 "B Get_LR_and_Branch \n"
126 "Get_LR_and_Branch: \n"
128 "B Hard_Fault_Handler \n"
144int32_t SH_DoCommand(int32_t n32In_R0, int32_t n32In_R1, int32_t *pn32Out_R0)
190 BNE HardFault_Handler_Ret
203 MRS R0, PSP ;stack use PSP
206 MRS R0, MSP ; stack use MSP
208 MOV R1, LR ; LR current
value
227__asm int32_t SH_DoCommand(int32_t n32In_R0, int32_t n32In_R1, int32_t *pn32Out_R0)
254# if defined ( __GNUC__ ) && !(__CC_ARM) && !(__ICCARM__)
274 "B Hard_Fault_Handler \n"
277 "B Hard_Fault_Handler \n"
283# elif defined(__ICCARM__)
300 "BEQ Stack_Use_MSP \n"
302 "B Get_LR_and_Branch \n"
305 "Get_LR_and_Branch: \n"
307 "B Hard_Fault_Handler \n"
331 MRS R0, PSP ;stack use PSP
334 MRS R0, MSP ; stack use MSP
336 MOV R1, LR ; LR current
value
374#if defined(DEBUG_ENABLE_SEMIHOST)
375 g_buf[g_buf_len++] = ch;
376 g_buf[g_buf_len] =
'\0';
377 if(g_buf_len + 1 >=
sizeof(g_buf) || ch ==
'\n' || ch ==
'\0')
382 if(SH_DoCommand(0x04, (
int)g_buf,
NULL) != 0)
391 for(i=0;i<g_buf_len;i++)
411#if defined(DEBUG_ENABLE_SEMIHOST)
412# if defined ( __CC_ARM )
414 while(SH_DoCommand(0x101, 0, &nRet) != 0)
418 SH_DoCommand(0x07, 0, &nRet);
424 while(SH_DoCommand(0x7, 0, &nRet) != 0)
492#if defined (__GNUC__) && !defined(__ARMCC_VERSION)
494int _write (
int fd,
char *ptr,
int len)
512int _read (
int fd,
char *ptr,
int len)
534#ifdef DEBUG_ENABLE_SEMIHOST
536void __exit(
int return_code)
541 if(SH_DoCommand(0x18, 0x20026,
NULL) == 0)
550void _sys_exit(
int return_code)
554 if(SH_DoCommand(0x18, 0x20026,
NULL) == 0)
Mini55 series peripheral access layer header file. This file contains all the peripheral register's d...
#define UART_FIFOSTS_TXFULL_Msk
#define UART_FIFOSTS_TXEMPTYF_Msk
#define UART_FIFOSTS_RXEMPTY_Msk
#define NULL
NULL pointer.
__asm int32_t HardFault_Handler(void)
This HardFault handler is implemented to show r0, r1, r2, r3, r12, lr, pc, psr.
int IsDebugFifoEmpty(void)
Check whether UART transmit FIFO is empty or not.
void SendChar_ToUART(int ch)
Write a char to UART.
int kbhit(void)
Check whether UART receive FIFO is empty or not.
int fputc(int ch, FILE *f)
void Hard_Fault_Handler(uint32_t stack[])
void SendChar(int ch)
Write a char to debug console.
char GetChar(void)
Read a char from debug console.
void stackDump(uint32_t stack[])