Struct stm32_hal2::dac::Dac

source ·
pub struct Dac<R> {
    pub regs: R,
    pub cfg: DacConfig,
    /* private fields */
}
Expand description

Represents a Digital to Analog Converter (DAC) peripheral.

Fields§

§regs: R§cfg: DacConfig

Implementations§

source§

impl<R> Dac<R>
where R: Deref<Target = RegisterBlock> + RccPeriph,

source

pub fn new(regs: R, cfg: DacConfig, vref: f32) -> Self

Initialize a DAC peripheral, including enabling and resetting its RCC peripheral clock. vref is in volts.

source

pub fn calibrate_buffer(&mut self, channel: DacChannel, delay: &mut Delay)

Calibrate the DAC output buffer by performing a “User trimming” operation. It is useful when the VDDA/VREF+ voltage or temperature differ from the factory trimming conditions.

The calibration is only valid when the DAC channel is operating with the buffer enabled. If applied in other modes it has no effect.

After the calibration operation, the DAC channel is disabled.

source

pub fn enable(&mut self, channel: DacChannel)

Enable the DAC, for a specific channel.

source

pub fn disable(&mut self, channel: DacChannel)

Disable the DAC, for a specific channel.

source

pub fn write(&mut self, channel: DacChannel, val: u16)

Set the DAC output word.

source

pub unsafe fn write_dma( &mut self, buf: &[u16], dac_channel: DacChannel, dma_channel: DmaChannel, channel_cfg: ChannelCfg, dma_periph: DmaPeriph )

Send values to the DAC using DMA. Each trigger (Eg using a timer; the basic timers Tim6 and Tim7 are designed for DAC triggering) sends one word from the buffer to the DAC’s output. Note that the dma_channel argument is unused on F3 and L4, since it is hard-coded, and can’t be configured using the DMAMUX peripheral. (dma::mux() fn).

source

pub fn write_voltage(&mut self, channel: DacChannel, volts: f32)

Set the DAC output voltage.

source

pub fn set_trigger(&mut self, channel: DacChannel, trigger: Trigger)

Select and activate a trigger. See f303 Reference manual, section 16.5.4. Each time a DAC interface detects a rising edge on the selected trigger source (refer to the table below), the last data stored into the DAC_DHRx register are transferred into the DAC_DORx register. The DAC_DORx register is updated three dac_pclk cycles after the trigger occurs.

source

pub fn trigger_lfsr(&mut self, channel: DacChannel, trigger: Trigger, data: u16)

Independent trigger with single LFSR generation See f303 Reference Manual section 16.5.2

source

pub fn trigger_triangle( &mut self, channel: DacChannel, trigger: Trigger, data: u16 )

Independent trigger with single triangle generation See f303 Reference Manual section 16.5.2

source

pub fn enable_interrupt(&mut self, channel: DacChannel)

Enable the DMA Underrun interrupt - the only interrupt available.

source

pub fn clear_interrupt(&mut self, channel: DacChannel)

Clear the DMA Underrun interrupt - the only interrupt available.

Auto Trait Implementations§

§

impl<R> RefUnwindSafe for Dac<R>
where R: RefUnwindSafe,

§

impl<R> Send for Dac<R>
where R: Send,

§

impl<R> Sync for Dac<R>
where R: Sync,

§

impl<R> Unpin for Dac<R>
where R: Unpin,

§

impl<R> UnwindSafe for Dac<R>
where R: UnwindSafe,

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.