12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- #ifndef _UMF_DEBUG_H_
- #define _UMF_DEBUG_H_
- #include <drv_debug.h>
- extern unsigned int sisdbgconf1;
- extern unsigned int sisdbgconf2;
- //========================================================================================================
- // for console mode debug using
- extern char RSTMP[256];
- extern void con_SaveDbgMsgtoUSB(unsigned char bTx, short len, unsigned char *pStr);
- #define RSDBG(fmt, args...) do {sprintf(RSTMP, "[UMF] " fmt, ## args); con_SaveDbgMsgtoUSB(3, 256, (unsigned char *)RSTMP);}while(0)
- //========================================================================================================
- #ifndef CONFIG_SUPPORT_DEBUG_MESSAGE
- #define UMFDBG(level, fmt, args...)
- #define UMFDBG2(level, fmt, args...)
- #define DEBUG_ERR(fmt, arg...)
- #else
- #define UMFDEBUG
- #ifdef UMFDEBUG
- #define UMFDBG(level, fmt, args...) do {if (sisdbgconf1 & DBGCFG_UMF) fprintf(stderr, "[UMF] " fmt, ## args);}while(0)
- //#define UMFDBG(level, fmt, args...) RSDBG(fmt, ##args) // use to save umf debug message to usb.
- #define UMFDBG2(level, fmt, args...) do {if (sisdbgconf2 & DBGCFG_UMF) fprintf(stderr, fmt, ## args);}while(0)
-
- #define DEBUG_ERR(fmt, arg...) printf("\33[1;31m[%s:%d]"fmt"\33[0m", __FUNCTION__, __LINE__, ##arg)
- #else
- #define UMFDBG(level, fmt, args...)
- #define UMFDBG2(level, fmt, args...)
- #define DEBUG_ERR(fmt, arg...)
- #endif
- #endif
- //========================================================================================================
- #define ENABLE_UMFDBG_PRINT_FUNCTION 0
- #if ENABLE_UMFDBG_PRINT_FUNCTION
- #define UMFDBG_FUNCIN(x) UMFDBG(0, "FUNC ==>, %s\n", __FUNCTION__)
- #define UMFDBG_FUNCOUT(x) UMFDBG(0, "<== FUNC, %s %d\n", __FUNCTION__, __LINE__)
- #else
- #define UMFDBG_FUNCIN(x)
- #define UMFDBG_FUNCOUT(x)
- #endif
- //========================================================================================================
- #include <assert.h>
- #if 1
- #define IS_ARRAY(arr) ((void*)&(arr) == &(arr)[0])
- #define STATIC_EXP(e) (0 * sizeof (struct { int ARRAY_SIZE_FAILED:(2 * (e) - 1);}))
- #define ARRAY_SIZE(arr) (sizeof(arr)+ STATIC_EXP(IS_ARRAY(arr)))
- #define SPRINTF(buf,args...) snprintf(buf,ARRAY_SIZE(buf), ## args)
- #define SNPRINTF_PP(buf,args...) snprintf(buf,## args)
- #else //like never change
- #define ARRAY_SIZE(arr) sizeof(arr)
- #define SPRINTF(buf,args...) sprintf(buf, ## args)
- #define SNPRINTF_PP(buf,size,args...) sprintf(buf,## args)
- #endif
- #endif
|