嵌入式系统日志
void wdbg_printf(const char * format, ... ) {
va_list args;
s32 len;
if(g_trace_handle == NULL) {
return;
}
s8* buf = (s8*)sys_malloc(128);
if(buf) {
va_start(args, format);
len = vsnprintf ((char*)buf, 128, format, args);
va_end (args);
if(len > 0 ) {
if(xStreamBufferSpacesAvailable(g_trace_handle) > len){
xStreamBufferSend(g_trace_handle, buf, len, 5);
}
}
sys_free(buf);
}
}
#if (SUPPORT_DBG == 1)
#include <stdarg.h>
#include <stdio.h>
extern void wdbg_printf(const char * format, ... );
#define WDBG(fmt, ...) wdbg_printf( "%d:INFO %s %d:"fmt"\n",HAL_GetTick(), __func__, __LINE__, ##__VA_ARGS__)
#define WDBGE(fmt, ...) wdbg_printf("%d:E %s %d:"fmt"\n",HAL_GetTick(), __func__, __LINE__, ##__VA_ARGS__)
#define WDBGW(fmt, ...) wdbg_printf("%d:W %s %d:"fmt"\n",HAL_GetTick(), __func__, __LINE__, ##__VA_ARGS__)
#define WDBGN(fmt, ...) wdbg_printf( fmt"\n", ##__VA_ARGS__)
#define WDBG_HEX(...)
#else
#define WDBG(...)
#define WDBGW(...)
#define WDBGE(...)
#define WDBGN(...)
#define WDBG_HEX(...)