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.

53 lines
2.3 KiB

2 years ago
  1. #pragma once
  2. #ifdef __cplusplus
  3. extern "C" {
  4. #endif
  5. #include <stdbool.h>
  6. #include <stdint.h>
  7. #include "chip.h"
  8. #include "delay.h"
  9. /***********************************************************************************************************************
  10. * =============================================================================================================== *
  11. ***********************************************************************************************************************/
  12. extern bool g_enable_log;
  13. #define ZLOG_RELEASE(TAG, fmt, ...) \
  14. if (g_enable_log) { \
  15. printf(TAG "" fmt "\n", ##__VA_ARGS__); \
  16. }
  17. #define ZLOGI(TAG, fmt, ...) \
  18. if (g_enable_log) { \
  19. printf("%08u INFO [%-8s] " fmt "\n", ifly_get_ticket(), TAG, ##__VA_ARGS__); \
  20. }
  21. #define ZLOGD(TAG, fmt, ...) \
  22. if (g_enable_log) { \
  23. printf("%08u DEBU [%-8s] " fmt "\n", ifly_get_ticket(), TAG, ##__VA_ARGS__); \
  24. }
  25. #define ZLOGE(TAG, fmt, ...) \
  26. if (g_enable_log) { \
  27. printf("%08u ERRO [%-8s] " fmt "\n", ifly_get_ticket(), TAG, ##__VA_ARGS__); \
  28. }
  29. #define ZLOGI_HEX(TAG, hextable, table_size) \
  30. if (g_enable_log) { \
  31. printf("%08u INFO [%-8s] \t", ifly_get_ticket(), TAG); \
  32. for (int i = 0; i < table_size; i++) { \
  33. printf(" %02X", hextable[i]); \
  34. } \
  35. printf("\n"); \
  36. }
  37. #define ZASSERT(cond) \
  38. if (!(cond)) { \
  39. while (1) { \
  40. printf("ASSERT: %s [%s:%d]\n", #cond, __FILE__, __LINE__); \
  41. ifly_delay_ms(1000); \
  42. } \
  43. }
  44. void ifly_loggger_init(UART_HandleTypeDef *huart);
  45. void ifly_loggger_enable(bool enable);
  46. #ifdef __cplusplus
  47. }
  48. #endif