fsl_flexio_camera_edma.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  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_FLEXIO_CAMERA_EDMA_H_
  9. #define _FSL_FLEXIO_CAMERA_EDMA_H_
  10. #include "fsl_flexio_camera.h"
  11. #include "fsl_edma.h"
  12. /*!
  13. * @addtogroup flexio_edma_camera
  14. * @{
  15. */
  16. /*******************************************************************************
  17. * Definitions
  18. ******************************************************************************/
  19. /*! @name Driver version */
  20. /*@{*/
  21. /*! @brief FlexIO Camera EDMA driver version 2.1.3. */
  22. #define FSL_FLEXIO_CAMERA_EDMA_DRIVER_VERSION (MAKE_VERSION(2, 1, 3))
  23. /*@}*/
  24. /*! @brief Forward declaration of the handle typedef. */
  25. typedef struct _flexio_camera_edma_handle flexio_camera_edma_handle_t;
  26. /*! @brief Camera transfer callback function. */
  27. typedef void (*flexio_camera_edma_transfer_callback_t)(FLEXIO_CAMERA_Type *base,
  28. flexio_camera_edma_handle_t *handle,
  29. status_t status,
  30. void *userData);
  31. /*!
  32. * @brief Camera eDMA handle
  33. */
  34. struct _flexio_camera_edma_handle
  35. {
  36. flexio_camera_edma_transfer_callback_t callback; /*!< Callback function. */
  37. void *userData; /*!< Camera callback function parameter.*/
  38. size_t rxSize; /*!< Total bytes to be received. */
  39. edma_handle_t *rxEdmaHandle; /*!< The eDMA RX channel used. */
  40. uint8_t nbytes; /*!< eDMA minor byte transfer count initially configured. */
  41. volatile uint8_t rxState; /*!< RX transfer state */
  42. };
  43. /*******************************************************************************
  44. * API
  45. ******************************************************************************/
  46. #if defined(__cplusplus)
  47. extern "C" {
  48. #endif
  49. /*!
  50. * @name eDMA transactional
  51. * @{
  52. */
  53. /*!
  54. * @brief Initializes the Camera handle, which is used in transactional functions.
  55. *
  56. * @param base Pointer to the FLEXIO_CAMERA_Type.
  57. * @param handle Pointer to flexio_camera_edma_handle_t structure.
  58. * @param callback The callback function.
  59. * @param userData The parameter of the callback function.
  60. * @param rxEdmaHandle User requested DMA handle for RX DMA transfer.
  61. * @retval kStatus_Success Successfully create the handle.
  62. * @retval kStatus_OutOfRange The FlexIO Camera eDMA type/handle table out of range.
  63. */
  64. status_t FLEXIO_CAMERA_TransferCreateHandleEDMA(FLEXIO_CAMERA_Type *base,
  65. flexio_camera_edma_handle_t *handle,
  66. flexio_camera_edma_transfer_callback_t callback,
  67. void *userData,
  68. edma_handle_t *rxEdmaHandle);
  69. /*!
  70. * @brief Receives data using eDMA.
  71. *
  72. * This function receives data using eDMA. This is a non-blocking function, which returns
  73. * right away. When all data is received, the receive callback function is called.
  74. *
  75. * @param base Pointer to the FLEXIO_CAMERA_Type.
  76. * @param handle Pointer to the flexio_camera_edma_handle_t structure.
  77. * @param xfer Camera eDMA transfer structure, see #flexio_camera_transfer_t.
  78. * @retval kStatus_Success if succeeded, others failed.
  79. * @retval kStatus_CAMERA_RxBusy Previous transfer on going.
  80. */
  81. status_t FLEXIO_CAMERA_TransferReceiveEDMA(FLEXIO_CAMERA_Type *base,
  82. flexio_camera_edma_handle_t *handle,
  83. flexio_camera_transfer_t *xfer);
  84. /*!
  85. * @brief Aborts the receive data which used the eDMA.
  86. *
  87. * This function aborts the receive data which used the eDMA.
  88. *
  89. * @param base Pointer to the FLEXIO_CAMERA_Type.
  90. * @param handle Pointer to the flexio_camera_edma_handle_t structure.
  91. */
  92. void FLEXIO_CAMERA_TransferAbortReceiveEDMA(FLEXIO_CAMERA_Type *base, flexio_camera_edma_handle_t *handle);
  93. /*!
  94. * @brief Gets the remaining bytes to be received.
  95. *
  96. * This function gets the number of bytes still not received.
  97. *
  98. * @param base Pointer to the FLEXIO_CAMERA_Type.
  99. * @param handle Pointer to the flexio_camera_edma_handle_t structure.
  100. * @param count Number of bytes sent so far by the non-blocking transaction.
  101. * @retval kStatus_Success Succeed get the transfer count.
  102. * @retval kStatus_InvalidArgument The count parameter is invalid.
  103. */
  104. status_t FLEXIO_CAMERA_TransferGetReceiveCountEDMA(FLEXIO_CAMERA_Type *base,
  105. flexio_camera_edma_handle_t *handle,
  106. size_t *count);
  107. /*@}*/
  108. #if defined(__cplusplus)
  109. }
  110. #endif
  111. /*! @}*/
  112. #endif /* _FSL_CAMERA_EDMA_H_ */