基质喷涂
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

57 lines
2.4 KiB

  1. #pragma once
  2. #include "zbase.h"
  3. extern bool g_xs_enable_log;
  4. extern uint32_t zget_ticket(void);
  5. extern void zdelay_ms(int ms);
  6. #define ZLOG_RELEASE(TAG, fmt, ...) \
  7. if (g_xs_enable_log) { \
  8. zlog(TAG "" fmt "\n", ##__VA_ARGS__); \
  9. }
  10. #define ZLOGI(TAG, fmt, ...) \
  11. if (g_xs_enable_log) { \
  12. zlog("INFO [%-8s] " fmt "\n", TAG, ##__VA_ARGS__); \
  13. }
  14. #define ZLOGD(TAG, fmt, ...) \
  15. if (g_xs_enable_log && enDebugFlag) { \
  16. zlog("%08lu DEBU [%-8s] " fmt "\n", zget_ticket(), TAG, ##__VA_ARGS__); \
  17. }
  18. #define ZLOGE(TAG, fmt, ...) \
  19. if (g_xs_enable_log) { \
  20. zlog("【 ERRO 】 [%-8s] " fmt "\n", TAG, ##__VA_ARGS__); \
  21. }
  22. #define ZLOGW(TAG, fmt, ...) \
  23. if (g_xs_enable_log) { \
  24. zlog("%08lu WARN [%-8s] " fmt "\n", zget_ticket(), TAG, ##__VA_ARGS__); \
  25. }
  26. #define ASSERT(cond, info) \
  27. if (!(cond)) { \
  28. while (1) { \
  29. zlog("ASSERT: %s [%s:%d] %s\n", #cond, __FILE__, __LINE__, info); \
  30. } \
  31. }
  32. #define ZASSERT_INFO(cond, fmt, ...) \
  33. if (!(cond)) { \
  34. while (1) { \
  35. zlog("ASSERT: %s [%s:%d]" fmt "\n", #cond, __FILE__, __LINE__, ##__VA_ARGS__); \
  36. } \
  37. }
  38. #define ZASSERT(cond) ASSERT(cond, "")
  39. #define ZASSERT(cond) ASSERT(cond, "")
  40. #define HAL_ASSERT(exptr) \
  41. { \
  42. HAL_StatusTypeDef status = (exptr); \
  43. ASSERT(status == HAL_OK, #exptr); \
  44. }
  45. #define ZARRAY_SIZE(arr) (sizeof(arr) / sizeof(arr[0]))
  46. void zlog_init(UART_HandleTypeDef* uart);
  47. void zlog(const char* fmt, ...);
  48. void zlog_raw(const char* info);
  49. void zlog_enable(bool enable);