rusEFI
The most advanced open source ECU
Loading...
Searching...
No Matches
Data Structures | Variables
Lpuart_edma_driver

Data Structures

struct  _lpuart_edma_handle
 LPUART eDMA handle. More...
 

Variables

lpuart_edma_transfer_callback_t _lpuart_edma_handle::callback
 
void * _lpuart_edma_handle::userData
 
size_t _lpuart_edma_handle::rxDataSizeAll
 
size_t _lpuart_edma_handle::txDataSizeAll
 
edma_handle_t_lpuart_edma_handle::txEdmaHandle
 
edma_handle_t_lpuart_edma_handle::rxEdmaHandle
 
uint8_t _lpuart_edma_handle::nbytes
 
volatile uint8_t _lpuart_edma_handle::txState
 
volatile uint8_t _lpuart_edma_handle::rxState
 

Driver version

typedef struct _lpuart_edma_handle lpuart_edma_handle_t
 
typedef void(* lpuart_edma_transfer_callback_t) (LPUART_Type *base, lpuart_edma_handle_t *handle, status_t status, void *userData)
 LPUART transfer callback function.
 

eDMA transactional

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.
 
status_t LPUART_SendEDMA (LPUART_Type *base, lpuart_edma_handle_t *handle, lpuart_transfer_t *xfer)
 Sends data using eDMA.
 
status_t LPUART_ReceiveEDMA (LPUART_Type *base, lpuart_edma_handle_t *handle, lpuart_transfer_t *xfer)
 Receives data using eDMA.
 
void LPUART_TransferAbortSendEDMA (LPUART_Type *base, lpuart_edma_handle_t *handle)
 Aborts the sent data using eDMA.
 
void LPUART_TransferAbortReceiveEDMA (LPUART_Type *base, lpuart_edma_handle_t *handle)
 Aborts the received data using eDMA.
 
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_TransferGetReceiveCountEDMA (LPUART_Type *base, lpuart_edma_handle_t *handle, uint32_t *count)
 Gets the number of received bytes.
 

Detailed Description

Typedef Documentation

◆ lpuart_edma_handle_t

Definition at line 30 of file fsl_lpuart_edma.h.

◆ lpuart_edma_transfer_callback_t

typedef void(* lpuart_edma_transfer_callback_t) (LPUART_Type *base, lpuart_edma_handle_t *handle, status_t status, void *userData)

LPUART transfer callback function.

Definition at line 33 of file fsl_lpuart_edma.h.

Function Documentation

◆ LPUART_ReceiveEDMA()

status_t LPUART_ReceiveEDMA ( LPUART_Type *  base,
lpuart_edma_handle_t handle,
lpuart_transfer_t xfer 
)

Receives data using eDMA.

This function receives data using eDMA. This is non-blocking function, which returns right away. When all data is received, the receive callback function is called.

Parameters
baseLPUART peripheral base address.
handlePointer to lpuart_edma_handle_t structure.
xferLPUART eDMA transfer structure, see lpuart_transfer_t.
Return values
kStatus_Successif succeed, others fail.
kStatus_LPUART_RxBusyPrevious transfer ongoing.
kStatus_InvalidArgumentInvalid argument.

brief Receives data using eDMA.

This function receives data using eDMA. This is non-blocking function, which returns right away. When all data is received, the receive callback function is called.

param base LPUART peripheral base address. param handle Pointer to lpuart_edma_handle_t structure. param xfer LPUART eDMA transfer structure, see lpuart_transfer_t. retval kStatus_Success if succeed, others fail. retval kStatus_LPUART_RxBusy Previous transfer ongoing. retval kStatus_InvalidArgument Invalid argument.

Definition at line 287 of file fsl_lpuart_edma.c.

