pub struct WritableRingBuffer<'a, W: Word> { /* private fields */ }
Expand description
Ringbuffer for writing data using DMA circular mode.
Implementations§
Source§impl<'a, W: Word> WritableRingBuffer<'a, W>
impl<'a, W: Word> WritableRingBuffer<'a, W>
Sourcepub unsafe fn new(
channel: impl Peripheral<P = impl Channel> + 'a,
_request: Request,
peri_addr: *mut W,
buffer: &'a mut [W],
options: TransferOptions,
) -> Self
pub unsafe fn new( channel: impl Peripheral<P = impl Channel> + 'a, _request: Request, peri_addr: *mut W, buffer: &'a mut [W], options: TransferOptions, ) -> Self
Create a new ring buffer.
Sourcepub fn start(&mut self)
pub fn start(&mut self)
Start the ring buffer operation.
You must call this after creating it for it to work.
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 elements directly to the raw buffer. This can be used to fill the buffer before starting the DMA transfer.
Sourcepub fn write(&mut self, buf: &[W]) -> Result<(usize, usize), Error>
pub fn write(&mut self, buf: &[W]) -> Result<(usize, usize), Error>
Write elements from the ring buffer Return a tuple of the length written and the length remaining in the buffer
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 elements to the ringbuffer.
Sourcepub fn set_waker(&mut self, waker: &Waker)
pub fn set_waker(&mut self, waker: &Waker)
Set a waker to be woken when at least one byte is received.
Sourcepub fn request_stop(&mut self)
pub fn request_stop(&mut self)
Request the DMA to stop.
The configuration for this channel will not be preserved. If you need to restart the transfer
at a later point with the same configuration, see request_pause
instead.
This doesn’t immediately stop the transfer, you have to wait until is_running
returns false.
Sourcepub fn request_pause(&mut self)
pub fn request_pause(&mut self)
Request the transfer to pause, keeping the existing configuration for this channel.
To restart the transfer, call start
again.
This doesn’t immediately stop the transfer, you have to wait until is_running
returns false.
Sourcepub fn is_running(&mut self) -> bool
pub fn is_running(&mut self) -> bool
Return whether DMA is still running.
If this returns false
, it can be because either the transfer finished, or
it was requested to stop early with request_stop
.