Struct embassy_stm32::dma::WritableRingBuffer
source · 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), OverrunError>
pub fn write_immediate( &mut self, buf: &[W], ) -> Result<(usize, usize), OverrunError>
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), OverrunError>
pub fn write(&mut self, buf: &[W]) -> Result<(usize, usize), OverrunError>
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, OverrunError>
pub async fn write_exact(&mut self, buffer: &[W]) -> Result<usize, OverrunError>
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 DMA to stop.
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
.