embassy-stm32

Crates

git

Versions

stm32u575vi

Flavors

Struct WritableRingBuffer

Source
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>

Source

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.

Source

pub fn start(&mut self)

Start the ring buffer operation.

Source

pub fn clear(&mut self)

Clear all data in the ring buffer.

Source

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.

Source

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

Source

pub async fn write_exact(&mut self, buffer: &[W]) -> Result<usize, Error>

Write an exact number of elements to the ringbuffer.

Source

pub async fn wait_write_error(&mut self) -> Result<usize, Error>

Wait for any ring buffer write error.

Source

pub fn len(&mut self) -> Result<usize, Error>

The current length of the ringbuffer

Source

pub const fn capacity(&self) -> usize

The capacity of the ringbuffer

Source

pub fn set_waker(&mut self, waker: &Waker)

Set a waker to be woken when at least one byte is received.

Source

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.

Source

pub fn request_resume(&mut self)

Request the DMA to resume transfers after being suspended.

Source

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.

Source

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.

Source

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().

Trait Implementations§

Source§

impl<'a, W: Word> Drop for WritableRingBuffer<'a, W>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl<'a, W> Freeze for WritableRingBuffer<'a, W>

§

impl<'a, W> RefUnwindSafe for WritableRingBuffer<'a, W>
where W: RefUnwindSafe,

§

impl<'a, W> Send for WritableRingBuffer<'a, W>
where W: Send,

§

impl<'a, W> Sync for WritableRingBuffer<'a, W>
where W: Sync,

§

impl<'a, W> Unpin for WritableRingBuffer<'a, W>

§

impl<'a, W> !UnwindSafe for WritableRingBuffer<'a, W>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.