mirror of
https://github.com/rtic-rs/rtic.git
synced 2024-12-24 02:49:34 +01:00
drop the Static wrapper
This commit is contained in:
parent
0f5784c240
commit
219e172680
8 changed files with 28 additions and 26 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,5 +1,6 @@
|
|||
**/*.rs.bk
|
||||
*.org
|
||||
.#*
|
||||
.gdb_history
|
||||
Cargo.lock
|
||||
target/
|
||||
|
|
|
@ -15,7 +15,8 @@ version = "0.3.0"
|
|||
[dependencies]
|
||||
cortex-m = { git = "https://github.com/japaric/cortex-m" }
|
||||
untagged-option = "0.1.1"
|
||||
rtfm-core = "0.1.0"
|
||||
# rtfm-core = "0.1.0"
|
||||
rtfm-core = { git = "https://github.com/japaric/rtfm-core", branch = "no-static" }
|
||||
cortex-m-rtfm-macros = { path = "macros" }
|
||||
|
||||
[target.'cfg(target_arch = "x86_64")'.dev-dependencies]
|
||||
|
|
|
@ -63,22 +63,22 @@ mod main {
|
|||
*r.OWNED != *r.OWNED;
|
||||
|
||||
if *r.OWNED {
|
||||
if r.SHARED.claim(t, |shared, _| **shared) {
|
||||
if r.SHARED.claim(t, |shared, _| *shared) {
|
||||
rtfm::wfi();
|
||||
}
|
||||
} else {
|
||||
r.SHARED.claim_mut(t, |shared, _| **shared = !**shared);
|
||||
r.SHARED.claim_mut(t, |shared, _| *shared = !*shared);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn sys_tick(_t: &mut Threshold, r: SYS_TICK::Resources) {
|
||||
**r.ON = !**r.ON;
|
||||
*r.ON = !*r.ON;
|
||||
|
||||
**r.CO_OWNED += 1;
|
||||
*r.CO_OWNED += 1;
|
||||
}
|
||||
|
||||
fn tim2(_t: &mut Threshold, r: TIM2::Resources) {
|
||||
**r.CO_OWNED += 1;
|
||||
*r.CO_OWNED += 1;
|
||||
}
|
||||
|
|
|
@ -79,9 +79,9 @@ fn idle() -> ! {
|
|||
#[allow(unsafe_code)]
|
||||
fn sys_tick(_t: &mut Threshold, r: SYS_TICK::Resources) {
|
||||
// toggle state
|
||||
**r.ON = !**r.ON;
|
||||
*r.ON = !*r.ON;
|
||||
|
||||
if **r.ON {
|
||||
if *r.ON {
|
||||
// set the pin PC13 high
|
||||
// NOTE(unsafe) atomic write to a stateless register
|
||||
unsafe {
|
||||
|
|
|
@ -47,7 +47,7 @@ fn sys_tick(_t: &mut Threshold, r: SYS_TICK::Resources) {
|
|||
|
||||
// This task can't be preempted by `tim2` so it has direct access to the
|
||||
// resource data
|
||||
**r.COUNTER += 1;
|
||||
*r.COUNTER += 1;
|
||||
|
||||
// ..
|
||||
}
|
||||
|
@ -61,7 +61,7 @@ fn tim2(t: &mut Threshold, mut r: TIM2::Resources) {
|
|||
// lead to undefined behavior.
|
||||
r.COUNTER.claim_mut(t, |counter, _t| {
|
||||
// `claim_mut` creates a critical section
|
||||
**counter += 1;
|
||||
*counter += 1;
|
||||
});
|
||||
|
||||
// ..
|
||||
|
|
|
@ -45,7 +45,7 @@ fn idle() -> ! {
|
|||
fn sys_tick(_t: &mut Threshold, r: SYS_TICK::Resources) {
|
||||
// ..
|
||||
|
||||
**r.COUNTER += 1;
|
||||
*r.COUNTER += 1;
|
||||
|
||||
// ..
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ fn sys_tick(_t: &mut Threshold, r: SYS_TICK::Resources) {
|
|||
fn tim2(_t: &mut Threshold, r: TIM2::Resources) {
|
||||
// ..
|
||||
|
||||
**r.COUNTER += 1;
|
||||
*r.COUNTER += 1;
|
||||
|
||||
// ..
|
||||
}
|
||||
|
|
|
@ -176,11 +176,11 @@ fn init(app: &App, main: &mut Vec<Tokens>, root: &mut Vec<Tokens>) {
|
|||
let ty = &resource.ty;
|
||||
|
||||
fields.push(quote! {
|
||||
pub #name: &'a mut #krate::Static<#ty>,
|
||||
pub #name: &'a mut #ty,
|
||||
});
|
||||
|
||||
rexprs.push(quote! {
|
||||
#name: ::#krate::Static::ref_mut(&mut ::#_name),
|
||||
#name: &mut ::#_name,
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -369,20 +369,20 @@ fn resources(app: &App, ownerships: &Ownerships, root: &mut Vec<Tokens>) {
|
|||
fn borrow<'cs>(
|
||||
&'cs self,
|
||||
t: &'cs #krate::Threshold,
|
||||
) -> &'cs #krate::Static<#ty> {
|
||||
) -> &'cs #ty {
|
||||
assert!(t.value() >= #ceiling);
|
||||
|
||||
unsafe { #krate::Static::ref_(&#res_rvalue) }
|
||||
unsafe { &#res_rvalue }
|
||||
}
|
||||
|
||||
fn borrow_mut<'cs>(
|
||||
&'cs mut self,
|
||||
t: &'cs #krate::Threshold,
|
||||
) -> &'cs mut #krate::Static<#ty> {
|
||||
) -> &'cs mut #ty {
|
||||
assert!(t.value() >= #ceiling);
|
||||
|
||||
unsafe {
|
||||
#krate::Static::ref_mut(&mut #res_rvalue)
|
||||
&mut #res_rvalue
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -393,12 +393,12 @@ fn resources(app: &App, ownerships: &Ownerships, root: &mut Vec<Tokens>) {
|
|||
) -> R
|
||||
where
|
||||
F: FnOnce(
|
||||
&#krate::Static<#ty>,
|
||||
&#ty,
|
||||
&mut #krate::Threshold) -> R
|
||||
{
|
||||
unsafe {
|
||||
#krate::claim(
|
||||
#krate::Static::ref_(&#res_rvalue),
|
||||
&#res_rvalue,
|
||||
#ceiling,
|
||||
#device::NVIC_PRIO_BITS,
|
||||
t,
|
||||
|
@ -414,12 +414,12 @@ fn resources(app: &App, ownerships: &Ownerships, root: &mut Vec<Tokens>) {
|
|||
) -> R
|
||||
where
|
||||
F: FnOnce(
|
||||
&mut #krate::Static<#ty>,
|
||||
&mut #ty,
|
||||
&mut #krate::Threshold) -> R
|
||||
{
|
||||
unsafe {
|
||||
#krate::claim(
|
||||
#krate::Static::ref_mut(&mut #res_rvalue),
|
||||
&mut #res_rvalue,
|
||||
#ceiling,
|
||||
#device::NVIC_PRIO_BITS,
|
||||
t,
|
||||
|
@ -510,16 +510,16 @@ fn tasks(app: &App, ownerships: &Ownerships, root: &mut Vec<Tokens>) {
|
|||
let ty = &resource.ty;
|
||||
|
||||
fields.push(quote! {
|
||||
pub #name: &'a mut ::#krate::Static<#ty>,
|
||||
pub #name: &'a mut #ty,
|
||||
});
|
||||
|
||||
exprs.push(if resource.expr.is_some() {
|
||||
quote! {
|
||||
#name: ::#krate::Static::ref_mut(&mut ::#_name),
|
||||
#name: &mut ::#_name,
|
||||
}
|
||||
} else {
|
||||
quote! {
|
||||
#name: ::#krate::Static::ref_mut(::#_name.as_mut()),
|
||||
#name: ::#_name.as_mut(),
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -84,7 +84,7 @@ extern crate untagged_option;
|
|||
|
||||
use core::u8;
|
||||
|
||||
pub use rtfm_core::{Resource, Static, Threshold};
|
||||
pub use rtfm_core::{Resource, Threshold};
|
||||
pub use cortex_m::asm::{bkpt, wfi};
|
||||
pub use cortex_m_rtfm_macros::app;
|
||||
#[doc(hidden)]
|
||||
|
|
Loading…
Reference in a new issue