embassy-mcxa

Crates

git

Versions

mcx-a256

Flavors

BbqRxMode

Enum BbqRxMode 

Source
#[non_exhaustive]
pub enum BbqRxMode { Efficiency, MaxFrame { size: usize, }, }
Expand description

RX Reception mode

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

Efficiency

Default mode, attempts to utilize the ring buffer as maximally as possible.

In this mode, the interrupt will use whatever space is available, up to 1/4 the total ring buffer size, or the max DMA transfer size, whichever is smaller. however this may mean that if we are at the “end” of the ring buffer, some transfers may be smaller, meaning we need to “reload” the interrupt more often.

At slower UART rates (like 115_200), this is probably acceptable, as we have roughly 347us to service the “end of transfer” interrupt and reload the next DMA transfer. However at higher speeds (like 4_000_000), this time shrinks to 10us, meaning that critical sections (including defmt logging) may cause us to lose data.

If you know your maximum frame/burst size, you can instead use [RxMode::MaxFrame], which will never allow “short” grants, with the trade off that we may reduce the total usable capacity temporarily if we need to wrap around the ring buffer early.

§

MaxFrame

Max Frame mode, ensures that dma transfers always have exactly size bytes available

In this mode, we will always make DMA transfers of the given size. This is intended for cases where we are receving bursts of data <= size, ideally with a short gap between bursts. This means that we will receive an IDLE interrupt, and switch over receiving grants in the quiet period, avoiding potentially latency-sensitive DMA transfer updates while data is still being transferred. This is especially useful at higher baudrates.

The tradeoff here is that we can temporarily “waste” up to (size - 1) bytes if we are forced to wrap-around the ring buffer early. For example if there is only 1023 bytes in the ring buffer before it wraps around, and size = 1024, we will be forced to wrap around the ring early, skipping that capacity. In some cases, where the required 1024 bytes are not available at the beginning of the ring buffer either, we will not begin a transfer at all, potentially losing data if capacity is not freed up before the next transfer starts (each time the ring buffer is drained, we will automatically re-start receiving if enough capacity is made available).

size must be <= (capacity / 4).

Fields

§size: usize

Trait Implementations§

Source§

impl Clone for BbqRxMode

Source§

fn clone(&self) -> BbqRxMode

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for BbqRxMode

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for BbqRxMode

Source§

fn default() -> BbqRxMode

Returns the “default value” for a type. Read more
Source§

impl Copy for BbqRxMode

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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.