hal_debug_interface.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. /**
  2. * Copyright (c) 2016 - 2020 Nordic Semiconductor ASA and Luxoft Global Operations Gmbh.
  3. *
  4. * All Rights Reserved.
  5. *
  6. * Redistribution and use in source and binary forms, with or without modification,
  7. * are permitted provided that the following conditions are met:
  8. *
  9. *
  10. * 1. Redistributions of source code must retain the above copyright notice, this
  11. * list of conditions and the following disclaimer.
  12. *
  13. * 2. Redistributions in binary form, except as embedded into a Nordic
  14. * Semiconductor ASA integrated circuit in a product or a software update for
  15. * such product, must reproduce the above copyright notice, this list of
  16. * conditions and the following disclaimer in the documentation and/or other
  17. * materials provided with the distribution.
  18. *
  19. * 3. Neither the name of Nordic Semiconductor ASA nor the names of its
  20. * contributors may be used to endorse or promote products derived from this
  21. * software without specific prior written permission.
  22. *
  23. * 4. This software, with or without modification, must only be used with a
  24. * Nordic Semiconductor ASA integrated circuit.
  25. *
  26. * 5. Any software provided in binary form under this license must not be reverse
  27. * engineered, decompiled, modified and/or disassembled.
  28. *
  29. *
  30. * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
  31. * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  32. * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
  33. * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE
  34. * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  35. * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
  36. * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  37. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  38. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  39. * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  40. *
  41. */
  42. #ifndef HAL_DEBUG_INTERFACE_H_INCLUDED
  43. #define HAL_DEBUG_INTERFACE_H_INCLUDED
  44. #if defined(NRF52) || defined(NRF52840_XXAA)
  45. #include "nrf_assert.h"
  46. #endif // NRF52
  47. /**
  48. * @defgroup hal_debug_interface HAL Debug Interface
  49. * @ingroup hal_15_4
  50. * @{
  51. * @brief Module to declare HAL debug interface
  52. */
  53. #ifdef CONFIG_DEBUG
  54. #include <stdint.h>
  55. #define HAL_DEBUG_INTERFACE_INIT() hal_debug_init()
  56. #define HAL_DEBUG_INTERFACE_PUT(c, n) hal_debug_put(c, n)
  57. #define HAL_DEBUG_INTERFACE_PUTC(c) hal_debug_putc(c)
  58. #define HAL_DEBUG_INTERFACE_PUTS(s) hal_debug_puts(s)
  59. /**
  60. * @brief Debug interface initialization
  61. */
  62. void hal_debug_init(void);
  63. /**
  64. * @brief Sends string to the debug interface
  65. *
  66. * @details send debug data using debug interface
  67. *
  68. * @param[in] p_data debug string.
  69. * @param[in] len string length.
  70. */
  71. void hal_debug_put(const void * p_data, uint8_t len);
  72. /**
  73. * @brief Sends char symbol to the debug interface
  74. *
  75. * @details send debug data using debug interface
  76. *
  77. * @param[in] data char symbol.
  78. */
  79. void hal_debug_putc(const char data);
  80. /**
  81. * @brief Sends a null-terminated string to the debug interface
  82. *
  83. * @details send debug data using debug interface
  84. *
  85. * @param[in] p_data null-terminated string.
  86. */
  87. void hal_debug_puts(const char * p_data);
  88. #else
  89. /* If debug is disabled, these macros are just a stub.*/
  90. #define HAL_DEBUG_INTERFACE_INIT()
  91. #define HAL_DEBUG_INTERFACE_PUT(c, n)
  92. #define HAL_DEBUG_INTERFACE_PUTC(c)
  93. #define HAL_DEBUG_INTERFACE_PUTS(s)
  94. #endif // CONFIG_DEBUG
  95. /** @} */
  96. #endif // HAL_DEBUG_INTERFACE_H_INCLUDED