Struct embassy_stm32::dma::WritableRingBuffer
source · pub struct WritableRingBuffer<'a, C: Channel, W: Word> { /* private fields */ }
Expand description
Ringbuffer for writing data using DMA circular mode.
Implementations§
source§impl<'a, C: Channel, W: Word> WritableRingBuffer<'a, C, W>
impl<'a, C: Channel, W: Word> WritableRingBuffer<'a, C, W>
sourcepub unsafe fn new(
channel: impl Peripheral<P = C> + 'a,
_request: Request,
peri_addr: *mut W,
buffer: &'a mut [W],
_options: TransferOptions
) -> Self
pub unsafe fn new( channel: impl Peripheral<P = C> + '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(&mut self, buf: &[W]) -> Result<(usize, usize), OverrunError>
pub fn write(&mut self, buf: &[W]) -> Result<(usize, usize), OverrunError>
Write elements to 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 sent.
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
.
Trait Implementations§
Auto Trait Implementations§
impl<'a, C, W> Freeze for WritableRingBuffer<'a, C, W>where
C: Freeze,
impl<'a, C, W> RefUnwindSafe for WritableRingBuffer<'a, C, W>where
C: RefUnwindSafe,
W: RefUnwindSafe,
impl<'a, C, W> Send for WritableRingBuffer<'a, C, W>
impl<'a, C, W> Sync for WritableRingBuffer<'a, C, W>
impl<'a, C, W> Unpin for WritableRingBuffer<'a, C, W>where
C: Unpin,
impl<'a, C, W> !UnwindSafe for WritableRingBuffer<'a, C, W>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more