Skip to main content
Senior
August 21, 2024
Solved

The purpose of the 'if ((hspi->hdmatx->Mode & DMA_LINKEDLIST) == DMA_LINKEDLIST)' in STM32U5 SPI transfer with DMA APIs

  • August 21, 2024
  • 2 replies
  • 1504 views

Hi,

I'm trying to combine the SPI and GPDMA on STM32U5. In the various SPI transfer APIs with suffix '_DMA', I can see the code below:

 /* Enable the Tx DMA Stream/Channel */
 if ((hspi->hdmatx->Mode & DMA_LINKEDLIST) == DMA_LINKEDLIST)
 {
 if (hspi->hdmatx->LinkedListQueue != NULL)
 {
 /* Set DMA data size */
 hspi->hdmatx->LinkedListQueue->Head->LinkRegisters[NODE_CBR1_DEFAULT_OFFSET] = hspi->TxXferCount;

 /* Set DMA source address */
 hspi->hdmatx->LinkedListQueue->Head->LinkRegisters[NODE_CSAR_DEFAULT_OFFSET] = (uint32_t)hspi->pTxBuffPtr;

 /* Set DMA destination address */
 hspi->hdmatx->LinkedListQueue->Head->LinkRegisters[NODE_CDAR_DEFAULT_OFFSET] = (uint32_t)&hspi->Instance->TXDR;

 status = HAL_DMAEx_List_Start_IT(hspi->hdmatx);
 }
 else
 {
 status = HAL_ERROR;
 }
 }
 else
 {
 status = HAL_DMA_Start_IT(hspi->hdmatx, (uint32_t)hspi->pTxBuffPtr, (uint32_t)&hspi->Instance->TXDR,
 hspi->TxXferCount);
 }

It seems the code try to support the 'DMA_LINKEDLIST' mode. But can't find a way to set it to 'DMA_LINKEDLIST' in the .ioc file. So, how ST expect us to use this mode?

Thanks.

Best answer by Imen.D

Hello @diverger ,

You can specify the DMA_LINKEDLIST mode through GPDMA1 Mode and configuration on STM32CubeMX (please see attachment files).
The Execution Mode can be: Circular or Linear (By Default) 

  • Circular Mode :

 

handle_GPDMA1_Channel15.InitLinkedList.LinkedListMode = DMA_LINKEDLIST_CIRCULAR;
#define DMA_LINKEDLIST_CIRCULAR (DMA_LINKEDLIST | (0x01U)​

 

  • Linear Mode :

 

handle_GPDMA1_Channel15.InitLinkedList.LinkedListMode = DMA_LINKEDLIST_NORMAL;
#define DMA_LINKEDLIST_NORMAL DMA_LINKEDLIST​

 

2 replies

Imen.DBest answer
Technical Moderator
August 21, 2024

Hello @diverger ,

You can specify the DMA_LINKEDLIST mode through GPDMA1 Mode and configuration on STM32CubeMX (please see attachment files).
The Execution Mode can be: Circular or Linear (By Default) 

  • Circular Mode :

 

handle_GPDMA1_Channel15.InitLinkedList.LinkedListMode = DMA_LINKEDLIST_CIRCULAR;
#define DMA_LINKEDLIST_CIRCULAR (DMA_LINKEDLIST | (0x01U)​

 

  • Linear Mode :

 

handle_GPDMA1_Channel15.InitLinkedList.LinkedListMode = DMA_LINKEDLIST_NORMAL;
#define DMA_LINKEDLIST_NORMAL DMA_LINKEDLIST​

 

"When your question is answered, please close this topic by clicking ""Accept as Solution"".ThanksImen"
Technical Moderator
August 27, 2024

Hi @diverger ,

Did the solution shared solve your problem?

I'll be waiting for your feedback :) 

"When your question is answered, please close this topic by clicking ""Accept as Solution"".ThanksImen"