Back to home page

LXR

 
 

    


File indexing completed on 2025-05-11 08:22:59

0001 /*
0002  * Copyright (c) 2015, Freescale Semiconductor, Inc.
0003  * Copyright 2016-2020 NXP
0004  * All rights reserved.
0005  *
0006  * SPDX-License-Identifier: BSD-3-Clause
0007  */
0008 #ifndef _FSL_FLEXIO_CAMERA_EDMA_H_
0009 #define _FSL_FLEXIO_CAMERA_EDMA_H_
0010 
0011 #include "fsl_flexio_camera.h"
0012 #include "fsl_edma.h"
0013 
0014 /*!
0015  * @addtogroup flexio_edma_camera
0016  * @{
0017  */
0018 
0019 /*******************************************************************************
0020  * Definitions
0021  ******************************************************************************/
0022 
0023 /*! @name Driver version */
0024 /*@{*/
0025 /*! @brief FlexIO Camera EDMA driver version 2.1.3. */
0026 #define FSL_FLEXIO_CAMERA_EDMA_DRIVER_VERSION (MAKE_VERSION(2, 1, 3))
0027 /*@}*/
0028 
0029 /*! @brief Forward declaration of the handle typedef. */
0030 typedef struct _flexio_camera_edma_handle flexio_camera_edma_handle_t;
0031 
0032 /*! @brief Camera transfer callback function. */
0033 typedef void (*flexio_camera_edma_transfer_callback_t)(FLEXIO_CAMERA_Type *base,
0034                                                        flexio_camera_edma_handle_t *handle,
0035                                                        status_t status,
0036                                                        void *userData);
0037 
0038 /*!
0039  * @brief Camera eDMA handle
0040  */
0041 struct _flexio_camera_edma_handle
0042 {
0043     flexio_camera_edma_transfer_callback_t callback; /*!< Callback function. */
0044     void *userData;                                  /*!< Camera callback function parameter.*/
0045     size_t rxSize;                                   /*!< Total bytes to be received. */
0046     edma_handle_t *rxEdmaHandle;                     /*!< The eDMA RX channel used. */
0047     uint8_t nbytes;                                  /*!< eDMA minor byte transfer count initially configured. */
0048     volatile uint8_t rxState;                        /*!< RX transfer state */
0049 };
0050 
0051 /*******************************************************************************
0052  * API
0053  ******************************************************************************/
0054 
0055 #if defined(__cplusplus)
0056 extern "C" {
0057 #endif
0058 
0059 /*!
0060  * @name eDMA transactional
0061  * @{
0062  */
0063 
0064 /*!
0065  * @brief Initializes the Camera handle, which is used in transactional functions.
0066  *
0067  * @param base Pointer to the FLEXIO_CAMERA_Type.
0068  * @param handle Pointer to flexio_camera_edma_handle_t structure.
0069  * @param callback The callback function.
0070  * @param userData The parameter of the callback function.
0071  * @param rxEdmaHandle User requested DMA handle for RX DMA transfer.
0072  * @retval kStatus_Success Successfully create the handle.
0073  * @retval kStatus_OutOfRange The FlexIO Camera eDMA type/handle table out of range.
0074  */
0075 status_t FLEXIO_CAMERA_TransferCreateHandleEDMA(FLEXIO_CAMERA_Type *base,
0076                                                 flexio_camera_edma_handle_t *handle,
0077                                                 flexio_camera_edma_transfer_callback_t callback,
0078                                                 void *userData,
0079                                                 edma_handle_t *rxEdmaHandle);
0080 
0081 /*!
0082  * @brief Receives data using eDMA.
0083  *
0084  * This function receives data using eDMA. This is a non-blocking function, which returns
0085  * right away. When all data is received, the receive callback function is called.
0086  *
0087  * @param base Pointer to the FLEXIO_CAMERA_Type.
0088  * @param handle Pointer to the flexio_camera_edma_handle_t structure.
0089  * @param xfer Camera eDMA transfer structure, see #flexio_camera_transfer_t.
0090  * @retval kStatus_Success if succeeded, others failed.
0091  * @retval kStatus_CAMERA_RxBusy Previous transfer on going.
0092  */
0093 status_t FLEXIO_CAMERA_TransferReceiveEDMA(FLEXIO_CAMERA_Type *base,
0094                                            flexio_camera_edma_handle_t *handle,
0095                                            flexio_camera_transfer_t *xfer);
0096 
0097 /*!
0098  * @brief Aborts the receive data which used the eDMA.
0099  *
0100  * This function aborts the receive data which used the eDMA.
0101  *
0102  * @param base Pointer to the FLEXIO_CAMERA_Type.
0103  * @param handle Pointer to the flexio_camera_edma_handle_t structure.
0104  */
0105 void FLEXIO_CAMERA_TransferAbortReceiveEDMA(FLEXIO_CAMERA_Type *base, flexio_camera_edma_handle_t *handle);
0106 
0107 /*!
0108  * @brief Gets the remaining bytes to be received.
0109  *
0110  * This function gets the number of bytes still not received.
0111  *
0112  * @param base Pointer to the FLEXIO_CAMERA_Type.
0113  * @param handle Pointer to the flexio_camera_edma_handle_t structure.
0114  * @param count Number of bytes sent so far by the non-blocking transaction.
0115  * @retval kStatus_Success Succeed get the transfer count.
0116  * @retval kStatus_InvalidArgument The count parameter is invalid.
0117  */
0118 status_t FLEXIO_CAMERA_TransferGetReceiveCountEDMA(FLEXIO_CAMERA_Type *base,
0119                                                    flexio_camera_edma_handle_t *handle,
0120                                                    size_t *count);
0121 
0122 /*@}*/
0123 
0124 #if defined(__cplusplus)
0125 }
0126 #endif
0127 
0128 /*! @}*/
0129 
0130 #endif /* _FSL_CAMERA_EDMA_H_ */