embassy-stm32

Crates

git

Versions

stm32h747ig-cm7

Flavors

๐Ÿ“ฃ We want to hear from you! Fill the Rust Embedded 2024 micro-survey.

Struct embassy_stm32::hsem::HardwareSemaphore

source ยท
pub struct HardwareSemaphore<'d, T: Instance> { /* private fields */ }
Expand description

HSEM driver

Implementationsยง

sourceยง

impl<'d, T: Instance> HardwareSemaphore<'d, T>

source

pub fn new(peripheral: impl Peripheral<P = T> + 'd) -> Self

Creates a new HardwareSemaphore instance.

source

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.

source

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.

source

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.

source

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.

source

pub fn is_semaphore_locked(&self, sem_id: u8) -> bool

Checks if the semaphore is locked.

source

pub fn set_clear_key(&mut self, key: u16)

Sets the clear (unlock) key

source

pub fn get_clear_key(&mut self) -> u16

Gets the clear (unlock) key

source

pub fn enable_interrupt(&mut self, core_id: CoreId, sem_x: usize, enable: bool)

Sets the interrupt enable bit for the semaphore.

source

pub fn is_interrupt_active(&mut self, core_id: CoreId, sem_x: usize) -> bool

Gets the interrupt flag for the semaphore.

source

pub fn clear_interrupt(&mut self, core_id: CoreId, sem_x: usize)

Clears the interrupt flag for the semaphore.

Auto Trait Implementationsยง

ยง

impl<'d, T> Freeze for HardwareSemaphore<'d, T>
where T: Freeze,

ยง

impl<'d, T> RefUnwindSafe for HardwareSemaphore<'d, T>
where T: RefUnwindSafe,

ยง

impl<'d, T> Send for HardwareSemaphore<'d, T>

ยง

impl<'d, T> Sync for HardwareSemaphore<'d, T>
where T: Sync,

ยง

impl<'d, T> Unpin for HardwareSemaphore<'d, T>
where T: Unpin,

ยง

impl<'d, T> !UnwindSafe for HardwareSemaphore<'d, 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> 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.