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

Reimplement ADC HAL #163

Merged
merged 6 commits into from
Mar 13, 2021
Merged

Reimplement ADC HAL #163

merged 6 commits into from
Mar 13, 2021

Conversation

Rahix
Copy link
Owner

@Rahix Rahix commented Mar 13, 2021

Re-implementation of the ADC HAL and support for all MCUs in atmega-hal. Also addressed issue #33 already.

Notably, I dropped the implementation of the embedded-hal ADC traits for now. As discussed in #33 they are currently unfit for the purpose and instead of bending over backwards, I dropped them with the intention to re-add an implementation once embedded-hal hits 1.0.

Downstream code will look like this now:

@Rahix Rahix added the hal-api API design for the different components of avr-hal label Mar 13, 2021
@Rahix Rahix added this to the New APIs milestone Mar 13, 2021
@Rahix Rahix marked this pull request as draft March 13, 2021 10:16
@Rahix Rahix changed the base branch from master to next March 13, 2021 10:16
Reimplement the ADC HAL with a design similar to the other new
implementations.  This means we have a common `Adc<...>` type defined in
avr-hal-generic which internally uses a concrete ADC peripheral which
implements the `AdcOps` trait.

Additionally, an `AdcChannel` trait is used to mark channels which can
be used with a certain ADC.
Add necessary plumbing to use IO pins as ADC channels.  This consists
of:

 - The `into_analog_input()` method to "convert" an IO pin into an ADC
   channel.  Under the hood, this sets the "DIDR" (Digital Input
   Disable) bit.

 - The `analog_read()` method for ADC pins.  This is sugar for calling
   `adc.read_blocking(&pin)`, to provide an API that's close the the one
   commonly used in the Arduino world.
Implement ADC support for all currently supported ATmega
microcontrollers.
Reexport the `adc` module from the HAL crate to make the ADC easily
usable.
Add a type that can represent any channel for e.g. storing a list of
channels in an array.

Ref: #33
Add ADC examples for all boards to demonstrate how to read from the
analog pins.
@Rahix Rahix marked this pull request as ready for review March 13, 2021 17:28
@Rahix Rahix merged commit af926bd into next Mar 13, 2021
@Rahix Rahix deleted the new-adc branch March 13, 2021 17:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hal-api API design for the different components of avr-hal
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant