-
Notifications
You must be signed in to change notification settings - Fork 60
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
Add support for continous conversions to ADC #86
Conversation
This is going to be useful to implement continuous or asynchronous one-shot modes.
`AdcExt` was mixed in between the `Adc` `impl` blocks.
I'm working on implementing other means of reading ADC values, so being able to reuse this method will be useful.
This doesn't do anything in itself, as the ADC API is currently not making use of this.
Add some crate-public methods that are useful when working with circular DMA transfers.
Without support for hardware triggers, this API is of limited use, as it's basically impossible to process the as fast as the ADC and DMA are producing it. Still, this puts in place a lot of infrastructure, and can be extended to become more useful.
There was a compiler warning when building for STM32L0x1/STM32L0x3. Fixing this involved dropping a commit, hence the force-push. |
CI failed due to an unrelated compiler warning. Pushed another commit to fix it. |
This change guards against some unexpected leftover configuration from earlier interferring with the desired operation of the ADC.
I added support for hardware triggers. Since this pull request hasn't been reviewed yet, I figured I'd just push the new commits here instead of creating a new pull request. This addition makes the new API fully useful. |
And two more commits, adding support for multi-channel conversions. I'm done now, I promise :-) |
It doesn't compile on the other targets.
CI was broken on non-STM32L0x2 targets. Pushed a commit that should fix that. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice inline documentation comments 🙂
Buf: DerefMut + 'static, | ||
Buf::Target: AsMutSlice<Element=u16>, | ||
DmaChan: dma::Channel, | ||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for this case of classical bikeshedding (I'm not qualified enough to review the actual logic), but do we apply rustfmt to this project?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, not as a general rule.
What a great feature! Thanks so much! |
Adds support for continuous conversions via DMA to the ADC API. This is of somewhat limited use (as the example shows), as it's impossible to process the data as fast as the ADC can produce it. It requires support for hardware triggers, to become fully usable.
However, this PR adds some valuable infrastructure, like circular DMA transfers and the DMA buffer code in
adc
. I think it's worth getting it merged, as it's a solid base to build upon (which I intend to do).