LPSPI EDMA Help - MIMXRT1050 Board

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

LPSPI EDMA Help - MIMXRT1050 Board

2,212 次查看
kamal1
Contributor III

Hello,

 

I am using the MIMXRT1050-EVK board with Keilv5 Pro edition. I am working on a project which involves LPSPI. My goal is to use one of the LPSPI ports and EDMA to communicate with an external device. I am having issues getting the LPSPI EDMA set up, I am using an example from the Keil pack which uses LPSPI and FlexSPI for communication.

 

I have successfully got the LPSPI working in which I can transmit and receive bytes, but I don’t understand how to use the LPSPI EDMA.

 

I have found the fsl_lpspi_edma files and do not understand how to use the functions. The ultimate goal is to use the EDMA to send data through LPSPI involving arrays of data. Currently, I am trying to figure out how to use the LPSPI_MasterTransferCreateHandleEDMA function then use the LPSPI_MasterTransferEDMA to send data. The code below is the function which creates the LPSPI EDMA handle but I don't know where to get the correct parameters for my project. Any help is appreciated.

/*!
* 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.
*/
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)
{
   assert(handle);
   assert(edmaRxRegToRxDataHandle);
   assert(edmaTxDataToTxRegHandle);

   /* Zero the handle. */
   memset(handle, 0, sizeof(*handle));\

   uint32_t instance = LPSPI_GetInstance(base);

   s_lpspiMasterEdmaPrivateHandle[instance].base = base;
   s_lpspiMasterEdmaPrivateHandle[instance].handle = handle;

   handle->callback = callback;
   handle->userData = userData;

   handle->edmaRxRegToRxDataHandle = edmaRxRegToRxDataHandle;
   handle->edmaTxDataToTxRegHandle = edmaTxDataToTxRegHandle;
}

Best,

Kamal

标签 (1)
标记 (3)
0 项奖励
回复
4 回复数

1,942 次查看
kamal1
Contributor III

Thank you for the helpful tips. I have already looked at all these examples, the reason I am having an issue is that in my case I am using 1 LPSPI port to send and receive data from. I have already successfully sent data and read it through the same LPSPI port by sending one bit at a time but the issue I am having now is I want to send and read the same data using DMA. The DMA will point to an address containing data which gets sent to the LPSPI tx register then when I get the data back through the rx register, the DMA will take that data and store it at a specific address.

 

Maybe for my case I should not be using the LPSPI_EMDA functions since they all require a different port for the master and slave functions. Maybe using the DMA separately from the LPSPI and just have the DMA send and receive data at a specified address or register is easier to code. Any other suggestions?

0 项奖励
回复

1,942 次查看
victorjimenez
NXP TechSupport
NXP TechSupport

Hello, Kamal

Based on your approach, you could use the edma memory_to_memory example that we provide within the SDK as a base to achieve the implementation you are trying to do. The EDMA memory to memory example executes a  one-shot transfer from source buffer to a destination buffer using the SDK EDMA drivers.

Regards, 

Victor 

0 项奖励
回复

1,942 次查看
daweiyou
NXP Employee
NXP Employee

Hello:

I just write this demo to customer with similiar reques, please check attach demo.

put the demo into SDK_2.6.1_EVKB-IMXRT1050\boards\evkbimxrt1050\driver_examples\lpspi, and compile with Keil.

make sure follow the readme to adjust resistor on EVKB of RT1050.

0 项奖励
回复

1,942 次查看
victorjimenez
NXP TechSupport
NXP TechSupport

Hello, Kamal

As a starting point to understand how to add EDMA to your LPSPI example, I recommend you refer to the example lexio_spi_edma_lpspi_transfer_master of the SDK. This example uses the FLexIO module to emulate an SPI communication instead of the LPSPI module. However, the drivers fsl_felxio_spi_edma and fsl_lpspi_edma, are pretty much the same, so you could use this example to see how to implement the drivers fsl_lpspi_edma in your application. 


Have a great day,
Victor

-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

0 项奖励
回复