| | |
| | | *****************************************************************************/ |
| | | #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 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); |
| | | } |
| | | } |
| | | #else |
| | | return(0); |
| | | #endif |
| | | |
| | | #if CONFIG_RTT_LOG_ENABLE |
| | | return SEGGER_RTT_WaitKey(); |
| | | #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 |
| | | } |
| | | |
| | | /*---------------------------------------------------------------------------------------------------------*/ |