DMA + SPI, TD run-time configuration | Cypress Semiconductor
DMA + SPI, TD run-time configuration
Hi, hope all is good.
I have been trying to make DMA and SPI work together for at least two weeks, and i think i have something usefull, the end application of this is drive the nRF24 chip with DMA on the PSoC 5LP.
I have some doubts and hope somebody can help me, or suggest me a more efficient way to do it.
SPI FIFO is 4 bytes deep so i send 1 byte each time using the Tx FIFO not Full signal, if i try to send more bytes al goes crazy, same i get 1 byte on the receiver buffer with help of the Rx FIFO Not Empty signal.
nRF24 chip have several registers, most of them are 1 byte size, and few others are 32 bytes long, so to be able to read or write to them i need to send a read/write command byte + all the bytes of data, for this i was tinking on have 1 TD to send the command + 1 TD to send the data on the Tx side, and 1 TD for the received data. I did this on a function (DMATransfer on the attached project) but i do not know if i have to allocate the TD on the beggining of the function and then free the TD when i'm finishing the function, all this because i'm changing the TD transfer size parameter each time i call the function.
And also i would like to know if there's a way to avoid this:
while(0u == (SPI_TX_STATUS_REG & SPI_STS_SPI_DONE));
i have to do it because if i don't do it the /SS line never goes 'high' when i'm done sending the number of bytes i pass as parameter.
Attached the most recent project. Thanks in advance
PS: I'm bad explaining, so any doubts pls let me know :D