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

Data Structures

struct  _lpspi_master_edma_handle
 LPSPI master eDMA transfer handle structure used for transactional API. More...
 
struct  _lpspi_slave_edma_handle
 LPSPI slave eDMA transfer handle structure used for transactional API. More...
 

Variables

volatile bool _lpspi_master_edma_handle::isPcsContinuous
 
volatile bool _lpspi_master_edma_handle::isByteSwap
 
volatile uint8_t _lpspi_master_edma_handle::fifoSize
 
volatile uint8_t _lpspi_master_edma_handle::rxWatermark
 
volatile uint8_t _lpspi_master_edma_handle::bytesEachWrite
 
volatile uint8_t _lpspi_master_edma_handle::bytesEachRead
 
volatile uint8_t _lpspi_master_edma_handle::bytesLastRead
 
volatile uint8_t _lpspi_master_edma_handle::isThereExtraRxBytes
 
uint8_t *volatile _lpspi_master_edma_handle::txData
 
uint8_t *volatile _lpspi_master_edma_handle::rxData
 
volatile size_t _lpspi_master_edma_handle::txRemainingByteCount
 
volatile size_t _lpspi_master_edma_handle::rxRemainingByteCount
 
volatile uint32_t _lpspi_master_edma_handle::writeRegRemainingTimes
 
volatile uint32_t _lpspi_master_edma_handle::readRegRemainingTimes
 
uint32_t _lpspi_master_edma_handle::totalByteCount
 
uint32_t _lpspi_master_edma_handle::txBuffIfNull
 
uint32_t _lpspi_master_edma_handle::rxBuffIfNull
 
uint32_t _lpspi_master_edma_handle::transmitCommand
 
volatile uint8_t _lpspi_master_edma_handle::state
 
uint8_t _lpspi_master_edma_handle::nbytes
 
lpspi_master_edma_transfer_callback_t _lpspi_master_edma_handle::callback
 
void * _lpspi_master_edma_handle::userData
 
edma_handle_t_lpspi_master_edma_handle::edmaRxRegToRxDataHandle
 
edma_handle_t_lpspi_master_edma_handle::edmaTxDataToTxRegHandle
 
edma_tcd_t _lpspi_master_edma_handle::lpspiSoftwareTCD [3]
 
volatile bool _lpspi_slave_edma_handle::isByteSwap
 
volatile uint8_t _lpspi_slave_edma_handle::fifoSize
 
volatile uint8_t _lpspi_slave_edma_handle::rxWatermark
 
volatile uint8_t _lpspi_slave_edma_handle::bytesEachWrite
 
volatile uint8_t _lpspi_slave_edma_handle::bytesEachRead
 
volatile uint8_t _lpspi_slave_edma_handle::bytesLastRead
 
volatile uint8_t _lpspi_slave_edma_handle::isThereExtraRxBytes
 
uint8_t _lpspi_slave_edma_handle::nbytes
 
uint8_t *volatile _lpspi_slave_edma_handle::txData
 
uint8_t *volatile _lpspi_slave_edma_handle::rxData
 
volatile size_t _lpspi_slave_edma_handle::txRemainingByteCount
 
volatile size_t _lpspi_slave_edma_handle::rxRemainingByteCount
 
volatile uint32_t _lpspi_slave_edma_handle::writeRegRemainingTimes
 
volatile uint32_t _lpspi_slave_edma_handle::readRegRemainingTimes
 
uint32_t _lpspi_slave_edma_handle::totalByteCount
 
uint32_t _lpspi_slave_edma_handle::txBuffIfNull
 
uint32_t _lpspi_slave_edma_handle::rxBuffIfNull
 
volatile uint8_t _lpspi_slave_edma_handle::state
 
uint32_t _lpspi_slave_edma_handle::errorCount
 
lpspi_slave_edma_transfer_callback_t _lpspi_slave_edma_handle::callback
 
void * _lpspi_slave_edma_handle::userData
 
edma_handle_t_lpspi_slave_edma_handle::edmaRxRegToRxDataHandle
 
edma_handle_t_lpspi_slave_edma_handle::edmaTxDataToTxRegHandle
 
edma_tcd_t _lpspi_slave_edma_handle::lpspiSoftwareTCD [2]
 

Driver version

typedef struct _lpspi_master_edma_handle lpspi_master_edma_handle_t
 Forward declaration of the _lpspi_master_edma_handle typedefs.
 
typedef struct _lpspi_slave_edma_handle lpspi_slave_edma_handle_t
 Forward declaration of the _lpspi_slave_edma_handle typedefs.
 
typedef void(* lpspi_master_edma_transfer_callback_t) (LPSPI_Type *base, lpspi_master_edma_handle_t *handle, status_t status, void *userData)
 Completion callback function pointer type.
 
typedef void(* lpspi_slave_edma_transfer_callback_t) (LPSPI_Type *base, lpspi_slave_edma_handle_t *handle, status_t status, void *userData)
 Completion callback function pointer type.
 
void LPSPI_MasterTransferCreateHandleEDMA (LPSPI_Type *base, lpspi_master_edma_handle_t *handle, lpspi_master_edma_transfer_callback_t callback, void *userData, edma_handle_t *edmaRxRegToRxDataHandle, edma_handle_t *edmaTxDataToTxRegHandle)
 Initializes the LPSPI master eDMA handle.
 
status_t LPSPI_MasterTransferEDMA (LPSPI_Type *base, lpspi_master_edma_handle_t *handle, lpspi_transfer_t *transfer)
 LPSPI master transfer data using eDMA.
 
void LPSPI_MasterTransferAbortEDMA (LPSPI_Type *base, lpspi_master_edma_handle_t *handle)
 LPSPI master aborts a transfer which is using eDMA.
 
status_t LPSPI_MasterTransferGetCountEDMA (LPSPI_Type *base, lpspi_master_edma_handle_t *handle, size_t *count)
 Gets the master eDMA transfer remaining bytes.
 
void LPSPI_SlaveTransferCreateHandleEDMA (LPSPI_Type *base, lpspi_slave_edma_handle_t *handle, lpspi_slave_edma_transfer_callback_t callback, void *userData, edma_handle_t *edmaRxRegToRxDataHandle, edma_handle_t *edmaTxDataToTxRegHandle)
 Initializes the LPSPI slave eDMA handle.
 
status_t LPSPI_SlaveTransferEDMA (LPSPI_Type *base, lpspi_slave_edma_handle_t *handle, lpspi_transfer_t *transfer)
 LPSPI slave transfers data using eDMA.
 
void LPSPI_SlaveTransferAbortEDMA (LPSPI_Type *base, lpspi_slave_edma_handle_t *handle)
 LPSPI slave aborts a transfer which is using eDMA.
 
status_t LPSPI_SlaveTransferGetCountEDMA (LPSPI_Type *base, lpspi_slave_edma_handle_t *handle, size_t *count)
 Gets the slave eDMA transfer remaining bytes.
 

Detailed Description

Typedef Documentation

◆ lpspi_master_edma_handle_t

Forward declaration of the _lpspi_master_edma_handle typedefs.

Definition at line 31 of file fsl_lpspi_edma.h.

◆ lpspi_master_edma_transfer_callback_t

typedef void(* lpspi_master_edma_transfer_callback_t) (LPSPI_Type *base, lpspi_master_edma_handle_t *handle, status_t status, void *userData)

Completion callback function pointer type.

Parameters
baseLPSPI peripheral base address.
handlePointer to the handle for the LPSPI master.
statusSuccess or error code describing whether the transfer completed.
userDataArbitrary pointer-dataSized value passed from the application.

Definition at line 46 of file fsl_lpspi_edma.h.

◆ lpspi_slave_edma_handle_t

Forward declaration of the _lpspi_slave_edma_handle typedefs.

Definition at line 36 of file fsl_lpspi_edma.h.

◆ lpspi_slave_edma_transfer_callback_t

typedef void(* lpspi_slave_edma_transfer_callback_t) (LPSPI_Type *base, lpspi_slave_edma_handle_t *handle, status_t status, void *userData)

Completion callback function pointer type.

Parameters
baseLPSPI peripheral base address.
handlePointer to the handle for the LPSPI slave.
statusSuccess or error code describing whether the transfer completed.
userDataArbitrary pointer-dataSized value passed from the application.

Definition at line 58 of file fsl_lpspi_edma.h.

Function Documentation

◆ LPSPI_MasterTransferAbortEDMA()

