pub struct HardwareSemaphoreChannel<'a, T: Instance> { /* private fields */ }Expand description
Hardware semaphore channel
Implementations§
Source§impl<'a, T: Instance> HardwareSemaphoreChannel<'a, T>
impl<'a, T: Instance> HardwareSemaphoreChannel<'a, T>
Sourcepub async fn fast_lock(&mut self) -> HardwareSemaphoreMutex<'a, T>
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
Sourcepub async fn lock(&mut self, process_id: u8) -> HardwareSemaphoreMutex<'a, T>
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
Sourcepub fn blocking_lock(&mut self, process_id: u8) -> HardwareSemaphoreMutex<'a, T>
pub fn blocking_lock(&mut self, process_id: u8) -> HardwareSemaphoreMutex<'a, T>
Locks the semaphore in a blocking wait loop
Sourcepub fn blocking_notify(&mut self)
pub fn blocking_notify(&mut self)
Lock and unlock the semaphore to notify a listening core
Sourcepub fn blocking_listen(&mut self)
pub fn blocking_listen(&mut self)
Blocking wait for a notification on this semaphore channel.
A notification sent by Self::blocking_notify or Self::unlock on the
other core is not lost if it was sent before this call: if one is already
pending it is consumed and this returns immediately. Otherwise this waits
for the next notification and consumes it.
Sourcepub async fn listen(&mut self)
pub async fn listen(&mut self)
Asynchronous wait for a notification on this semaphore channel.
A notification sent by Self::blocking_notify or Self::unlock on the
other core is not lost if it was sent before this call: if one is already
pending it is consumed and this returns immediately. Otherwise this waits
for the next notification and consumes it.
Sourcepub fn is_notified(&self) -> bool
pub fn is_notified(&self) -> bool
Returns whether a notification is pending on this semaphore channel.
Unlike Self::blocking_listen and Self::listen, this does not consume
the notification: it stays pending until Self::clear_notification is
called. This makes it usable as a persistent “the other core has notified”
level, which survives restarting this core.
Sourcepub fn clear_notification(&mut self)
pub fn clear_notification(&mut self)
Clear a pending notification on this semaphore channel.
A notification is broadcast: unlocking the channel latches the interrupt flag in the status register of every core. This clears the flag for all cores, discarding a pending notification even if the other core has not observed it yet.
Sourcepub fn try_lock(
&mut self,
process_id: u8,
) -> Option<HardwareSemaphoreMutex<'a, T>>
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.
Sourcepub fn try_fast_lock(&mut self) -> Option<HardwareSemaphoreMutex<'a, T>>
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
Sourcepub fn two_step_lock(&mut self, process_id: u8) -> Result<(), HsemError>
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.
Sourcepub fn one_step_lock(&mut self) -> Result<(), HsemError>
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