rusEFI
The most advanced open source ECU
Loading...
Searching...
No Matches
fsl_lpuart_edma.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2015, Freescale Semiconductor, Inc.
3 * Copyright 2016-2017 NXP
4 * All rights reserved.
5 *
6 * SPDX-License-Identifier: BSD-3-Clause
7 */
8#ifndef _FSL_LPUART_EDMA_H_
9#define _FSL_LPUART_EDMA_H_
10
11#include "fsl_lpuart.h"
12#include "fsl_edma.h"
13
14/*!
15 * @addtogroup lpuart_edma_driver
16 * @{
17 */
18
19/*******************************************************************************
20 * Definitions
21 ******************************************************************************/
22
23/*! @name Driver version */
24/*@{*/
25/*! @brief LPUART EDMA driver version 2.2.6. */
26#define FSL_LPUART_EDMA_DRIVER_VERSION (MAKE_VERSION(2, 2, 6))
27/*@}*/
28
29/* Forward declaration of the handle typedef. */
31
32/*! @brief LPUART transfer callback function. */
33typedef void (*lpuart_edma_transfer_callback_t)(LPUART_Type *base,
35 status_t status,
36 void *userData);
37
38/*!
39* @brief LPUART eDMA handle
40*/
42{
43 lpuart_edma_transfer_callback_t callback; /*!< Callback function. */
44 void *userData; /*!< LPUART callback function parameter.*/
45 size_t rxDataSizeAll; /*!< Size of the data to receive. */
46 size_t txDataSizeAll; /*!< Size of the data to send out. */
47
48 edma_handle_t *txEdmaHandle; /*!< The eDMA TX channel used. */
49 edma_handle_t *rxEdmaHandle; /*!< The eDMA RX channel used. */
50
51 uint8_t nbytes; /*!< eDMA minor byte transfer count initially configured. */
52
53 volatile uint8_t txState; /*!< TX transfer state. */
54 volatile uint8_t rxState; /*!< RX transfer state */
55};
56
57/*******************************************************************************
58 * API
59 ******************************************************************************/
60
61#if defined(__cplusplus)
62extern "C" {
63#endif
64
65/*!
66 * @name eDMA transactional
67 * @{
68 */
69
70/*!
71 * @brief Initializes the LPUART handle which is used in transactional functions.
72 * @param base LPUART peripheral base address.
73 * @param handle Pointer to lpuart_edma_handle_t structure.
74 * @param callback Callback function.
75 * @param userData User data.
76 * @param txEdmaHandle User requested DMA handle for TX DMA transfer.
77 * @param rxEdmaHandle User requested DMA handle for RX DMA transfer.
78 */
79void LPUART_TransferCreateHandleEDMA(LPUART_Type *base,
82 void *userData,
83 edma_handle_t *txEdmaHandle,
84 edma_handle_t *rxEdmaHandle);
85
86/*!
87 * @brief Sends data using eDMA.
88 *
89 * This function sends data using eDMA. This is a non-blocking function, which returns
90 * right away. When all data is sent, the send callback function is called.
91 *
92 * @param base LPUART peripheral base address.
93 * @param handle LPUART handle pointer.
94 * @param xfer LPUART eDMA transfer structure. See #lpuart_transfer_t.
95 * @retval kStatus_Success if succeed, others failed.
96 * @retval kStatus_LPUART_TxBusy Previous transfer on going.
97 * @retval kStatus_InvalidArgument Invalid argument.
98 */
99status_t LPUART_SendEDMA(LPUART_Type *base, lpuart_edma_handle_t *handle, lpuart_transfer_t *xfer);
100
101/*!
102 * @brief Receives data using eDMA.
103 *
104 * This function receives data using eDMA. This is non-blocking function, which returns
105 * right away. When all data is received, the receive callback function is called.
106 *
107 * @param base LPUART peripheral base address.
108 * @param handle Pointer to lpuart_edma_handle_t structure.
109 * @param xfer LPUART eDMA transfer structure, see #lpuart_transfer_t.
110 * @retval kStatus_Success if succeed, others fail.
111 * @retval kStatus_LPUART_RxBusy Previous transfer ongoing.
112 * @retval kStatus_InvalidArgument Invalid argument.
113 */
114status_t LPUART_ReceiveEDMA(LPUART_Type *base, lpuart_edma_handle_t *handle, lpuart_transfer_t *xfer);
115
116/*!
117 * @brief Aborts the sent data using eDMA.
118 *
119 * This function aborts the sent data using eDMA.
120 *
121 * @param base LPUART peripheral base address.
122 * @param handle Pointer to lpuart_edma_handle_t structure.
123 */
124void LPUART_TransferAbortSendEDMA(LPUART_Type *base, lpuart_edma_handle_t *handle);
125
126/*!
127 * @brief Aborts the received data using eDMA.
128 *
129 * This function aborts the received data using eDMA.
130 *
131 * @param base LPUART peripheral base address.
132 * @param handle Pointer to lpuart_edma_handle_t structure.
133 */
134void LPUART_TransferAbortReceiveEDMA(LPUART_Type *base, lpuart_edma_handle_t *handle);
135
136/*!
137 * @brief Gets the number of bytes written to the LPUART TX register.
138 *
139 * This function gets the number of bytes written to the LPUART TX
140 * register by DMA.
141 *
142 * @param base LPUART peripheral base address.
143 * @param handle LPUART handle pointer.
144 * @param count Send bytes count.
145 * @retval kStatus_NoTransferInProgress No send in progress.
146 * @retval kStatus_InvalidArgument Parameter is invalid.
147 * @retval kStatus_Success Get successfully through the parameter \p count;
148 */
149status_t LPUART_TransferGetSendCountEDMA(LPUART_Type *base, lpuart_edma_handle_t *handle, uint32_t *count);
150
151/*!
152 * @brief Gets the number of received bytes.
153 *
154 * This function gets the number of received bytes.
155 *
156 * @param base LPUART peripheral base address.
157 * @param handle LPUART handle pointer.
158 * @param count Receive bytes count.
159 * @retval kStatus_NoTransferInProgress No receive in progress.
160 * @retval kStatus_InvalidArgument Parameter is invalid.
161 * @retval kStatus_Success Get successfully through the parameter \p count;
162 */
163status_t LPUART_TransferGetReceiveCountEDMA(LPUART_Type *base, lpuart_edma_handle_t *handle, uint32_t *count);
164
165/*@}*/
166
167#if defined(__cplusplus)
168}
169#endif
170
171/*! @}*/
172
173#endif /* _FSL_LPUART_EDMA_H_ */
int32_t status_t
Type used for all status and error return values.
Definition fsl_common.h:169
status_t LPUART_TransferGetSendCountEDMA(LPUART_Type *base, lpuart_edma_handle_t *handle, uint32_t *count)
Gets the number of bytes written to the LPUART TX register.
status_t LPUART_SendEDMA(LPUART_Type *base, lpuart_edma_handle_t *handle, lpuart_transfer_t *xfer)
Sends data using eDMA.
lpuart_edma_transfer_callback_t callback
status_t LPUART_TransferGetReceiveCountEDMA(LPUART_Type *base, lpuart_edma_handle_t *handle, uint32_t *count)
Gets the number of received bytes.
void LPUART_TransferAbortSendEDMA(LPUART_Type *base, lpuart_edma_handle_t *handle)
Aborts the sent data using eDMA.
void LPUART_TransferCreateHandleEDMA(LPUART_Type *base, lpuart_edma_handle_t *handle, lpuart_edma_transfer_callback_t callback, void *userData, edma_handle_t *txEdmaHandle, edma_handle_t *rxEdmaHandle)
Initializes the LPUART handle which is used in transactional functions.
void(* lpuart_edma_transfer_callback_t)(LPUART_Type *base, lpuart_edma_handle_t *handle, status_t status, void *userData)
LPUART transfer callback function.
status_t LPUART_ReceiveEDMA(LPUART_Type *base, lpuart_edma_handle_t *handle, lpuart_transfer_t *xfer)
Receives data using eDMA.
volatile uint8_t rxState
edma_handle_t * rxEdmaHandle
edma_handle_t * txEdmaHandle
volatile uint8_t txState
void LPUART_TransferAbortReceiveEDMA(LPUART_Type *base, lpuart_edma_handle_t *handle)
Aborts the received data using eDMA.
eDMA transfer handle structure
Definition fsl_edma.h:246
LPUART eDMA handle.
LPUART transfer structure.
Definition fsl_lpuart.h:216
uint16_t count
Definition tunerstudio.h:1