embassy-stm32

Crates

git

Versions

stm32l053c6

Flavors

๐Ÿ“ฃ We want to hear from you! Fill the Rust Embedded 2024 micro-survey.

Struct embassy_stm32::dac::Dac

source ยท
pub struct Dac<'d, T: Instance, DMACh1 = NoDma, DMACh2 = NoDma> { /* private fields */ }
Expand description

DAC driver.

Use this struct when you want to use both channels, either together or independently.

ยงExample

โ“˜
// Pins may need to be changed for your specific device.
let (dac_ch1, dac_ch2) = embassy_stm32::dac::Dac::new(p.DAC1, NoDma, NoDma, p.PA4, p.PA5).split();

Implementationsยง

sourceยง

impl<'d, T: Instance, DMACh1, DMACh2> Dac<'d, T, DMACh1, DMACh2>

source

pub fn new( _peri: impl Peripheral<P = T> + 'd, dma_ch1: impl Peripheral<P = DMACh1> + 'd, dma_ch2: impl Peripheral<P = DMACh2> + 'd, pin_ch1: impl Peripheral<P = impl DacPin<T, 1> + Pin> + 'd, pin_ch2: impl Peripheral<P = impl DacPin<T, 2> + Pin> + 'd, ) -> Self

Create a new Dac instance, consuming the underlying DAC peripheral.

This struct allows you to access both channels of the DAC, where available. You can either call split() to obtain separate DacChannels, or use methods on Dac to use the two channels together.

The channels are enabled on creation and begin to drive their output pins. Note that some methods, such as set_trigger() and set_mode(), will disable the channel; you must re-enable them with enable().

By default, triggering is disabled, but it can be enabled using the set_trigger() method on the underlying channels.

source

pub fn split(self) -> (DacCh1<'d, T, DMACh1>, DacCh2<'d, T, DMACh2>)

Split this Dac into separate channels.

You can access and move the channels around separately after splitting.

source

pub fn ch1(&mut self) -> &mut DacCh1<'d, T, DMACh1>

Temporarily access channel 1.

source

pub fn ch2(&mut self) -> &mut DacCh2<'d, T, DMACh2>

Temporarily access channel 2.

source

pub fn set(&mut self, values: DualValue)

Simultaneously update channels 1 and 2 with a new value.

If triggering is not enabled, the new values are immediately output; otherwise, they will be output after the next trigger.

Auto Trait Implementationsยง

ยง

impl<'d, T, DMACh1, DMACh2> Freeze for Dac<'d, T, DMACh1, DMACh2>
where DMACh1: Freeze, DMACh2: Freeze,

ยง

impl<'d, T, DMACh1, DMACh2> RefUnwindSafe for Dac<'d, T, DMACh1, DMACh2>
where DMACh1: RefUnwindSafe, DMACh2: RefUnwindSafe, T: RefUnwindSafe,

ยง

impl<'d, T, DMACh1, DMACh2> Send for Dac<'d, T, DMACh1, DMACh2>
where DMACh1: Send, DMACh2: Send, T: Send,

ยง

impl<'d, T, DMACh1, DMACh2> Sync for Dac<'d, T, DMACh1, DMACh2>
where DMACh1: Sync, DMACh2: Sync, T: Sync,

ยง

impl<'d, T, DMACh1, DMACh2> Unpin for Dac<'d, T, DMACh1, DMACh2>
where DMACh1: Unpin, DMACh2: Unpin,

ยง

impl<'d, T, DMACh1 = NoDma, DMACh2 = NoDma> !UnwindSafe for Dac<'d, T, DMACh1, DMACh2>

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.