Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(adc): spike for ADC reads using DMA w/ circular buffer #442

Closed
wants to merge 1 commit into from

Conversation

dobrite
Copy link

@dobrite dobrite commented Jul 28, 2023

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:

  • Needing to pass in an array of u8s instead of an array of pins.
  • 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.

examples/adc_dma_circ.rs Outdated Show resolved Hide resolved
@dobrite
Copy link
Author

dobrite commented Sep 1, 2023

Closing as no interest.

@dobrite dobrite closed this Sep 1, 2023
@dobrite dobrite deleted the do/feat-adc-dma-circ branch September 1, 2023 14:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants