Embassy
embassy-stm32

Crates

git

Versions

stm32f051c8

Flavors

Struct embassy_stm32::dac::DacChannel

source ·
pub struct DacChannel<'d, T: Instance, const N: u8, DMA = NoDma> { /* private fields */ }
Expand description

Driver for a single DAC channel.

If you want to use both channels, either together or independently, create a Dac first and use it to access each channel.

Implementations§

source§

impl<'d, T: Instance, const N: u8, DMA> DacChannel<'d, T, N, DMA>

source

pub fn new( _peri: impl Peripheral<P = T> + 'd, dma: impl Peripheral<P = DMA> + 'd, pin: impl Peripheral<P = impl DacPin<T, N> + Pin> + 'd ) -> Self

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

If you’re not using DMA, pass [dma::NoDma] for the dma argument.

The channel is enabled on creation and begins to drive the output pin. Note that some methods, such as set_trigger() and set_mode(), will disable the channel; you must re-enable it with enable().

By default, triggering is disabled, but it can be enabled using DacChannel::set_trigger().

source

pub fn set_enable(&mut self, on: bool)

Enable or disable this channel.

source

pub fn enable(&mut self)

Enable this channel.

source

pub fn disable(&mut self)

Disable this channel.

source

pub fn set_trigger(&mut self, source: TriggerSel)

Set the trigger source for this channel.

This method disables the channel, so you may need to re-enable afterwards.

source

pub fn set_triggering(&mut self, on: bool)

Enable or disable triggering for this channel.

source

pub fn trigger(&mut self)

Software trigger this channel.

source

pub fn set(&mut self, value: Value)

Write a new value to this channel.

If triggering is not enabled, the new value is immediately output; otherwise, it will be output after the next trigger.

source

pub fn read(&self) -> u16

Read the current output value of the DAC.

source§

impl<'d, T: Instance, DMA> DacChannel<'d, T, 1, DMA>
where DMA: DacDma1<T>,

source

pub async fn write(&mut self, data: ValueArray<'_>, circular: bool)

Write data to this channel via DMA.

To prevent delays or glitches when outputing a periodic waveform, the circular flag can be set. This configures a circular DMA transfer that continually outputs data. Note that for performance reasons in circular mode the transfer-complete interrupt is disabled.

source§

impl<'d, T: Instance, DMA> DacChannel<'d, T, 2, DMA>
where DMA: DacDma2<T>,

source

pub async fn write(&mut self, data: ValueArray<'_>, circular: bool)

Write data to this channel via DMA.

To prevent delays or glitches when outputing a periodic waveform, the circular flag can be set. This configures a circular DMA transfer that continually outputs data. Note that for performance reasons in circular mode the transfer-complete interrupt is disabled.

Trait Implementations§

source§

impl<'d, T: Instance, const N: u8, DMA> Drop for DacChannel<'d, T, N, DMA>

source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl<'d, T, const N: u8, DMA> Freeze for DacChannel<'d, T, N, DMA>
where DMA: Freeze,

§

impl<'d, T, const N: u8, DMA> RefUnwindSafe for DacChannel<'d, T, N, DMA>

§

impl<'d, T, const N: u8, DMA> Send for DacChannel<'d, T, N, DMA>
where DMA: Send, T: Send,

§

impl<'d, T, const N: u8, DMA> Sync for DacChannel<'d, T, N, DMA>
where DMA: Sync, T: Sync,

§

impl<'d, T, const N: u8, DMA> Unpin for DacChannel<'d, T, N, DMA>
where DMA: Unpin,

§

impl<'d, T, const N: u8, DMA = NoDma> !UnwindSafe for DacChannel<'d, T, N, DMA>

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.