ADC

Struct ADC 

Source
pub struct ADC { /* private fields */ }
Expand description

Analog to Digital converter interface

Implementations§

Source§

impl ADC

Source

pub fn new( adc: ADC1, common: ADC_COMMON, ahb: &mut AHB2, ccipr: &mut CCIPR, delay: &mut impl DelayUs<u32>, ) -> Self

Initialize the ADC

Source

pub fn enable_vref(&mut self, delay: &mut impl DelayUs<u32>) -> Vref

Enable and get the Vref

Source

pub fn enable_temperature( &mut self, delay: &mut impl DelayUs<u32>, ) -> Temperature

Enable and get the Temperature

Source

pub fn enable_vbat(&mut self) -> Vbat

Enable and get the Vbat

Source

pub fn calibrate(&mut self, vref: &mut Vref)

Calculates the system VDDA by sampling the internal VREF channel and comparing the result with the value stored at the factory. If the chip’s VDDA is not stable, run this before each ADC conversion.

Source

pub fn set_resolution(&mut self, resolution: Resolution)

Set the ADC resolution

Source

pub fn set_sample_time(&mut self, sample_time: SampleTime)

Set the sample time

Source

pub fn get_max_value(&self) -> u16

Get the max value for the current resolution

Source

pub fn release(self) -> (ADC1, ADC_COMMON)

Release the ADC peripheral

Drops ADC and returns the (pac::ADC, pad::ADC_COMMON) that is was wrapping, giving the user full access to the peripheral.

Source

pub fn to_millivolts(&self, sample: u16) -> u16

Convert a measurement to millivolts

Source

pub fn to_degrees_centigrade(&self, sample: u16) -> f32

Convert a raw sample from the Temperature to deg C

Source

pub fn get_data(&self) -> u16

Source

pub fn configure_sequence<C>( &mut self, channel: &mut C, sequence: Sequence, sample_time: SampleTime, )
where C: Channel,

Configure the channel for a specific step in the sequence.

Automatically sets the sequence length to the farthes sequence index that has been used so far. Use ADC::reset_sequence to reset the sequence length.

Source

pub fn reset_sequence(&mut self)

Reset the sequence length to 1

Does not erase previously configured sequence settings, only changes the sequence length

Source

pub fn has_completed_conversion(&self) -> bool

Source

pub fn has_completed_sequence(&self) -> bool

Source

pub fn clear_end_flags(&mut self)

Source

pub fn start_conversion(&mut self)

Source

pub fn is_converting(&self) -> bool

Source

pub fn listen(&mut self, event: Event)

Source

pub fn unlisten(&mut self, event: Event)

Source

pub fn enable(&mut self)

Source

pub fn is_enabled(&self) -> bool

Source

pub fn disable(&mut self)

Trait Implementations§

Source§

impl Channel<ADC> for PA0<Analog>

Source§

type ID = u8

Channel ID type Read more
Source§

fn channel() -> Self::ID

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

impl Channel<ADC> for PA1<Analog>

Source§

type ID = u8

Channel ID type Read more
Source§

fn channel() -> Self::ID

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

impl Channel<ADC> for PA2<Analog>

Source§

type ID = u8

Channel ID type Read more
Source§

fn channel() -> Self::ID

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

impl Channel<ADC> for PA3<Analog>

Source§

type ID = u8

Channel ID type Read more
Source§

fn channel() -> Self::ID

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

impl Channel<ADC> for PA4<Analog>

Source§

type ID = u8

Channel ID type Read more
Source§

fn channel() -> Self::ID

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

impl Channel<ADC> for PA5<Analog>

Source§

type ID = u8

Channel ID type Read more
Source§

fn channel() -> Self::ID

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

impl Channel<ADC> for PA6<Analog>

Source§

type ID = u8

Channel ID type Read more
Source§

fn channel() -> Self::ID

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

impl Channel<ADC> for PA7<Analog>

Source§

type ID = u8

Channel ID type Read more
Source§

fn channel() -> Self::ID

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

impl Channel<ADC> for PB0<Analog>

Source§

type ID = u8

Channel ID type Read more
Source§

fn channel() -> Self::ID

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

impl Channel<ADC> for PB1<Analog>

Source§

type ID = u8

Channel ID type Read more
Source§

fn channel() -> Self::ID

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

impl Channel<ADC> for PC0<Analog>

Source§

type ID = u8

Channel ID type Read more
Source§

fn channel() -> Self::ID

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

impl Channel<ADC> for PC1<Analog>

Source§

type ID = u8

Channel ID type Read more
Source§

fn channel() -> Self::ID

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

impl Channel<ADC> for PC2<Analog>

Source§

type ID = u8

Channel ID type Read more
Source§

fn channel() -> Self::ID

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

impl Channel<ADC> for PC3<Analog>

Source§

type ID = u8

Channel ID type Read more
Source§

fn channel() -> Self::ID

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

impl Channel<ADC> for PC4<Analog>

Source§

type ID = u8

Channel ID type Read more
Source§

fn channel() -> Self::ID

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

impl Channel<ADC> for PC5<Analog>

Source§

type ID = u8

Channel ID type Read more
Source§

fn channel() -> Self::ID

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

impl Channel<ADC> for Temperature

Source§

type ID = u8

Channel ID type Read more
Source§

fn channel() -> Self::ID

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

impl Channel<ADC> for Vbat

Source§

type ID = u8

Channel ID type Read more
Source§

fn channel() -> Self::ID

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

impl Channel<ADC> for Vref

Source§

type ID = u8

Channel ID type Read more
Source§

fn channel() -> Self::ID

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

impl<C> OneShot<ADC, u16, C> for ADC
where C: Channel,

Source§

type Error = Infallible

Error type returned by ADC methods
Source§

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

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

Auto Trait Implementations§

§

impl Freeze for ADC

§

impl RefUnwindSafe for ADC

§

impl Send for ADC

§

impl !Sync for ADC

§

impl Unpin for ADC

§

impl UnwindSafe for ADC

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.