1use cortex_m::interrupt;
3
4pub trait InterruptModer {
6 #[doc(hidden)]
7 fn critical_section<R, F: FnOnce(&interrupt::CriticalSection) -> R>(f: F) -> R;
8}
9
10pub struct InterruptFree;
12impl InterruptModer for InterruptFree {
13 #[inline]
14 #[doc(hidden)]
15 fn critical_section<R, F: FnOnce(&interrupt::CriticalSection) -> R>(f: F) -> R {
16 interrupt::free(f)
17 }
18}
19
20pub struct InterruptOk;
22impl InterruptModer for InterruptOk {
23 #[inline]
24 #[doc(hidden)]
25 fn critical_section<R, F: FnOnce(&interrupt::CriticalSection) -> R>(f: F) -> R {
26 f(&unsafe { interrupt::CriticalSection::new() })
27 }
28}