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_UART_DMA_H_
0009 #define _FSL_FLEXIO_UART_DMA_H_
0010 
0011 #include "fsl_flexio_uart.h"
0012 #include "fsl_dma.h"
0013 
0014 /*!
0015  * @addtogroup flexio_dma_uart
0016  * @{
0017  */
0018 
0019 /*******************************************************************************
0020  * Definitions
0021  ******************************************************************************/
0022 
0023 /*! @name Driver version */
0024 /*@{*/
0025 /*! @brief FlexIO UART DMA driver version. */
0026 #define FSL_FLEXIO_UART_DMA_DRIVER_VERSION (MAKE_VERSION(2, 4, 0))
0027 /*@}*/
0028 
0029 /* Forward declaration of the handle typedef. */
0030 typedef struct _flexio_uart_dma_handle flexio_uart_dma_handle_t;
0031 
0032 /*! @brief UART transfer callback function. */
0033 typedef void (*flexio_uart_dma_transfer_callback_t)(FLEXIO_UART_Type *base,
0034                                                     flexio_uart_dma_handle_t *handle,
0035                                                     status_t status,
0036                                                     void *userData);
0037 
0038 /*!
0039  * @brief UART DMA handle
0040  */
0041 struct _flexio_uart_dma_handle
0042 {
0043     flexio_uart_dma_transfer_callback_t callback; /*!< Callback function. */
0044     void *userData;                               /*!< UART callback function parameter.*/
0045 
0046     size_t txDataSizeAll; /*!< Total bytes to be sent. */
0047     size_t rxDataSizeAll; /*!< Total bytes to be received. */
0048 
0049     dma_handle_t *txDmaHandle; /*!< The DMA TX channel used. */
0050     dma_handle_t *rxDmaHandle; /*!< The DMA RX channel used. */
0051 
0052     volatile uint8_t txState; /*!< TX transfer state. */
0053     volatile uint8_t rxState; /*!< RX transfer state */
0054 };
0055 
0056 /*******************************************************************************
0057  * API
0058  ******************************************************************************/
0059 
0060 #if defined(__cplusplus)
0061 extern "C" {
0062 #endif
0063 
0064 /*!
0065  * @name eDMA transactional
0066  * @{
0067  */
0068 
0069 /*!
0070  * @brief Initializes the FLEXIO_UART handle which is used in transactional functions.
0071  *
0072  * @param base Pointer to FLEXIO_UART_Type structure.
0073  * @param handle Pointer to flexio_uart_dma_handle_t structure.
0074  * @param callback FlexIO UART callback, NULL means no callback.
0075  * @param userData User callback function data.
0076  * @param txDmaHandle User requested DMA handle for TX DMA transfer.
0077  * @param rxDmaHandle User requested DMA handle for RX DMA transfer.
0078  * @retval kStatus_Success Successfully create the handle.
0079  * @retval kStatus_OutOfRange The FlexIO UART DMA type/handle table out of range.
0080  */
0081 status_t FLEXIO_UART_TransferCreateHandleDMA(FLEXIO_UART_Type *base,
0082                                              flexio_uart_dma_handle_t *handle,
0083                                              flexio_uart_dma_transfer_callback_t callback,
0084                                              void *userData,
0085                                              dma_handle_t *txDmaHandle,
0086                                              dma_handle_t *rxDmaHandle);
0087 
0088 /*!
0089  * @brief Sends data using DMA.
0090  *
0091  * This function send data using DMA. This is non-blocking function, which returns
0092  * right away. When all data is sent out, the send callback function is called.
0093  *
0094  * @param base Pointer to FLEXIO_UART_Type structure
0095  * @param handle Pointer to flexio_uart_dma_handle_t structure
0096  * @param xfer FLEXIO_UART DMA transfer structure, see #flexio_uart_transfer_t.
0097  * @retval kStatus_Success if succeed, others failed.
0098  * @retval kStatus_FLEXIO_UART_TxBusy Previous transfer on going.
0099  */
0100 status_t FLEXIO_UART_TransferSendDMA(FLEXIO_UART_Type *base,
0101                                      flexio_uart_dma_handle_t *handle,
0102                                      flexio_uart_transfer_t *xfer);
0103 
0104 /*!
0105  * @brief Receives data using DMA.
0106  *
0107  * This function receives data using DMA. This is non-blocking function, which returns
0108  * right away. When all data is received, the receive callback function is called.
0109  *
0110  * @param base Pointer to FLEXIO_UART_Type structure
0111  * @param handle Pointer to flexio_uart_dma_handle_t structure
0112  * @param xfer FLEXIO_UART DMA transfer structure, see #flexio_uart_transfer_t.
0113  * @retval kStatus_Success if succeed, others failed.
0114  * @retval kStatus_FLEXIO_UART_RxBusy Previous transfer on going.
0115  */
0116 status_t FLEXIO_UART_TransferReceiveDMA(FLEXIO_UART_Type *base,
0117                                         flexio_uart_dma_handle_t *handle,
0118                                         flexio_uart_transfer_t *xfer);
0119 
0120 /*!
0121  * @brief Aborts the sent data which using DMA.
0122  *
0123  * This function aborts the sent data which using DMA.
0124  *
0125  * @param base Pointer to FLEXIO_UART_Type structure
0126  * @param handle Pointer to flexio_uart_dma_handle_t structure
0127  */
0128 void FLEXIO_UART_TransferAbortSendDMA(FLEXIO_UART_Type *base, flexio_uart_dma_handle_t *handle);
0129 
0130 /*!
0131  * @brief Aborts the receive data which using DMA.
0132  *
0133  * This function aborts the receive data which using DMA.
0134  *
0135  * @param base Pointer to FLEXIO_UART_Type structure
0136  * @param handle Pointer to flexio_uart_dma_handle_t structure
0137  */
0138 void FLEXIO_UART_TransferAbortReceiveDMA(FLEXIO_UART_Type *base, flexio_uart_dma_handle_t *handle);
0139 
0140 /*!
0141  * @brief Gets the number of bytes sent out.
0142  *
0143  * This function gets the number of bytes sent out.
0144  *
0145  * @param base Pointer to FLEXIO_UART_Type structure
0146  * @param handle Pointer to flexio_uart_dma_handle_t structure
0147  * @param count Number of bytes sent so far by the non-blocking transaction.
0148  * @retval kStatus_NoTransferInProgress transfer has finished or no transfer in progress.
0149  * @retval kStatus_Success Successfully return the count.
0150  */
0151 status_t FLEXIO_UART_TransferGetSendCountDMA(FLEXIO_UART_Type *base, flexio_uart_dma_handle_t *handle, size_t *count);
0152 
0153 /*!
0154  * @brief Gets the number of bytes received.
0155  *
0156  * This function gets the number of bytes received.
0157  *
0158  * @param base Pointer to FLEXIO_UART_Type structure
0159  * @param handle Pointer to flexio_uart_dma_handle_t structure
0160  * @param count Number of bytes received so far by the non-blocking transaction.
0161  * @retval kStatus_NoTransferInProgress transfer has finished or no transfer in progress.
0162  * @retval kStatus_Success Successfully return the count.
0163  */
0164 status_t FLEXIO_UART_TransferGetReceiveCountDMA(FLEXIO_UART_Type *base,
0165                                                 flexio_uart_dma_handle_t *handle,
0166                                                 size_t *count);
0167 
0168 /*@}*/
0169 
0170 #if defined(__cplusplus)
0171 }
0172 #endif
0173 
0174 /*! @}*/
0175 
0176 #endif /* _FSL_UART_DMA_H_ */