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

Add support for continous conversions to ADC #86

Merged
merged 20 commits into from
Mar 27, 2020
Merged

Add support for continous conversions to ADC #86

merged 20 commits into from
Mar 27, 2020

Conversation

hannobraun
Copy link
Contributor

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).

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.
@hannobraun
Copy link
Contributor Author

There was a compiler warning when building for STM32L0x1/STM32L0x3. Fixing this involved dropping a commit, hence the force-push.

@hannobraun
Copy link
Contributor Author

CI failed due to an unrelated compiler warning. Pushed another commit to fix it.

@hannobraun
Copy link
Contributor Author

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.

@hannobraun
Copy link
Contributor Author

And two more commits, adding support for multi-channel conversions. I'm done now, I promise :-)

@hannobraun hannobraun mentioned this pull request Mar 25, 2020
It doesn't compile on the other targets.
@hannobraun
Copy link
Contributor Author

hannobraun commented Mar 26, 2020

CI was broken on non-STM32L0x2 targets. Pushed a commit that should fix that.

Copy link
Contributor

@dbrgn dbrgn left a 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,
{
Copy link
Contributor

@dbrgn dbrgn Mar 26, 2020

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?

Copy link
Contributor Author

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.

@arkorobotics arkorobotics merged commit 6700dbc into stm32-rs:master Mar 27, 2020
@arkorobotics
Copy link
Member

What a great feature! Thanks so much!

@hannobraun hannobraun deleted the adc branch March 30, 2020 10:24
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.

None yet

3 participants