This implements continuous ADC reads of multiple channels using DMA and a circular buffer. Values should be able to be read directly from the buffer from any context, not just interrupts.
This is unsafe, but it's working and so gives a jumping off point for improvements. I'm not actually sure if the use-case is even possible in safe Rust.
Having to read_volatile because the transfer has &mut ownership over the buffer. There would also need to be an API to access this buffer from outside an interrupt context, where we might not have access to the transfer.
DmaConfig needs to be setup correctly (e.g. circular_buffer(true)), otherwise it won't work.
Anything else! I'm relatively new to embedded, and I'm sure there are tons of spots where this approach and code can be improved.
This implements continuous ADC reads of multiple channels using DMA and a circular buffer. Values should be able to be read directly from the buffer from any context, not just interrupts.
This is unsafe, but it's working and so gives a jumping off point for improvements. I'm not actually sure if the use-case is even possible in safe Rust.
Seeking ideas to improve:
u8
s instead of an array of pins.read_volatile
because the transfer has&mut
ownership over the buffer. There would also need to be an API to access this buffer from outside an interrupt context, where we might not have access to the transfer.DmaConfig
needs to be setup correctly (e.g.circular_buffer(true)
), otherwise it won't work.