SPI DMA with variable lenght and timeout?
Hi, my project is an ethernet server made with the STM32F411RET6. It receives and transmits data over SPI as a slave in 16bit mode, chip select disabled. At the moment i poll with HAL_SPI_Receive() and HAL_SPI_Transmit(). After transmit the master is triggered via gpio. My loop time is about 110us. For transmiting, there is a buffer in the ethernet part. So i cand send word after word. The problem is with receiving. I get sometimes 4 words in a row, sometimes only 1 word or something in between. No matter how many words arrive they should be sent fast, ideally once per loop at least. With HAL_SPI_Receive_DMA() and a buffer that fits 4 words, a 1 word package can be delayed. I would like to avoid interrupts. Is there a way to use the DMA but then poll and flush the buffer once a loop? I've seen HAL_SPIEx_FlushRxFifo() but i am not sure if this does what i need. Seems like it reads DR Register. I am new to Stm32 and CubeIDE and would like to understand whats going on instead of trying without knowing what i do. Any help is appreciated.
Thanks
Martin
