cancel
Showing results for 
Search instead for 
Did you mean: 

How to cancel HAL_SPI_TransmitReceive_DMA

pass3master
Senior

How to cancel HAL_SPI_TransmitReceive_DMA

We are developing SPI communication devices using HAL_SPI_TransmitReceive_DMA.
We would like to cancel or stop HAL_SPI_TransmitReceive_DMA even in the middle of transmission by GPIO interrupt, but we do not know how to do it.
Is it possible to cancel in the middle of transmission?
Also, how should I program it?

2 REPLIES 2
NEdom.1
Associate III

If you are using SPI to access a large amount of data in SPI flash in a single operation, then you need to stop the DMA operation in some situation. I don't see any stopping DMA mechanism inside HAL_SPI_TransmitReceive_DMA API. I think you might implement your own SPI DMA functions in which you can inject the GPIO interrupt or polling this GPIO to determine whether or not to exit DMA mode. To do this, you need to dig into how the SPI DMA works, which is not in a quick kick.

In the same time you might need a strategy to process the available data transmitted or received.

 


@NEdom.1 wrote:

you might need a strategy to process the available data transmitted or received.


also to ensure that the Slave is left in a "sensible" state ...