Back to home page

LXR

 
 

    


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

0001 /*
0002  * Copyright (c) 2016, Freescale Semiconductor, Inc.
0003  * Copyright 2016-2020 NXP
0004  * All rights reserved.
0005  *
0006  * SPDX-License-Identifier: BSD-3-Clause
0007  */
0008 
0009 #ifndef _FSL_FLEXIO_MCULCD_EDMA_H_
0010 #define _FSL_FLEXIO_MCULCD_EDMA_H_
0011 
0012 #include "fsl_edma.h"
0013 #include "fsl_flexio_mculcd.h"
0014 
0015 /*!
0016  * @addtogroup flexio_edma_mculcd
0017  * @{
0018  */
0019 
0020 /*******************************************************************************
0021  * Definitions
0022  ******************************************************************************/
0023 
0024 /*@{*/
0025 /*! @brief FlexIO MCULCD EDMA driver version. */
0026 #define FSL_FLEXIO_MCULCD_EDMA_DRIVER_VERSION (MAKE_VERSION(2, 0, 4))
0027 /*@}*/
0028 
0029 /*! @brief  typedef for flexio_mculcd_edma_handle_t in advance. */
0030 typedef struct _flexio_mculcd_edma_handle flexio_mculcd_edma_handle_t;
0031 
0032 /*! @brief FlexIO MCULCD master callback for transfer complete.
0033  *
0034  * When transfer finished, the callback function is called and returns the
0035  * @p status as kStatus_FLEXIO_MCULCD_Idle.
0036  */
0037 typedef void (*flexio_mculcd_edma_transfer_callback_t)(FLEXIO_MCULCD_Type *base,
0038                                                        flexio_mculcd_edma_handle_t *handle,
0039                                                        status_t status,
0040                                                        void *userData);
0041 
0042 /*! @brief FlexIO MCULCD eDMA transfer handle, users should not touch the
0043  * content of the handle.*/
0044 struct _flexio_mculcd_edma_handle
0045 {
0046     FLEXIO_MCULCD_Type *base;       /*!< Pointer to the FLEXIO_MCULCD_Type. */
0047     uint8_t txShifterNum;           /*!< Number of shifters used for TX. */
0048     uint8_t rxShifterNum;           /*!< Number of shifters used for RX. */
0049     uint32_t minorLoopBytes;        /*!< eDMA transfer minor loop bytes. */
0050     edma_modulo_t txEdmaModulo;     /*!< Modulo value for the FlexIO shifter buffer access. */
0051     edma_modulo_t rxEdmaModulo;     /*!< Modulo value for the FlexIO shifter buffer access. */
0052     uint32_t dataAddrOrSameValue;   /*!< When sending the same value for many times,
0053                                          this is the value to send. When writing or
0054                                          reading array, this is the address of the
0055                                          data array. */
0056     size_t dataCount;               /*!< Total count to be transferred. */
0057     volatile size_t remainingCount; /*!< Remaining count still not transfered. */
0058     volatile uint32_t state;        /*!< FlexIO MCULCD driver internal state. */
0059     edma_handle_t *txDmaHandle;     /*!< DMA handle for MCULCD TX */
0060     edma_handle_t *rxDmaHandle;     /*!< DMA handle for MCULCD RX */
0061     flexio_mculcd_edma_transfer_callback_t completionCallback; /*!< Callback for MCULCD DMA transfer */
0062     void *userData;                                            /*!< User Data for MCULCD DMA callback */
0063 };
0064 
0065 /*******************************************************************************
0066  * APIs
0067  ******************************************************************************/
0068 #if defined(__cplusplus)
0069 extern "C" {
0070 #endif
0071 
0072 /*!
0073  * @name eDMA Transactional
0074  * @{
0075  */
0076 
0077 /*!
0078  * @brief Initializes the FLEXO MCULCD master eDMA handle.
0079  *
0080  * This function initializes the FLEXO MCULCD master eDMA handle which can be
0081  * used for other FLEXO MCULCD transactional APIs. For a specified FLEXO MCULCD
0082  * instance, call this API once to get the initialized handle.
0083  *
0084  * @param base Pointer to FLEXIO_MCULCD_Type structure.
0085  * @param handle Pointer to flexio_mculcd_edma_handle_t structure to store the
0086  * transfer state.
0087  * @param callback MCULCD transfer complete callback, NULL means no callback.
0088  * @param userData callback function parameter.
0089  * @param txDmaHandle User requested eDMA handle for FlexIO MCULCD eDMA TX,
0090  * the DMA request source of this handle should be the first of TX shifters.
0091  * @param rxDmaHandle User requested eDMA handle for FlexIO MCULCD eDMA RX,
0092  * the DMA request source of this handle should be the last of RX shifters.
0093  * @retval kStatus_Success Successfully create the handle.
0094  */
0095 status_t FLEXIO_MCULCD_TransferCreateHandleEDMA(FLEXIO_MCULCD_Type *base,
0096                                                 flexio_mculcd_edma_handle_t *handle,
0097                                                 flexio_mculcd_edma_transfer_callback_t callback,
0098                                                 void *userData,
0099                                                 edma_handle_t *txDmaHandle,
0100                                                 edma_handle_t *rxDmaHandle);
0101 
0102 /*!
0103  * @brief Performs a non-blocking FlexIO MCULCD transfer using eDMA.
0104  *
0105  * This function returns immediately after transfer initiates. To check whether
0106  * the transfer is completed, user could:
0107  * 1. Use the transfer completed callback;
0108  * 2. Polling function FLEXIO_MCULCD_GetTransferCountEDMA
0109  *
0110  * @param base pointer to FLEXIO_MCULCD_Type structure.
0111  * @param handle pointer to flexio_mculcd_edma_handle_t structure to store the
0112  * transfer state.
0113  * @param xfer Pointer to FlexIO MCULCD transfer structure.
0114  * @retval kStatus_Success Successfully start a transfer.
0115  * @retval kStatus_InvalidArgument Input argument is invalid.
0116  * @retval kStatus_FLEXIO_MCULCD_Busy FlexIO MCULCD is not idle, it is running another
0117  * transfer.
0118  */
0119 status_t FLEXIO_MCULCD_TransferEDMA(FLEXIO_MCULCD_Type *base,
0120                                     flexio_mculcd_edma_handle_t *handle,
0121                                     flexio_mculcd_transfer_t *xfer);
0122 
0123 /*!
0124  * @brief Aborts a FlexIO MCULCD transfer using eDMA.
0125  *
0126  * @param base pointer to FLEXIO_MCULCD_Type structure.
0127  * @param handle FlexIO MCULCD eDMA handle pointer.
0128  */
0129 void FLEXIO_MCULCD_TransferAbortEDMA(FLEXIO_MCULCD_Type *base, flexio_mculcd_edma_handle_t *handle);
0130 
0131 /*!
0132  * @brief Gets the remaining bytes for FlexIO MCULCD eDMA transfer.
0133  *
0134  * @param base pointer to FLEXIO_MCULCD_Type structure.
0135  * @param handle FlexIO MCULCD eDMA handle pointer.
0136  * @param count Number of count transferred so far by the eDMA transaction.
0137  * @retval kStatus_Success Get the transferred count Successfully.
0138  * @retval kStatus_NoTransferInProgress No transfer in process.
0139  */
0140 status_t FLEXIO_MCULCD_TransferGetCountEDMA(FLEXIO_MCULCD_Type *base,
0141                                             flexio_mculcd_edma_handle_t *handle,
0142                                             size_t *count);
0143 
0144 /*! @} */
0145 
0146 #if defined(__cplusplus)
0147 }
0148 #endif
0149 
0150 /*!
0151  * @}
0152  */
0153 #endif /* _FSL_FLEXIO_MCULCD_EDMA_H_ */