Struct stm32_hal2::adc::Adc[][src]

pub struct Adc<ADC> { /* fields omitted */ }

Analog to Digital converter peripheral

Implementations

impl Adc<ADC1>[src]

pub fn new_adc1<C: ClockCfg>(
    regs: ADC1,
    adc_common: &mut ADC_COMMON,
    ckmode: ClockMode,
    clocks: &C,
    rcc: &mut RCC
) -> Self
[src]

Init a new ADC

Enables the clock, performs a calibration and enables the ADC

Panics

If one of the following occurs:

  • the clocksetting is not well defined.
  • the clock was already enabled with a different setting

pub fn setup_oneshot(&mut self)[src]

sets up adc in one shot mode for a single channel

pub fn set_sequence_len(&mut self, len: u8)[src]

pub fn set_align(&self, align: Align)[src]

pub fn stop_conversions(&mut self)[src]

If any conversions are in progress, stop them. This is a step listed in the RMs for disable, and calibration procedures. See L4 RM: 16.4.17. When the ADSTP bit is set by software, any ongoing regular conversion is aborted with partial result discarded (ADC_DR register is not updated with the current conversion). When the JADSTP bit is set by software, any ongoing injected conversion is aborted with partial result discarded (ADC_JDRy register is not updated with the current conversion). The scan sequence is also aborted and reset (meaning that relaunching the ADC would restart a new sequence).

pub fn advregen_enable<C: ClockCfg>(&mut self, clocks: &C)[src]

Enable the voltage regulator, and exit deep sleep mode (some MCUs)

pub fn advregen_disable(&mut self)[src]

Disable power, eg to save power in low power modes. Inferred from RM, we should run this before entering STOP mode, in conjunction with with disabling the ADC.

pub fn calibrate<C: ClockCfg>(&mut self, input_type: InputType, clocks: &C)[src]

Calibrate. See L4 RM, 16.5.8, or F404 RM, section 15.3.8. Stores calibration values, which can be re-inserted later, eg after entering ADC deep sleep mode, or MCU STANDBY or VBAT.

pub fn inject_calibration(&mut self)[src]

Insert a previously-saved calibration value into the ADC. Se L4 RM, 16.4.8.

pub fn set_input_type(&mut self, channel: u8, input_type: InputType)[src]

Select single-ended, or differential conversions for a given channel.

pub fn start_conversion(&mut self, chan: u8, mode: OperationMode)[src]

Start a conversion: Either a single measurement, or continuous conversions. See L4 RM 16.4.15 for details.

pub fn read_result(&mut self) -> u16[src]

Read data from a conversion. In OneShot mode, this will generally be run right after start_conversion.

pub fn set_sample_time(&mut self, chan: u8, smp: SampleTime)[src]

Select the sample time for a given channel.

Trait Implementations

impl<WORD, PIN> OneShot<ADC1, WORD, PIN> for Adc<ADC1> where
    WORD: From<u16>,
    PIN: Channel<ADC1, ID = u8>, 
[src]

type Error = ()

Error type returned by ADC methods

Auto Trait Implementations

impl<ADC> Send for Adc<ADC> where
    ADC: Send

impl<ADC> Sync for Adc<ADC> where
    ADC: Sync

impl<ADC> Unpin for Adc<ADC> where
    ADC: Unpin

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.