Adc

Struct Adc 

Source
pub struct Adc<State> {
    pub onchip_channels: OnChipChannels,
    /* private fields */
}
Expand description

Interface for ADC Peripheral.

Returned by calling HALExt::split on the pac ADC structure. Holds state of peripheral.

Fields§

§onchip_channels: OnChipChannels

Contains the On-Chip ADC Channels, like the MCU’s temperature sensor.

Implementations§

Source§

impl Adc<Enabled>

Source

pub fn is_done(&self) -> bool

Poll to determine if ADC conversion is complete.

Note: This flag is cleared when the sampling mode is changed, interrupts are enabled, Adc::set_channel is called, and when Adc::result is called (including Adc::try_result)

Source

pub fn is_converting(&self) -> bool

Poll to determine if ADC conversion is underway

Source

pub fn result(&self) -> u16

Grab the last ADC conversion result.

Source

pub fn try_result(&self) -> Option<u16>

Poll for conversion completion, if done return the result.

Source

pub fn set_channel<T: Channel<Adc<Enabled>, ID = u8>>(&self, _pin: &T)

Set ADC target channel.

In Single conversion mode (OneShot), setting the channel begins the conversion. In FIFO mode the channel is added to the FIFO buffer.

Note: If the channel is changed while a conversion is in progress the current conversion will be cancelled. If in FIFO mode, conversion will resume once the FIFO channels are refilled.

Source

pub fn configure(self, config: AdcConfig) -> Adc<Enabled>

Set the ADC’s configuration

Source§

impl Adc<Disabled>

Source

pub fn enable(self) -> Adc<Enabled>

Connects the bus clock to the adc via the SIM peripheral, allowing read and write access to ADC registers.

Any attempt to access ADC registers while disabled results in a HardFault, generated by hardware.

This also enables the bandgap voltage reference.

Source

pub fn configure(self, config: AdcConfig) -> Adc<Enabled>

Set the ADC’s configuration

This is a sugar method for calling Adc::enable followed by Adc::configure

Source§

impl<Mode> Adc<Mode>

Source

pub fn into_interrupt(self) -> Adc<Mode>

Not Implemented

Source

pub fn into_fifo(self, _depth: u8) -> Adc<Mode>

Not Implemented

Source

pub fn into_continuous(self) -> Adc<Mode>

Not Implemented

Trait Implementations§

Source§

impl<OldMode> Channel<Adc<Enabled>> for Analog<Bandgap<OldMode>>

Source§

type ID = u8

Channel ID type Read more
Source§

fn channel() -> u8

Get the specific ID that identifies this channel, for example 0_u8 for the first ADC channel, if Self::ID is u8.
Source§

impl<OldMode> Channel<Adc<Enabled>> for Analog<DummyDisable<OldMode>>

Source§

type ID = u8

Channel ID type Read more
Source§

fn channel() -> u8

Get the specific ID that identifies this channel, for example 0_u8 for the first ADC channel, if Self::ID is u8.
Source§

impl<OldMode> Channel<Adc<Enabled>> for Analog<PTA0<OldMode>>

Source§

type ID = u8

Channel ID type Read more
Source§

fn channel() -> u8

Get the specific ID that identifies this channel, for example 0_u8 for the first ADC channel, if Self::ID is u8.
Source§

impl<OldMode> Channel<Adc<Enabled>> for Analog<PTA1<OldMode>>

Source§

type ID = u8

Channel ID type Read more
Source§

fn channel() -> u8

Get the specific ID that identifies this channel, for example 0_u8 for the first ADC channel, if Self::ID is u8.
Source§

impl<OldMode> Channel<Adc<Enabled>> for Analog<PTA6<OldMode>>

Source§

type ID = u8

Channel ID type Read more
Source§

fn channel() -> u8

Get the specific ID that identifies this channel, for example 0_u8 for the first ADC channel, if Self::ID is u8.
Source§

impl<OldMode> Channel<Adc<Enabled>> for Analog<PTA7<OldMode>>

Source§

type ID = u8

Channel ID type Read more
Source§

fn channel() -> u8

Get the specific ID that identifies this channel, for example 0_u8 for the first ADC channel, if Self::ID is u8.
Source§

impl<OldMode> Channel<Adc<Enabled>> for Analog<PTB0<OldMode>>

Source§

type ID = u8

Channel ID type Read more
Source§

fn channel() -> u8

Get the specific ID that identifies this channel, for example 0_u8 for the first ADC channel, if Self::ID is u8.
Source§

impl<OldMode> Channel<Adc<Enabled>> for Analog<PTB1<OldMode>>

Source§

type ID = u8

Channel ID type Read more
Source§

fn channel() -> u8

Get the specific ID that identifies this channel, for example 0_u8 for the first ADC channel, if Self::ID is u8.
Source§

impl<OldMode> Channel<Adc<Enabled>> for Analog<PTB2<OldMode>>

Source§

type ID = u8

Channel ID type Read more
Source§

