pub struct HardwareSemaphore<'d, T: Instance> { /* private fields */ }
Expand description
HSEM driver
Implementations§
source§impl<'d, T: Instance> HardwareSemaphore<'d, T>
impl<'d, T: Instance> HardwareSemaphore<'d, T>
sourcepub fn new(peripheral: impl Peripheral<P = T> + 'd) -> Self
pub fn new(peripheral: impl Peripheral<P = T> + 'd) -> Self
Creates a new HardwareSemaphore instance.
sourcepub fn two_step_lock(
&mut self,
sem_id: u8,
process_id: u8,
) -> Result<(), HsemError>
pub fn two_step_lock( &mut self, sem_id: u8, 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, sem_id: u8) -> Result<(), HsemError>
pub fn one_step_lock(&mut self, sem_id: u8) -> 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.
sourcepub fn unlock(&mut self, sem_id: u8, process_id: u8)
pub fn unlock(&mut self, sem_id: u8, 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.
sourcepub fn unlock_all(&mut self, key: u16, core_id: u8)
pub fn unlock_all(&mut self, key: u16, core_id: u8)
Unlocks all semaphores. All semaphores locked by a COREID can be unlocked at once by using the HSEM_CR register. Write COREID and correct KEY value in HSEM_CR. All locked semaphores with a matching COREID are unlocked, and may generate an interrupt when enabled.
sourcepub fn is_semaphore_locked(&self, sem_id: u8) -> bool
pub fn is_semaphore_locked(&self, sem_id: u8) -> bool
Checks if the semaphore is locked.
sourcepub fn set_clear_key(&mut self, key: u16)
pub fn set_clear_key(&mut self, key: u16)
Sets the clear (unlock) key
sourcepub fn get_clear_key(&mut self) -> u16
pub fn get_clear_key(&mut self) -> u16
Gets the clear (unlock) key
sourcepub fn enable_interrupt(&mut self, core_id: CoreId, sem_x: usize, enable: bool)
pub fn enable_interrupt(&mut self, core_id: CoreId, sem_x: usize, enable: bool)
Sets the interrupt enable bit for the semaphore.
sourcepub fn is_interrupt_active(&mut self, core_id: CoreId, sem_x: usize) -> bool
pub fn is_interrupt_active(&mut self, core_id: CoreId, sem_x: usize) -> bool
Gets the interrupt flag for the semaphore.
sourcepub fn clear_interrupt(&mut self, core_id: CoreId, sem_x: usize)
pub fn clear_interrupt(&mut self, core_id: CoreId, sem_x: usize)
Clears the interrupt flag for the semaphore.