wm_debug.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. /**
  2. * @file wm_debug.h
  3. *
  4. * @brief debug Module APIs
  5. *
  6. * @author dave
  7. *
  8. * Copyright (c) 2014 Winner Microelectronics Co., Ltd.
  9. */
  10. #ifndef WM_DEBUG_H
  11. #define WM_DEBUG_H
  12. #include <stdio.h>
  13. #include <stdlib.h>
  14. #include "wm_config.h"
  15. #include "wm_osal.h"
  16. /* 0x00000000 - 0x80000000 */
  17. /** Define the debugging switch: on */
  18. #define TLS_DBG_ON 1
  19. /** Define the debugging switch: off */
  20. #define TLS_DBG_OFF 0
  21. #define TLS_DBG_SIMPLE 1
  22. /* 0x0000000F - 0x00000001 */
  23. /** Define the debugging level: info */
  24. #define TLS_DBG_LEVEL_INFO TLS_DBG_OFF
  25. /** Define the debugging level: warning */
  26. #define TLS_DBG_LEVEL_WARNING TLS_DBG_OFF
  27. /** Define the debugging level: error */
  28. #define TLS_DBG_LEVEL_ERR TLS_DBG_OFF
  29. /** Define the debugging level: dump */
  30. #define TLS_DBG_LEVEL_DUMP TLS_DBG_OFF
  31. /** general debug info switch, default: off */
  32. #define TLS_GENERAL_DBG TLS_DBG_OFF
  33. #if TLS_DBG_SIMPLE
  34. #define __TLS_DBGPRT_INFO(fmt, ...) printf(fmt, ##__VA_ARGS__)
  35. #define __TLS_DBGPRT_WARNING(fmt, ...) printf(fmt, ##__VA_ARGS__)
  36. #define __TLS_DBGPRT_ERR(fmt, ...) printf(fmt, ##__VA_ARGS__)
  37. #else
  38. #define __TLS_DBGPRT_INFO(fmt, ...) \
  39. do { \
  40. u32 time = tls_os_get_time(); \
  41. printf("[WM_I] <%d.%02d> %s : "fmt, (time/100), (time%100), __func__ , ##__VA_ARGS__); \
  42. } while (0)
  43. #define __TLS_DBGPRT_WARNING(fmt, ...) \
  44. do { \
  45. u32 time = tls_os_get_time(); \
  46. printf("[WM_W] <%d.%02d> %s : "fmt, (time/100), (time%100), __func__ , ##__VA_ARGS__); \
  47. } while (0)
  48. #define __TLS_DBGPRT_ERR(fmt, ...) \
  49. do { \
  50. u32 time = tls_os_get_time(); \
  51. printf("[WM_E] <%d.%02d> %s : "fmt, (time/100), (time%100), __func__ , ##__VA_ARGS__); \
  52. } while (0)
  53. #endif
  54. /**
  55. * @defgroup System_APIs System APIs
  56. * @brief System APIs
  57. */
  58. /**
  59. * @addtogroup System_APIs
  60. * @{
  61. */
  62. /**
  63. * @defgroup DEBUG_APIs DEBUG APIs
  64. * @brief DEBUG APIs
  65. */
  66. /**
  67. * @addtogroup DEBUG_APIs
  68. * @{
  69. */
  70. #if (TLS_GENERAL_DBG && TLS_DBG_LEVEL_INFO)
  71. /** Print information of the info level */
  72. #define TLS_DBGPRT_INFO(f, a...) __TLS_DBGPRT_INFO(f, ##a)
  73. #else
  74. /** Print information of the info level */
  75. #define TLS_DBGPRT_INFO(f, a...)
  76. #endif
  77. #if (TLS_GENERAL_DBG && TLS_DBG_LEVEL_WARNING)
  78. /** Print information of the warning level */
  79. #define TLS_DBGPRT_WARNING(f, a...) __TLS_DBGPRT_WARNING(f, ##a)
  80. #else
  81. /** Print information of the warning level */
  82. #define TLS_DBGPRT_WARNING(f, a...)
  83. #endif
  84. #if (TLS_GENERAL_DBG && TLS_DBG_LEVEL_ERR)
  85. /** Print information of the error level */
  86. #define TLS_DBGPRT_ERR(f, a...) __TLS_DBGPRT_ERR(f, ##a)
  87. #else
  88. /** Print information of the error level */
  89. #define TLS_DBGPRT_ERR(f, a...)
  90. #endif
  91. #if (TLS_GENERAL_DBG && TLS_DBG_LEVEL_DUMP)
  92. /**
  93. * @brief dump memory
  94. *
  95. * @param[in] *p pointer the memory
  96. * @param[in] len length of memory
  97. *
  98. * @return None
  99. *
  100. * @note None
  101. */
  102. void TLS_DBGPRT_DUMP(char *p, u32 len);
  103. #else
  104. /** Print information of the dump level */
  105. #define TLS_DBGPRT_DUMP(p, len)
  106. #endif
  107. /**
  108. * @}
  109. */
  110. /**
  111. * @}
  112. */
  113. #endif /* end of WM_DEBUG_H */