pub struct Adc<H, ADC: AdcOps<H>, CLOCK> { /* private fields */ }
Expand description

Analog-to-Digital Converter

let dp = atmega_hal::Peripherals::take().unwrap();
let pins = atmega_hal::pins!(dp);
let mut adc = atmega_hal::Adc::new(dp.ADC, Default::default());

let a0 = dp.pc0.into_analog_input(&mut adc);

// the following two calls are equivalent
let voltage = a0.analog_read(&mut adc);
let voltage = adc.read_blocking(&a0);

// alternatively, a non-blocking interface exists
let voltage = nb::block!(adc.read_nonblocking(&a0)).void_unwrap();

Implementations

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.