Files
bishe-STM32/System/Debug.h
T
2026-05-21 08:07:16 +08:00

32 lines
943 B
C
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#ifndef __DEBUG_H
#define __DEBUG_H
#include "stm32f10x.h"
#include <stdio.h>
// 调试功能开关(1=开启调试,0=关闭调试)
#define DEBUG_ENABLE 1 // 暂时关闭,添加Debug.c后改回1
// 调试串口初始化(使用USART2,PA2/PA3)
// 函数作用:初始化调试串口 USART2,供 DEBUG_PRINT 输出日志使用。
void Debug_Init(void);
// 调试信息输出函数
// 函数作用:按 printf 格式输出调试日志到调试串口。
void Debug_Printf(const char* format, ...);
// 快捷宏定义
#if DEBUG_ENABLE
#define DEBUG_PRINT(...) Debug_Printf(__VA_ARGS__)
#define DEBUG_INFO(msg) Debug_Printf("[INFO] %s\r\n", msg)
#define DEBUG_ERROR(msg) Debug_Printf("[ERROR] %s\r\n", msg)
#define DEBUG_OK(msg) Debug_Printf("[OK] %s\r\n", msg)
#else
#define DEBUG_PRINT(...)
#define DEBUG_INFO(msg)
#define DEBUG_ERROR(msg)
#define DEBUG_OK(msg)
#endif
#endif