trace.h 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. #ifndef _TRACE_H
  2. #define _TRACE_H
  3. #ifndef TRACE_BUF_LEN_MAX
  4. /*定义trace的buf长度*/
  5. #define TRACE_BUF_LEN_MAX 1024
  6. #endif
  7. typedef int(* trace_msg_send)(u8 uartid, const char *buf, u32 buflen);
  8. /* 格式输出到trace的目的地
  9. 输入参数:
  10. fmt, 输出格式,printf相同的格式约定
  11. ..., 可选参数,printf相同的格式约定
  12. 返回值:
  13. 格式化后的字符串长度,与printf的返回值的约定相同
  14. */
  15. u32 trace_otp_trace(const char * fmt, ...);
  16. u32 trace_otp_trace1(trace_msg_send msg_send_cb, u8 uartid, const char * fmt, ...);
  17. /*****************************************************************************
  18. *trace_init trace初始化函数
  19. *Input:
  20. * None
  21. *Output:
  22. * None
  23. *Return:
  24. * 0/-1
  25. */
  26. int trace_init(void);
  27. #define NEWLINE "\r\n"
  28. #define SPACE 0x20
  29. #define cmd_out trace_otp_trace
  30. #define OTP_TRACE trace_otp_trace
  31. #define OTP_TRACE_LINE OTP_TRACE( "TRC-ERR : %d@%s"NEWLINE, __LINE__, __FILE__)
  32. #define OTP_TRACE_FMT_ERR(fmt,arg...) OTP_TRACE("TRC-ERR : %d@%s, " fmt NEWLINE, __LINE__,__FILE__, ##arg)
  33. //#define EXE_ASSERT
  34. #ifdef EXE_ASSERT
  35. /*此处的assert暂时无法调试,暂时屏蔽 test */
  36. #define ASSERT(c) \
  37. do{\
  38. if(!(c)) \
  39. {\
  40. (void)trace_otp_trace( NEWLINE"ASSERT : %d@%s"NEWLINE"%s"NEWLINE, __LINE__, __FILE__,__FUNCTION__);\
  41. }\
  42. }while(0)
  43. #else
  44. #define ASSERT(c);
  45. #endif
  46. #endif