pub struct DacChannel<'d, M: PeriMode> { /* 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> DacChannel<'d, Async>
impl<'d> DacChannel<'d, Async>
Sourcepub fn new<T: Instance, C: Channel, D: Dma<T, C>>(
peri: Peri<'d, T>,
dma: Peri<'d, D>,
_irq: impl Binding<D::Interrupt, InterruptHandler<D>> + 'd,
pin: Peri<'d, impl DacPin<T, C>>,
) -> Self
pub fn new<T: Instance, C: Channel, D: Dma<T, C>>( peri: Peri<'d, T>, dma: Peri<'d, D>, _irq: impl Binding<D::Interrupt, InterruptHandler<D>> + 'd, pin: Peri<'d, impl DacPin<T, C>>, ) -> Self
Create a new DacChannel instance, consuming the underlying DAC peripheral.
The channel is enabled on creation and begin 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().
Sourcepub fn new_triggered<T: Instance, C: Channel, D: Dma<T, C>>(
peri: Peri<'d, T>,
dma: Peri<'d, D>,
trigger: impl ChannelTrigger<T>,
_irq: impl Binding<D::Interrupt, InterruptHandler<D>> + 'd,
pin: Peri<'d, impl DacPin<T, C>>,
) -> Self
pub fn new_triggered<T: Instance, C: Channel, D: Dma<T, C>>( peri: Peri<'d, T>, dma: Peri<'d, D>, trigger: impl ChannelTrigger<T>, _irq: impl Binding<D::Interrupt, InterruptHandler<D>> + 'd, pin: Peri<'d, impl DacPin<T, C>>, ) -> Self
Create a new DacChannel instance, consuming the underlying DAC peripheral.
The channel is enabled on creation and begin 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().
Sourcepub fn new_internal<T: Instance, C: Channel, D: Dma<T, C>>(
peri: Peri<'d, T>,
dma: Peri<'d, D>,
_irq: impl Binding<D::Interrupt, InterruptHandler<D>> + 'd,
) -> Self
pub fn new_internal<T: Instance, C: Channel, D: Dma<T, C>>( peri: Peri<'d, T>, dma: Peri<'d, D>, _irq: impl Binding<D::Interrupt, InterruptHandler<D>> + 'd, ) -> Self
Create a new DacChannel instance where the external output pin is not used,
so the DAC can only be used to generate internal signals.
The GPIO pin is therefore available to be used for other functions.
The channel is 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 it with enable().
Sourcepub fn new_triggered_internal<T: Instance, C: Channel, D: Dma<T, C>>(
peri: Peri<'d, T>,
dma: Peri<'d, D>,
trigger: impl ChannelTrigger<T>,
_irq: impl Binding<D::Interrupt, InterruptHandler<D>> + 'd,
) -> Self
pub fn new_triggered_internal<T: Instance, C: Channel, D: Dma<T, C>>( peri: Peri<'d, T>, dma: Peri<'d, D>, trigger: impl ChannelTrigger<T>, _irq: impl Binding<D::Interrupt, InterruptHandler<D>> + 'd, ) -> Self
Create a new DacChannel instance where the external output pin is not used,
so the DAC can only be used to generate internal signals.
The GPIO pin is therefore available to be used for other functions.
The channel is 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 it with enable().
Sourcepub fn into_ring_buffered_8bit(
self,
dma_buf: &'d mut [u32],
) -> RingBufferedDacChannel<'d, u32>
pub fn into_ring_buffered_8bit( self, dma_buf: &'d mut [u32], ) -> RingBufferedDacChannel<'d, u32>
Convert this channel into a ring-buffered DAC channel using 8-bit output (DHR8Rx).
Each element of dma_buf holds one 8-bit sample in bits [7:0]. DMA transfers are
32-bit wide as required by the DAC peripheral, so the upper bits are ignored by hardware.
The DMA runs in circular mode so output is uninterrupted between writes.
Use RingBufferedDacChannel::write_immediate to pre-fill the buffer before
calling RingBufferedDacChannel::start.
Sourcepub fn into_ring_buffered_12right(
self,
dma_buf: &'d mut [u32],
) -> RingBufferedDacChannel<'d, u32>
pub fn into_ring_buffered_12right( self, dma_buf: &'d mut [u32], ) -> RingBufferedDacChannel<'d, u32>
Convert this channel into a ring-buffered DAC channel using 12-bit right-aligned output (DHR12Rx).
Each element of dma_buf holds one 12-bit sample in bits [11:0]. DMA transfers are
32-bit wide as required by the DAC peripheral, so bits [31:12] are ignored by hardware.
The DMA runs in circular mode so output is uninterrupted between writes.
Use RingBufferedDacChannel::write_immediate to pre-fill the buffer before
calling RingBufferedDacChannel::start.
Source§impl<'d> DacChannel<'d, Blocking>
impl<'d> DacChannel<'d, Blocking>
Sourcepub fn new_blocking<T: Instance, C: Channel>(
peri: Peri<'d, T>,
pin: Peri<'d, impl DacPin<T, C>>,
) -> Self
pub fn new_blocking<T: Instance, C: Channel>( peri: Peri<'d, T>, pin: Peri<'d, impl DacPin<T, C>>, ) -> Self
Create a new DacChannel instance, consuming the underlying DAC peripheral.
The channel is enabled on creation and begin 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()].
Sourcepub fn new_internal_blocking<T: Instance, C: Channel>(peri: Peri<'d, T>) -> Self
pub fn new_internal_blocking<T: Instance, C: Channel>(peri: Peri<'d, T>) -> Self
Create a new DacChannel instance where the external output pin is not used,
so the DAC can only be used to generate internal signals.
The GPIO pin is therefore available to be used for other functions.
The channel is 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 it with enable().
By default, triggering is disabled, but it can be enabled using
[DacChannel::set_trigger()].
Source§impl<'d, M: PeriMode> DacChannel<'d, M>
impl<'d, M: PeriMode> DacChannel<'d, M>
Sourcepub fn set_enable(&mut self, on: bool)
pub fn set_enable(&mut self, on: bool)
Enable or disable this channel.
Sourcepub fn set_triggering(&mut self, on: bool)
pub fn set_triggering(&mut self, on: bool)
Enable or disable triggering for this channel.
Sourcepub fn trigger(&mut self)
pub fn trigger(&mut self)
Software trigger this channel.
NOTE: In sawtooth mode, this only works with SOFTWARE as reset_trigger source
Sourcepub fn set_mode(&mut self, mode: Mode)
pub fn set_mode(&mut self, mode: Mode)
Set mode of this channel.
This method disables the channel, so you may need to re-enable afterwards.