fsl_flexio_mculcd_edma.h 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. /*
  2. * Copyright (c) 2016, Freescale Semiconductor, Inc.
  3. * Copyright 2016-2020 NXP
  4. * All rights reserved.
  5. *
  6. * SPDX-License-Identifier: BSD-3-Clause
  7. */
  8. #ifndef _FSL_FLEXIO_MCULCD_EDMA_H_
  9. #define _FSL_FLEXIO_MCULCD_EDMA_H_
  10. #include "fsl_edma.h"
  11. #include "fsl_flexio_mculcd.h"
  12. /*!
  13. * @addtogroup flexio_edma_mculcd
  14. * @{
  15. */
  16. /*******************************************************************************
  17. * Definitions
  18. ******************************************************************************/
  19. /*@{*/
  20. /*! @brief FlexIO MCULCD EDMA driver version. */
  21. #define FSL_FLEXIO_MCULCD_EDMA_DRIVER_VERSION (MAKE_VERSION(2, 0, 4))
  22. /*@}*/
  23. /*! @brief typedef for flexio_mculcd_edma_handle_t in advance. */
  24. typedef struct _flexio_mculcd_edma_handle flexio_mculcd_edma_handle_t;
  25. /*! @brief FlexIO MCULCD master callback for transfer complete.
  26. *
  27. * When transfer finished, the callback function is called and returns the
  28. * @p status as kStatus_FLEXIO_MCULCD_Idle.
  29. */
  30. typedef void (*flexio_mculcd_edma_transfer_callback_t)(FLEXIO_MCULCD_Type *base,
  31. flexio_mculcd_edma_handle_t *handle,
  32. status_t status,
  33. void *userData);
  34. /*! @brief FlexIO MCULCD eDMA transfer handle, users should not touch the
  35. * content of the handle.*/
  36. struct _flexio_mculcd_edma_handle
  37. {
  38. FLEXIO_MCULCD_Type *base; /*!< Pointer to the FLEXIO_MCULCD_Type. */
  39. uint8_t txShifterNum; /*!< Number of shifters used for TX. */
  40. uint8_t rxShifterNum; /*!< Number of shifters used for RX. */
  41. uint32_t minorLoopBytes; /*!< eDMA transfer minor loop bytes. */
  42. edma_modulo_t txEdmaModulo; /*!< Modulo value for the FlexIO shifter buffer access. */
  43. edma_modulo_t rxEdmaModulo; /*!< Modulo value for the FlexIO shifter buffer access. */
  44. uint32_t dataAddrOrSameValue; /*!< When sending the same value for many times,
  45. this is the value to send. When writing or
  46. reading array, this is the address of the
  47. data array. */
  48. size_t dataCount; /*!< Total count to be transferred. */
  49. volatile size_t remainingCount; /*!< Remaining count still not transfered. */
  50. volatile uint32_t state; /*!< FlexIO MCULCD driver internal state. */
  51. edma_handle_t *txDmaHandle; /*!< DMA handle for MCULCD TX */
  52. edma_handle_t *rxDmaHandle; /*!< DMA handle for MCULCD RX */
  53. flexio_mculcd_edma_transfer_callback_t completionCallback; /*!< Callback for MCULCD DMA transfer */
  54. void *userData; /*!< User Data for MCULCD DMA callback */
  55. };
  56. /*******************************************************************************
  57. * APIs
  58. ******************************************************************************/
  59. #if defined(__cplusplus)
  60. extern "C" {
  61. #endif
  62. /*!
  63. * @name eDMA Transactional
  64. * @{
  65. */
  66. /*!
  67. * @brief Initializes the FLEXO MCULCD master eDMA handle.
  68. *
  69. * This function initializes the FLEXO MCULCD master eDMA handle which can be
  70. * used for other FLEXO MCULCD transactional APIs. For a specified FLEXO MCULCD
  71. * instance, call this API once to get the initialized handle.
  72. *
  73. * @param base Pointer to FLEXIO_MCULCD_Type structure.
  74. * @param handle Pointer to flexio_mculcd_edma_handle_t structure to store the
  75. * transfer state.
  76. * @param callback MCULCD transfer complete callback, NULL means no callback.
  77. * @param userData callback function parameter.
  78. * @param txDmaHandle User requested eDMA handle for FlexIO MCULCD eDMA TX,
  79. * the DMA request source of this handle should be the first of TX shifters.
  80. * @param rxDmaHandle User requested eDMA handle for FlexIO MCULCD eDMA RX,
  81. * the DMA request source of this handle should be the last of RX shifters.
  82. * @retval kStatus_Success Successfully create the handle.
  83. */
  84. status_t FLEXIO_MCULCD_TransferCreateHandleEDMA(FLEXIO_MCULCD_Type *base,
  85. flexio_mculcd_edma_handle_t *handle,
  86. flexio_mculcd_edma_transfer_callback_t callback,
  87. void *userData,
  88. edma_handle_t *txDmaHandle,
  89. edma_handle_t *rxDmaHandle);
  90. /*!
  91. * @brief Performs a non-blocking FlexIO MCULCD transfer using eDMA.
  92. *
  93. * This function returns immediately after transfer initiates. To check whether
  94. * the transfer is completed, user could:
  95. * 1. Use the transfer completed callback;
  96. * 2. Polling function FLEXIO_MCULCD_GetTransferCountEDMA
  97. *
  98. * @param base pointer to FLEXIO_MCULCD_Type structure.
  99. * @param handle pointer to flexio_mculcd_edma_handle_t structure to store the
  100. * transfer state.
  101. * @param xfer Pointer to FlexIO MCULCD transfer structure.
  102. * @retval kStatus_Success Successfully start a transfer.
  103. * @retval kStatus_InvalidArgument Input argument is invalid.
  104. * @retval kStatus_FLEXIO_MCULCD_Busy FlexIO MCULCD is not idle, it is running another
  105. * transfer.
  106. */
  107. status_t FLEXIO_MCULCD_TransferEDMA(FLEXIO_MCULCD_Type *base,
  108. flexio_mculcd_edma_handle_t *handle,
  109. flexio_mculcd_transfer_t *xfer);
  110. /*!
  111. * @brief Aborts a FlexIO MCULCD transfer using eDMA.
  112. *
  113. * @param base pointer to FLEXIO_MCULCD_Type structure.
  114. * @param handle FlexIO MCULCD eDMA handle pointer.
  115. */
  116. void FLEXIO_MCULCD_TransferAbortEDMA(FLEXIO_MCULCD_Type *base, flexio_mculcd_edma_handle_t *handle);
  117. /*!
  118. * @brief Gets the remaining bytes for FlexIO MCULCD eDMA transfer.
  119. *
  120. * @param base pointer to FLEXIO_MCULCD_Type structure.
  121. * @param handle FlexIO MCULCD eDMA handle pointer.
  122. * @param count Number of count transferred so far by the eDMA transaction.
  123. * @retval kStatus_Success Get the transferred count Successfully.
  124. * @retval kStatus_NoTransferInProgress No transfer in process.
  125. */
  126. status_t FLEXIO_MCULCD_TransferGetCountEDMA(FLEXIO_MCULCD_Type *base,
  127. flexio_mculcd_edma_handle_t *handle,
  128. size_t *count);
  129. /*! @} */
  130. #if defined(__cplusplus)
  131. }
  132. #endif
  133. /*!
  134. * @}
  135. */
  136. #endif /* _FSL_FLEXIO_MCULCD_EDMA_H_ */