Struct imxrt_hal::adc::Adc

source ·
pub struct Adc<const N: u8> { /* private fields */ }
Expand description

The ADC driver.

The ADC starts out with a default configuration of 4 hardware samples, a conversion speed of medium, a resolution of 10 bits, and low power mode disabled. It’s also pre-calibrated using 32 averages and a slow conversion speed.

Implementations§

source§

impl<const N: u8> Adc<N>

source

pub fn new( reg: Instance<N>, clock: ClockSelect, division: ClockDivision ) -> Self

Constuct an ADC from a RAL ADC instance

source

pub fn set_resolution(&mut self, bits: ResolutionBits)

Sets the resolution that analog reads return, in bits

source

pub fn set_averaging(&mut self, avg: AveragingCount)

Sets the number of hardware averages taken by the ADC

source

pub fn set_conversion_speed(&mut self, conversion_speed: ConversionSpeed)

Sets the conversion speed for this ADC, see ConversionSpeed for clock cycle counts.

source

pub fn set_low_power_mode(&mut self, state: bool)

Enables or disables the low power configuration in the ADC. This does limit the ADACK clock frequency (<= 20MHz)

source

pub fn calibrate(&mut self)

Calibrates the ADC, will wait for finish

source

pub fn read_blocking<P>(&mut self, _: &mut AnalogInput<P, N>) -> u16
where P: Pin<N>,

Perform a blocking read for an ADC sample.

source

pub fn read_blocking_channel(&mut self, channel: u32) -> u16

Perform a blocking read using the specified ADC channel.

Unlike read_blocking(), which ensures that the pin is configured as an ADC input, you’re responsible for configuring the pin as an ADC input before using this method. Otherwise, this method may not produce a (correct) value.

Panics

Panics if the ADC channel is greater than 15.

source

pub fn release(self) -> Instance<N>

Release the ADC’s register block.

You can use this to re-construct the driver with new configurations.

Auto Trait Implementations§

§

impl<const N: u8> !RefUnwindSafe for Adc<N>

§

impl<const N: u8> Send for Adc<N>

§

impl<const N: u8> !Sync for Adc<N>

§

impl<const N: u8> Unpin for Adc<N>

§

impl<const N: u8> !UnwindSafe for Adc<N>

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.