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.