void LPSPI_MasterTransferAbortEDMA ( LPSPI_Type *  base,
lpspi_master_edma_handle_t handle 
)

LPSPI master aborts a transfer which is using eDMA.

This function aborts a transfer which is using eDMA.

Parameters
baseLPSPI peripheral base address.
handlepointer to lpspi_master_edma_handle_t structure which stores the transfer state.

brief LPSPI master aborts a transfer which is using eDMA.

This function aborts a transfer which is using eDMA.

param base LPSPI peripheral base address. param handle pointer to lpspi_master_edma_handle_t structure which stores the transfer state.

Definition at line 631 of file fsl_lpspi_edma.c.

632{
633 assert(handle);
634
636
639
640 handle->state = kLPSPI_Idle;
641}
void EDMA_AbortTransfer(edma_handle_t *handle)
eDMA aborts transfer.
Definition fsl_edma.c:1164
static void LPSPI_DisableDMA(LPSPI_Type *base, uint32_t mask)
Disables the LPSPI DMA request.
Definition fsl_lpspi.h:658
@ kLPSPI_Idle
Definition fsl_lpspi.h:249
@ kLPSPI_TxDmaEnable
Definition fsl_lpspi.h:81
@ kLPSPI_RxDmaEnable
Definition fsl_lpspi.h:82
edma_handle_t * edmaTxDataToTxRegHandle
edma_handle_t * edmaRxRegToRxDataHandle
Here is the call graph for this function:

◆ LPSPI_MasterTransferCreateHandleEDMA()

void LPSPI_MasterTransferCreateHandleEDMA ( LPSPI_Type *  base,
lpspi_master_edma_handle_t handle,
lpspi_master_edma_transfer_callback_t  callback,
void *  userData,
edma_handle_t edmaRxRegToRxDataHandle,
edma_handle_t edmaTxDataToTxRegHandle 
)

Initializes the LPSPI master eDMA handle.

This function initializes the LPSPI eDMA handle which can be used for other LPSPI transactional APIs. Usually, for a specified LPSPI instance, call this API once to get the initialized handle.

Note that the LPSPI eDMA has a separated (Rx and Rx as two sources) or shared (Rx and Tx are the same source) DMA request source. (1) For a separated DMA request source, enable and set the Rx DMAMUX source for edmaRxRegToRxDataHandle and Tx DMAMUX source for edmaIntermediaryToTxRegHandle. (2) For a shared DMA request source, enable and set the Rx/Rx DMAMUX source for edmaRxRegToRxDataHandle.

Parameters
baseLPSPI peripheral base address.
handleLPSPI handle pointer to lpspi_master_edma_handle_t.
callbackLPSPI callback.
userDatacallback function parameter.
edmaRxRegToRxDataHandleedmaRxRegToRxDataHandle pointer to edma_handle_t.
edmaTxDataToTxRegHandleedmaTxDataToTxRegHandle pointer to edma_handle_t.

brief Initializes the LPSPI master eDMA handle.

This function initializes the LPSPI eDMA handle which can be used for other LPSPI transactional APIs. Usually, for a specified LPSPI instance, call this API once to get the initialized handle.

Note that the LPSPI eDMA has a separated (Rx and Rx as two sources) or shared (Rx and Tx are the same source) DMA request source. (1) For a separated DMA request source, enable and set the Rx DMAMUX source for edmaRxRegToRxDataHandle and Tx DMAMUX source for edmaIntermediaryToTxRegHandle. (2) For a shared DMA request source, enable and set the Rx/Rx DMAMUX source for edmaRxRegToRxDataHandle.

param base LPSPI peripheral base address. param handle LPSPI handle pointer to lpspi_master_edma_handle_t. param callback LPSPI callback. param userData callback function parameter. param edmaRxRegToRxDataHandle edmaRxRegToRxDataHandle pointer to edma_handle_t. param edmaTxDataToTxRegHandle edmaTxDataToTxRegHandle pointer to edma_handle_t.

Definition at line 177 of file fsl_lpspi_edma.c.

183{
184 assert(handle);
185 assert(edmaRxRegToRxDataHandle);
186 assert(edmaTxDataToTxRegHandle);
187
188 /* Zero the handle. */
189 memset(handle, 0, sizeof(*handle));
190
191 uint32_t instance = LPSPI_GetInstance(base);
192
195
196 handle->callback = callback;
197 handle->userData = userData;
198
199 handle->edmaRxRegToRxDataHandle = edmaRxRegToRxDataHandle;
200 handle->edmaTxDataToTxRegHandle = edmaTxDataToTxRegHandle;
201}
static BenchController instance
static uint32_t LPSPI_GetInstance(LPSPI_Type *base)
Get instance number for LPSPI module.
static lpspi_master_edma_private_handle_t s_lpspiMasterEdmaPrivateHandle[ARRAY_SIZE(s_lpspiBases)]
Pointers to lpspi edma handles for each instance.
lpspi_master_edma_transfer_callback_t callback
Here is the call graph for this function:

◆ LPSPI_MasterTransferEDMA()

status_t LPSPI_MasterTransferEDMA ( LPSPI_Type *  base,
lpspi_master_edma_handle_t handle,
lpspi_transfer_t transfer 
)

LPSPI master transfer data using eDMA.

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

Note: The transfer data size should be an integer multiple of bytesPerFrame if bytesPerFrame is less than or equal to 4. For bytesPerFrame greater than 4: The transfer data size should be equal to bytesPerFrame if the bytesPerFrame is not an integer multiple of 4. Otherwise, the transfer data size can be an integer multiple of bytesPerFrame.

Parameters
baseLPSPI peripheral base address.
handlepointer to lpspi_master_edma_handle_t structure which stores the transfer state.
transferpointer to lpspi_transfer_t structure.
Returns
status of status_t.

brief LPSPI master transfer data using eDMA.

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

Note: The transfer data size should be an integer multiple of bytesPerFrame if bytesPerFrame is less than or equal to 4. For bytesPerFrame greater than 4: The transfer data size should be equal to bytesPerFrame if the bytesPerFrame is not an integer multiple of 4. Otherwise, the transfer data size can be an integer multiple of bytesPerFrame.

param base LPSPI peripheral base address. param handle pointer to lpspi_master_edma_handle_t structure which stores the transfer state. param transfer pointer to lpspi_transfer_t structure. return status of status_t.

Definition at line 220 of file fsl_lpspi_edma.c.

