embassy-stm32

Crates

git

Versions

stm32u5g9nj

Flavors

embassy_stm32::adc::adc4

Struct Adc4

Source
pub struct Adc4<'d, T: Instance> { /* private fields */ }

Implementations§

Source§

impl<'d, T: Instance> Adc4<'d, T>

Source

pub fn new(adc: impl Peripheral<P = T> + 'd) -> Self

Create a new ADC driver.

Source

pub fn enable_vrefint(&self) -> VrefInt

Enable reading the voltage reference internal channel.

Source

pub fn enable_temperature(&self) -> Temperature

Enable reading the temperature internal channel.

Source

pub fn enable_vbat(&self) -> Vbat

Enable reading the vbat internal channel.

Source

pub fn enable_vcore(&self) -> Vcore

Enable reading the vbat internal channel.

Source

pub fn enable_dac_channel(&self, dac: DacChannel) -> Dac

Enable reading the vbat internal channel.

Source

pub fn set_sample_time(&mut self, sample_time: SampleTime)

Set the ADC sample time.

Source

pub fn sample_time(&self) -> SampleTime

Get the ADC sample time.

Source

pub fn set_resolution(&mut self, resolution: Resolution)

Set the ADC resolution.

Source

pub fn set_averaging(&mut self, averaging: Averaging)

Set hardware averaging.

Source

pub fn blocking_read(&mut self, channel: &mut impl AdcChannel<T>) -> u16

Read an ADC channel.

Source

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.