embassy-stm32

Crates

git

Versions

stm32h7b0zb

Flavors

Skip to main content

RingBufferedFilter

Struct RingBufferedFilter 

Source
pub struct RingBufferedFilter<'e, T, M, DM: DmaMode>{ /* private fields */ }
Expand description

A filter bound to a DMA ring buffer, for reading converted samples.

The buffer holds raw u32 data-register words, not decoded samples: data in bits [23:8] (24-bit), channel in bits [2:0], and, for regular conversions, the pending flag in bit [4]. The channel byte is load-bearing in scan mode: it identifies which transceiver produced each word. The buffer is 32-bit words only.

Decode each word with ResultRegular::from_word or ResultInjected::from_word; use FilterRegular::read for already-decoded, sign-extended results.

§Note

The ring buffer is circular: it wraps and overwrites the oldest samples. A filter can have only one ring buffer (one DMA channel) attached at a time.

Implementations§

Source§

impl<'e, T, M, DM: DmaMode> RingBufferedFilter<'e, T, M, DM>

Source

pub fn start_conversion(&mut self)

Start a conversion. Regular conversions start one conversion (or continuous, if enabled); injected conversions start one group (or a scan, if enabled).

Source

pub fn start(&mut self)

Start the DMA transfers. Does not start a conversion; call start_conversion separately.

Source

pub fn stop(&mut self)

Pause the DMA transfers. Conversions are not stopped.

Source

pub fn clear(&mut self)

Discard all buffered samples.

Source

pub fn is_running(&mut self) -> bool

Whether the DMA ring buffer is running.

Source

pub fn capacity(&self) -> usize

Number of samples the ring buffer can hold.

Source

pub fn read_latest(&mut self, buf: &mut [u32]) -> Result<usize, Error>

Read the most recent samples, discarding older data. Never blocks; returns the number of samples written into buf.

buf receives raw u32 data-register words; decode each with ResultRegular::from_word or ResultInjected::from_word.

Source

pub async fn read(&mut self, buf: &mut [u32]) -> Result<usize, Error>

Asynchronously read buf.len() samples. buf.len() must equal half of capacity, or this panics. Starts the DMA if needed; returns Error::Overrun if the buffer overran.

buf receives raw u32 data-register words; decode each with ResultRegular::from_word or ResultInjected::from_word.

§Note

Like FilterRegular::read, this hangs forever if the filter is starved; see that method for the layered starvation detection.

Source

pub fn blocking_read(&mut self, buf: &mut [u32]) -> Result<usize, Error>

Blocking counterpart of read: waits until at least one sample is available, then returns whatever is currently ready (at most buf.len(), which must equal half of capacity). Returns Error::Overrun if the buffer overran.

Like read, this never returns if the filter is starved.

Auto Trait Implementations§

§

impl<'e, T, M, DM> !RefUnwindSafe for RingBufferedFilter<'e, T, M, DM>

§

impl<'e, T, M, DM> !Send for RingBufferedFilter<'e, T, M, DM>

§

impl<'e, T, M, DM> !Sync for RingBufferedFilter<'e, T, M, DM>

§

impl<'e, T, M, DM> !UnwindSafe for RingBufferedFilter<'e, T, M, DM>

§

impl<'e, T, M, DM> Freeze for RingBufferedFilter<'e, T, M, DM>
where PhantomData<DM>: Freeze, &'e mut dyn FilterDma<T, M>: Freeze,

§

impl<'e, T, M, DM> Unpin for RingBufferedFilter<'e, T, M, DM>
where PhantomData<DM>: Unpin, &'e mut dyn FilterDma<T, M>: Unpin,

§

impl<'e, T, M, DM> UnsafeUnpin for RingBufferedFilter<'e, T, M, DM>
where PhantomData<DM>: UnsafeUnpin, &'e mut dyn FilterDma<T, M>: UnsafeUnpin,

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 = !

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.