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
#[cfg(all(cortex_m, feature = "critical-section-single-core"))]
mod single_core_critical_section {
use critical_section::{set_impl, Impl, RawRestoreState};
use crate::interrupt;
use crate::register::primask;
struct SingleCoreCriticalSection;
set_impl!(SingleCoreCriticalSection);
unsafe impl Impl for SingleCoreCriticalSection {
unsafe fn acquire() -> RawRestoreState {
let was_active = primask::read().is_active();
interrupt::disable();
was_active
}
unsafe fn release(was_active: RawRestoreState) {
if was_active {
interrupt::enable()
}
}
}
}