[−][src]Struct stm32f1xx_hal::adc::Adc
ADC configuration
Implementations
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]
PIN: Channel<ADC1, ID = u8>,
pub fn with_scan_dma<PINS>(self, pins: PINS, dma_ch: C1) -> AdcDma<PINS, Scan> where
Self: SetChannels<PINS>,
[src]
Self: SetChannels<PINS>,
Trait Implementations
impl ChannelTimeSequence for Adc<ADC1>
[src]
fn set_channel_sample_time(&mut self, chan: u8, sample_time: SampleTime)
[src]
fn set_regular_sequence(&mut self, channels: &[u8])
[src]
impl ChannelTimeSequence for Adc<ADC2>
[src]
fn set_channel_sample_time(&mut self, chan: u8, sample_time: SampleTime)
[src]
fn set_regular_sequence(&mut self, channels: &[u8])
[src]
impl<WORD, PIN> OneShot<ADC1, WORD, PIN> for Adc<ADC1> where
WORD: From<u16>,
PIN: Channel<ADC1, ID = u8>,
[src]
WORD: From<u16>,
PIN: Channel<ADC1, ID = u8>,
type Error = ()
Error type returned by ADC methods
fn read(&mut self, _pin: &mut PIN) -> Result<WORD, Self::Error>
[src]
impl<WORD, PIN> OneShot<ADC2, WORD, PIN> for Adc<ADC2> where
WORD: From<u16>,
PIN: Channel<ADC2, ID = u8>,
[src]
WORD: From<u16>,
PIN: Channel<ADC2, ID = u8>,
Auto Trait Implementations
impl<ADC> Send for Adc<ADC> where
ADC: Send,
ADC: Send,
impl<ADC> Sync for Adc<ADC> where
ADC: Sync,
ADC: Sync,
impl<ADC> Unpin for Adc<ADC> where
ADC: Unpin,
ADC: Unpin,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
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]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,