pub struct Adc4<'d, T: Instance> { /* private fields */ }
Implementations§
Source§impl<'d, T: Instance> Adc4<'d, T>
impl<'d, T: Instance> Adc4<'d, T>
Sourcepub fn new(adc: impl Peripheral<P = T> + 'd) -> Self
pub fn new(adc: impl Peripheral<P = T> + 'd) -> Self
Create a new ADC driver.
Sourcepub fn enable_vrefint(&self) -> VrefInt
pub fn enable_vrefint(&self) -> VrefInt
Enable reading the voltage reference internal channel.
Sourcepub fn enable_temperature(&self) -> Temperature
pub fn enable_temperature(&self) -> Temperature
Enable reading the temperature internal channel.
Sourcepub fn enable_vbat(&self) -> Vbat
pub fn enable_vbat(&self) -> Vbat
Enable reading the vbat internal channel.
Sourcepub fn enable_vcore(&self) -> Vcore
pub fn enable_vcore(&self) -> Vcore
Enable reading the vbat internal channel.
Sourcepub fn enable_dac_channel(&self, dac: DacChannel) -> Dac
pub fn enable_dac_channel(&self, dac: DacChannel) -> Dac
Enable reading the vbat internal channel.
Sourcepub fn set_sample_time(&mut self, sample_time: SampleTime)
pub fn set_sample_time(&mut self, sample_time: SampleTime)
Set the ADC sample time.
Sourcepub fn sample_time(&self) -> SampleTime
pub fn sample_time(&self) -> SampleTime
Get the ADC sample time.
Sourcepub fn set_resolution(&mut self, resolution: Resolution)
pub fn set_resolution(&mut self, resolution: Resolution)
Set the ADC resolution.
Sourcepub fn set_averaging(&mut self, averaging: Averaging)
pub fn set_averaging(&mut self, averaging: Averaging)
Set hardware averaging.
Sourcepub fn blocking_read(&mut self, channel: &mut impl AdcChannel<T>) -> u16
pub fn blocking_read(&mut self, channel: &mut impl AdcChannel<T>) -> u16
Read an ADC channel.
Sourcepub async fn read(
&mut self,
rx_dma: &mut impl RxDma4<T>,
sequence: impl ExactSizeIterator<Item = &mut AnyAdcChannel<T>>,
readings: &mut [u16],
) -> Result<(), Adc4Error>
pub async fn read( &mut self, rx_dma: &mut impl RxDma4<T>, sequence: impl ExactSizeIterator<Item = &mut AnyAdcChannel<T>>, readings: &mut [u16], ) -> Result<(), Adc4Error>
Read one or multiple ADC channels using DMA.
sequence
iterator and readings
must have the same length.
The channels in sequence
must be in ascending order.
Example
ⓘ
use embassy_stm32::adc::adc4;
use embassy_stm32::adc::AdcChannel;
let mut adc4 = adc4::Adc4::new(p.ADC4);
let mut adc4_pin1 = p.PC1;
let mut adc4_pin2 = p.PC0;
let mut degraded41 = adc4_pin1.degrade_adc();
let mut degraded42 = adc4_pin2.degrade_adc();
let mut measurements = [0u16; 2];
// not that the channels must be in ascending order
adc4.read(
&mut p.GPDMA1_CH1,
[
&mut degraded42,
&mut degraded41,
]
.into_iter(),
&mut measurements,
).await.unwrap();
Auto Trait Implementations§
impl<'d, T> Freeze for Adc4<'d, T>where
T: Freeze,
impl<'d, T> RefUnwindSafe for Adc4<'d, T>where
T: RefUnwindSafe,
impl<'d, T> Send for Adc4<'d, T>where
T: Send,
impl<'d, T> Sync for Adc4<'d, T>where
T: Sync,
impl<'d, T> Unpin for Adc4<'d, T>where
T: Unpin,
impl<'d, T> !UnwindSafe for Adc4<'d, T>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more