embassy-stm32

Crates

git

Versions

stm32h753ii

Flavors

HardwareSemaphoreChannel

Struct HardwareSemaphoreChannel 

Source
pub struct HardwareSemaphoreChannel<'a, T: Instance> { /* private fields */ }
Expand description

Hardware semaphore channel

Implementations§

Source§

impl<'a, T: Instance> HardwareSemaphoreChannel<'a, T>

Source

pub async fn fast_lock(&mut self) -> HardwareSemaphoreMutex<'a, T>

Asynchronously lock a hardware semaphore with 1-step lock procedure and interrupts This lock does not use process ID, and should only be used to synchronize between cores. Locking a 1 step lock from the same AHB bus master ID will read the semaphore as locked

Source

pub async fn lock(&mut self, process_id: u8) -> HardwareSemaphoreMutex<'a, T>

Asynchronously lock a hardware semaphore with 2-step lock procedure and interrupts outlined in RM0399 11.3.7.

  • Try to lock the semaphore and return if it is obtained
  • If the lock fails:
    • Clear pending interrupt status and retry the lock
    • If the lock is obtained, return
    • If the lock fails, register the waker and enable interrupt in IER
Source

pub fn blocking_lock(&mut self, process_id: u8) -> HardwareSemaphoreMutex<'a, T>

Locks the semaphore in a blocking wait loop

Source

pub fn blocking_notify(&mut self)

Lock and unlock the semaphore to notify a listening core

Source

pub fn blocking_listen(&mut self)

Blocking poll for semaphore interrupt flag

Source

pub async fn listen(&mut self)

Asynchronous listen for a notification interrupt when this semaphore channel is unlocked

Source

pub fn try_lock( &mut self, process_id: u8, ) -> Option<HardwareSemaphoreMutex<'a, T>>

Try to lock the semaphore The 2-step lock procedure consists in a write to lock the semaphore, followed by a read to check if the lock has been successful, carried out from the HSEM_Rx register.

Source

pub fn try_fast_lock(&mut self) -> Option<HardwareSemaphoreMutex<'a, T>>

Try to a lock a single step semaphore. This should only be used from different cores, as fast locks do not use process IDs

Source

pub fn two_step_lock(&mut self, process_id: u8) -> Result<(), HsemError>

Locks the semaphore. The 2-step lock procedure consists in a write to lock the semaphore, followed by a read to check if the lock has been successful, carried out from the HSEM_Rx register.

Source

pub fn one_step_lock(&mut self) -> Result<(), HsemError>

Locks the semaphore. The 1-step procedure consists in a read to lock and check the semaphore in a single step, carried out from the HSEM_RLRx register.

This is only safe to use when acquiring from different cores/AHB masters, as a 1-step is only exclusive per core, AHB bus master ID

Source

pub fn unlock(&mut self, process_id: u8)

Unlocks the semaphore. Unlocking a semaphore is a protected process, to prevent accidental clearing by a AHB bus core ID or by a process not having the semaphore lock right.

Source

pub const fn channel(&self) -> u8

Return the channel number

Trait Implementations§

Source§

impl<'a, T: Clone + Instance> Clone for HardwareSemaphoreChannel<'a, T>

Source§

fn clone(&self) -> HardwareSemaphoreChannel<'a, T>

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<'a, T: Copy + Instance> Copy for HardwareSemaphoreChannel<'a, T>

Auto Trait Implementations§

§

impl<'a, T> Freeze for HardwareSemaphoreChannel<'a, T>

§

impl<'a, T> RefUnwindSafe for HardwareSemaphoreChannel<'a, T>
where T: RefUnwindSafe,

§

impl<'a, T> Send for HardwareSemaphoreChannel<'a, T>

§

impl<'a, T> Sync for HardwareSemaphoreChannel<'a, T>
where T: Sync,

§

impl<'a, T> Unpin for HardwareSemaphoreChannel<'a, T>

§

impl<'a, T> !UnwindSafe for HardwareSemaphoreChannel<'a, T>

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.