Skip to main content

Adc

Struct Adc 

Source
pub struct Adc<'d, ADC, Dm: DriverMode> { /* private fields */ }
Available on crate feature unstable only.
Expand description

Analog-to-Digital Converter peripheral driver.

Implementations§

Source§

impl<'d, ADCX> Adc<'d, ADCX, Blocking>
where ADCX: RegisterAccess + 'd,

Source

pub fn new(adc_instance: ADCX, config: AdcConfig<ADCX>) -> Result<Self, Error>

Configures a given ADC instance using the provided configuration, and initializes the ADC for use.

§Errors

Returns Error::Adc2InUse if ADC2 is already in use by the radio. ADC2 cannot be used simultaneously with radio functionalities. The handle is consumed even on failure; pass a reborrowed handle to retry later.

Source

pub fn read_oneshot<PIN, CS>( &mut self, pin: &mut AdcPin<PIN, ADCX, CS>, ) -> Result<u16, Error>
where PIN: AdcChannel, CS: AdcCalScheme<ADCX>,

Requests that the ADC begin a conversion on the specified pin.

Takes an AdcPin reference, as it is expected that the ADC will be able to sample whatever channel underlies the pin.

§Errors

Returns Error::ChannelNotConfigured if the channel was not configured in AdcConfig.

Trait Implementations§

Source§

impl<ADC, Dm: DriverMode> Drop for Adc<'_, ADC, Dm>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

Auto Trait Implementations§

§

impl<'d, ADC, Dm> !UnwindSafe for Adc<'d, ADC, Dm>

§

impl<'d, ADC, Dm> Freeze for Adc<'d, ADC, Dm>
where ADC: Freeze,

§

impl<'d, ADC, Dm> RefUnwindSafe for Adc<'d, ADC, Dm>
where ADC: RefUnwindSafe, Dm: RefUnwindSafe,

§

impl<'d, ADC, Dm> Send for Adc<'d, ADC, Dm>
where ADC: Send, Dm: Send,

§

impl<'d, ADC, Dm> Sync for Adc<'d, ADC, Dm>
where ADC: Sync, Dm: Sync,

§

impl<'d, ADC, Dm> Unpin for Adc<'d, ADC, Dm>
where ADC: Unpin, Dm: Unpin,

§

impl<'d, ADC, Dm> UnsafeUnpin for Adc<'d, ADC, Dm>
where ADC: UnsafeUnpin,

Blanket Implementations§

§

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

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

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

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

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

§

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

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

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

§

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> Same for T

Source§

type Output = T

Should always be Self
§

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

§

type Error = Infallible

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

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

Performs the conversion.
§

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.
§

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

Performs the conversion.