| | |
| | | *****************************************************************************/ |
| | | #include <stdio.h> |
| | | #include "PanSeries.h" |
| | | #if CONFIG_RTT_LOG_ENABLE |
| | | #include "SEGGER_RTT.h" |
| | | #endif |
| | | |
| | | #define UART0_ENABLE (1) |
| | | /* Suppress the build warning #111-D: statement is unreachable */ |
| | | #pragma diag_suppress 111 |
| | | |
| | | #if defined ( __CC_ARM ) |
| | | #if (__ARMCC_VERSION < 400000) |
| | |
| | | #else |
| | | #define DEBUG_PORT UART0 |
| | | #endif |
| | | |
| | | /* Un-comment this line to disable all printf and getchar. getchar() will always return 0x00*/ |
| | | //#define DISABLE_UART |
| | | |
| | | /*---------------------------------------------------------------------------------------------------------*/ |
| | | /* Global variables */ |
| | | /*---------------------------------------------------------------------------------------------------------*/ |
| | | |
| | | |
| | | //#if !(defined(__ICCARM__) && (__VER__ >= 6010000)) |
| | | //struct __FILE { int handle; /* Add whatever you need here */ }; |
| | |
| | | |
| | | void Hard_Fault_Handler(uint32_t stack[]) |
| | | { |
| | | #if CONFIG_IO_TIMING_TRACK |
| | | PAN_IO_TIMING_TRACK_LEVEL(CONFIG_TRACK_PIN_HARDFAULT_IRQ, 1); |
| | | #endif |
| | | |
| | | printf("In Hard Fault Handler\r\n"); |
| | | |
| | | stackDump(stack); |
| | | |
| | | //Chip Reset |
| | | //SYS_UnlockReg(); |
| | | //SYS->IPRSTC1 |= SYS_IPRSTC1_CHIP_RST_Msk; |
| | | while(1){}; |
| | | |
| | | while(1); |
| | | // Although program won't run into here, we write a statement |
| | | // just for symmetry. |
| | | #if CONFIG_IO_TIMING_TRACK |
| | | PAN_IO_TIMING_TRACK_LEVEL(CONFIG_TRACK_PIN_HARDFAULT_IRQ, 0); |
| | | #endif |
| | | } |
| | | |
| | | |
| | |
| | | |
| | | void SendChar_ToUART(int ch) |
| | | { |
| | | #ifndef DISABLE_UART |
| | | |
| | | #if (UART0_ENABLE) |
| | | while(UART_IsTxFifoFull(DEBUG_PORT)); |
| | | DEBUG_PORT->RBR_THR_DLL = ch; |
| | | #endif //UART0_ENABLE |
| | | |
| | | #endif //DISABLE_UART |
| | | while(UART_IsTxFifoFull(DEBUG_PORT)); |
| | | DEBUG_PORT->RBR_THR_DLL = ch; |
| | | } |
| | | |
| | | |
| | |
| | | g_buf_len = 0; |
| | | } |
| | | } |
| | | #else |
| | | #endif |
| | | |
| | | #if CONFIG_RTT_LOG_ENABLE |
| | | SEGGER_RTT_PutCharSkipNoLock(0, ch); |
| | | #endif |
| | | |
| | | #if CONFIG_UART_LOG_ENABLE |
| | | SendChar_ToUART(ch); |
| | | #endif |
| | | } |
| | |
| | | } |
| | | #endif |
| | | #endif |
| | | #ifndef DISABLE_UART |
| | | |
| | | #if CONFIG_UART_LOG_ENABLE |
| | | while (1) |
| | | { |
| | | if((DEBUG_PORT->USR & UART_USR_RFNE_Msk)) |
| | |
| | | return (DEBUG_PORT->RBR_THR_DLL); |
| | | } |
| | | } |
| | | #elif CONFIG_RTT_LOG_ENABLE |
| | | return SEGGER_RTT_WaitKey(); |
| | | #else |
| | | return(0); |
| | | return 0; |
| | | #endif |
| | | } |
| | | |
| | |
| | | */ |
| | | int kbhit(void) |
| | | { |
| | | #ifndef DISABLE_UART |
| | | return (DEBUG_PORT->USR & UART_USR_RFNE_Msk); |
| | | #else |
| | | return(0); |
| | | #endif |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | int IsDebugFifoEmpty(void) |
| | | { |
| | | #ifndef DISABLE_UART |
| | | return (DEBUG_PORT->USR & UART_USR_TFE_Msk) ? 1 : 0; |
| | | #else |
| | | return(1); |
| | | #endif |
| | | } |
| | | |
| | | /*---------------------------------------------------------------------------------------------------------*/ |