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 = 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
sourceimpl<H, ADC, CLOCK> Adc<H, ADC, CLOCK> where
ADC: AdcOps<H>,
CLOCK: Clock,
impl<H, ADC, CLOCK> Adc<H, ADC, CLOCK> where
ADC: AdcOps<H>,
CLOCK: Clock,
pub fn new(p: ADC, settings: ADC::Settings) -> Self
pub fn initialize(&mut self, settings: ADC::Settings)
pub fn read_blocking<PIN: AdcChannel<H, ADC>>(&mut self, pin: &PIN) -> u16
pub fn read_nonblocking<PIN: AdcChannel<H, ADC>>(
&mut self,
pin: &PIN
) -> Result<u16, Void>
Auto Trait Implementations
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
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more