fsl_log.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. /*
  2. * The Clear BSD License
  3. * Copyright 2017 NXP
  4. * All rights reserved.
  5. *
  6. *
  7. * Redistribution and use in source and binary forms, with or without modification,
  8. * are permitted (subject to the limitations in the disclaimer below) provided
  9. * that the following conditions are met:
  10. *
  11. * o Redistributions of source code must retain the above copyright notice, this list
  12. * of conditions and the following disclaimer.
  13. *
  14. * o Redistributions in binary form must reproduce the above copyright notice, this
  15. * list of conditions and the following disclaimer in the documentation and/or
  16. * other materials provided with the distribution.
  17. *
  18. * o Neither the name of Freescale Semiconductor, Inc. nor the names of its
  19. * contributors may be used to endorse or promote products derived from this
  20. * software without specific prior written permission.
  21. *
  22. * NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY THIS LICENSE.
  23. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
  24. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  25. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  26. * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
  27. * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  28. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  29. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
  30. * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  31. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  32. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  33. *
  34. */
  35. #ifndef _FSL_LOG_H
  36. #define _FSL_LOG_H
  37. #include "fsl_common.h"
  38. /*!
  39. * @addtogroup debugconsole
  40. * @{
  41. */
  42. /*******************************************************************************
  43. * Definitions
  44. ******************************************************************************/
  45. /*************************************************************************************************
  46. * Prototypes
  47. ************************************************************************************************/
  48. #if defined(__cplusplus)
  49. extern "C" {
  50. #endif /* __cplusplus */
  51. /*!
  52. * @brief Initializes
  53. *
  54. * Call this function to init the buffer
  55. * @param baseAddr, device base address
  56. * @param device, device type
  57. * @param baudRate, device communicate baudrate
  58. * @param clkSrcFreq, device source clock freq
  59. *
  60. * @return Indicates whether initialization was successful or not.
  61. * @retval kStatus_Success Execution successfully
  62. * @retval kStatus_Fail Execution failure
  63. */
  64. status_t LOG_Init(uint32_t baseAddr, uint8_t device, uint32_t baudRate, uint32_t clkSrcFreq);
  65. /*!
  66. * @brief De-Initializes
  67. *
  68. * Call this function to deinit the buffer
  69. *
  70. * @return Indicates whether Deinit was successful or not.
  71. */
  72. void LOG_Deinit(void);
  73. /*!
  74. * @brief log push interface
  75. *
  76. * Call this function to print log
  77. * @param fmt, buffer pointer
  78. * @param size, avaliable size
  79. * @return indicate the push size
  80. * @retval-1 indicate buffer is full or transfer fail.
  81. * @retval size return the push log size.
  82. */
  83. int LOG_Push(uint8_t *buf, size_t size);
  84. /*!
  85. * @brief log read one line function
  86. *
  87. * Call this function to print log
  88. * @param fmt, buffer pointer
  89. * @param size, avaliable size
  90. * @reutrn the number of the recieved character
  91. */
  92. int LOG_ReadLine(uint8_t *buf, size_t size);
  93. /*!
  94. * @brief log read one character function
  95. *
  96. * Call this function to GETCHAR
  97. * @param ch receive address
  98. * @reutrn the number of the recieved character
  99. */
  100. int LOG_ReadCharacter(uint8_t *ch);
  101. /*!
  102. * @brief wait log and io idle
  103. *
  104. * Call this function to wait log buffer empty and io idle before enter low power mode.
  105. * @return Indicates whether wait idle was successful or not.
  106. */
  107. status_t LOG_WaitIdle(void);
  108. #ifdef DEBUG_CONSOLE_TRANSFER_NON_BLOCKING
  109. /*!
  110. * @brief log try read one character
  111. * Call this function to check character avaliable or not, if not return fail, otherwise return it.
  112. * @param ch the address of char to receive
  113. * @return Indicates try getchar was successful or not.
  114. */
  115. status_t LOG_TryReadCharacter(uint8_t *ch);
  116. #endif
  117. /*!
  118. * @brief log pop function
  119. *
  120. * Call this function to pop log from buffer.
  121. * @param buf buffer address to pop
  122. * @param size log size to pop
  123. * @return pop log size.
  124. */
  125. int LOG_Pop(uint8_t *buf, size_t size);
  126. #if defined(__cplusplus)
  127. }
  128. #endif /* __cplusplus */
  129. /*! @} */
  130. #endif