221{
222 assert(handle);
223 assert(transfer);
224
225 uint32_t bitsPerFrame = ((base->TCR & LPSPI_TCR_FRAMESZ_MASK) >> LPSPI_TCR_FRAMESZ_SHIFT) + 1;
226 uint32_t bytesPerFrame = (bitsPerFrame + 7) / 8;
227 uint32_t temp = 0U;
228
229 if (!LPSPI_CheckTransferArgument(transfer, bitsPerFrame, bytesPerFrame))
230 {
232 }
233
234 /*And since the dma transfer can not support 3 bytes .*/
235 if ((bytesPerFrame % 4U) == 3)
236 {
238 }
239
240 /* Check that we're not busy.*/
241 if (handle->state == kLPSPI_Busy)
242 {
243 return kStatus_LPSPI_Busy;
244 }
245
246 handle->state = kLPSPI_Busy;
247
248 uint32_t instance = LPSPI_GetInstance(base);
249 uint32_t rxAddr = LPSPI_GetRxRegisterAddress(base);
250 uint32_t txAddr = LPSPI_GetTxRegisterAddress(base);
251
252 uint32_t whichPcs = (transfer->configFlags & LPSPI_MASTER_PCS_MASK) >> LPSPI_MASTER_PCS_SHIFT;
253
254 /*Because DMA is fast enough , so set the RX and TX watermarks to 0 .*/
255 uint8_t txWatermark = 0;
256 uint8_t rxWatermark = 0;
257
258 /*Used for byte swap*/
259 uint32_t dif = 0;
260
261 uint8_t bytesLastWrite = 0;
262
263 bool isThereExtraTxBytes = false;
264
265 uint8_t dummyData = g_lpspiDummyData[instance];
266
267 edma_transfer_config_t transferConfigRx;
268 edma_transfer_config_t transferConfigTx;
269
270 edma_tcd_t *softwareTCD_extraBytes = (edma_tcd_t *)((uint32_t)(&handle->lpspiSoftwareTCD[1]) & (~0x1FU));
271 edma_tcd_t *softwareTCD_pcsContinuous = (edma_tcd_t *)((uint32_t)(&handle->lpspiSoftwareTCD[2]) & (~0x1FU));
272
273 handle->txData = transfer->txData;
274 handle->rxData = transfer->rxData;
275 handle->txRemainingByteCount = transfer->dataSize;
276 handle->rxRemainingByteCount = transfer->dataSize;
277 handle->totalByteCount = transfer->dataSize;
278
279 handle->writeRegRemainingTimes = (transfer->dataSize / bytesPerFrame) * ((bytesPerFrame + 3) / 4);
281
282 handle->txBuffIfNull =
283 ((uint32_t)dummyData) | ((uint32_t)dummyData << 8) | ((uint32_t)dummyData << 16) | ((uint32_t)dummyData << 24);
284
285 /*The TX and RX FIFO sizes are always the same*/
286 handle->fifoSize = LPSPI_GetRxFifoSize(base);
287
289 handle->isByteSwap = (bool)(transfer->configFlags & kLPSPI_MasterByteSwap);
290
291 LPSPI_SetFifoWatermarks(base, txWatermark, rxWatermark);
292
293 /*Transfers will stall when transmit FIFO is empty or receive FIFO is full. */
294 LPSPI_Enable(base, false);
295 base->CFGR1 &= (~LPSPI_CFGR1_NOSTALL_MASK);
296 /* Check if using 3-wire mode and the txData is NULL, set the output pin to tristated. */
297 temp = base->CFGR1;
298 temp &= LPSPI_CFGR1_PINCFG_MASK;
299 if ((temp == LPSPI_CFGR1_PINCFG(kLPSPI_SdiInSdiOut)) || (temp == LPSPI_CFGR1_PINCFG(kLPSPI_SdoInSdoOut)))
300 {
301 if (!handle->txData)
302 {
303 base->CFGR1 |= LPSPI_CFGR1_OUTCFG_MASK;
304 }
305 /* The 3-wire mode can't send and receive data at the same time. */
306 if ((handle->txData) && (handle->rxData))
307 {
309 }
310 }
311
312 /*Flush FIFO , clear status , disable all the inerrupts.*/
313 LPSPI_FlushFifo(base, true, true);
316
317 /* For DMA transfer , we'd better not masked the transmit data and receive data in TCR since the transfer flow is
318 * hard to controlled by software.
319 */
320 base->TCR = (base->TCR & ~(LPSPI_TCR_CONT_MASK | LPSPI_TCR_CONTC_MASK | LPSPI_TCR_BYSW_MASK | LPSPI_TCR_PCS_MASK)) |
321 LPSPI_TCR_CONT(handle->isPcsContinuous) | LPSPI_TCR_CONTC(0U) | LPSPI_TCR_BYSW(handle->isByteSwap) |
322 LPSPI_TCR_PCS(whichPcs);
323
324 isThereExtraTxBytes = false;
325 handle->isThereExtraRxBytes = false;
326
327 /*Calculate the bytes for write/read the TX/RX register each time*/
328 if (bytesPerFrame <= 4)
329 {
330 handle->bytesEachWrite = bytesPerFrame;
331 handle->bytesEachRead = bytesPerFrame;
332
333 handle->bytesLastRead = bytesPerFrame;
334 }
335 else
336 {
337 handle->bytesEachWrite = 4;
338 handle->bytesEachRead = 4;
339
340 handle->bytesLastRead = 4;
341
342 if ((transfer->dataSize % 4) != 0)
343 {
344 bytesLastWrite = transfer->dataSize % 4;
345 handle->bytesLastRead = bytesLastWrite;
346
347 isThereExtraTxBytes = true;
348
349 --handle->writeRegRemainingTimes;
350
351 --handle->readRegRemainingTimes;
352 handle->isThereExtraRxBytes = true;
353 }
354 }
355
357
360
361 /*Rx*/
363
364 if (handle->rxData)
365 {
366 transferConfigRx.destAddr = (uint32_t) & (handle->rxData[0]);
367 transferConfigRx.destOffset = 1;
368 }
369 else
370 {
371 transferConfigRx.destAddr = (uint32_t) & (handle->rxBuffIfNull);
372 transferConfigRx.destOffset = 0;
373 }
375
376 dif = 0;
377 switch (handle->bytesEachRead)
378 {
379 case (1U):
380 transferConfigRx.srcTransferSize = kEDMA_TransferSize1Bytes;
381 transferConfigRx.minorLoopBytes = 1;
382 if (handle->isByteSwap)
383 {
384 dif = 3;
385 }
386 break;
387
388 case (2U):
389 transferConfigRx.srcTransferSize = kEDMA_TransferSize2Bytes;
390 transferConfigRx.minorLoopBytes = 2;
391 if (handle->isByteSwap)
392 {
393 dif = 2;
394 }
395 break;
396
397 case (4U):
398 transferConfigRx.srcTransferSize = kEDMA_TransferSize4Bytes;
399 transferConfigRx.minorLoopBytes = 4;
400 break;
401
402 default:
403 transferConfigRx.srcTransferSize = kEDMA_TransferSize1Bytes;
404 transferConfigRx.minorLoopBytes = 1;
405 assert(false);
406 break;
407 }
408
409 transferConfigRx.srcAddr = (uint32_t)rxAddr + dif;
410 transferConfigRx.srcOffset = 0;
411
412 transferConfigRx.majorLoopCounts = handle->readRegRemainingTimes;
413
414 /* Store the initially configured eDMA minor byte transfer count into the LPSPI handle */
415 handle->nbytes = transferConfigRx.minorLoopBytes;
416
418 &transferConfigRx, NULL);
421
422 /*Tx*/
424
425 if (isThereExtraTxBytes)
426 {
427 if (handle->txData)
428 {
429 transferConfigTx.srcAddr = (uint32_t) & (transfer->txData[transfer->dataSize - bytesLastWrite]);
430 transferConfigTx.srcOffset = 1;
431 }
432 else
433 {
434 transferConfigTx.srcAddr = (uint32_t)(&handle->txBuffIfNull);
435 transferConfigTx.srcOffset = 0;
436 }
437
438 transferConfigTx.destOffset = 0;
439
440 transferConfigTx.srcTransferSize = kEDMA_TransferSize1Bytes;
441
442 dif = 0;
443 switch (bytesLastWrite)
444 {
445 case (1U):
447 transferConfigTx.minorLoopBytes = 1;
448 if (handle->isByteSwap)
449 {
450 dif = 3;
451 }
452 break;
453
454 case (2U):
456 transferConfigTx.minorLoopBytes = 2;
457 if (handle->isByteSwap)
458 {
459 dif = 2;
460 }
461 break;
462
463 default:
465 transferConfigTx.minorLoopBytes = 1;
466 assert(false);
467 break;
468 }
469
470 transferConfigTx.destAddr = (uint32_t)txAddr + dif;
471 transferConfigTx.majorLoopCounts = 1;
472
473 EDMA_TcdReset(softwareTCD_extraBytes);
474
475 if (handle->isPcsContinuous)
476 {
477 EDMA_TcdSetTransferConfig(softwareTCD_extraBytes, &transferConfigTx, softwareTCD_pcsContinuous);
478 }
479 else
480 {
481 EDMA_TcdSetTransferConfig(softwareTCD_extraBytes, &transferConfigTx, NULL);
482 }
483 }
484
485 if (handle->isPcsContinuous)
486 {
487 handle->transmitCommand = base->TCR & ~(LPSPI_TCR_CONTC_MASK | LPSPI_TCR_CONT_MASK);
488
489 transferConfigTx.srcAddr = (uint32_t) & (handle->transmitCommand);
490 transferConfigTx.srcOffset = 0;
491
492 transferConfigTx.destAddr = (uint32_t) & (base->TCR);
493 transferConfigTx.destOffset = 0;
494
495 transferConfigTx.srcTransferSize = kEDMA_TransferSize4Bytes;
497 transferConfigTx.minorLoopBytes = 4;
498 transferConfigTx.majorLoopCounts = 1;
499
500 EDMA_TcdReset(softwareTCD_pcsContinuous);
501 EDMA_TcdSetTransferConfig(softwareTCD_pcsContinuous, &transferConfigTx, NULL);
502 }
503
504 if (handle->txData)
505 {
506 transferConfigTx.srcAddr = (uint32_t)(handle->txData);
507 transferConfigTx.srcOffset = 1;
508 }
509 else
510 {
511 transferConfigTx.srcAddr = (uint32_t)(&handle->txBuffIfNull);
512 transferConfigTx.srcOffset = 0;
513 }
514
515 transferConfigTx.destOffset = 0;
516
517 transferConfigTx.srcTransferSize = kEDMA_TransferSize1Bytes;
518
519 dif = 0;
520 switch (handle->bytesEachRead)
521 {
522 case (1U):
524 transferConfigTx.minorLoopBytes = 1;
525 if (handle->isByteSwap)
526 {
527 dif = 3;
528 }
529 break;
530
531 case (2U):
533 transferConfigTx.minorLoopBytes = 2;
534
535 if (handle->isByteSwap)
536 {
537 dif = 2;
538 }
539 break;
540
541 case (4U):
543 transferConfigTx.minorLoopBytes = 4;
544 break;
545
546 default:
548 transferConfigTx.minorLoopBytes = 1;
549 assert(false);
550 break;
551 }
552
553 transferConfigTx.destAddr = (uint32_t)txAddr + dif;
554
555 transferConfigTx.majorLoopCounts = handle->writeRegRemainingTimes;
556
557 if (isThereExtraTxBytes)
558 {
560 &transferConfigTx, softwareTCD_extraBytes);
561 }
562 else if (handle->isPcsContinuous)
563 {
565 &transferConfigTx, softwareTCD_pcsContinuous);
566 }
567 else
568 {
570 &transferConfigTx, NULL);
571 }
572
575
577 LPSPI_Enable(base, true);
578
579 return kStatus_Success;
580}
static void EDMA_LpspiMasterCallback(edma_handle_t *edmaHandle, void *g_lpspiEdmaPrivateHandle, bool transferDone, uint32_t tcds)
EDMA_LpspiMasterCallback after the LPSPI master transfer completed by using EDMA. This is not a publi...
edma_transfer_size_t destTransferSize
Definition fsl_edma.h:175
void EDMA_EnableChannelInterrupts(DMA_Type *base, uint32_t channel, uint32_t mask)
Enables the interrupt source for the eDMA transfer.
Definition fsl_edma.c:330
DMA_Type * base
Definition fsl_edma.h:249
uint32_t majorLoopCounts
Definition fsl_edma.h:181
void EDMA_TcdReset(edma_tcd_t *tcd)
Sets all fields to default values for the TCD structure.
Definition fsl_edma.c:392
edma_transfer_size_t srcTransferSize
Definition fsl_edma.h:174
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 minorLoopBytes
Definition fsl_edma.h:180
void EDMA_SetTransferConfig(DMA_Type *base, uint32_t channel, const edma_transfer_config_t *config, edma_tcd_t *nextTcd)
Configures the eDMA transfer attribute.
Definition fsl_edma.c:221
void EDMA_StartTransfer(edma_handle_t *handle)
eDMA starts transfer.
Definition fsl_edma.c:1103
uint8_t channel
Definition fsl_edma.h:251
void EDMA_TcdSetTransferConfig(edma_tcd_t *tcd, const edma_transfer_config_t *config, edma_tcd_t *nextTcd)
Configures the eDMA TCD transfer attribute.
Definition fsl_edma.c:439
void EDMA_ResetChannel(DMA_Type *base, uint32_t channel)
Sets all TCD registers to default values.
Definition fsl_edma.c:189
@ kEDMA_MajorInterruptEnable
Definition fsl_edma.h:131
@ kEDMA_TransferSize4Bytes
Definition fsl_edma.h:40
@ kEDMA_TransferSize2Bytes
Definition fsl_edma.h:39
@ kEDMA_TransferSize1Bytes
Definition fsl_edma.h:38
@ kStatus_Success
Definition fsl_common.h:159
@ kStatus_InvalidArgument
Definition fsl_common.h:163
static uint32_t LPSPI_GetRxFifoSize(LPSPI_Type *base)
Gets the LPSPI Rx FIFO size.
Definition fsl_lpspi.h:537
static void LPSPI_FlushFifo(LPSPI_Type *base, bool flushTxFifo, bool flushRxFifo)
Flushes the LPSPI FIFOs.
Definition fsl_lpspi.h:743
static void LPSPI_DisableInterrupts(LPSPI_Type *base, uint32_t mask)
Disables the LPSPI interrupts.
Definition fsl_lpspi.h:617
static uint32_t LPSPI_GetRxRegisterAddress(LPSPI_Type *base)
Gets the LPSPI Receive Data Register address for a DMA operation.
Definition fsl_lpspi.h:688
static void LPSPI_ClearStatusFlags(LPSPI_Type *base, uint32_t statusFlags)
Clears the LPSPI status flag.
Definition fsl_lpspi.h:575
static void LPSPI_Enable(LPSPI_Type *base, bool enable)
Enables the LPSPI peripheral and sets the MCR MDIS to 0.
Definition fsl_lpspi.h:491
static void LPSPI_SetFifoWatermarks(LPSPI_Type *base, uint32_t txWater, uint32_t rxWater)
Sets the transmit and receive FIFO watermark values.
Definition fsl_lpspi.h:759
volatile uint8_t g_lpspiDummyData[ARRAY_SIZE(s_lpspiBases)]
Global variable for dummy data value setting.
Definition fsl_lpspi.c:142
static void LPSPI_EnableDMA(LPSPI_Type *base, uint32_t mask)
Enables the LPSPI DMA request.
Definition fsl_lpspi.h:642
bool LPSPI_CheckTransferArgument(lpspi_transfer_t *transfer, uint32_t bitsPerFrame, uint32_t bytesPerFrame)
Check the argument for transfer .
Definition fsl_lpspi.c:713
static uint32_t LPSPI_GetTxRegisterAddress(LPSPI_Type *base)
Gets the LPSPI Transmit Data Register address for a DMA operation.
Definition fsl_lpspi.h:673
@ kLPSPI_Busy
Definition fsl_lpspi.h:250
@ kLPSPI_SdiInSdiOut
Definition fsl_lpspi.h:164
@ kLPSPI_SdoInSdoOut
Definition fsl_lpspi.h:165
@ kLPSPI_MasterPcsContinuous
Definition fsl_lpspi.h:203
@ kLPSPI_MasterByteSwap
Definition fsl_lpspi.h:205
@ kStatus_LPSPI_Busy
Definition fsl_lpspi.h:39
@ kLPSPI_AllInterruptEnable
Definition fsl_lpspi.h:73
@ kLPSPI_AllStatusFlag
Definition fsl_lpspi.h:57
volatile uint8_t fifoSize
volatile uint8_t bytesEachWrite
volatile uint32_t readRegRemainingTimes
volatile uint32_t writeRegRemainingTimes
uint8_t *volatile txData
volatile uint8_t bytesLastRead
volatile size_t rxRemainingByteCount
volatile uint8_t isThereExtraRxBytes
volatile uint8_t bytesEachRead
uint8_t *volatile rxData
volatile size_t txRemainingByteCount
eDMA TCD.
Definition fsl_edma.h:207
eDMA transfer configuration
Definition fsl_edma.h:171
uint8_t * rxData
Definition fsl_lpspi.h:339
uint32_t configFlags
Definition fsl_lpspi.h:343
volatile size_t dataSize
Definition fsl_lpspi.h:340
uint8_t * txData
Definition fsl_lpspi.h:338
Here is the call graph for this function:

