[][src]Struct stm32f1xx_hal::adc::Adc

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

ADC configuration

Methods

impl Adc<ADC1>[src]

pub fn read_temp(&mut self) -> i32[src]

Temperature sensor is connected to channel 16 on ADC1. This sensor can be used to measure ambient temperature of the device. However note that the returned value is not an absolute temperature value.

In particular, according to section 11.10 from Reference Manual RM0008 Rev 20: "The temperature sensor output voltage changes linearly with temperature. The offset of this line varies from chip to chip due to process variation (up to 45 °C from one chip to another). The internal temperature sensor is more suited to applications that detect temperature variations instead of absolute temperatures. If accurate temperature readings are needed, an external temperature sensor part should be used."

Formula to calculate temperature value is also taken from the section 11.10.

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

Internal reference voltage Vrefint is connected to channel 17 on ADC1. According to section 5.3.4 "Embedded reference voltage" from STM32F1xx datasheets, typical value of this reference voltage is 1200 mV.

This value is useful when ADC readings need to be converted into voltages. For instance, reading from any ADC channel can be converted into voltage (mV) using the following formula: v_chan = adc.read(chan) * 1200 / adc.read_vref()

impl Adc<ADC1>[src]

pub fn adc1(adc: ADC1, apb2: &mut APB2, clocks: Clocks) -> Self[src]

Init a new Adc

Sets all configurable parameters to one-shot defaults, performs a boot-time calibration.

pub fn save_cfg(&mut self) -> StoredConfig[src]

Save current ADC config

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

Restore saved ADC config

pub fn default_cfg(&mut self) -> StoredConfig[src]

Reset the ADC config to default, return existing config

pub fn set_sample_time(&mut self, t_samp: SampleTime)[src]

Set ADC sampling time

Options can be found in SampleTime.

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

Set the Adc result alignment

Options can be found in Align.

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

Returns the largest possible sample value for the current settings

pub fn set_external_trigger(&mut self, trigger: EXTSEL_A)[src]

pub fn release(self, apb2: &mut APB2) -> ADC1[src]

Powers down the ADC, disables the ADC clock and releases the ADC Peripheral

impl Adc<ADC2>[src]

pub fn adc2(adc: ADC2, apb2: &mut APB2, clocks: Clocks) -> Self[src]

Init a new Adc

Sets all configurable parameters to one-shot defaults, performs a boot-time calibration.

pub fn save_cfg(&mut self) -> StoredConfig[src]

Save current ADC config

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

Restore saved ADC config

pub fn default_cfg(&mut self) -> StoredConfig[src]

Reset the ADC config to default, return existing config

pub fn set_sample_time(&mut self, t_samp: SampleTime)[src]

Set ADC sampling time

Options can be found in SampleTime.

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

Set the Adc result alignment

Options can be found in Align.

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

Returns the largest possible sample value for the current settings

pub fn set_external_trigger(&mut self, trigger: EXTSEL_A)[src]

pub fn release(self, apb2: &mut APB2) -> ADC2[src]

Powers down the ADC, disables the ADC clock and releases the ADC Peripheral

impl Adc<ADC1>[src]

pub fn with_dma<PIN>(self, pins: PIN, dma_ch: C1) -> AdcDma<PIN, Continuous> where
    PIN: Channel<ADC1, ID = u8>, 
[src]

pub fn with_scan_dma<PINS>(self, pins: PINS, dma_ch: C1) -> AdcDma<PINS, Scan> where
    Self: SetChannels<PINS>, 
[src]

Trait Implementations

impl ChannelTimeSequence for Adc<ADC1>[src]

impl ChannelTimeSequence for Adc<ADC2>[src]

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

impl<WORD, PIN> OneShot<ADC2, WORD, PIN> for Adc<ADC2> where
    WORD: From<u16>,
    PIN: Channel<ADC2, 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.