pub struct Adc<'d, T: Instance> { /* private fields */ }
Expand description
Analog to Digital driver.
Implementations§
source§impl<'d, T: Instance> Adc<'d, T>
impl<'d, T: Instance> Adc<'d, T>
sourcepub fn into_ring_buffered(
self,
dma: impl Peripheral<P = impl RxDma<T>> + 'd,
dma_buf: &'d mut [u16],
) -> RingBufferedAdc<'d, T>
pub fn into_ring_buffered( self, dma: impl Peripheral<P = impl RxDma<T>> + 'd, dma_buf: &'d mut [u16], ) -> RingBufferedAdc<'d, T>
Configures the ADC to use a DMA ring buffer for continuous data acquisition.
The dma_buf
should be large enough to prevent DMA buffer overrun.
The length of the dma_buf
should be a multiple of the ADC channel count.
For example, if 3 channels are measured, its length can be 3 * 40 = 120 measurements.
read
method is used to read out measurements from the DMA ring buffer, and its buffer should be exactly half of the dma_buf
length.
It is critical to call read
frequently to prevent DMA buffer overrun.
source§impl<'d, T> Adc<'d, T>where
T: Instance,
impl<'d, T> Adc<'d, T>where
T: Instance,
pub fn new(adc: impl Peripheral<P = T> + 'd) -> Self
pub fn set_sample_time(&mut self, sample_time: SampleTime)
pub fn set_resolution(&mut self, resolution: Resolution)
sourcepub fn enable_vrefint(&self) -> VrefInt
pub fn enable_vrefint(&self) -> VrefInt
Enables internal voltage reference and returns VrefInt, which can be used in [Adc::read_internal()] to perform conversion.
sourcepub fn enable_temperature(&self) -> Temperature
pub fn enable_temperature(&self) -> Temperature
Enables internal temperature sensor and returns Temperature, which can be used in [Adc::read_internal()] to perform conversion.
On STM32F42 and STM32F43 this can not be used together with Vbat. If both are enabled, temperature sensor will return vbat value.
sourcepub fn enable_vbat(&self) -> Vbat
pub fn enable_vbat(&self) -> Vbat
Enables vbat input and returns Vbat, which can be used in [Adc::read_internal()] to perform conversion.