This commit is contained in:
2026-05-21 08:07:16 +08:00
parent 90908cf018
commit 84d8874a38
32 changed files with 271 additions and 27 deletions
+6
View File
@@ -10,6 +10,7 @@ static char debug_buffer[256];
/**
* @brief 初始化调试串口(USART2, PA2=TX, PA3=RX)
*/
/* 函数作用:初始化 USART2 调试串口并输出启动日志。 */
void Debug_Init(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
@@ -52,6 +53,7 @@ void Debug_Init(void)
/**
* @brief 通过调试串口发送一个字节
*/
/* 函数作用:通过 USART2 发送单个调试字节。 */
static void Debug_SendByte(uint8_t byte)
{
while (USART_GetFlagStatus(USART2, USART_FLAG_TXE) == RESET);
@@ -61,6 +63,7 @@ static void Debug_SendByte(uint8_t byte)
/**
* @brief 通过调试串口发送字符串
*/
/* 函数作用:通过 USART2 连续发送调试字符串。 */
static void Debug_SendString(const char* str)
{
while (*str)
@@ -72,6 +75,7 @@ static void Debug_SendString(const char* str)
/**
* @brief 格式化调试信息输出(类似printf)
*/
/* 函数作用:格式化调试信息并通过串口输出。 */
void Debug_Printf(const char* format, ...)
{
va_list args;
@@ -85,7 +89,9 @@ void Debug_Printf(const char* format, ...)
#else
// 调试关闭时,提供空实现
/* 函数作用:调试关闭时提供空初始化函数,保持接口兼容。 */
void Debug_Init(void) {}
/* 函数作用:调试关闭时丢弃格式化输出,保持接口兼容。 */
void Debug_Printf(const char* format, ...) {}
#endif