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>
impl<R> Dac<R>
Sourcepub fn new(regs: R, cfg: DacConfig, vref: f32) -> Self
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.
Sourcepub fn enable(&mut self, channel: DacChannel)
pub fn enable(&mut self, channel: DacChannel)
Enable the DAC, for a specific channel.
Sourcepub fn disable(&mut self, channel: DacChannel)
pub fn disable(&mut self, channel: DacChannel)
Disable the DAC, for a specific channel.
Sourcepub fn write(&mut self, channel: DacChannel, val: u16)
pub fn write(&mut self, channel: DacChannel, val: u16)
Set the DAC output word.
Sourcepub unsafe fn write_dma(
&mut self,
buf: &[u16],
channel: DacChannel,
dma_channel: DmaChannel,
channel_cfg: ChannelCfg,
dma_periph: DmaPeriph,
) -> Result<()>
pub unsafe fn write_dma( &mut self, buf: &[u16], channel: DacChannel, dma_channel: DmaChannel, channel_cfg: ChannelCfg, dma_periph: DmaPeriph, ) -> Result<()>
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).
Sourcepub fn write_voltage(&mut self, channel: DacChannel, volts: f32)
pub fn write_voltage(&mut self, channel: DacChannel, volts: f32)
Set the DAC output voltage.
Sourcepub fn set_trigger(&mut self, channel: DacChannel, trigger: Trigger)
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 DHRx register are transferred into the DORx register. The DORx register is updated three pclk cycles after the trigger occurs.
Sourcepub fn trigger_lfsr(&mut self, channel: DacChannel, trigger: Trigger, data: u16)
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
Sourcepub fn trigger_triangle(
&mut self,
channel: DacChannel,
trigger: Trigger,
data: u16,
)
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
Sourcepub fn enable_interrupt(&mut self, channel: DacChannel)
pub fn enable_interrupt(&mut self, channel: DacChannel)
Enable the DMA Underrun interrupt - the only interrupt available.