Arrow / Mbed OS DAPLink Reset
Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers fsl_uart_edma.h Source File

fsl_uart_edma.h

00001 /*
00002  * Copyright (c) 2015, Freescale Semiconductor, Inc.
00003  * Copyright 2016-2017 NXP
00004  * All rights reserved.
00005  *
00006  * SPDX-License-Identifier: BSD-3-Clause
00007  */
00008 #ifndef _FSL_UART_EDMA_H_
00009 #define _FSL_UART_EDMA_H_
00010 
00011 #include "fsl_uart.h"
00012 #include "fsl_edma.h"
00013 
00014 /*!
00015  * @addtogroup uart_edma_driver
00016  * @{
00017  */
00018 
00019 /*******************************************************************************
00020  * Definitions
00021  ******************************************************************************/
00022 
00023 /*! @name Driver version */
00024 /*@{*/
00025 /*! @brief UART EDMA driver version 2.1.6. */
00026 #define FSL_UART_EDMA_DRIVER_VERSION (MAKE_VERSION(2, 1, 6))
00027 /*@}*/
00028 
00029 /* Forward declaration of the handle typedef. */
00030 typedef struct _uart_edma_handle uart_edma_handle_t;
00031 
00032 /*! @brief UART transfer callback function. */
00033 typedef void (*uart_edma_transfer_callback_t)(UART_Type *base,
00034                                               uart_edma_handle_t *handle,
00035                                               status_t status,
00036                                               void *userData );
00037 
00038 /*!
00039 * @brief UART eDMA handle
00040 */
00041 struct _uart_edma_handle
00042 {
00043     uart_edma_transfer_callback_t callback ; /*!< Callback function. */
00044     void *userData ;                         /*!< UART callback function parameter.*/
00045     size_t rxDataSizeAll ;                   /*!< Size of the data to receive. */
00046     size_t txDataSizeAll ;                   /*!< Size of the data to send out. */
00047 
00048     edma_handle_t *txEdmaHandle ; /*!< The eDMA TX channel used. */
00049     edma_handle_t *rxEdmaHandle ; /*!< The eDMA RX channel used. */
00050 
00051     uint8_t nbytes ; /*!< eDMA minor byte transfer count initially configured. */
00052 
00053     volatile uint8_t txState ; /*!< TX transfer state. */
00054     volatile uint8_t rxState ; /*!< RX transfer state */
00055 };
00056 
00057 /*******************************************************************************
00058  * API
00059  ******************************************************************************/
00060 
00061 #if defined(__cplusplus)
00062 extern "C" {
00063 #endif
00064 
00065 /*!
00066  * @name eDMA transactional
00067  * @{
00068  */
00069 
00070 /*!
00071  * @brief Initializes the UART handle which is used in transactional functions.
00072  * @param base UART peripheral base address.
00073  * @param handle Pointer to the uart_edma_handle_t structure.
00074  * @param callback UART callback, NULL means no callback.
00075  * @param userData User callback function data.
00076  * @param rxEdmaHandle User-requested DMA handle for RX DMA transfer.
00077  * @param txEdmaHandle User-requested DMA handle for TX DMA transfer.
00078  */
00079 void UART_TransferCreateHandleEDMA(UART_Type *base,
00080                                    uart_edma_handle_t *handle,
00081                                    uart_edma_transfer_callback_t callback,
00082                                    void *userData,
00083                                    edma_handle_t *txEdmaHandle,
00084                                    edma_handle_t *rxEdmaHandle);
00085 
00086 /*!
00087  * @brief Sends data using eDMA.
00088  *
00089  * This function sends data using eDMA. This is a non-blocking function, which returns
00090  * right away. When all data is sent, the send callback function is called.
00091  *
00092  * @param base UART peripheral base address.
00093  * @param handle UART handle pointer.
00094  * @param xfer UART eDMA transfer structure. See #uart_transfer_t.
00095  * @retval kStatus_Success if succeeded; otherwise failed.
00096  * @retval kStatus_UART_TxBusy Previous transfer ongoing.
00097  * @retval kStatus_InvalidArgument Invalid argument.
00098  */
00099 status_t UART_SendEDMA(UART_Type *base, uart_edma_handle_t *handle, uart_transfer_t *xfer);
00100 
00101 /*!
00102  * @brief Receives data using eDMA.
00103  *
00104  * This function receives data using eDMA. This is a non-blocking function, which returns
00105  * right away. When all data is received, the receive callback function is called.
00106  *
00107  * @param base UART peripheral base address.
00108  * @param handle Pointer to the uart_edma_handle_t structure.
00109  * @param xfer UART eDMA transfer structure. See #uart_transfer_t.
00110  * @retval kStatus_Success if succeeded; otherwise failed.
00111  * @retval kStatus_UART_RxBusy Previous transfer ongoing.
00112  * @retval kStatus_InvalidArgument Invalid argument.
00113  */
00114 status_t UART_ReceiveEDMA(UART_Type *base, uart_edma_handle_t *handle, uart_transfer_t *xfer);
00115 
00116 /*!
00117  * @brief Aborts the sent data using eDMA.
00118  *
00119  * This function aborts sent data using eDMA.
00120  *
00121  * @param base UART peripheral base address.
00122  * @param handle Pointer to the uart_edma_handle_t structure.
00123  */
00124 void UART_TransferAbortSendEDMA(UART_Type *base, uart_edma_handle_t *handle);
00125 
00126 /*!
00127  * @brief Aborts the receive data using eDMA.
00128  *
00129  * This function aborts receive data using eDMA.
00130  *
00131  * @param base UART peripheral base address.
00132  * @param handle Pointer to the uart_edma_handle_t structure.
00133  */
00134 void UART_TransferAbortReceiveEDMA(UART_Type *base, uart_edma_handle_t *handle);
00135 
00136 /*!
00137  * @brief Gets the number of bytes that have been written to UART TX register.
00138  *
00139  * This function gets the number of bytes that have been written to UART TX
00140  * register by DMA.
00141  *
00142  * @param base UART peripheral base address.
00143  * @param handle UART handle pointer.
00144  * @param count Send bytes count.
00145  * @retval kStatus_NoTransferInProgress No send in progress.
00146  * @retval kStatus_InvalidArgument Parameter is invalid.
00147  * @retval kStatus_Success Get successfully through the parameter \p count;
00148  */
00149 status_t UART_TransferGetSendCountEDMA(UART_Type *base, uart_edma_handle_t *handle, uint32_t *count);
00150 
00151 /*!
00152  * @brief Gets the number of received bytes.
00153  *
00154  * This function gets the number of received bytes.
00155  *
00156  * @param base UART peripheral base address.
00157  * @param handle UART handle pointer.
00158  * @param count Receive bytes count.
00159  * @retval kStatus_NoTransferInProgress No receive in progress.
00160  * @retval kStatus_InvalidArgument Parameter is invalid.
00161  * @retval kStatus_Success Get successfully through the parameter \p count;
00162  */
00163 status_t UART_TransferGetReceiveCountEDMA(UART_Type *base, uart_edma_handle_t *handle, uint32_t *count);
00164 
00165 /*@}*/
00166 
00167 #if defined(__cplusplus)
00168 }
00169 #endif
00170 
00171 /*! @}*/
00172 
00173 #endif /* _FSL_UART_EDMA_H_ */