The right way to check SPI DMA completion
Posted: Thu Jul 26, 2018 1:03 am
I experimented dual frame buffer driver in ESP-32, which connects ili9341 LCD controller over SPI. I need to synchronize SPI DMA completion to switch frame buffer.
There seem to be two ways to do this.
1. After calling a number of spi_device_queue_trans function to send DMA transaction to the queue, invoke the corresponding number of spi_device_get_trans_result with max ticks to wait.
2. In struct spi_device_interface_config_t, set call back method in post_cb member.
I implemented method 1. But there are scars in screen (see Video -- https://www.youtube.com/watch?v=ftyc87KdjmI). It seems that spi_device_get_trans_result returns before DMA complete. Thus, it overwrites what it is being DMA.
I wonder if anyone could share their experience on SPI DMA. What's the right way to check SPI DMA completion.
There seem to be two ways to do this.
1. After calling a number of spi_device_queue_trans function to send DMA transaction to the queue, invoke the corresponding number of spi_device_get_trans_result with max ticks to wait.
2. In struct spi_device_interface_config_t, set call back method in post_cb member.
I implemented method 1. But there are scars in screen (see Video -- https://www.youtube.com/watch?v=ftyc87KdjmI). It seems that spi_device_get_trans_result returns before DMA complete. Thus, it overwrites what it is being DMA.
I wonder if anyone could share their experience on SPI DMA. What's the right way to check SPI DMA completion.