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>
impl<H, ADC, CLOCK> Adc<H, ADC, 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, Infallible>
Auto Trait Implementations§
impl<H, ADC, CLOCK> Freeze for Adc<H, ADC, CLOCK>
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>
impl<H, ADC, CLOCK> Sync for Adc<H, ADC, CLOCK>
impl<H, ADC, CLOCK> Unpin for Adc<H, ADC, CLOCK>
impl<H, ADC, CLOCK> UnwindSafe for Adc<H, ADC, CLOCK>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more