embassy-stm32

Crates

git

Versions

stm32u083rc

Flavors

embassy_stm32::dac

Struct 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 new_internal( _peri: impl Peripheral<P = T> + 'd, dma_ch1: impl Peripheral<P = DMACh1> + 'd, dma_ch2: impl Peripheral<P = DMACh2> + 'd, ) -> Self

Create a new Dac instance where the external output pins are not used, so the DAC can only be used to generate internal signals but the GPIO pins remain available for other functions.

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 set to Mode::NormalInternalUnbuffered and enabled on creation. 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.