Embassy
embassy-stm32

Crates

git

Versions

stm32f101vf

Flavors

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.DAC, 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 begins 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>,

§

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>,

§

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.