mirror of
https://github.com/rtic-rs/rtic.git
synced 2024-11-27 14:04:56 +01:00
late example now works with RacyCell
This commit is contained in:
parent
d4d5713e5a
commit
7c731fdbaf
3 changed files with 22 additions and 15 deletions
|
@ -20,7 +20,7 @@ mod app {
|
||||||
// Late resources
|
// Late resources
|
||||||
#[resources]
|
#[resources]
|
||||||
struct Resources {
|
struct Resources {
|
||||||
// p: Producer<'static, u32, U4>,
|
p: Producer<'static, u32, U4>,
|
||||||
c: Consumer<'static, u32, U4>,
|
c: Consumer<'static, u32, U4>,
|
||||||
#[task_local]
|
#[task_local]
|
||||||
#[init(Queue(i::Queue::new()))]
|
#[init(Queue(i::Queue::new()))]
|
||||||
|
@ -32,8 +32,7 @@ mod app {
|
||||||
let (p, c) = cx.resources.q.split();
|
let (p, c) = cx.resources.q.split();
|
||||||
|
|
||||||
// Initialization of late resources
|
// Initialization of late resources
|
||||||
// (init::LateResources { p, c }, init::Monotonics())
|
(init::LateResources { p, c }, init::Monotonics())
|
||||||
(init::LateResources { c }, init::Monotonics())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[idle(resources = [c])]
|
#[idle(resources = [c])]
|
||||||
|
@ -49,8 +48,8 @@ mod app {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// #[task(binds = UART0, resources = [p])]
|
#[task(binds = UART0, resources = [p])]
|
||||||
// fn uart0(mut c: uart0::Context) {
|
fn uart0(mut c: uart0::Context) {
|
||||||
// c.resources.p.lock(|p| p.enqueue(42).unwrap());
|
c.resources.p.lock(|p| p.enqueue(42).unwrap());
|
||||||
// }
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -93,17 +93,23 @@ pub fn codegen(
|
||||||
}
|
}
|
||||||
));
|
));
|
||||||
|
|
||||||
let ptr = if expr.is_none() {
|
let (ptr, doc) = if expr.is_none() {
|
||||||
// late resource
|
// late resource
|
||||||
|
(
|
||||||
quote!(
|
quote!(
|
||||||
#(#cfgs)*
|
#(#cfgs)*
|
||||||
&mut #mangled_name.get_mut_unchecked().assume_init()
|
#mangled_name.get_mut_unchecked().as_mut_ptr()
|
||||||
|
),
|
||||||
|
"late",
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
// early resource
|
// early resource
|
||||||
|
(
|
||||||
quote!(
|
quote!(
|
||||||
#(#cfgs)*
|
#(#cfgs)*
|
||||||
unsafe { #mangled_name.get_mut_unchecked() }
|
#mangled_name.get_mut_unchecked()
|
||||||
|
),
|
||||||
|
"early",
|
||||||
)
|
)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -114,6 +120,8 @@ pub fn codegen(
|
||||||
None => 0,
|
None => 0,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// let doc = format!(" RTIC internal ({} resource): {}:{}", doc, file!(), line!());
|
||||||
|
|
||||||
mod_app.push(util::impl_mutex(
|
mod_app.push(util::impl_mutex(
|
||||||
extra,
|
extra,
|
||||||
cfgs,
|
cfgs,
|
||||||
|
|
Loading…
Reference in a new issue