pub struct WritableRingBuffer<'a, W: Word> { /* private fields */ }
Expand description
Ringbuffer for writing data using GPDMA linked-list mode.
Implementations§
Source§impl<'a, W: Word> WritableRingBuffer<'a, W>
impl<'a, W: Word> WritableRingBuffer<'a, W>
Sourcepub unsafe fn new(
channel: Peri<'a, impl Channel>,
request: Request,
peri_addr: *mut W,
buffer: &'a mut [W],
options: TransferOptions,
) -> Self
pub unsafe fn new( channel: Peri<'a, impl Channel>, request: Request, peri_addr: *mut W, buffer: &'a mut [W], options: TransferOptions, ) -> Self
Create a new ring buffer.
Transfer options are applied to the individual linked list items.
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 async fn wait_write_error(&mut self) -> Result<usize, Error>
pub async fn wait_write_error(&mut self) -> Result<usize, Error>
Wait for any ring buffer write error.
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_pause(&mut self)
pub fn request_pause(&mut self)
Request the DMA to suspend.
To resume the transfer, call request_resume
again.
This doesn’t immediately stop the transfer, you have to wait until is_running
returns false.
Sourcepub fn request_resume(&mut self)
pub fn request_resume(&mut self)
Request the DMA to resume transfers after being suspended.
Sourcepub fn request_reset(&mut self)
pub fn request_reset(&mut self)
Request the DMA to reset.
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.
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
.
Sourcepub async fn stop(&mut self)
pub async fn stop(&mut self)
Stop the DMA transfer and await until the buffer is full.
This disables the DMA transfer’s circular mode so that the transfer stops when the buffer is full.
This is designed to be used with streaming input data such as the I2S/SAI or ADC.
When using the UART, you probably want request_stop()
.