debug.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. #ifndef _DEBUG_H
  2. #define _DEBUG_H
  3. /************************************************************
  4. * @brief debug.h
  5. * @author jiejie
  6. * @github https://github.com/jiejieTop
  7. * @date 2018-xx-xx
  8. * @version v1.0
  9. * @note 此文件用于打印日志信息
  10. ***********************************************************/
  11. /**
  12. * @name Debug print
  13. * @{
  14. */
  15. #define PRINT_DEBUG_ENABLE 0 /* 打印调试信息 */
  16. #define PRINT_ERR_ENABLE 0 /* 打印错误信息 */
  17. #define PRINT_INFO_ENABLE 0 /* 打印个人信息 */
  18. #if PRINT_DEBUG_ENABLE
  19. #define PRINT_DEBUG(fmt, args...) do{(printf("\n[DEBUG] >> "), printf(fmt, ##args));}while(0)
  20. #else
  21. #define PRINT_DEBUG(fmt, args...)
  22. #endif
  23. #if PRINT_ERR_ENABLE
  24. #define PRINT_ERR(fmt, args...) do{(printf("\n[ERR] >> "), printf(fmt, ##args));}while(0)
  25. #else
  26. #define PRINT_ERR(fmt, args...)
  27. #endif
  28. #if PRINT_INFO_ENABLE
  29. #define PRINT_INFO(fmt, args...) do{(printf("\n[INFO] >> "), printf(fmt, ##args));}while(0)
  30. #else
  31. #define PRINT_INFO(fmt, args...)
  32. #endif
  33. /**@} */
  34. //针对不同的编译器调用不同的stdint.h文件
  35. #if defined(__ICCARM__) || defined(__CC_ARM) || defined(__GNUC__)
  36. #include <stdint.h>
  37. #endif
  38. /* 断言 Assert */
  39. #define AssertCalled(char,int) printf("\nError:%s,%d\r\n",char,int)
  40. #define ASSERT(x) if((x)==0) AssertCalled(__FILE__,__LINE__)
  41. typedef enum
  42. {
  43. ASSERT_ERR = 0, /* 错误 */
  44. ASSERT_SUCCESS = !ASSERT_ERR /* 正确 */
  45. } Assert_ErrorStatus;
  46. typedef enum
  47. {
  48. FALSE = 0, /* 假 */
  49. TRUE = !FALSE /* 真 */
  50. }ResultStatus;
  51. #endif /* __DEBUG_H */