app_trace.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. #ifndef __DEBUG_H_
  2. #define __DEBUG_H_
  3. #include <stdint.h>
  4. #include <stdio.h>
  5. /**
  6. * @defgroup app_trace Debug Logger
  7. * @ingroup app_common
  8. * @{
  9. * @brief Enables debug logs/ trace over UART.
  10. * @details Enables debug logs/ trace over UART. Tracing is enabled only if
  11. * ENABLE_DEBUG_LOG_SUPPORT is defined in the project.
  12. */
  13. #ifdef ENABLE_DEBUG_LOG_SUPPORT
  14. #include "nrf_log.h"
  15. /**
  16. * @brief Module Initialization.
  17. *
  18. * @details Initializes the module to use UART as trace output.
  19. *
  20. * @warning This function will configure UART using default board configuration.
  21. * Do not call this function if UART is configured from a higher level in the application.
  22. */
  23. void app_trace_init(void);
  24. /**
  25. * @brief Log debug messages.
  26. *
  27. * @details This API logs messages over UART. The module must be initialized before using this API.
  28. *
  29. * @note Though this is currently a macro, it should be used used and treated as function.
  30. */
  31. #define app_trace_log NRF_LOG_PRINTF
  32. /**
  33. * @brief Dump auxiliary byte buffer to the debug trace.
  34. *
  35. * @details This API logs messages over UART. The module must be initialized before using this API.
  36. *
  37. * @param[in] p_buffer Buffer to be dumped on the debug trace.
  38. * @param[in] len Size of the buffer.
  39. */
  40. void app_trace_dump(uint8_t * p_buffer, uint32_t len);
  41. #else // ENABLE_DEBUG_LOG_SUPPORT
  42. #define app_trace_init(...)
  43. #define app_trace_log(...)
  44. #define app_trace_dump(...)
  45. #endif // ENABLE_DEBUG_LOG_SUPPORT
  46. /** @} */
  47. #endif //__DEBUG_H_