fn channel() -> u8

Get the specific ID that identifies this channel, for example 0_u8 for the first ADC channel, if Self::ID is u8.
Source§

impl<OldMode> Channel<Adc<Enabled>> for Analog<PTB3<OldMode>>

Source§

type ID = u8

Channel ID type Read more
Source§

fn channel() -> u8

Get the specific ID that identifies this channel, for example 0_u8 for the first ADC channel, if Self::ID is u8.
Source§

impl<OldMode> Channel<Adc<Enabled>> for Analog<PTC0<OldMode>>

Source§

type ID = u8

Channel ID type Read more
Source§

fn channel() -> u8

Get the specific ID that identifies this channel, for example 0_u8 for the first ADC channel, if Self::ID is u8.
Source§

impl<OldMode> Channel<Adc<Enabled>> for Analog<PTC1<OldMode>>

Source§

type ID = u8

Channel ID type Read more
Source§

fn channel() -> u8

Get the specific ID that identifies this channel, for example 0_u8 for the first ADC channel, if Self::ID is u8.
Source§

impl<OldMode> Channel<Adc<Enabled>> for Analog<PTC2<OldMode>>

Source§

type ID = u8

Channel ID type Read more
Source§

fn channel() -> u8

Get the specific ID that identifies this channel, for example 0_u8 for the first ADC channel, if Self::ID is u8.
Source§

impl<OldMode> Channel<Adc<Enabled>> for Analog<PTC3<OldMode>>

Source§

type ID = u8

Channel ID type Read more
Source§

fn channel() -> u8

Get the specific ID that identifies this channel, for example 0_u8 for the first ADC channel, if Self::ID is u8.
Source§

impl<OldMode> Channel<Adc<Enabled>> for Analog<PTF4<OldMode>>

Source§

type ID = u8

Channel ID type Read more
Source§

fn channel() -> u8

Get the specific ID that identifies this channel, for example 0_u8 for the first ADC channel, if Self::ID is u8.
Source§

impl<OldMode> Channel<Adc<Enabled>> for Analog<PTF5<OldMode>>

Source§

type ID = u8

Channel ID type Read more
Source§

fn channel() -> u8

Get the specific ID that identifies this channel, for example 0_u8 for the first ADC channel, if Self::ID is u8.
Source§

impl<OldMode> Channel<Adc<Enabled>> for Analog<PTF6<OldMode>>

Source§

type ID = u8

Channel ID type Read more
Source§

fn channel() -> u8

Get the specific ID that identifies this channel, for example 0_u8 for the first ADC channel, if Self::ID is u8.
Source§

impl<OldMode> Channel<Adc<Enabled>> for Analog<PTF7<OldMode>>

Source§

type ID = u8

Channel ID type Read more
Source§

fn channel() -> u8

Get the specific ID that identifies this channel, for example 0_u8 for the first ADC channel, if Self::ID is u8.
Source§

impl<OldMode> Channel<Adc<Enabled>> for Analog<TempSense<OldMode>>

Source§

type ID = u8

Channel ID type Read more
Source§

fn channel() -> u8

Get the specific ID that identifies this channel, for example 0_u8 for the first ADC channel, if Self::ID is u8.
Source§

impl<OldMode> Channel<Adc<Enabled>> for Analog<VrefH<OldMode>>

Source§

type ID = u8

Channel ID type Read more
Source§

fn channel() -> u8

Get the specific ID that identifies this channel, for example 0_u8 for the first ADC channel, if Self::ID is u8.
Source§

impl<OldMode> Channel<Adc<Enabled>> for Analog<VrefL<OldMode>>

Source§

type ID = u8

Channel ID type Read more
Source§

fn channel() -> u8

Get the specific ID that identifies this channel, for example 0_u8 for the first ADC channel, if Self::ID is u8.
Source§

impl<OldMode> Channel<Adc<Enabled>> for Analog<Vss<OldMode>>

Source§

type ID = u8

Channel ID type Read more
Source§

fn channel() -> u8

Get the specific ID that identifies this channel, for example 0_u8 for the first ADC channel, if Self::ID is u8.
Source§

impl<Pin> OneShot<Adc<Enabled>, u16, Pin> for Adc<Enabled>
where Pin: Channel<Adc<Enabled>, ID = u8>,

Source§

type Error = Infallible

Error type returned by ADC methods
Source§

fn read(&mut self, pin: &mut Pin) -> Result<u16, Self::Error>

Request that the ADC begin a conversion on the specified pin Read more

Auto Trait Implementations§

§

impl<State> Freeze for Adc<State>

§

impl<State> RefUnwindSafe for Adc<State>
where State: RefUnwindSafe,

§

impl<State> Send for Adc<State>
where State: Send,

§

impl<State> !Sync for Adc<State>

§

impl<State> Unpin for Adc<State>
where State: Unpin,

§

impl<State> UnwindSafe for Adc<State>
where State: 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>,

Source§

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>,

Source§

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.