#ifndef __DEBUG_H #define __DEBUG_H #include "bsp.h" #if (USE_DEBUG != 0) #define BUFSIZE 128 #define DEBUG_BUFF_SIZE_MAX 512 void vcom_Send( char *format, ... ); void vcom_Send2(uint8_t *sData, uint16_t len); #define DBG_LOG2(x, y) vcom_Send2(x, y) //打印长度超过缓存DEBUG_BUFF_SIZE_MAX的信息 #define DBG_LOG(...) vcom_Send(__VA_ARGS__) #define DBG_LOG_F(fmt,arg...) LOG("[%s] "fmt,__FUNCTION__,##arg) #define DBG_ARRAY(ARRAY,SIZE) { \ if(ARRAY != NULL) { \ for(int i = 0; i < SIZE; i++) { \ DBG_LOG("%02x ",ARRAY[i]); \ } \ DBG_LOG("\r\n"); \ } \ } typedef void (*DebugExec)(int argc, char *argv[]); typedef struct{ char *DBGCmd; DebugExec DBGExec; }DBGFunType; /* 控制盒信息帧→复位→恢复 观测打印: ISR推事件, 主循环打印完整时间线(未知帧全记录用于捕捉过热报错) */ void Uart3ErrLog_Push(uint8_t type, const uint8_t *pFrame, uint16_t height); /* type:0首次信息帧 1复位中回应 2复位完成 3未知帧 */ void Uart3ErrLogLoopHandler(void); /* 主循环调用: 打印报错/复位事件 */ void DebugUartIRQ(char Data); void DebugLoopHandler(void); void Dbg1msRoutine(void); #else #define DBG_LOG2(x, y) #define DBG_LOG(...) #define DBG_LOG_F(fmt,arg...) #define DBG_ARRAY(ARRAY,SIZE) #define Uart3ErrLog_Push(type, pFrame, height) (0) #define Uart3ErrLogLoopHandler() (0) #endif #endif