I'm programming the FRDM-K64 and are trying to get input from SAI using DMA.
The idea is to get the DMA read to one buffer while I'm processing the other, and then we could switch buffers (ping - pong).
The DMA is configured as this:
uint32_t *fifo_addr = SAI_DRV_RxGetFifoAddr(0, chan);
uint8_t saiBuff[1000];
EDMA_DRV_InstallCallback(&dmaCh0, RxDmaCallback, (void *)0);
EDMA_DRV_ConfigLoopTransfer(&dmaCh0, i2s0Tcd, kEDMAPeripheralToMemory,
(uint32_t)fifo_addr, (uint32_t)saiBuff,
4, // Transfer size pr DMA read/write in bytes
32, // bytes on each DMA work cycle
64, // totalLength (buffer size)
2); // number of TCDs
As I understand it from the doc/debugger:
Each DMA cycle will transfer 4 bytes (using SPI in 32-bit mode, this is correct?)
I get a Rx IRQ callback after 32 bytes has been transfered by the DMA
My buffer is 64 bytes long.
The DMA and I have split the buffer in 2.
The question is: In the RxDmaCallback(), how do I find out which buffer (ping or pong) is ready for processing?