288{
289 assert(handle);
290 assert(handle->rxEdmaHandle);
291 assert(xfer);
292 assert(xfer->data);
293 assert(xfer->dataSize);
294
295 edma_transfer_config_t xferConfig;
296 status_t status;
297
298 /* If previous RX not finished. */
299 if (kLPUART_RxBusy == handle->rxState)
300 {
301 status = kStatus_LPUART_RxBusy;
302 }
303 else
304 {
305 handle->rxState = kLPUART_RxBusy;
306 handle->rxDataSizeAll = xfer->dataSize;
307
308 /* Prepare transfer. */
309 EDMA_PrepareTransfer(&xferConfig, (void *)LPUART_GetDataRegisterAddress(base), sizeof(uint8_t), xfer->data,
310 sizeof(uint8_t), sizeof(uint8_t), xfer->dataSize, kEDMA_PeripheralToMemory);
311
312 /* Store the initially configured eDMA minor byte transfer count into the LPUART handle */
313 handle->nbytes = sizeof(uint8_t);
314
315 /* Submit transfer. */
316 EDMA_SubmitTransfer(handle->rxEdmaHandle, &xferConfig);
318
319 /* Enable LPUART RX EDMA. */
320 LPUART_EnableRxDMA(base, true);
321
322 status = kStatus_Success;
323 }
324
325 return status;
326}
@ kLPUART_RxBusy
status_t EDMA_SubmitTransfer(edma_handle_t *handle, const edma_transfer_config_t *config)
Submits the eDMA transfer request.
Definition fsl_edma.c:956
void EDMA_PrepareTransfer(edma_transfer_config_t *config, void *srcAddr, uint32_t srcWidth, void *destAddr, uint32_t destWidth, uint32_t bytesEachRequest, uint32_t transferBytes, edma_transfer_type_t type)
Prepares the eDMA transfer structure.
Definition fsl_edma.c:861
void EDMA_StartTransfer(edma_handle_t *handle)
eDMA starts transfer.
Definition fsl_edma.c:1103
@ kEDMA_PeripheralToMemory
Definition fsl_edma.h:139
int32_t status_t
Type used for all status and error return values.
Definition fsl_common.h:169
@ kStatus_Success
Definition fsl_common.h:159
static void LPUART_EnableRxDMA(LPUART_Type *base, bool enable)
Enables or disables the LPUART receiver DMA.
Definition fsl_lpuart.h:510
static uint32_t LPUART_GetDataRegisterAddress(LPUART_Type *base)
Gets the LPUART data register address.
Definition fsl_lpuart.h:477
@ kStatus_LPUART_RxBusy
Definition fsl_lpuart.h:32
volatile uint8_t rxState
edma_handle_t * rxEdmaHandle
eDMA transfer configuration
Definition fsl_edma.h:171

Referenced by uart_lld_start_receive().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ LPUART_SendEDMA()

status_t LPUART_SendEDMA ( LPUART_Type *  base,
lpuart_edma_handle_t handle,
lpuart_transfer_t xfer 
)

Sends data using eDMA.

This function sends data using eDMA. This is a non-blocking function, which returns right away. When all data is sent, the send callback function is called.

Parameters
baseLPUART peripheral base address.
handleLPUART handle pointer.
xferLPUART eDMA transfer structure. See lpuart_transfer_t.
Return values
kStatus_Successif succeed, others failed.
kStatus_LPUART_TxBusyPrevious transfer on going.
kStatus_InvalidArgumentInvalid argument.

brief Sends data using eDMA.

This function sends data using eDMA. This is a non-blocking function, which returns right away. When all data is sent, the send callback function is called.

param base LPUART peripheral base address. param handle LPUART handle pointer. param xfer LPUART eDMA transfer structure. See lpuart_transfer_t. retval kStatus_Success if succeed, others failed. retval kStatus_LPUART_TxBusy Previous transfer on going. retval kStatus_InvalidArgument Invalid argument.

Definition at line 233 of file fsl_lpuart_edma.c.

234{
235 assert(handle);
236 assert(handle->txEdmaHandle);
237 assert(xfer);
238 assert(xfer->data);
239 assert(xfer->dataSize);
240
241 edma_transfer_config_t xferConfig;
242 status_t status;
243
244 /* If previous TX not finished. */
245 if (kLPUART_TxBusy == handle->txState)
246 {
247 status = kStatus_LPUART_TxBusy;
248 }
249 else
250 {
251 handle->txState = kLPUART_TxBusy;
252 handle->txDataSizeAll = xfer->dataSize;
253
254 /* Prepare transfer. */
255 EDMA_PrepareTransfer(&xferConfig, xfer->data, sizeof(uint8_t), (void *)LPUART_GetDataRegisterAddress(base),
256 sizeof(uint8_t), sizeof(uint8_t), xfer->dataSize, kEDMA_MemoryToPeripheral);
257
258 /* Store the initially configured eDMA minor byte transfer count into the LPUART handle */
259 handle->nbytes = sizeof(uint8_t);
260
261 /* Submit transfer. */
262 EDMA_SubmitTransfer(handle->txEdmaHandle, &xferConfig);
264
265 /* Enable LPUART TX EDMA. */
266 LPUART_EnableTxDMA(base, true);
267
268 status = kStatus_Success;
269 }
270
271 return status;
272}
@ kLPUART_TxBusy
@ kEDMA_MemoryToPeripheral
Definition fsl_edma.h:140
static void LPUART_EnableTxDMA(LPUART_Type *base, bool enable)
Enables or disables the LPUART transmitter DMA request.
Definition fsl_lpuart.h:490
@ kStatus_LPUART_TxBusy
Definition fsl_lpuart.h:31
edma_handle_t * txEdmaHandle
volatile uint8_t txState

Referenced by uart_lld_start_send().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ LPUART_TransferAbortReceiveEDMA()

void LPUART_TransferAbortReceiveEDMA ( LPUART_Type *  base,
lpuart_edma_handle_t handle 
)

Aborts the received data using eDMA.

This function aborts the received data using eDMA.

Parameters
baseLPUART peripheral base address.
handlePointer to lpuart_edma_handle_t structure.

brief Aborts the received data using eDMA.

This function aborts the received data using eDMA.

param base LPUART peripheral base address. param handle Pointer to lpuart_edma_handle_t structure.

Definition at line 358 of file fsl_lpuart_edma.c.

359{
360 assert(handle);
361 assert(handle->rxEdmaHandle);
362
363 /* Disable LPUART RX EDMA. */
364 LPUART_EnableRxDMA(base, false);
365
366 /* Stop transfer. */
368
369 handle->rxState = kLPUART_RxIdle;
370}
@ kLPUART_RxIdle
void EDMA_AbortTransfer(edma_handle_t *handle)
eDMA aborts transfer.
Definition fsl_edma.c:1164

Referenced by LPUART_ReceiveEDMACallback(), and uart_lld_stop_receive().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ LPUART_TransferAbortSendEDMA()

void LPUART_TransferAbortSendEDMA ( LPUART_Type *  base,
lpuart_edma_handle_t handle 
)

Aborts the sent data using eDMA.

This function aborts the sent data using eDMA.

Parameters
baseLPUART peripheral base address.
handlePointer to lpuart_edma_handle_t structure.

brief Aborts the sent data using eDMA.

This function aborts the sent data using eDMA.

param base LPUART peripheral base address. param handle Pointer to lpuart_edma_handle_t structure.

Definition at line 336 of file fsl_lpuart_edma.c.

337{
338 assert(handle);
339 assert(handle->txEdmaHandle);
340
341 /* Disable LPUART TX EDMA. */
342 LPUART_EnableTxDMA(base, false);
343
344 /* Stop transfer. */
346
347 handle->txState = kLPUART_TxIdle;
348}
@ kLPUART_TxIdle

Referenced by LPUART_SendEDMACallback(), and uart_lld_stop_send().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ LPUART_TransferCreateHandleEDMA()

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.

