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