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