◆ LPSPI_MasterTransferGetCountEDMA()

status_t LPSPI_MasterTransferGetCountEDMA ( LPSPI_Type *  base,
lpspi_master_edma_handle_t handle,
size_t count 
)

Gets the master eDMA transfer remaining bytes.

This function gets the master eDMA transfer remaining bytes.

Parameters
baseLPSPI peripheral base address.
handlepointer to lpspi_master_edma_handle_t structure which stores the transfer state.
countNumber of bytes transferred so far by the EDMA transaction.
Returns
status of status_t.

brief Gets the master eDMA transfer remaining bytes.

This function gets the master eDMA transfer remaining bytes.

param base LPSPI peripheral base address. param handle pointer to lpspi_master_edma_handle_t structure which stores the transfer state. param count Number of bytes transferred so far by the EDMA transaction. return status of status_t.

Definition at line 653 of file fsl_lpspi_edma.c.

654{
655 assert(handle);
656
657 if (!count)
658 {
660 }
661
662 /* Catch when there is not an active transfer. */
663 if (handle->state != kLPSPI_Busy)
664 {
665 *count = 0;
667 }
668
669 size_t remainingByte;
670
671 remainingByte =
674
675 *count = handle->totalByteCount - remainingByte;
676
677 return kStatus_Success;
678}
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
@ kStatus_NoTransferInProgress
Definition fsl_common.h:165
uint16_t count
Definition tunerstudio.h:1
Here is the call graph for this function:

