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>
impl<'e, T, M, DM: DmaMode> RingBufferedFilter<'e, T, M, DM>
Sourcepub fn start_conversion(&mut self)
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).
Sourcepub fn start(&mut self)
pub fn start(&mut self)
Start the DMA transfers. Does not start a conversion; call
start_conversion separately.
Sourcepub fn is_running(&mut self) -> bool
pub fn is_running(&mut self) -> bool
Whether the DMA ring buffer is running.
Sourcepub fn read_latest(&mut self, buf: &mut [u32]) -> Result<usize, Error>
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.
Sourcepub async fn read(&mut self, buf: &mut [u32]) -> Result<usize, Error>
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.
Sourcepub fn blocking_read(&mut self, buf: &mut [u32]) -> Result<usize, Error>
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.