Struct avr_hal_generic::adc::Adc

source ·
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 = pins.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)).unwrap_infallible();

Implementations§

source§

impl<H, ADC, CLOCK> Adc<H, ADC, CLOCK>
where ADC: AdcOps<H>, CLOCK: Clock,

source

pub fn new(p: ADC, settings: ADC::Settings) -> Self

source

pub fn initialize(&mut self, settings: ADC::Settings)

source

pub fn read_blocking<PIN: AdcChannel<H, ADC>>(&mut self, pin: &PIN) -> u16

source

pub fn read_nonblocking<PIN: AdcChannel<H, ADC>>( &mut self, pin: &PIN ) -> Result<u16, Infallible>

Auto Trait Implementations§

§

impl<H, ADC, CLOCK> Freeze for Adc<H, ADC, CLOCK>
where ADC: Freeze, <ADC as AdcOps<H>>::Channel: Freeze,

§

impl<H, ADC, CLOCK> RefUnwindSafe for Adc<H, ADC, CLOCK>
where ADC: RefUnwindSafe, CLOCK: RefUnwindSafe, H: RefUnwindSafe, <ADC as AdcOps<H>>::Channel: RefUnwindSafe,

§

impl<H, ADC, CLOCK> Send for Adc<H, ADC, CLOCK>
where ADC: Send, CLOCK: Send, H: Send, <ADC as AdcOps<H>>::Channel: Send,

§

impl<H, ADC, CLOCK> Sync for Adc<H, ADC, CLOCK>
where ADC: Sync, CLOCK: Sync, H: Sync, <ADC as AdcOps<H>>::Channel: Sync,

§

impl<H, ADC, CLOCK> Unpin for Adc<H, ADC, CLOCK>
where ADC: Unpin, CLOCK: Unpin, H: Unpin, <ADC as AdcOps<H>>::Channel: Unpin,

§

impl<H, ADC, CLOCK> UnwindSafe for Adc<H, ADC, CLOCK>
where ADC: UnwindSafe, CLOCK: UnwindSafe, H: UnwindSafe, <ADC as AdcOps<H>>::Channel: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

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

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.