◆ LPSPI_SlaveTransferAbortEDMA()

void LPSPI_SlaveTransferAbortEDMA ( LPSPI_Type *  base,
lpspi_slave_edma_handle_t handle 
)

LPSPI slave aborts a transfer which is using eDMA.

This function aborts a transfer which is using eDMA.

Parameters
baseLPSPI peripheral base address.
handlepointer to lpspi_slave_edma_handle_t structure which stores the transfer state.

brief LPSPI slave aborts a transfer which is using eDMA.

This function aborts a transfer which is using eDMA.

param base LPSPI peripheral base address. param handle pointer to lpspi_slave_edma_handle_t structure which stores the transfer state.

Definition at line 1123 of file fsl_lpspi_edma.c.

1124{
1125 assert(handle);
1126
1128
1131
1132 handle->state = kLPSPI_Idle;
1133}
edma_handle_t * edmaTxDataToTxRegHandle
edma_handle_t * edmaRxRegToRxDataHandle
Here is the call graph for this function:

◆ LPSPI_SlaveTransferCreateHandleEDMA()

void LPSPI_SlaveTransferCreateHandleEDMA ( LPSPI_Type *  base,
lpspi_slave_edma_handle_t handle,
lpspi_slave_edma_transfer_callback_t  callback,
void *  userData,
edma_handle_t edmaRxRegToRxDataHandle,
edma_handle_t edmaTxDataToTxRegHandle 
)

Initializes the LPSPI slave eDMA handle.

This function initializes the LPSPI eDMA handle which can be used for other LPSPI transactional APIs. Usually, for a specified LPSPI instance, call this API once to get the initialized handle.

Note that LPSPI eDMA has a separated (Rx and Tx as two sources) or shared (Rx and Tx as the same source) DMA request source.

(1) For a separated DMA request source, enable and set the Rx DMAMUX source for edmaRxRegToRxDataHandle and Tx DMAMUX source for edmaTxDataToTxRegHandle. (2) For a shared DMA request source, enable and set the Rx/Rx DMAMUX source for edmaRxRegToRxDataHandle .

Parameters
baseLPSPI peripheral base address.
handleLPSPI handle pointer to lpspi_slave_edma_handle_t.
callbackLPSPI callback.
userDatacallback function parameter.
edmaRxRegToRxDataHandleedmaRxRegToRxDataHandle pointer to edma_handle_t.
edmaTxDataToTxRegHandleedmaTxDataToTxRegHandle pointer to edma_handle_t.

brief Initializes the LPSPI slave eDMA handle.

This function initializes the LPSPI eDMA handle which can be used for other LPSPI transactional APIs. Usually, for a specified LPSPI instance, call this API once to get the initialized handle.

Note that LPSPI eDMA has a separated (Rx and Tx as two sources) or shared (Rx and Tx as the same source) DMA request source.

(1) For a separated DMA request source, enable and set the Rx DMAMUX source for edmaRxRegToRxDataHandle and Tx DMAMUX source for edmaTxDataToTxRegHandle. (2) For a shared DMA request source, enable and set the Rx/Rx DMAMUX source for edmaRxRegToRxDataHandle .

param base LPSPI peripheral base address. param handle LPSPI handle pointer to lpspi_slave_edma_handle_t. param callback LPSPI callback. param userData callback function parameter. param edmaRxRegToRxDataHandle edmaRxRegToRxDataHandle pointer to edma_handle_t. param edmaTxDataToTxRegHandle edmaTxDataToTxRegHandle pointer to edma_handle_t.

Definition at line 700 of file fsl_lpspi_edma.c.

706{
707 assert(handle);
708 assert(edmaRxRegToRxDataHandle);
709 assert(edmaTxDataToTxRegHandle);
710
711 /* Zero the handle. */
712 memset(handle, 0, sizeof(*handle));
713
714 uint32_t instance = LPSPI_GetInstance(base);
715
718
719 handle->callback = callback;
720 handle->userData = userData;
721
722 handle->edmaRxRegToRxDataHandle = edmaRxRegToRxDataHandle;
723 handle->edmaTxDataToTxRegHandle = edmaTxDataToTxRegHandle;
724}
static lpspi_slave_edma_private_handle_t s_lpspiSlaveEdmaPrivateHandle[ARRAY_SIZE(s_lpspiBases)]
lpspi_slave_edma_transfer_callback_t callback
Here is the call graph for this function:

◆ LPSPI_SlaveTransferEDMA()

status_t LPSPI_SlaveTransferEDMA ( LPSPI_Type *  base,
lpspi_slave_edma_handle_t handle,
lpspi_transfer_t transfer 
)

LPSPI slave transfers data using eDMA.

This function transfers data using eDMA. This is a non-blocking function, which return right away. When all data is transferred, the callback function is called.

Note: The transfer data size should be an integer multiple of bytesPerFrame if bytesPerFrame is less than or equal to 4. For bytesPerFrame greater than 4: The transfer data size should be equal to bytesPerFrame if the bytesPerFrame is not an integer multiple of 4. Otherwise, the transfer data size can be an integer multiple of bytesPerFrame.

Parameters
baseLPSPI peripheral base address.
handlepointer to lpspi_slave_edma_handle_t structure which stores the transfer state.
transferpointer to lpspi_transfer_t structure.
Returns
status of status_t.

brief LPSPI slave transfers data using eDMA.

This function transfers data using eDMA. This is a non-blocking function, which return right away. When all data is transferred, the callback function is called.

Note: The transfer data size should be an integer multiple of bytesPerFrame if bytesPerFrame is less than or equal to 4. For bytesPerFrame greater than 4: The transfer data size should be equal to bytesPerFrame if the bytesPerFrame is not an integer multiple of 4. Otherwise, the transfer data size can be an integer multiple of bytesPerFrame.

param base LPSPI peripheral base address. param handle pointer to lpspi_slave_edma_handle_t structure which stores the transfer state. param transfer pointer to lpspi_transfer_t structure. return status of status_t.

Definition at line 743 of file fsl_lpspi_edma.c.

