mirror of
https://github.com/rtic-rs/rtic.git
synced 2025-12-16 21:05:35 +01:00
export: cortex_source_mask update
This commit is contained in:
parent
e8428f7c2c
commit
d16ad16bd7
1 changed files with 24 additions and 18 deletions
|
|
@ -127,25 +127,27 @@ pub unsafe fn lock<T, R, const M: usize>(
|
|||
masks: &[Mask<M>; 3],
|
||||
f: impl FnOnce(&mut T) -> R,
|
||||
) -> R {
|
||||
if ceiling >= 4 {
|
||||
// safe to manipulate outside critical section
|
||||
// execute closure under protection of raised system ceiling
|
||||
unsafe {
|
||||
if ceiling >= 4 {
|
||||
// safe to manipulate outside critical section
|
||||
// execute closure under protection of raised system ceiling
|
||||
|
||||
// safe to manipulate outside critical section
|
||||
critical_section::with(|_| f(&mut *ptr))
|
||||
} else {
|
||||
// safe to manipulate outside critical section
|
||||
let mask = compute_mask(0, ceiling, masks);
|
||||
let old_mask = read_mask(mask);
|
||||
clear_enable_mask(mask);
|
||||
// safe to manipulate outside critical section
|
||||
critical_section::with(|_| f(&mut *ptr))
|
||||
} else {
|
||||
// safe to manipulate outside critical section
|
||||
let mask = compute_mask(0, ceiling, masks);
|
||||
let old_mask = read_mask(mask);
|
||||
clear_enable_mask(mask);
|
||||
|
||||
// execute closure under protection of raised system ceiling
|
||||
let r = f(&mut *ptr);
|
||||
// execute closure under protection of raised system ceiling
|
||||
let r = f(&mut *ptr);
|
||||
|
||||
set_enable_mask(mask, old_mask);
|
||||
set_enable_mask(mask, old_mask);
|
||||
|
||||
// safe to manipulate outside critical section
|
||||
r
|
||||
// safe to manipulate outside critical section
|
||||
r
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -187,7 +189,7 @@ unsafe fn read_mask<const M: usize>(mask: Mask<M>) -> Mask<M> {
|
|||
for i in 0..M {
|
||||
// This check should involve compile time constants and be optimized out.
|
||||
if mask.0[i] != 0 {
|
||||
out.0[i] = (*NVIC::PTR).iser[i].read();
|
||||
out.0[i] = unsafe { (*NVIC::PTR).iser[i].read() };
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -200,7 +202,9 @@ unsafe fn set_enable_mask<const M: usize>(mask: Mask<M>, old_mask: Mask<M>) {
|
|||
for i in 0..M {
|
||||
// This check should involve compile time constants and be optimized out.
|
||||
if mask.0[i] != 0 {
|
||||
(*NVIC::PTR).iser[i].write(old_mask.0[i]);
|
||||
unsafe {
|
||||
(*NVIC::PTR).iser[i].write(old_mask.0[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -211,7 +215,9 @@ unsafe fn clear_enable_mask<const M: usize>(mask: Mask<M>) {
|
|||
for i in 0..M {
|
||||
// This check should involve compile time constants and be optimized out.
|
||||
if mask.0[i] != 0 {
|
||||
(*NVIC::PTR).icer[i].write(mask.0[i]);
|
||||
unsafe {
|
||||
(*NVIC::PTR).icer[i].write(mask.0[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue