openamp_log.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. /**
  2. ******************************************************************************
  3. * @file log.h
  4. * @author MCD Application Team
  5. * @brief logging services
  6. ******************************************************************************
  7. *
  8. * @attention
  9. *
  10. * <h2><center>&copy; Copyright (c) 2019 STMicroelectronics.
  11. * All rights reserved.</center></h2>
  12. *
  13. * This software component is licensed by ST under BSD 3-Clause license,
  14. * the "License"; You may not use this file except in compliance with the
  15. * License. You may obtain a copy of the License at:
  16. * opensource.org/licenses/BSD-3-Clause
  17. *
  18. *
  19. ******************************************************************************
  20. */
  21. /** @addtogroup LOG
  22. * @{
  23. */
  24. /** @addtogroup stm32mp1xx_Log
  25. * @{
  26. */
  27. /**
  28. * @brief Define to prevent recursive inclusion
  29. */
  30. #ifndef __LOG_STM32MP1XX_H
  31. #define __LOG_STM32MP1XX_H
  32. #ifdef __cplusplus
  33. extern "C" {
  34. #endif
  35. /** @addtogroup STM32MP1xx_Log_Includes
  36. * @{
  37. */
  38. #include "stm32mp1xx_hal.h"
  39. /**
  40. * @}
  41. */
  42. /** @addtogroup STM32MP1xx_Log_Exported_Constants
  43. * @{
  44. */
  45. #if defined (__LOG_TRACE_IO_)
  46. #define SYSTEM_TRACE_BUF_SZ 2048
  47. #endif
  48. #define LOGQUIET 0
  49. #define LOGERR 1
  50. #define LOGWARN 2
  51. #define LOGINFO 3
  52. #define LOGDBG 4
  53. #ifndef LOGLEVEL
  54. #define LOGLEVEL LOGINFO
  55. #endif
  56. /**
  57. * @}
  58. */
  59. /** @addtogroup STM32MP1xx_Log_Exported_types
  60. * @{
  61. */
  62. #if defined (__LOG_TRACE_IO_)
  63. extern char system_log_buf[SYSTEM_TRACE_BUF_SZ]; /*!< buffer for debug traces */
  64. #endif /* __LOG_TRACE_IO_ */
  65. /**
  66. * @}
  67. */
  68. /** @addtogroup STM32MP1xx_Log_Exported_Macros
  69. * @{
  70. */
  71. #if defined (__LOG_TRACE_IO_) || defined(__LOG_UART_IO_)
  72. #if LOGLEVEL >= LOGDBG
  73. #define log_dbg(fmt, ...) printf("[%05ld.%03ld][DBG ]" fmt, HAL_GetTick()/1000, HAL_GetTick() % 1000, ##__VA_ARGS__)
  74. #else
  75. #define log_dbg(fmt, ...)
  76. #endif
  77. #if LOGLEVEL >= LOGINFO
  78. #define log_info(fmt, ...) printf("[%05ld.%03ld][INFO ]" fmt, HAL_GetTick()/1000, HAL_GetTick() % 1000, ##__VA_ARGS__)
  79. #else
  80. #define log_info(fmt, ...)
  81. #endif
  82. #if LOGLEVEL >= LOGWARN
  83. #define log_warn(fmt, ...) printf("[%05ld.%03ld][WARN ]" fmt, HAL_GetTick()/1000, HAL_GetTick() % 1000, ##__VA_ARGS__)
  84. #else
  85. #define log_warn(fmt, ...)
  86. #endif
  87. #if LOGLEVEL >= LOGERR
  88. #define log_err(fmt, ...) printf("[%05ld.%03ld][ERR ]" fmt, HAL_GetTick()/1000, HAL_GetTick() % 1000, ##__VA_ARGS__)
  89. #else
  90. #define log_err(fmt, ...)
  91. #endif
  92. #else
  93. #define log_dbg(fmt, ...)
  94. #define log_info(fmt, ...)
  95. #define log_warn(fmt, ...)
  96. #define log_err(fmt, ...)
  97. #endif /* __LOG_TRACE_IO_ */
  98. /**
  99. * @}
  100. */
  101. /** @addtogroup STM32MP1xx_Log_Exported_Functions
  102. * @{
  103. */
  104. /**
  105. * @}
  106. */
  107. #ifdef __cplusplus
  108. }
  109. #endif
  110. #endif /*__LOG_STM32MP1XX_H */
  111. /**
  112. * @}
  113. */
  114. /**
  115. * @}
  116. */
  117. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/