744{
745 assert(handle);
746 assert(transfer);
747
748 uint32_t bitsPerFrame = ((base->TCR & LPSPI_TCR_FRAMESZ_MASK) >> LPSPI_TCR_FRAMESZ_SHIFT) + 1;
749 uint32_t bytesPerFrame = (bitsPerFrame + 7) / 8;
750 uint32_t temp = 0U;
751
752 uint8_t dummyData = g_lpspiDummyData[LPSPI_GetInstance(base)];
753
754 if (!LPSPI_CheckTransferArgument(transfer, bitsPerFrame, bytesPerFrame))
755 {
757 }
758
759 /*And since the dma transfer can not support 3 bytes .*/
760 if ((bytesPerFrame % 4U) == 3)
761 {
763 }
764
765 /* Check that we're not busy.*/
766 if (handle->state == kLPSPI_Busy)
767 {
768 return kStatus_LPSPI_Busy;
769 }
770
771 handle->state = kLPSPI_Busy;
772
773 uint32_t rxAddr = LPSPI_GetRxRegisterAddress(base);
774 uint32_t txAddr = LPSPI_GetTxRegisterAddress(base);
775
776 edma_tcd_t *softwareTCD_extraBytes = (edma_tcd_t *)((uint32_t)(&handle->lpspiSoftwareTCD[1]) & (~0x1FU));
777
778 uint32_t whichPcs = (transfer->configFlags & LPSPI_MASTER_PCS_MASK) >> LPSPI_MASTER_PCS_SHIFT;
779
780 /*Because DMA is fast enough , so set the RX and TX watermarks to 0 .*/
781 uint8_t txWatermark = 0;
782 uint8_t rxWatermark = 0;
783
784 /*Used for byte swap*/
785 uint32_t dif = 0;
786
787 uint8_t bytesLastWrite = 0;
788
789 uint32_t instance = LPSPI_GetInstance(base);
790
791 edma_transfer_config_t transferConfigRx;
792 edma_transfer_config_t transferConfigTx;
793
794 bool isThereExtraTxBytes = false;
795
796 handle->txData = transfer->txData;
797 handle->rxData = transfer->rxData;
798 handle->txRemainingByteCount = transfer->dataSize;
799 handle->rxRemainingByteCount = transfer->dataSize;
800 handle->totalByteCount = transfer->dataSize;
801
802 handle->writeRegRemainingTimes = (transfer->dataSize / bytesPerFrame) * ((bytesPerFrame + 3) / 4);
804
805 handle->txBuffIfNull =
806 ((uint32_t)dummyData) | ((uint32_t)dummyData << 8) | ((uint32_t)dummyData << 16) | ((uint32_t)dummyData << 24);
807
808 /*The TX and RX FIFO sizes are always the same*/
809 handle->fifoSize = LPSPI_GetRxFifoSize(base);
810
811 handle->isByteSwap = (bool)(transfer->configFlags & kLPSPI_MasterByteSwap);
812
813 LPSPI_SetFifoWatermarks(base, txWatermark, rxWatermark);
814
815 /*Transfers will stall when transmit FIFO is empty or receive FIFO is full. */
816 LPSPI_Enable(base, false);
817 base->CFGR1 &= (~LPSPI_CFGR1_NOSTALL_MASK);
818 /* Check if using 3-wire mode and the txData is NULL, set the output pin to tristated. */
819 temp = base->CFGR1;
820 temp &= LPSPI_CFGR1_PINCFG_MASK;
821 if ((temp == LPSPI_CFGR1_PINCFG(kLPSPI_SdiInSdiOut)) || (temp == LPSPI_CFGR1_PINCFG(kLPSPI_SdoInSdoOut)))
822 {
823 if (!handle->txData)
824 {
825 base->CFGR1 |= LPSPI_CFGR1_OUTCFG_MASK;
826 }
827 /* The 3-wire mode can't send and receive data at the same time. */
828 if ((handle->txData) && (handle->rxData))
829 {
831 }
832 }
833
834 /*Flush FIFO , clear status , disable all the inerrupts.*/
835 LPSPI_FlushFifo(base, true, true);
838
839 /* For DMA transfer , we'd better not masked the transmit data and receive data in TCR since the transfer flow is
840 * hard to controlled by software.
841 */
842 base->TCR = (base->TCR & ~(LPSPI_TCR_CONT_MASK | LPSPI_TCR_CONTC_MASK | LPSPI_TCR_BYSW_MASK)) |
843 LPSPI_TCR_CONTC(0U) | LPSPI_TCR_BYSW(handle->isByteSwap) | LPSPI_TCR_PCS(whichPcs);
844
845 isThereExtraTxBytes = false;
846 handle->isThereExtraRxBytes = false;
847
848 /*Calculate the bytes for write/read the TX/RX register each time*/
849 if (bytesPerFrame <= 4)
850 {
851 handle->bytesEachWrite = bytesPerFrame;
852 handle->bytesEachRead = bytesPerFrame;
853
854 handle->bytesLastRead = bytesPerFrame;
855 }
856 else
857 {
858 handle->bytesEachWrite = 4;
859 handle->bytesEachRead = 4;
860
861 handle->bytesLastRead = 4;
862
863 if ((transfer->dataSize % 4) != 0)
864 {
865 bytesLastWrite = transfer->dataSize % 4;
866 handle->bytesLastRead = bytesLastWrite;
867
868 isThereExtraTxBytes = true;
869 --handle->writeRegRemainingTimes;
870
871 handle->isThereExtraRxBytes = true;
872 --handle->readRegRemainingTimes;
873 }
874 }
875
877
880
881 /*Rx*/
882 if (handle->readRegRemainingTimes > 0)
883 {
885
886 if (handle->rxData)
887 {
888 transferConfigRx.destAddr = (uint32_t) & (handle->rxData[0]);
889 transferConfigRx.destOffset = 1;
890 }
891 else
892 {
893 transferConfigRx.destAddr = (uint32_t) & (handle->rxBuffIfNull);
894 transferConfigRx.destOffset = 0;
895 }
897
898 dif = 0;
899 switch (handle->bytesEachRead)
900 {
901 case (1U):
902 transferConfigRx.srcTransferSize = kEDMA_TransferSize1Bytes;
903 transferConfigRx.minorLoopBytes = 1;
904 if (handle->isByteSwap)
905 {
906 dif = 3;
907 }
908 break;
909
910 case (2U):
911 transferConfigRx.srcTransferSize = kEDMA_TransferSize2Bytes;
912 transferConfigRx.minorLoopBytes = 2;
913 if (handle->isByteSwap)
914 {
915 dif = 2;
916 }
917 break;
918
919 case (4U):
920 transferConfigRx.srcTransferSize = kEDMA_TransferSize4Bytes;
921 transferConfigRx.minorLoopBytes = 4;
922 break;
923
924 default:
925 transferConfigRx.srcTransferSize = kEDMA_TransferSize1Bytes;
926 transferConfigRx.minorLoopBytes = 1;
927 assert(false);
928 break;
929 }
930
931 transferConfigRx.srcAddr = (uint32_t)rxAddr + dif;
932 transferConfigRx.srcOffset = 0;
933
934 transferConfigRx.majorLoopCounts = handle->readRegRemainingTimes;
935
936 /* Store the initially configured eDMA minor byte transfer count into the DSPI handle */
937 handle->nbytes = transferConfigRx.minorLoopBytes;
938
940 &transferConfigRx, NULL);
943 }
944
945 /*Tx*/
947
948 if (isThereExtraTxBytes)
949 {
950 if (handle->txData)
951 {
952 transferConfigTx.srcAddr = (uint32_t) & (transfer->txData[transfer->dataSize - bytesLastWrite]);
953 transferConfigTx.srcOffset = 1;
954 }
955 else
956 {
957 transferConfigTx.srcAddr = (uint32_t)(&handle->txBuffIfNull);
958 transferConfigTx.srcOffset = 0;
959 }
960
961 transferConfigTx.destOffset = 0;
962
963 transferConfigTx.srcTransferSize = kEDMA_TransferSize1Bytes;
964
965 dif = 0;
966 switch (bytesLastWrite)
967 {
968 case (1U):
970 transferConfigTx.minorLoopBytes = 1;
971 if (handle->isByteSwap)
972 {
973 dif = 3;
974 }
975 break;
976
977 case (2U):
979 transferConfigTx.minorLoopBytes = 2;
980 if (handle->isByteSwap)
981 {
982 dif = 2;
983 }
984 break;
985
986 default:
988 transferConfigTx.minorLoopBytes = 1;
989 assert(false);
990 break;
991 }
992
993 transferConfigTx.destAddr = (uint32_t)txAddr + dif;
994 transferConfigTx.majorLoopCounts = 1;
995
996 EDMA_TcdReset(softwareTCD_extraBytes);
997
998 EDMA_TcdSetTransferConfig(softwareTCD_extraBytes, &transferConfigTx, NULL);
999 }
1000
1001 if (handle->txData)
1002 {
1003 transferConfigTx.srcAddr = (uint32_t)(handle->txData);
1004 transferConfigTx.srcOffset = 1;
1005 }
1006 else
1007 {
1008 transferConfigTx.srcAddr = (uint32_t)(&handle->txBuffIfNull);
1009 transferConfigTx.srcOffset = 0;
1010 }
1011
1012 transferConfigTx.destOffset = 0;
1013
1014 transferConfigTx.srcTransferSize = kEDMA_TransferSize1Bytes;
1015
1016 dif = 0;
1017 switch (handle->bytesEachRead)
1018 {
1019 case (1U):
1020 transferConfigTx.destTransferSize = kEDMA_TransferSize1Bytes;
1021 transferConfigTx.minorLoopBytes = 1;
1022 if (handle->isByteSwap)
1023 {
1024 dif = 3;
1025 }
1026 break;
1027
1028 case (2U):
1029 transferConfigTx.destTransferSize = kEDMA_TransferSize2Bytes;
1030 transferConfigTx.minorLoopBytes = 2;
1031
1032 if (handle->isByteSwap)
1033 {
1034 dif = 2;
1035 }
1036 break;
1037
1038 case (4U):
1039 transferConfigTx.destTransferSize = kEDMA_TransferSize4Bytes;
1040 transferConfigTx.minorLoopBytes = 4;
1041 break;
1042
1043 default:
1044 transferConfigTx.destTransferSize = kEDMA_TransferSize1Bytes;
1045 transferConfigTx.minorLoopBytes = 1;
1046 assert(false);
1047 break;
1048 }
1049
1050 transferConfigTx.destAddr = (uint32_t)txAddr + dif;
1051
1052 transferConfigTx.majorLoopCounts = handle->writeRegRemainingTimes;
1053
1054 if (isThereExtraTxBytes)
1055 {
1057 &transferConfigTx, softwareTCD_extraBytes);
1058 }
1059 else
1060 {
1062 &transferConfigTx, NULL);
1063 }
1064
1067
1069 LPSPI_Enable(base, true);
1070
1071 return kStatus_Success;
1072}
static void EDMA_LpspiSlaveCallback(edma_handle_t *edmaHandle, void *g_lpspiEdmaPrivateHandle, bool transferDone, uint32_t tcds)
EDMA_LpspiSlaveCallback after the LPSPI slave transfer completed by using EDMA. This is not a public ...
volatile uint8_t bytesEachRead
uint8_t *volatile rxData
uint8_t *volatile txData
volatile uint8_t bytesEachWrite
volatile uint8_t isThereExtraRxBytes
volatile uint8_t fifoSize
volatile uint32_t writeRegRemainingTimes
volatile size_t rxRemainingByteCount
volatile uint32_t readRegRemainingTimes
volatile size_t txRemainingByteCount
volatile uint8_t bytesLastRead
Here is the call graph for this function:

