![]() |
|
|||
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_EDMA_H_ 0009 #define _FSL_LPUART_EDMA_H_ 0010 0011 #include "fsl_lpuart.h" 0012 #include "fsl_edma.h" 0013 0014 /*! 0015 * @addtogroup lpuart_edma_driver 0016 * @{ 0017 */ 0018 0019 /******************************************************************************* 0020 * Definitions 0021 ******************************************************************************/ 0022 0023 /*! @name Driver version */ 0024 /*@{*/ 0025 /*! @brief LPUART EDMA driver version. */ 0026 #define FSL_LPUART_EDMA_DRIVER_VERSION (MAKE_VERSION(2, 6, 0)) 0027 /*@}*/ 0028 0029 /* Forward declaration of the handle typedef. */ 0030 typedef struct _lpuart_edma_handle lpuart_edma_handle_t; 0031 0032 /*! @brief LPUART transfer callback function. */ 0033 typedef void (*lpuart_edma_transfer_callback_t)(LPUART_Type *base, 0034 lpuart_edma_handle_t *handle, 0035 status_t status, 0036 void *userData); 0037 0038 /*! 0039 * @brief LPUART eDMA handle 0040 */ 0041 struct _lpuart_edma_handle 0042 { 0043 lpuart_edma_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 edma_handle_t *txEdmaHandle; /*!< The eDMA TX channel used. */ 0049 edma_handle_t *rxEdmaHandle; /*!< The eDMA RX channel used. */ 0050 0051 uint8_t nbytes; /*!< eDMA minor byte transfer count initially configured. */ 0052 0053 volatile uint8_t txState; /*!< TX transfer state. */ 0054 volatile uint8_t rxState; /*!< RX transfer state */ 0055 }; 0056 0057 /******************************************************************************* 0058 * API 0059 ******************************************************************************/ 0060 0061 #if defined(__cplusplus) 0062 extern "C" { 0063 #endif 0064 0065 /*! 0066 * @name eDMA transactional 0067 * @{ 0068 */ 0069 0070 /*! 0071 * @brief Initializes the LPUART handle which is used in transactional functions. 0072 * 0073 * @note This function disables all LPUART interrupts. 0074 * 0075 * @param base LPUART peripheral base address. 0076 * @param handle Pointer to lpuart_edma_handle_t structure. 0077 * @param callback Callback function. 0078 * @param userData User data. 0079 * @param txEdmaHandle User requested DMA handle for TX DMA transfer. 0080 * @param rxEdmaHandle User requested DMA handle for RX DMA transfer. 0081 */ 0082 void LPUART_TransferCreateHandleEDMA(LPUART_Type *base, 0083 lpuart_edma_handle_t *handle, 0084 lpuart_edma_transfer_callback_t callback, 0085 void *userData, 0086 edma_handle_t *txEdmaHandle, 0087 edma_handle_t *rxEdmaHandle); 0088 0089 /*! 0090 * @brief Sends data using eDMA. 0091 * 0092 * This function sends data using eDMA. This is a non-blocking function, which returns 0093 * right away. When all data is sent, the send callback function is called. 0094 * 0095 * @param base LPUART peripheral base address. 0096 * @param handle LPUART handle pointer. 0097 * @param xfer LPUART eDMA transfer structure. See #lpuart_transfer_t. 0098 * @retval kStatus_Success if succeed, others failed. 0099 * @retval kStatus_LPUART_TxBusy Previous transfer on going. 0100 * @retval kStatus_InvalidArgument Invalid argument. 0101 */ 0102 status_t LPUART_SendEDMA(LPUART_Type *base, lpuart_edma_handle_t *handle, lpuart_transfer_t *xfer); 0103 0104 /*! 0105 * @brief Receives data using eDMA. 0106 * 0107 * This function receives data using eDMA. 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 LPUART peripheral base address. 0111 * @param handle Pointer to lpuart_edma_handle_t structure. 0112 * @param xfer LPUART eDMA transfer structure, see #lpuart_transfer_t. 0113 * @retval kStatus_Success if succeed, others fail. 0114 * @retval kStatus_LPUART_RxBusy Previous transfer ongoing. 0115 * @retval kStatus_InvalidArgument Invalid argument. 0116 */ 0117 status_t LPUART_ReceiveEDMA(LPUART_Type *base, lpuart_edma_handle_t *handle, lpuart_transfer_t *xfer); 0118 0119 /*! 0120 * @brief Aborts the sent data using eDMA. 0121 * 0122 * This function aborts the sent data using eDMA. 0123 * 0124 * @param base LPUART peripheral base address. 0125 * @param handle Pointer to lpuart_edma_handle_t structure. 0126 */ 0127 void LPUART_TransferAbortSendEDMA(LPUART_Type *base, lpuart_edma_handle_t *handle); 0128 0129 /*! 0130 * @brief Aborts the received data using eDMA. 0131 * 0132 * This function aborts the received data using eDMA. 0133 * 0134 * @param base LPUART peripheral base address. 0135 * @param handle Pointer to lpuart_edma_handle_t structure. 0136 */ 0137 void LPUART_TransferAbortReceiveEDMA(LPUART_Type *base, lpuart_edma_handle_t *handle); 0138 0139 /*! 0140 * @brief Gets the number of bytes written to the LPUART TX register. 0141 * 0142 * This function gets the number of bytes written to the LPUART TX 0143 * register by DMA. 0144 * 0145 * @param base LPUART peripheral base address. 0146 * @param handle LPUART handle pointer. 0147 * @param count Send bytes count. 0148 * @retval kStatus_NoTransferInProgress No send in progress. 0149 * @retval kStatus_InvalidArgument Parameter is invalid. 0150 * @retval kStatus_Success Get successfully through the parameter \p count; 0151 */ 0152 status_t LPUART_TransferGetSendCountEDMA(LPUART_Type *base, lpuart_edma_handle_t *handle, uint32_t *count); 0153 0154 /*! 0155 * @brief Gets the number of received bytes. 0156 * 0157 * This function gets the number of received bytes. 0158 * 0159 * @param base LPUART peripheral base address. 0160 * @param handle LPUART handle pointer. 0161 * @param count Receive bytes count. 0162 * @retval kStatus_NoTransferInProgress No receive in progress. 0163 * @retval kStatus_InvalidArgument Parameter is invalid. 0164 * @retval kStatus_Success Get successfully through the parameter \p count; 0165 */ 0166 status_t LPUART_TransferGetReceiveCountEDMA(LPUART_Type *base, lpuart_edma_handle_t *handle, uint32_t *count); 0167 0168 /*! 0169 * @brief LPUART eDMA IRQ handle function. 0170 * 0171 * This function handles the LPUART tx complete IRQ request and invoke user callback. 0172 * It is not set to static so that it can be used in user application. 0173 * @note This function is used as default IRQ handler by double weak mechanism. 0174 * If user's specific IRQ handler is implemented, make sure this function is invoked in the handler. 0175 * 0176 * @param base LPUART peripheral base address. 0177 * @param lpuartEdmaHandle LPUART handle pointer. 0178 */ 0179 void LPUART_TransferEdmaHandleIRQ(LPUART_Type *base, void *lpuartEdmaHandle); 0180 0181 /*@}*/ 0182 0183 #if defined(__cplusplus) 0184 } 0185 #endif 0186 0187 /*! @}*/ 0188 0189 #endif /* _FSL_LPUART_EDMA_H_ */
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
![]() ![]() |