pub struct RingBufferedDacChannel<'d, W: Word> { /* private fields */ }Expand description
A DAC channel backed by a DMA ring buffer.
Allows continuous waveform streaming by writing new samples into the ring buffer while DMA is simultaneously consuming and outputting them. DMA runs in circular mode so output never stops between writes.
Obtain this from [DacChannel::into_ring_buffered_8bit] or
[DacChannel::into_ring_buffered_12right].
Implementations§
Source§impl<'d, W: Word> RingBufferedDacChannel<'d, W>
impl<'d, W: Word> RingBufferedDacChannel<'d, W>
Sourcepub fn start(&mut self)
pub fn start(&mut self)
Start the DMA transfer.
Call this after creating the ring buffer (and optionally pre-filling it with
write_immediate) to begin DAC output.
Sourcepub fn write_immediate(&mut self, buf: &[W]) -> Result<(usize, usize), Error>
pub fn write_immediate(&mut self, buf: &[W]) -> Result<(usize, usize), Error>
Write samples directly into the raw DMA buffer without checking DMA position.
Useful for pre-filling the buffer before calling start. Writes
at most capacity elements aligned to the end of the buffer.
Sourcepub fn write(&mut self, buf: &[W]) -> Result<(usize, usize), Error>
pub fn write(&mut self, buf: &[W]) -> Result<(usize, usize), Error>
Write samples into the ring buffer.
Returns (written, remaining_space). Returns [Error::Overrun] if the DMA
consumed data faster than the CPU supplied it; the ring buffer resets itself
automatically in that case.
Sourcepub async fn write_exact(&mut self, buffer: &[W]) -> Result<usize, Error>
pub async fn write_exact(&mut self, buffer: &[W]) -> Result<usize, Error>
Write an exact number of samples, waiting asynchronously until space is available.
Sourcepub async fn wait_write_error(&mut self) -> Result<usize, Error>
pub async fn wait_write_error(&mut self) -> Result<usize, Error>
Wait for a ring buffer write error (underrun).
Sourcepub fn is_running(&mut self) -> bool
pub fn is_running(&mut self) -> bool
Return whether the DMA is currently running.
Sourcepub fn request_reset(&mut self)
pub fn request_reset(&mut self)
Request the DMA to stop, discarding the channel configuration.
Sourcepub fn request_pause(&mut self)
pub fn request_pause(&mut self)
Request the DMA to pause, preserving the channel configuration.
Resume with start.