◆ LPSPI_SlaveTransferGetCountEDMA()

status_t LPSPI_SlaveTransferGetCountEDMA ( LPSPI_Type *  base,
lpspi_slave_edma_handle_t handle,
size_t count 
)

Gets the slave eDMA transfer remaining bytes.

This function gets the slave eDMA transfer remaining bytes.

Parameters
baseLPSPI peripheral base address.
handlepointer to lpspi_slave_edma_handle_t structure which stores the transfer state.
countNumber of bytes transferred so far by the eDMA transaction.
Returns
status of status_t.

brief Gets the slave eDMA transfer remaining bytes.

This function gets the slave eDMA transfer remaining bytes.

param base LPSPI peripheral base address. param handle pointer to lpspi_slave_edma_handle_t structure which stores the transfer state. param count Number of bytes transferred so far by the eDMA transaction. return status of status_t.

Definition at line 1145 of file fsl_lpspi_edma.c.

1146{
1147 assert(handle);
1148
1149 if (!count)
1150 {
1152 }
1153
1154 /* Catch when there is not an active transfer. */
1155 if (handle->state != kLPSPI_Busy)
1156 {
1157 *count = 0;
1159 }
1160
1161 size_t remainingByte;
1162
1163 remainingByte =
1166
1167 *count = handle->totalByteCount - remainingByte;
1168
1169 return kStatus_Success;
1170}
Here is the call graph for this function:

Variable Documentation

◆ bytesEachRead [1/2]

volatile uint8_t _lpspi_master_edma_handle::bytesEachRead

Bytes for each read RDR.

Definition at line 75 of file fsl_lpspi_edma.h.

Referenced by LPSPI_MasterTransferEDMA().

◆ bytesEachRead [2/2]

volatile uint8_t _lpspi_slave_edma_handle::bytesEachRead

Bytes for each read RDR.

Definition at line 118 of file fsl_lpspi_edma.h.

Referenced by LPSPI_SlaveTransferEDMA().

◆ bytesEachWrite [1/2]

volatile uint8_t _lpspi_master_edma_handle::bytesEachWrite

Bytes for each write TDR.

Definition at line 74 of file fsl_lpspi_edma.h.

Referenced by LPSPI_MasterTransferEDMA().

◆ bytesEachWrite [2/2]

volatile uint8_t _lpspi_slave_edma_handle::bytesEachWrite

Bytes for each write TDR.

Definition at line 117 of file fsl_lpspi_edma.h.

Referenced by LPSPI_SlaveTransferEDMA().

◆ bytesLastRead [1/2]

volatile uint8_t _lpspi_master_edma_handle::bytesLastRead

Bytes for last read RDR.

Definition at line 77 of file fsl_lpspi_edma.h.

Referenced by LPSPI_MasterTransferEDMA().

◆ bytesLastRead [2/2]

volatile uint8_t _lpspi_slave_edma_handle::bytesLastRead

Bytes for last read RDR.

Definition at line 120 of file fsl_lpspi_edma.h.

Referenced by LPSPI_SlaveTransferEDMA().

◆ callback [1/2]

lpspi_master_edma_transfer_callback_t _lpspi_master_edma_handle::callback

Completion callback.

Definition at line 99 of file fsl_lpspi_edma.h.

Referenced by LPSPI_MasterTransferCreateHandleEDMA().

◆ callback [2/2]

lpspi_slave_edma_transfer_callback_t _lpspi_slave_edma_handle::callback

Completion callback.

Definition at line 142 of file fsl_lpspi_edma.h.

Referenced by LPSPI_SlaveTransferCreateHandleEDMA().

◆ edmaRxRegToRxDataHandle [1/2]

edma_handle_t* _lpspi_master_edma_handle::edmaRxRegToRxDataHandle

edma_handle_t handle point used for RxReg to RxData buff

Definition at line 102 of file fsl_lpspi_edma.h.

Referenced by LPSPI_MasterTransferAbortEDMA(), LPSPI_MasterTransferCreateHandleEDMA(), LPSPI_MasterTransferEDMA(), and LPSPI_MasterTransferGetCountEDMA().

◆ edmaRxRegToRxDataHandle [2/2]

edma_handle_t* _lpspi_slave_edma_handle::edmaRxRegToRxDataHandle

edma_handle_t handle point used for RxReg to RxData buff

Definition at line 145 of file fsl_lpspi_edma.h.

Referenced by LPSPI_SlaveTransferAbortEDMA(), LPSPI_SlaveTransferCreateHandleEDMA(), LPSPI_SlaveTransferEDMA(), and LPSPI_SlaveTransferGetCountEDMA().

◆ edmaTxDataToTxRegHandle [1/2]

edma_handle_t* _lpspi_master_edma_handle::edmaTxDataToTxRegHandle

edma_handle_t handle point used for TxData to TxReg buff

Definition at line 103 of file fsl_lpspi_edma.h.

Referenced by LPSPI_MasterTransferAbortEDMA(), LPSPI_MasterTransferCreateHandleEDMA(), and LPSPI_MasterTransferEDMA().

◆ edmaTxDataToTxRegHandle [2/2]

edma_handle_t* _lpspi_slave_edma_handle::edmaTxDataToTxRegHandle

edma_handle_t handle point used for TxData to TxReg

Definition at line 146 of file fsl_lpspi_edma.h.

Referenced by LPSPI_SlaveTransferAbortEDMA(), LPSPI_SlaveTransferCreateHandleEDMA(), and LPSPI_SlaveTransferEDMA().

◆ errorCount

uint32_t _lpspi_slave_edma_handle::errorCount

Error count for slave transfer.

Definition at line 140 of file fsl_lpspi_edma.h.

◆ fifoSize [1/2]

volatile uint8_t _lpspi_master_edma_handle::fifoSize

FIFO dataSize.

Definition at line 70 of file fsl_lpspi_edma.h.

Referenced by LPSPI_MasterTransferEDMA().

◆ fifoSize [2/2]

volatile uint8_t _lpspi_slave_edma_handle::fifoSize

FIFO dataSize.

Definition at line 113 of file fsl_lpspi_edma.h.

Referenced by LPSPI_SlaveTransferEDMA().

◆ isByteSwap [1/2]

volatile bool _lpspi_master_edma_handle::isByteSwap

A flag that whether should byte swap.

Definition at line 68 of file fsl_lpspi_edma.h.

Referenced by LPSPI_MasterTransferEDMA().

◆ isByteSwap [2/2]

volatile bool _lpspi_slave_edma_handle::isByteSwap

A flag that whether should byte swap.

Definition at line 111 of file fsl_lpspi_edma.h.

Referenced by LPSPI_SlaveTransferEDMA().

◆ isPcsContinuous

volatile bool _lpspi_master_edma_handle::isPcsContinuous

Is PCS continuous in transfer.

Definition at line 66 of file fsl_lpspi_edma.h.

Referenced by LPSPI_MasterTransferEDMA().

◆ isThereExtraRxBytes [1/2]

volatile uint8_t _lpspi_master_edma_handle::isThereExtraRxBytes

