cancel
Showing results for 
Search instead for 
Did you mean: 

HAL_DMA_RegisterCallback with SPI

STmine
Associate

Hi,

I'm just struggling with the same problem. I use SPI with DMA non-circular mode and want a callback for receive complete.

I can set the callback function with HAL_DMA_RegisterCallback but in HAL_SPI_TransmitReceive_DMA it will be overwritten:

 /* Set the SPI Tx/Rx DMA Half transfer complete callback */
  hspi->hdmarx->XferHalfCpltCallback = SPI_DMAHalfTransmitReceiveCplt;
  hspi->hdmarx->XferCpltCallback     = SPI_DMATransmitReceiveCplt;

Edit: Post moved from original thread How to know the when the DMA transfer done?, to give a chance to be answered. Please precise if you are using U5 as original one.

3 REPLIES 3
Saket_Om
ST Employee

Hello @STmine 

Could you provide more details about the issue please. 

What is the MCU you are using? 

 

I can set the callback function with HAL_DMA_RegisterCallback but in HAL_SPI_TransmitReceive_DMA it will be overwritten:

 /* Set the SPI Tx/Rx DMA Half transfer complete callback */
  hspi->hdmarx->XferHalfCpltCallback = SPI_DMAHalfTransmitReceiveCplt;
  hspi->hdmarx->XferCpltCallback     = SPI_DMATransmitReceiveCplt;

 


What you want to say by overwritten? How it is overriten?

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

Thanks
Omar
Billy OWEN
ST Employee

Hi @STmine 

 

This post has been escalated to the ST Online Support Team for additional assistance.  We'll contact you directly.

 

Regards,

Billy

KnarfB
Principal III

The DMA callbacks are used internall by SPI HAL and should not be changed.

You can override HAL_SPI_TxCpltCallback function and friends, or register your own callback function with HAL_SPI_RegisterCallback.

hth

KnarfB