Struct esp_idf_svc::hal::interrupt::asynch::HalIsrNotification

source ·
pub struct HalIsrNotification { /* private fields */ }
Expand description

Single-slot lock-free signaling primitive supporting signalling with a u32 bit-set. A variation of the IsrNotification HAL primitive which is however safe to be notified from an ISR context. The difference between this primitive and IsrNotification is that this one is hard-wired to the global HAL wake runner (HAL_WAKE_RUNNER) and is thus occupying less space.

It is useful for sending data between an ISR routine (or a regular task context) and an async task when the receiver only cares about the latest data, and therefore it’s fine to “lose” messages. This is often the case for “state” updates.

The sending part of the primitive is non-blocking and ISR-safe, so it can be called from anywhere.

Similar in spirit to the ESP-IDF FreeRTOS task notifications in that it is light-weight and operates on bit-sets, but for synchronization between an asynchronous task, and another one, which might be blocking or asynchronous.

Implementations§

source§

impl HalIsrNotification

source

pub const fn new() -> HalIsrNotification

Creates a new HalIsrNotification. This method is safe to call from an ISR context, yet such use cases should not normally occur in practice.

source

pub fn notify_lsb(&self) -> bool

Marks the least significant bit (bit 0) in this IsrNotification as nofified. This method is safe to call from an ISR context. Returns true if there was a registered waker which got awoken.

source

pub fn notify(&self, bits: NonZero<u32>) -> bool

Marks the supplied bits in this HalIsrNotification as notified. This method is safe to call from an ISR context. Returns true if there was a registered waker which got awoken.

source

pub fn reset(&self)

Clears the state of this notification by removing any registered waker and setting all bits to 0. This method is NOT safe to call from an ISR context.

source

pub fn wait(&self) -> impl Future<Output = NonZero<u32>>

Future that completes when this HalIsrNotification has been notified. This method is NOT safe to call from an ISR context.

source

pub fn poll_wait(&self, cx: &Context<'_>) -> Poll<NonZero<u32>>

Non-blocking method to check whether this notification has been notified. This method is NOT safe to call from an ISR context.

Trait Implementations§

source§

impl Default for HalIsrNotification

source§

fn default() -> HalIsrNotification

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

Auto Trait Implementations§

§

impl !Freeze for HalIsrNotification

§

impl !RefUnwindSafe for HalIsrNotification

§

impl Send for HalIsrNotification

§

impl Sync for HalIsrNotification

§

impl Unpin for HalIsrNotification

§

impl UnwindSafe for HalIsrNotification

Blanket Implementations§

§

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

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

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

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

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

§

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

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

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

§

fn into(self) -> U

Calls U::from(self).

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

§

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

§

type Error = Infallible

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

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

Performs the conversion.
§

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

§

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

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

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

Performs the conversion.