stm32f1_hal/
raw_os.rs

1use crate::os_trait::{
2    AtomicNotifier, AtomicNotifyWaiter, FakeRawMutex, TickDelay, TickTimeoutNs, TickTimeoutState,
3    prelude::*,
4};
5use crate::timer::SysTickInstant;
6
7/// RawOs implementation
8///
9/// # Safety
10///
11/// The sys_tick device should be setup before you use timeout or delay.
12/// The FakeRawMutex does not provide any synchronization between threads.
13pub struct RawOs;
14impl OsInterface for RawOs {
15    type RawMutex = FakeRawMutex;
16    type Notifier = AtomicNotifier<RawOs>;
17    type NotifyWaiter = AtomicNotifyWaiter<RawOs>;
18    type Timeout = TickTimeoutNs<SysTickInstant>;
19    type TimeoutState = TickTimeoutState<SysTickInstant>;
20    type DelayNs = TickDelay<SysTickInstant>;
21
22    const O: Self = Self {};
23
24    fn yield_thread() {}
25
26    fn delay() -> Self::DelayNs {
27        TickDelay::<SysTickInstant>::default()
28    }
29
30    fn notify() -> (Self::Notifier, Self::NotifyWaiter) {
31        AtomicNotifier::<RawOs>::new()
32    }
33}