Parameters
baseLPUART peripheral base address.
handlePointer to lpuart_edma_handle_t structure.
callbackCallback function.
userDataUser data.
txEdmaHandleUser requested DMA handle for TX DMA transfer.
rxEdmaHandleUser requested DMA handle for RX DMA transfer.

brief Initializes the LPUART handle which is used in transactional functions. param base LPUART peripheral base address. param handle Pointer to lpuart_edma_handle_t structure. param callback Callback function. param userData User data. param txEdmaHandle User requested DMA handle for TX DMA transfer. param rxEdmaHandle User requested DMA handle for RX DMA transfer.

Definition at line 167 of file fsl_lpuart_edma.c.

173{
174 assert(handle);
175
176 uint32_t instance = LPUART_GetInstance(base);
177
178 s_edmaPrivateHandle[instance].base = base;
179 s_edmaPrivateHandle[instance].handle = handle;
180
181 memset(handle, 0, sizeof(*handle));
182
183 handle->rxState = kLPUART_RxIdle;
184 handle->txState = kLPUART_TxIdle;
185
186 handle->rxEdmaHandle = rxEdmaHandle;
187 handle->txEdmaHandle = txEdmaHandle;
188
189 handle->callback = callback;
190 handle->userData = userData;
191
192#if defined(FSL_FEATURE_LPUART_HAS_FIFO) && FSL_FEATURE_LPUART_HAS_FIFO
193 /* Note:
194 Take care of the RX FIFO, EDMA request only assert when received bytes
195 equal or more than RX water mark, there is potential issue if RX water
196 mark larger than 1.
197 For example, if RX FIFO water mark is 2, upper layer needs 5 bytes and
198 5 bytes are received. the last byte will be saved in FIFO but not trigger
199 EDMA transfer because the water mark is 2.
200 */
201 if (rxEdmaHandle)
202 {
203 base->WATER &= (~LPUART_WATER_RXWATER_MASK);
204 }
205#endif
206
207 /* Configure TX. */
208 if (txEdmaHandle)
209 {
211 }
212
213 /* Configure RX. */
214 if (rxEdmaHandle)
215 {
217 }
218}
static BenchController instance
static void LPUART_ReceiveEDMACallback(edma_handle_t *handle, void *param, bool transferDone, uint32_t tcds)
LPUART EDMA receive finished callback function.
static lpuart_edma_private_handle_t s_edmaPrivateHandle[LPUART_HANDLE_ARRAY_SIZE]
static void LPUART_SendEDMACallback(edma_handle_t *handle, void *param, bool transferDone, uint32_t tcds)
LPUART EDMA send finished callback function.
void EDMA_SetCallback(edma_handle_t *handle, edma_callback callback, void *userData)
Installs a callback function for the eDMA transfer.
Definition fsl_edma.c:836
uint32_t LPUART_GetInstance(LPUART_Type *base)
Get the LPUART instance from peripheral base address.
Definition fsl_lpuart.c:111
lpuart_edma_transfer_callback_t callback

Referenced by uart_lld_start().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ LPUART_TransferGetReceiveCountEDMA()

status_t LPUART_TransferGetReceiveCountEDMA ( LPUART_Type *  base,
lpuart_edma_handle_t handle,
uint32_t *  count 
)

Gets the number of received bytes.

This function gets the number of received bytes.

Parameters
baseLPUART peripheral base address.
handleLPUART handle pointer.
countReceive bytes count.
Return values
kStatus_NoTransferInProgressNo receive in progress.
kStatus_InvalidArgumentParameter is invalid.
kStatus_SuccessGet successfully through the parameter count;

brief Gets the number of received bytes.

This function gets the number of received bytes.

param base LPUART peripheral base address. param handle LPUART handle pointer. param count Receive bytes count. retval kStatus_NoTransferInProgress No receive in progress. retval kStatus_InvalidArgument Parameter is invalid. retval kStatus_Success Get successfully through the parameter count;

