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.

59 lines
2.6 KiB

12 months ago
12 months ago
12 months ago
8 months ago
12 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
9 months ago
12 months ago
12 months ago
  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("%08lu INFO [%-8s] " fmt "\n", zget_ticket(), 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("%08lu ERRO [%-8s] " fmt "\n", zget_ticket(), 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. zdelay_ms(1000); \
  31. } \
  32. }
  33. #define ZASSERT_INFO(cond, fmt, ...) \
  34. if (!(cond)) { \
  35. while (1) { \
  36. zlog("ASSERT: %s [%s:%d]" fmt "\n", #cond, __FILE__, __LINE__, ##__VA_ARGS__); \
  37. zdelay_ms(1000); \
  38. } \
  39. }
  40. #define ZASSERT(cond) ASSERT(cond, "")
  41. #define ZASSERT(cond) ASSERT(cond, "")
  42. #define HAL_ASSERT(exptr) \
  43. { \
  44. HAL_StatusTypeDef status = (exptr); \
  45. ASSERT(status == HAL_OK, #exptr); \
  46. }
  47. #define ZARRAY_SIZE(arr) (sizeof(arr) / sizeof(arr[0]))
  48. void zlog_init(UART_HandleTypeDef* uart);
  49. void zlog(const char* fmt, ...);
  50. void zlog_raw(const char* info);
  51. void zlog_enable(bool enable);