adafruit / Adafruit_ZeroDMA

DMA helper/wrapped for ATSAMD21 such as Arduino Zero & Feather M0
MIT License
58 stars 23 forks source link

Add option for setting block interrupts #8

Open deanm1278 opened 6 years ago

deanm1278 commented 6 years ago

To avoid dropouts in audio or video while using ping-pong style buffers it's necessary for the system to be notified when a buffer is done transmitting so a new buffer can be filled, but have the DMAC continue on seamlessly to the next descriptor in the list. This can be done by setting desc->BTCTRL.bit.BLOCKACT = DMA_BLOCK_ACTION_INT The current library fixes this bit to desc->BTCTRL.bit.BLOCKACT = DMA_BLOCK_ACTION_NOACT and the user must change it manually in the descriptor.

It would be nice if we could add a setBlockact(action) method or something

dfl commented 4 years ago

I agree, it would be nice to have something explicit in the API. BTW I've made an example that makes use of this DMA_BLOCK_ACTION_INT mode, writing an audio buffer directly and then playing it seamlessly. It's not ping-pong, just a very short snippet of synthesized sine wave. https://github.com/dfl/Adafruit_ZeroDMA_I2S_DSP_example