Struct stm32_hal2::adc::Adc [−][src]
pub struct Adc<R> { /* fields omitted */ }
Expand description
Represents an Analog to Digital Converter (ADC) peripheral.
Implementations
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
sets up adc in one shot mode for a single channel
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).
Enable the voltage regulator, and exit deep sleep mode (some MCUs)
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.
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.
Insert a previously-saved calibration value into the ADC. Se L4 RM, 16.4.8.
Select single-ended, or differential conversions for a given channel.
Select a sequence to sample, by inputting a single channel and position.
Select the sample time for a given channel.
Convert a raw measurement into a voltage in Volts, using the calibrated VDDA. See RM0394, section 16.4.34
Start a conversion: Either a single measurement, or continuous conversions. See L4 RM 16.4.15 for details.
Read data from a conversion. In OneShot mode, this will generally be run right
after start_conversion
.
pub unsafe fn read_dma<D>(
&mut self,
buf: &mut [u16],
adc_channel: u8,
dma_channel: DmaChannel,
dma: &mut Dma<D>
) where
D: Deref<Target = RegisterBlock>,
pub unsafe fn read_dma<D>(
&mut self,
buf: &mut [u16],
adc_channel: u8,
dma_channel: DmaChannel,
dma: &mut Dma<D>
) where
D: Deref<Target = RegisterBlock>,
Take a one shot reading, using DMA. See L44 RM, 16.4.27: “DMA one shot mode”.
Note that the channel
argument is only used on F3 and L4.
Enable a specific type of ADC interrupt.
Clear an interrupt flag of the specified type. Consider running this in the corresponding ISR.