cancel
Showing results for 
Search instead for 
Did you mean: 

SPI with GPDMA

Rickou73
Associate II

Hi!

I would like to know if there is a way to handle "automaticaly" a transmit then receive transfert using SPI and DMA ?

I think using linked list should be possible, but i don't know how to configure that.. 

 

-Create a single linked list (only 1 GPDMA channel)

-Configure a 1st node with request from SPI1_TX, the tx buffer and len and add it to the linked list

-Configure a 2nd node with request from SPI1_RX, the rx buffer and len and add it to the linked list

-Call HAL_SPI_TransmitReceive_DMA

do you think it should works ?

 

The goal is multiple.. only 1 GPDMA channel used, manage automatically Transmit then Receive for 1 transfert..

 

I have same needs for 2 QuadSPI drivers.

 

thank for help.

2 REPLIES 2
KDJEM.1
ST Employee

Hello @Rickou73 ,

 

To configure SPI with GPDMA, I recommend you to start with available SPIs examples like these:

SPI_FullDuplex_ComDMA_Slave

SPI_FullDuplex_ComDMA_Master

 

Also, I advise you to take a look at this FAQ may help you "How to configure the GPDMA - STMicroelectronics Community"

 

I hope this help you.

Kaouthar

 

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

hi @KDJEM.1 

thank you but I already know these examples..

In my case, I'm targeting a device that is not full duplex.

In this specific setup, i need in a same chip select transfer to 1st transmit some bytes, then receive some bytes.

 

So, I asks if it's possible to:

Using a Single (or 2) DMA channel with linked list and HAL to do both "half transfert" in a single transaction without code interaction ?

actual pseudo-code:

txbuffer[4]={......};

rxbuffer[128];

ChipSelect_Enable();

HAL_SPI_Transmit_DMA(dmaCh1, txbuffer,4);

WaitForDMAComplete(dmaCh1);

HAL_SPI_Receive_DMA(dmaCh2,rxbuffer,128);

WaitForDMAComplete(dmaCh2);

ChipSelect_Disable();

 

Thinking pseudo-code:

txbuffer[4]={......};

rxbuffer[128];

ChipSelect_Enable();

HAL_SPI_Transmit_Receive_DMA(dmaCh1,txbuffer,4,rxbuffer,128); // In half duplex !

WaitForDMAComplete(dmaCh1);

ChipSelect_Disable();