![]() |
|
|||
File indexing completed on 2025-05-11 08:23:00
0001 /* 0002 * Copyright (c) 2015, Freescale Semiconductor, Inc. 0003 * Copyright 2016-2022 NXP 0004 * All rights reserved. 0005 * 0006 * SPDX-License-Identifier: BSD-3-Clause 0007 */ 0008 #ifndef _FSL_LPUART_DMA_H_ 0009 #define _FSL_LPUART_DMA_H_ 0010 0011 #include "fsl_lpuart.h" 0012 #include "fsl_dma.h" 0013 0014 /*! 0015 * @addtogroup lpuart_dma_driver 0016 * @{ 0017 */ 0018 0019 /******************************************************************************* 0020 * Definitions 0021 ******************************************************************************/ 0022 0023 /*! @name Driver version */ 0024 /*@{*/ 0025 /*! @brief LPUART DMA driver version. */ 0026 #define FSL_LPUART_DMA_DRIVER_VERSION (MAKE_VERSION(2, 6, 0)) 0027 /*@}*/ 0028 0029 /* Forward declaration of the handle typedef. */ 0030 typedef struct _lpuart_dma_handle lpuart_dma_handle_t; 0031 0032 /*! @brief LPUART transfer callback function. */ 0033 typedef void (*lpuart_dma_transfer_callback_t)(LPUART_Type *base, 0034 lpuart_dma_handle_t *handle, 0035 status_t status, 0036 void *userData); 0037 0038 /*! 0039 * @brief LPUART DMA handle 0040 */ 0041 struct _lpuart_dma_handle 0042 { 0043 lpuart_dma_transfer_callback_t callback; /*!< Callback function. */ 0044 void *userData; /*!< LPUART callback function parameter.*/ 0045 size_t rxDataSizeAll; /*!< Size of the data to receive. */ 0046 size_t txDataSizeAll; /*!< Size of the data to send out. */ 0047 0048 dma_handle_t *txDmaHandle; /*!< The DMA TX channel used. */ 0049 dma_handle_t *rxDmaHandle; /*!< The DMA RX channel used. */ 0050 0051 volatile uint8_t txState; /*!< TX transfer state. */ 0052 volatile uint8_t rxState; /*!< RX transfer state */ 0053 }; 0054 0055 /******************************************************************************* 0056 * API 0057 ******************************************************************************/ 0058 0059 #if defined(__cplusplus) 0060 extern "C" { 0061 #endif 0062 0063 /*! 0064 * @name EDMA transactional 0065 * @{ 0066 */ 0067 0068 /*! 0069 * @brief Initializes the LPUART handle which is used in transactional functions. 0070 * 0071 * @note This function disables all LPUART interrupts. 0072 * 0073 * @param base LPUART peripheral base address. 0074 * @param handle Pointer to lpuart_dma_handle_t structure. 0075 * @param callback Callback function. 0076 * @param userData User data. 0077 * @param txDmaHandle User-requested DMA handle for TX DMA transfer. 0078 * @param rxDmaHandle User-requested DMA handle for RX DMA transfer. 0079 */ 0080 void LPUART_TransferCreateHandleDMA(LPUART_Type *base, 0081 lpuart_dma_handle_t *handle, 0082 lpuart_dma_transfer_callback_t callback, 0083 void *userData, 0084 dma_handle_t *txDmaHandle, 0085 dma_handle_t *rxDmaHandle); 0086 0087 /*! 0088 * @brief Sends data using DMA. 0089 * 0090 * This function sends data using DMA. This is a non-blocking function, which returns 0091 * right away. When all data is sent, the send callback function is called. 0092 * 0093 * @param base LPUART peripheral base address. 0094 * @param handle LPUART handle pointer. 0095 * @param xfer LPUART DMA transfer structure. See #lpuart_transfer_t. 0096 * @retval kStatus_Success if succeed, others failed. 0097 * @retval kStatus_LPUART_TxBusy Previous transfer on going. 0098 * @retval kStatus_InvalidArgument Invalid argument. 0099 */ 0100 status_t LPUART_TransferSendDMA(LPUART_Type *base, lpuart_dma_handle_t *handle, lpuart_transfer_t *xfer); 0101 0102 /*! 0103 * @brief Receives data using DMA. 0104 * 0105 * This function receives data using DMA. This is a non-blocking function, which returns 0106 * right away. When all data is received, the receive callback function is called. 0107 * 0108 * @param base LPUART peripheral base address. 0109 * @param handle Pointer to lpuart_dma_handle_t structure. 0110 * @param xfer LPUART DMA transfer structure. See #lpuart_transfer_t. 0111 * @retval kStatus_Success if succeed, others failed. 0112 * @retval kStatus_LPUART_RxBusy Previous transfer on going. 0113 * @retval kStatus_InvalidArgument Invalid argument. 0114 */ 0115 status_t LPUART_TransferReceiveDMA(LPUART_Type *base, lpuart_dma_handle_t *handle, lpuart_transfer_t *xfer); 0116 0117 /*! 0118 * @brief Aborts the sent data using DMA. 0119 * 0120 * This function aborts send data using DMA. 0121 * 0122 * @param base LPUART peripheral base address 0123 * @param handle Pointer to lpuart_dma_handle_t structure 0124 */ 0125 void LPUART_TransferAbortSendDMA(LPUART_Type *base, lpuart_dma_handle_t *handle); 0126 0127 /*! 0128 * @brief Aborts the received data using DMA. 0129 * 0130 * This function aborts the received data using DMA. 0131 * 0132 * @param base LPUART peripheral base address 0133 * @param handle Pointer to lpuart_dma_handle_t structure 0134 */ 0135 void LPUART_TransferAbortReceiveDMA(LPUART_Type *base, lpuart_dma_handle_t *handle); 0136 0137 /*! 0138 * @brief Gets the number of bytes written to the LPUART TX register. 0139 * 0140 * This function gets the number of bytes that have been written to LPUART TX 0141 * register by DMA. 0142 * 0143 * @param base LPUART peripheral base address. 0144 * @param handle LPUART handle pointer. 0145 * @param count Send bytes count. 0146 * @retval kStatus_NoTransferInProgress No send in progress. 0147 * @retval kStatus_InvalidArgument Parameter is invalid. 0148 * @retval kStatus_Success Get successfully through the parameter \p count; 0149 */ 0150 status_t LPUART_TransferGetSendCountDMA(LPUART_Type *base, lpuart_dma_handle_t *handle, uint32_t *count); 0151 0152 /*! 0153 * @brief Gets the number of received bytes. 0154 * 0155 * This function gets the number of received bytes. 0156 * 0157 * @param base LPUART peripheral base address. 0158 * @param handle LPUART handle pointer. 0159 * @param count Receive bytes count. 0160 * @retval kStatus_NoTransferInProgress No receive in progress. 0161 * @retval kStatus_InvalidArgument Parameter is invalid. 0162 * @retval kStatus_Success Get successfully through the parameter \p count; 0163 */ 0164 status_t LPUART_TransferGetReceiveCountDMA(LPUART_Type *base, lpuart_dma_handle_t *handle, uint32_t *count); 0165 0166 /*! 0167 * @brief LPUART DMA IRQ handle function. 0168 * 0169 * This function handles the LPUART tx complete IRQ request and invoke user callback. 0170 * @note This function is used as default IRQ handler by double weak mechanism. 0171 * If user's specific IRQ handler is implemented, make sure this function is invoked in the handler. 0172 * 0173 * @param base LPUART peripheral base address. 0174 * @param lpuartDmaHandle LPUART handle pointer. 0175 */ 0176 void LPUART_TransferDMAHandleIRQ(LPUART_Type *base, void *lpuartDmaHandle); 0177 0178 /*@}*/ 0179 0180 #if defined(__cplusplus) 0181 } 0182 #endif 0183 0184 /*! @}*/ 0185 0186 #endif /* _FSL_LPUART_DMA_H_ */
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
![]() ![]() |