From aa38e5c1f48e31213ee349aa5cd6f06c85bda70d Mon Sep 17 00:00:00 2001
From: android <android@lingyun.com>
Date: Tue, 25 Jun 2024 21:49:39 +0800
Subject: [PATCH] Add GD32F103RCT6 ADC converter board SDK source code
---
mcu_sdk/gd32f103/rk_eFire/Utiles/Utilities/logger.c | 85 ++++++++++++++++++++++++++++++++++++++++++
1 files changed, 85 insertions(+), 0 deletions(-)
diff --git a/mcu_sdk/gd32f103/rk_eFire/Utiles/Utilities/logger.c b/mcu_sdk/gd32f103/rk_eFire/Utiles/Utilities/logger.c
new file mode 100644
index 0000000..792e9af
--- /dev/null
+++ b/mcu_sdk/gd32f103/rk_eFire/Utiles/Utilities/logger.c
@@ -0,0 +1,85 @@
+#include "board_common.h"
+
+static osMutexId PrintMutex;
+static int PrintCurLevel = TH_PRINT_CUR;
+osMutexDef(PrintMutex);
+
+static void Board_DebugMutexInit(void)
+{
+ PrintMutex = osMutexCreate(osMutex(PrintMutex));
+}
+
+static void Board_DebugMutexDeInit(void)
+{
+ osMutexDelete(PrintMutex);
+}
+
+static void Board_DebugSetLevel(int Level)
+{
+ PrintCurLevel = Level;
+}
+
+static void PrintToConsole(char *Color, char *Module, int Level, char *LevelName, char *FileName, int LineNum, const char *Func, char *Fmt, va_list argp)
+{
+ osMutexWait(PrintMutex, osWaitForever);
+ if (Level < TH_PRINT_MAX)
+ PRINTF("%s[%s][%s]>%s(%d,%s)>|", Color, Module, LevelName, FileName, LineNum, Func);
+
+ //���´��룬�ο�Report������
+ int8_t i8Ret;
+ char *Buffer = NULL;
+ uint32_t u8Size = 300;
+
+ //va_list list;
+ Buffer = (char*)pvPortMalloc(u8Size);
+ if(Buffer == NULL)
+ {
+ osMutexRelease(PrintMutex);
+ return;
+ }
+ memset(Buffer, 0x0, u8Size);
+
+ while(1)
+ {
+ i8Ret = TH_VSNPRINTF(Buffer, u8Size, Fmt, argp);
+ if(i8Ret > -1 && i8Ret < u8Size)
+ break;
+ }
+
+ PRINTF("%s", Buffer);
+
+ if (Buffer != NULL)
+ vPortFree(Buffer);
+ Buffer = NULL;
+
+ /* ��ԭĬ��������ɫ */
+ if (Level < TH_PRINT_MAX)
+ PRINTF("[%d]%c%c%s", (int32_t)uxTaskGetStackHighWaterMark(NULL), '\r', '\n', COLOR_NORMAL);
+
+ osMutexRelease(PrintMutex);
+}
+
+//�����еļ�1,��1,���ַ����Ľ�ֹ��'\0'
+void Board_DebugPrintf(char *Color, char *Module, int Level, char *LevelName, char *FileName, int LineNum, const char *Func, char *Fmt, ...)
+{
+ //�����ӡ�ļ��𣬱ȵ�ǰ���õļ���ͣ����ᱻ��ӡ
+ if(Level < PrintCurLevel)
+ return;
+
+ va_list argp;
+ va_start(argp, Fmt);
+ PrintToConsole(Color, Module, Level, LevelName, FileName, LineNum, Func, Fmt, argp);
+ va_end(argp);
+}
+
+void Board_DebugInit(int Level)
+{
+ Board_DebugMutexInit();
+ Board_DebugSetLevel(Level);
+}
+
+void Board_DebugDeInit(void)
+{
+ Board_DebugMutexDeInit();
+}
+
--
Gitblit v1.9.1