Is there extra RX byte.

Definition at line 78 of file fsl_lpspi_edma.h.

Referenced by LPSPI_MasterTransferEDMA().

◆ isThereExtraRxBytes [2/2]

volatile uint8_t _lpspi_slave_edma_handle::isThereExtraRxBytes

Is there extra RX byte.

Definition at line 121 of file fsl_lpspi_edma.h.

Referenced by LPSPI_SlaveTransferEDMA().

◆ lpspiSoftwareTCD [1/2]

edma_tcd_t _lpspi_slave_edma_handle::lpspiSoftwareTCD[2]

SoftwareTCD, internal used

Definition at line 148 of file fsl_lpspi_edma.h.

Referenced by LPSPI_SlaveTransferEDMA().

◆ lpspiSoftwareTCD [2/2]

edma_tcd_t _lpspi_master_edma_handle::lpspiSoftwareTCD[3]

SoftwareTCD, internal used

Definition at line 105 of file fsl_lpspi_edma.h.

Referenced by LPSPI_MasterTransferEDMA().

◆ nbytes [1/2]

uint8_t _lpspi_master_edma_handle::nbytes

eDMA minor byte transfer count initially configured.

Definition at line 97 of file fsl_lpspi_edma.h.

Referenced by LPSPI_MasterTransferEDMA(), and LPSPI_MasterTransferGetCountEDMA().

◆ nbytes [2/2]

uint8_t _lpspi_slave_edma_handle::nbytes

eDMA minor byte transfer count initially configured.

Definition at line 123 of file fsl_lpspi_edma.h.

Referenced by LPSPI_SlaveTransferEDMA(), and LPSPI_SlaveTransferGetCountEDMA().

◆ readRegRemainingTimes [1/2]

volatile uint32_t _lpspi_master_edma_handle::readRegRemainingTimes

Read RDR register remaining times.

Definition at line 86 of file fsl_lpspi_edma.h.

Referenced by LPSPI_MasterTransferEDMA().

◆ readRegRemainingTimes [2/2]

volatile uint32_t _lpspi_slave_edma_handle::readRegRemainingTimes

Read RDR register remaining times.

Definition at line 131 of file fsl_lpspi_edma.h.

Referenced by LPSPI_SlaveTransferEDMA().

◆ rxBuffIfNull [1/2]

uint32_t _lpspi_master_edma_handle::rxBuffIfNull

Used if there is not rxData for DMA purpose.

Definition at line 91 of file fsl_lpspi_edma.h.

Referenced by LPSPI_MasterTransferEDMA().

◆ rxBuffIfNull [2/2]

uint32_t _lpspi_slave_edma_handle::rxBuffIfNull

Used if there is not rxData for DMA purpose.

Definition at line 136 of file fsl_lpspi_edma.h.

Referenced by LPSPI_SlaveTransferEDMA().

◆ rxData [1/2]

uint8_t* volatile _lpspi_master_edma_handle::rxData

Receive buffer.

Definition at line 81 of file fsl_lpspi_edma.h.

Referenced by LPSPI_MasterTransferEDMA().

◆ rxData [2/2]

uint8_t* volatile _lpspi_slave_edma_handle::rxData

Receive buffer.

Definition at line 126 of file fsl_lpspi_edma.h.

Referenced by LPSPI_SlaveTransferEDMA().

◆ rxRemainingByteCount [1/2]

volatile size_t _lpspi_master_edma_handle::rxRemainingByteCount

Number of bytes remaining to receive.

Definition at line 83 of file fsl_lpspi_edma.h.

Referenced by LPSPI_MasterTransferEDMA().

◆ rxRemainingByteCount [2/2]

volatile size_t _lpspi_slave_edma_handle::rxRemainingByteCount

Number of bytes remaining to receive.

Definition at line 128 of file fsl_lpspi_edma.h.

Referenced by LPSPI_SlaveTransferEDMA().

◆ rxWatermark [1/2]

volatile uint8_t _lpspi_master_edma_handle::rxWatermark

Rx watermark.

Definition at line 72 of file fsl_lpspi_edma.h.

◆ rxWatermark [2/2]

volatile uint8_t _lpspi_slave_edma_handle::rxWatermark

Rx watermark.

Definition at line 115 of file fsl_lpspi_edma.h.

◆ state [1/2]

volatile uint8_t _lpspi_master_edma_handle::state

LPSPI transfer state , _lpspi_transfer_state.

Definition at line 95 of file fsl_lpspi_edma.h.

Referenced by LPSPI_MasterTransferAbortEDMA(), LPSPI_MasterTransferEDMA(), and LPSPI_MasterTransferGetCountEDMA().

◆ state [2/2]

volatile uint8_t _lpspi_slave_edma_handle::state

LPSPI transfer state.

Definition at line 138 of file fsl_lpspi_edma.h.

Referenced by LPSPI_SlaveTransferAbortEDMA(), LPSPI_SlaveTransferEDMA(), and LPSPI_SlaveTransferGetCountEDMA().

◆ totalByteCount [1/2]

uint32_t _lpspi_master_edma_handle::totalByteCount

Number of transfer bytes

Definition at line 88 of file fsl_lpspi_edma.h.

Referenced by LPSPI_MasterTransferEDMA(), and LPSPI_MasterTransferGetCountEDMA().

◆ totalByteCount [2/2]

uint32_t _lpspi_slave_edma_handle::totalByteCount

Number of transfer bytes

Definition at line 133 of file fsl_lpspi_edma.h.

Referenced by LPSPI_SlaveTransferEDMA(), and LPSPI_SlaveTransferGetCountEDMA().

◆ transmitCommand

uint32_t _lpspi_master_edma_handle::transmitCommand

Used to write TCR for DMA purpose.

Definition at line 93 of file fsl_lpspi_edma.h.

Referenced by LPSPI_MasterTransferEDMA().

◆ txBuffIfNull [1/2]

uint32_t _lpspi_master_edma_handle::txBuffIfNull

Used if there is not txData for DMA purpose.

Definition at line 90 of file fsl_lpspi_edma.h.

Referenced by LPSPI_MasterTransferEDMA().

◆ txBuffIfNull [2/2]

uint32_t _lpspi_slave_edma_handle::txBuffIfNull

Used if there is not txData for DMA purpose.

Definition at line 135 of file fsl_lpspi_edma.h.

Referenced by LPSPI_SlaveTransferEDMA().

◆ txData [1/2]

uint8_t* volatile _lpspi_master_edma_handle::txData

Send buffer.

Definition at line 80 of file fsl_lpspi_edma.h.

Referenced by LPSPI_MasterTransferEDMA().

◆ txData [2/2]

uint8_t* volatile _lpspi_slave_edma_handle::txData

Send buffer.

Definition at line 125 of file fsl_lpspi_edma.h.

Referenced by LPSPI_SlaveTransferEDMA().

◆ txRemainingByteCount [1/2]

volatile size_t _lpspi_master_edma_handle::txRemainingByteCount

Number of bytes remaining to send.

Definition at line 82 of file fsl_lpspi_edma.h.

Referenced by LPSPI_MasterTransferEDMA().

◆ txRemainingByteCount [2/2]

volatile size_t _lpspi_slave_edma_handle::txRemainingByteCount

Number of bytes remaining to send.

Definition at line 127 of file fsl_lpspi_edma.h.

Referenced by LPSPI_SlaveTransferEDMA().

◆ userData [1/2]

void* _lpspi_master_edma_handle::userData

Callback user data.

Definition at line 100 of file fsl_lpspi_edma.h.

Referenced by LPSPI_MasterTransferCreateHandleEDMA().

◆ userData [2/2]

void* _lpspi_slave_edma_handle::userData

Callback user data.

Definition at line 143 of file fsl_lpspi_edma.h.

Referenced by LPSPI_SlaveTransferCreateHandleEDMA().

◆ writeRegRemainingTimes [1/2]

volatile uint32_t _lpspi_master_edma_handle::writeRegRemainingTimes

Write TDR register remaining times.

Definition at line 85 of file fsl_lpspi_edma.h.

Referenced by LPSPI_MasterTransferEDMA().

◆ writeRegRemainingTimes [2/2]

volatile uint32_t _lpspi_slave_edma_handle::writeRegRemainingTimes

Write TDR register remaining times.

Definition at line 130 of file fsl_lpspi_edma.h.

Referenced by LPSPI_SlaveTransferEDMA().