Definition at line 384 of file fsl_lpuart_edma.c.

385{
386 assert(handle);
387 assert(handle->rxEdmaHandle);
388 assert(count);
389
390 if (kLPUART_RxIdle == handle->rxState)
391 {
393 }
394
395 *count = handle->rxDataSizeAll -
396 (uint32_t)handle->nbytes *
398
399 return kStatus_Success;
400}
uint32_t EDMA_GetRemainingMajorLoopCount(DMA_Type *base, uint32_t channel)
Gets the remaining major loop count from the eDMA current channel TCD.
Definition fsl_edma.c:648
DMA_Type * base
Definition fsl_edma.h:249
uint8_t channel
Definition fsl_edma.h:251
@ kStatus_NoTransferInProgress
Definition fsl_common.h:165
uint16_t count
Definition tunerstudio.h:1

Referenced by uart_lld_stop_receive().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ LPUART_TransferGetSendCountEDMA()

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.

This function gets the number of bytes written to the LPUART TX register by DMA.

Parameters
baseLPUART peripheral base address.
handleLPUART handle pointer.
countSend bytes count.
Return values
kStatus_NoTransferInProgressNo send in progress.
kStatus_InvalidArgumentParameter is invalid.
kStatus_SuccessGet successfully through the parameter count;

brief Gets the number of bytes written to the LPUART TX register.

This function gets the number of bytes written to the LPUART TX register by DMA.

param base LPUART peripheral base address. param handle LPUART handle pointer. param count Send bytes count. retval kStatus_NoTransferInProgress No send in progress. retval kStatus_InvalidArgument Parameter is invalid. retval kStatus_Success Get successfully through the parameter count;

Definition at line 415 of file fsl_lpuart_edma.c.

416{
417 assert(handle);
418 assert(handle->txEdmaHandle);
419 assert(count);
420
421 if (kLPUART_TxIdle == handle->txState)
422 {
424 }
425
426 *count = handle->txDataSizeAll -
427 (uint32_t)handle->nbytes *
429
430 return kStatus_Success;
431}
Here is the call graph for this function:

Variable Documentation

◆ callback

lpuart_edma_transfer_callback_t _lpuart_edma_handle::callback

Callback function.

Definition at line 43 of file fsl_lpuart_edma.h.

Referenced by LPUART_TransferCreateHandleEDMA().

◆ nbytes

uint8_t _lpuart_edma_handle::nbytes

eDMA minor byte transfer count initially configured.

Definition at line 51 of file fsl_lpuart_edma.h.

Referenced by LPUART_ReceiveEDMA(), LPUART_SendEDMA(), LPUART_TransferGetReceiveCountEDMA(), and LPUART_TransferGetSendCountEDMA().

◆ rxDataSizeAll

size_t _lpuart_edma_handle::rxDataSizeAll

Size of the data to receive.

Definition at line 45 of file fsl_lpuart_edma.h.

Referenced by LPUART_ReceiveEDMA(), LPUART_TransferGetReceiveCountEDMA(), and uart_lld_stop_receive().

◆ rxEdmaHandle

edma_handle_t* _lpuart_edma_handle::rxEdmaHandle

◆ rxState

volatile uint8_t _lpuart_edma_handle::rxState

◆ txDataSizeAll

size_t _lpuart_edma_handle::txDataSizeAll

Size of the data to send out.

Definition at line 46 of file fsl_lpuart_edma.h.

Referenced by LPUART_SendEDMA(), and LPUART_TransferGetSendCountEDMA().

◆ txEdmaHandle

edma_handle_t* _lpuart_edma_handle::txEdmaHandle

◆ txState

volatile uint8_t _lpuart_edma_handle::txState

◆ userData

void* _lpuart_edma_handle::userData

LPUART callback function parameter.

Definition at line 44 of file fsl_lpuart_edma.h.

Referenced by LPUART_TransferCreateHandleEDMA().