Skip to content
Snippets Groups Projects
Commit 9a828b83 authored by Per's avatar Per
Browse files

did not work out

parent 34f4fdc7
Branches noread
No related tags found
No related merge requests found
......@@ -39,6 +39,18 @@
"$rustc"
]
},
{
"label": "xargo build --release --example nested_noread",
"type": "shell",
"command": "xargo build --features \"wcet_bkpt\" --example nested_noread",
"group": {
"kind": "build",
"isDefault": true
},
"problemMatcher": [
"$rustc"
]
},
{
"label": "xargo build --release --example nested --features wcet_bkpt",
"type": "shell",
......
......@@ -122,11 +122,13 @@ fn exti0(
rtfm::bkpt();
}
#[inline(never)]
fn exti1(_t: &mut Threshold, _r: EXTI1::Resources) {
// C, J
rtfm::bkpt();
}
#[inline(never)]
fn exti2(_t: &mut Threshold, _r: EXTI2::Resources) {
// E, H
rtfm::bkpt();
......
......@@ -427,6 +427,27 @@ fn resources(app: &App, ownerships: &Ownerships, root: &mut Vec<Tokens>) {
)
}
}
fn claim_mut_noread<R, F>(
&mut self,
t: &mut #krate::Threshold,
f: F,
) -> R
where
F: FnOnce(
&mut #krate::Static<#ty>,
&mut #krate::Threshold) -> R
{
unsafe {
#krate::claim_noread(
#krate::Static::ref_mut(&mut #res_rvalue),
#ceiling,
#device::NVIC_PRIO_BITS,
t,
f,
)
}
}
});
} else {
impl_items.push(quote! {
......@@ -501,6 +522,30 @@ fn resources(app: &App, ownerships: &Ownerships, root: &mut Vec<Tokens>) {
)
}
}
thueothueoa
fn claim_mut_noread<R, F>(
&mut self,
t: &mut #krate::Threshold,
f: F,
) -> R
where
F: FnOnce(
&mut #krate::Static<#device::#name>,
&mut #krate::Threshold) -> R
{
unsafe {
#krate::claim_noread(
#krate::Static::ref_mut(
&mut *#device::#name.get(),
),
#ceiling,
#device::NVIC_PRIO_BITS,
t,
f,
)
}
}
});
}
......
......@@ -142,9 +142,50 @@ where
basepri::write(hw);
if cfg!(feature = "wcet_bkpt") {bkpt();} else {nop();}
let ret = f(data, &mut Threshold::new(ceiling));
if cfg!(feature = "wcet_bkpt") {bkpt();} else {nop();}
basepri::write(old);
ret
}
}
}
} else {
f(data, t)
}
}
#[inline]
#[doc(hidden)]
pub unsafe fn claim_noread<T, R, F>(
data: T,
ceiling: u8,
_nvic_prio_bits: u8,
t: &mut Threshold,
f: F,
) -> R
where
F: FnOnce(T, &mut Threshold) -> R,
{
if ceiling > t.value() {
match () {
#[cfg(armv6m)]
() => atomic(t, |t| f(data, t)),
#[cfg(not(armv6m))]
() => {
let max_priority = 1 << _nvic_prio_bits;
if ceiling == max_priority {
atomic(t, |t| f(data, t))
} else {
//let old = basepri::read();
let hw = (max_priority - ceiling) << (8 - _nvic_prio_bits);
basepri::write(hw);
if cfg!(feature = "wcet_bkpt") {bkpt();} else {nop();}
let ret = f(data, &mut Threshold::new(ceiling));
if cfg!(feature = "wcet_bkpt") {bkpt();} else {nop();}
let old = (max_priority - t.value()) << (8 - _nvic_prio_bits);
basepri::write(old);
ret
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment