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 Delay = TickDelay<SysTickInstant>;
21
22    const O: Self = Self {};
23
24    fn yield_thread() {}
25
26    #[inline]
27    fn timeout() -> Self::Timeout {
28        TickTimeoutNs::<SysTickInstant>::new()
29    }
30
31    #[inline]
32    fn delay() -> Self::Delay {
33        TickDelay::<SysTickInstant>::default()
34    }
35
36    #[inline]
37    fn notify() -> (Self::Notifier, Self::NotifyWaiter) {
38        AtomicNotifier::<RawOs>::new()
39    }
40}