Struct Adc

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

Analog to Digital converter interface

Implementations§

Source§

impl Adc

Source

pub fn new(adc: ADC, rcc: &mut Rcc) -> Self

Init a new Adc

Sets all configurable parameters to defaults, enables the HSI14 clock for the ADC if it is not already enabled and performs a boot time calibration. As such this method may take an appreciable time to run.

Source

pub fn save_cfg(&mut self) -> StoredConfig

Saves a copy of the current ADC config

Source

pub fn restore_cfg(&mut self, cfg: StoredConfig)

Restores a stored config

Source

pub fn default_cfg(&mut self) -> StoredConfig

Resets the ADC config to default, returning the existing config as a stored config.

Source

pub fn set_sample_time(&mut self, t_samp: AdcSampleTime)

Set the Adc sampling time

Options can be found in AdcSampleTime.

Source

pub fn set_align(&mut self, align: AdcAlign)

Set the Adc result alignment

Options can be found in AdcAlign.

Source

pub fn set_precision(&mut self, precision: AdcPrecision)

Set the Adc precision

Options can be found in AdcPrecision.

Source

pub fn max_sample(&self) -> u16

Returns the largest possible sample value for the current settings

Source

pub fn read_abs_mv<PIN: Channel<Adc, ID = u8>>(&mut self, pin: &mut PIN) -> u16

Read the value of a channel and converts the result to milli-volts

Trait Implementations§

Source§

impl Channel<Adc> for PA0<Analog>

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 Channel<Adc> for PA1<Analog>

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 Channel<Adc> for PA2<Analog>

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 Channel<Adc> for PA3<Analog>

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 Channel<Adc> for PA4<Analog>

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 Channel<Adc> for PA5<Analog>

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 Channel<Adc> for PA6<Analog>

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 Channel<Adc> for PA7<Analog>

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 Channel<Adc> for PB0<Analog>

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 Channel<Adc> for PB1<Analog>

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 Channel<Adc> for VBat

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 Channel<Adc> for VRef

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 Channel<Adc> for VTemp

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<WORD, PIN> OneShot<Adc, WORD, PIN> for Adc
where WORD: From<u16>, PIN: Channel<Adc, ID = u8>,

Source§

type Error = ()

Error type returned by ADC methods
Source§

fn read(&mut self, _pin: &mut PIN) -> Result<WORD, 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.