-
I'm searching for a way to use tu_fifo_t with DMA on rp2040, in order to move data from/to USB to/from other interfaces without cpu intervention. If I get it right, I can set f->wr_idx as dma destination address (or f->rd_idx as source address), let it go for n bytes, and then on DMA block completion call tu_fifo_advance_write_pointer (or tu_fifo_advance_read_pointer) to update the indexes of n bytes. And do not be worried of wrap around and max_pointer_idx as the advance_pointer() already takes care of it. And in the case I need for this to be done from multiple tasks/cores, I can use the existing mutex (with OS_PICO) to avoid clashes.
not accessible outside of src/class/cdc/cdc_device.c unit. And there are no functions to get a pointer. |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 18 replies
-
Yes, it is how you should use fifo + dma. However since the cdc data is not time sensitive and the dma usage is new. It is currently only applied to audio driver. Why do you want to do fifo+dma in the first place ? |
Beta Was this translation helpful? Give feedback.
-
This might be enough
It builds but I need more time to use this in my code and see if it works. |
Beta Was this translation helpful? Give feedback.
-
I don't know if this was clear so far, in case you want to use the DMA, use the functions
to get the corresponding pointers and possible lengths to read/write. You must reduce the possible lenghts to your desired one (if you have any of course). As for audio class (i am not familiar with the details of CDC), you get a callback function called every time data is to be sent/received via USB interface or another callback function called when data was sent/received informing you that the corresponding FIFOs are empty now. You may add something like that into the CDC class driver to get informed when to update the DMA and when to advance the read/write pointers. |
Beta Was this translation helpful? Give feedback.
I don't know if this was clear so far, in case you want to use the DMA, use the functions
to get the corresponding pointers and possible lengths to read/write. You must reduce the possible lenghts to your desired one (if you have any of course). As for audio class (i am not familiar with the details of CDC), you get a callback function called every time data is to be sent/received via USB interface or another callback function called when data was sent/received informing you that the corresponding FIFOs are empty now. You may add something like t…