84 lines
2.4 KiB
C
84 lines
2.4 KiB
C
/*
|
|
* debug.h
|
|
*
|
|
* Created on: May 14, 2025
|
|
* Author: cc
|
|
*/
|
|
|
|
#ifndef MCU_DRIVER_DEBUG_H_
|
|
#define MCU_DRIVER_DEBUG_H_
|
|
|
|
#include "ch564.h"
|
|
#include <stdio.h>
|
|
|
|
/* UART Printf Definition */
|
|
#define DEBUG_UART0 1
|
|
#define DEBUG_UART1 2
|
|
#define DEBUG_UART2 3
|
|
#define DEBUG_UART3 4
|
|
|
|
/* DEBUG log function. DEBUG printf() 相关定义*/
|
|
#ifndef DBG_LOG_EN
|
|
#define DBG_LOG_EN 1 //DEBUG LOG 输出总开关
|
|
#endif
|
|
|
|
#define DBG_Particular_EN 1 //详细信息输出 -- 具体到文件名,调用函数,行号
|
|
#define DBG_NET_LOG_EN 1 //网络模块调试信息开关
|
|
|
|
/*调试信息初始状态*/
|
|
#define DBG_OPT_ActCond_STATUS 1 //动作执行条件信息打印开关
|
|
#define DBG_OPT_MQTT_STATUS 1 //MQTT调试信息打印开关
|
|
#define DBG_OPT_Debug_STATUS 1 //临时调试信息打印开关
|
|
#define DBG_OPT_LOGIC_STATUS 1 //逻辑调试信息打印开关
|
|
#define DBG_OPT_DEVICE_STATUS 1 //设备驱动层打印调试信息打印开关
|
|
#define DBG_OPT_NET_STATUS 1 //网络调试信息打印开关
|
|
#define DBG_OPT_SYS_STATUS 1 //系统调试信息打印开关
|
|
|
|
/*调试信息输出控制位*/
|
|
#define DBG_BIT_ActCond_STATUS_bit 6
|
|
#define DBG_BIT_MQTT_STATUS_bit 5
|
|
#define DBG_BIT_Debug_STATUS_bit 4
|
|
#define DBG_BIT_LOGIC_STATUS_bit 3
|
|
#define DBG_BIT_DEVICE_STATUS_bit 2
|
|
#define DBG_BIT_NET_STATUS_bit 1
|
|
#define DBG_BIT_SYS_STATUS_bit 0
|
|
|
|
|
|
#ifdef DBG_LOG_EN
|
|
#define DBG_Printf(...) printf(__VA_ARGS__)
|
|
#else
|
|
#define DBG_Printf(...)
|
|
#endif
|
|
|
|
#ifdef DBG_Particular_EN
|
|
#define DBG_log(...) {DBG_Printf("%s %s-%d :",__FILE__,__func__,__LINE__);DBG_Printf(__VA_ARGS__);}
|
|
#else
|
|
#define DBG_log(...) DBG_Printf(__VA_ARGS__)
|
|
#endif
|
|
|
|
#define DBG_INFO(msg) DBG_Printf("%s %s-%d :%s",__FILE__,__func__,__LINE__,msg)
|
|
|
|
#ifdef DBG_NET_LOG_EN
|
|
#define DBG_NET_log(...) DBG_Printf(__VA_ARGS__)
|
|
#else
|
|
#define DBG_NET_log(...)
|
|
#endif
|
|
|
|
extern uint32_t Dbg_Switch;
|
|
|
|
|
|
extern volatile uint32_t SysTick_100us;
|
|
extern volatile uint32_t SysTick_1ms;
|
|
extern volatile uint32_t SysTick_1s;
|
|
|
|
void Systick_Init(void);
|
|
void Delay_Us(uint32_t n);
|
|
void Delay_Ms(uint32_t n);
|
|
|
|
void Dbg_NoTick_Print(int DbgOptBit ,const char *cmd, ...);
|
|
void Dbg_Print(int DbgOptBit ,const char *cmd, ...);
|
|
void Dbg_Println(int DbgOptBit ,const char *cmd, ...);
|
|
void Dbg_Print_Buff(int DbgOptBit ,const char *cmd ,uint8_t *buff,uint32_t len);
|
|
|
|
#endif /* MCU_DRIVER_DEBUG_H_ */
|