WXK
2025-01-16 13e0fafc140c16539691d26afafaca417e7e2fbc
01_SDK/modules/hal/panchip/panplat/pan1070/bsp/device/Source/retarget.c
@@ -10,8 +10,12 @@
*****************************************************************************/
#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)
@@ -28,14 +32,6 @@
#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 */ };
@@ -334,14 +330,8 @@
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;
}
@@ -374,7 +364,13 @@
            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
}
@@ -409,7 +405,8 @@
    }
#endif
#endif
#ifndef DISABLE_UART
#if CONFIG_UART_LOG_ENABLE
        while (1)
        {
            if((DEBUG_PORT->USR & UART_USR_RFNE_Msk))
@@ -417,8 +414,10 @@
                return (DEBUG_PORT->RBR_THR_DLL);
            }
        }
#else
    return(0);
#endif
#if CONFIG_RTT_LOG_ENABLE
    return SEGGER_RTT_WaitKey();
#endif
}
@@ -432,11 +431,7 @@
  */
int kbhit(void)
{
#ifndef DISABLE_UART
    return (DEBUG_PORT->USR & UART_USR_RFNE_Msk);
#else
    return(0);
#endif
}
/**
@@ -448,11 +443,7 @@
  */
int IsDebugFifoEmpty(void)
{
#ifndef DISABLE_UART
    return (DEBUG_PORT->USR & UART_USR_TFE_Msk) ? 1 : 0;
#else
    return(1);
#endif
}
/*---------------------------------------------------------------------------------------------------------*/