選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。
 
 
 

174 行
5.8 KiB

  1. /*
  2. * Copyright (c) 2015, Freescale Semiconductor, Inc.
  3. * Copyright 2016-2020 NXP
  4. * All rights reserved.
  5. *
  6. * SPDX-License-Identifier: BSD-3-Clause
  7. */
  8. #ifndef _FSL_UART_EDMA_H_
  9. #define _FSL_UART_EDMA_H_
  10. #include "fsl_uart.h"
  11. #include "fsl_edma.h"
  12. /*!
  13. * @addtogroup uart_edma_driver
  14. * @{
  15. */
  16. /*******************************************************************************
  17. * Definitions
  18. ******************************************************************************/
  19. /*! @name Driver version */
  20. /*@{*/
  21. /*! @brief UART EDMA driver version 2.3.0. */
  22. #define FSL_UART_EDMA_DRIVER_VERSION (MAKE_VERSION(2, 3, 0))
  23. /*@}*/
  24. /* Forward declaration of the handle typedef. */
  25. typedef struct _uart_edma_handle uart_edma_handle_t;
  26. /*! @brief UART transfer callback function. */
  27. typedef void (*uart_edma_transfer_callback_t)(UART_Type *base,
  28. uart_edma_handle_t *handle,
  29. status_t status,
  30. void *userData);
  31. /*!
  32. * @brief UART eDMA handle
  33. */
  34. struct _uart_edma_handle
  35. {
  36. uart_edma_transfer_callback_t callback; /*!< Callback function. */
  37. void *userData; /*!< UART callback function parameter.*/
  38. size_t rxDataSizeAll; /*!< Size of the data to receive. */
  39. size_t txDataSizeAll; /*!< Size of the data to send out. */
  40. edma_handle_t *txEdmaHandle; /*!< The eDMA TX channel used. */
  41. edma_handle_t *rxEdmaHandle; /*!< The eDMA RX channel used. */
  42. uint8_t nbytes; /*!< eDMA minor byte transfer count initially configured. */
  43. volatile uint8_t txState; /*!< TX transfer state. */
  44. volatile uint8_t rxState; /*!< RX transfer state */
  45. };
  46. /*******************************************************************************
  47. * API
  48. ******************************************************************************/
  49. #if defined(__cplusplus)
  50. extern "C" {
  51. #endif
  52. /*!
  53. * @name eDMA transactional
  54. * @{
  55. */
  56. /*!
  57. * @brief Initializes the UART handle which is used in transactional functions.
  58. * @param base UART peripheral base address.
  59. * @param handle Pointer to the uart_edma_handle_t structure.
  60. * @param callback UART callback, NULL means no callback.
  61. * @param userData User callback function data.
  62. * @param rxEdmaHandle User-requested DMA handle for RX DMA transfer.
  63. * @param txEdmaHandle User-requested DMA handle for TX DMA transfer.
  64. */
  65. void UART_TransferCreateHandleEDMA(UART_Type *base,
  66. uart_edma_handle_t *handle,
  67. uart_edma_transfer_callback_t callback,
  68. void *userData,
  69. edma_handle_t *txEdmaHandle,
  70. edma_handle_t *rxEdmaHandle);
  71. /*!
  72. * @brief Sends data using eDMA.
  73. *
  74. * This function sends data using eDMA. This is a non-blocking function, which returns
  75. * right away. When all data is sent, the send callback function is called.
  76. *
  77. * @param base UART peripheral base address.
  78. * @param handle UART handle pointer.
  79. * @param xfer UART eDMA transfer structure. See #uart_transfer_t.
  80. * @retval kStatus_Success if succeeded; otherwise failed.
  81. * @retval kStatus_UART_TxBusy Previous transfer ongoing.
  82. * @retval kStatus_InvalidArgument Invalid argument.
  83. */
  84. status_t UART_SendEDMA(UART_Type *base, uart_edma_handle_t *handle, uart_transfer_t *xfer);
  85. /*!
  86. * @brief Receives data using eDMA.
  87. *
  88. * This function receives data using eDMA. This is a non-blocking function, which returns
  89. * right away. When all data is received, the receive callback function is called.
  90. *
  91. * @param base UART peripheral base address.
  92. * @param handle Pointer to the uart_edma_handle_t structure.
  93. * @param xfer UART eDMA transfer structure. See #uart_transfer_t.
  94. * @retval kStatus_Success if succeeded; otherwise failed.
  95. * @retval kStatus_UART_RxBusy Previous transfer ongoing.
  96. * @retval kStatus_InvalidArgument Invalid argument.
  97. */
  98. status_t UART_ReceiveEDMA(UART_Type *base, uart_edma_handle_t *handle, uart_transfer_t *xfer);
  99. /*!
  100. * @brief Aborts the sent data using eDMA.
  101. *
  102. * This function aborts sent data using eDMA.
  103. *
  104. * @param base UART peripheral base address.
  105. * @param handle Pointer to the uart_edma_handle_t structure.
  106. */
  107. void UART_TransferAbortSendEDMA(UART_Type *base, uart_edma_handle_t *handle);
  108. /*!
  109. * @brief Aborts the receive data using eDMA.
  110. *
  111. * This function aborts receive data using eDMA.
  112. *
  113. * @param base UART peripheral base address.
  114. * @param handle Pointer to the uart_edma_handle_t structure.
  115. */
  116. void UART_TransferAbortReceiveEDMA(UART_Type *base, uart_edma_handle_t *handle);
  117. /*!
  118. * @brief Gets the number of bytes that have been written to UART TX register.
  119. *
  120. * This function gets the number of bytes that have been written to UART TX
  121. * register by DMA.
  122. *
  123. * @param base UART peripheral base address.
  124. * @param handle UART handle pointer.
  125. * @param count Send bytes count.
  126. * @retval kStatus_NoTransferInProgress No send in progress.
  127. * @retval kStatus_InvalidArgument Parameter is invalid.
  128. * @retval kStatus_Success Get successfully through the parameter \p count;
  129. */
  130. status_t UART_TransferGetSendCountEDMA(UART_Type *base, uart_edma_handle_t *handle, uint32_t *count);
  131. /*!
  132. * @brief Gets the number of received bytes.
  133. *
  134. * This function gets the number of received bytes.
  135. *
  136. * @param base UART peripheral base address.
  137. * @param handle UART handle pointer.
  138. * @param count Receive bytes count.
  139. * @retval kStatus_NoTransferInProgress No receive in progress.
  140. * @retval kStatus_InvalidArgument Parameter is invalid.
  141. * @retval kStatus_Success Get successfully through the parameter \p count;
  142. */
  143. status_t UART_TransferGetReceiveCountEDMA(UART_Type *base, uart_edma_handle_t *handle, uint32_t *count);
  144. /*@}*/
  145. #if defined(__cplusplus)
  146. }
  147. #endif
  148. /*! @}*/
  149. #endif /* _FSL_UART_EDMA_H_ */