aboutsummaryrefslogtreecommitdiff
path: root/examples/shared-with-init.rs
diff options
context:
space:
mode:
authorGravatar Jorge Aparicio <jorge@japaric.io> 2019-07-10 22:42:44 +0200
committerGravatar Jorge Aparicio <jorge@japaric.io> 2019-07-10 22:42:44 +0200
commit9195038c87703fc94b6e99f6de593886d51c2b19 (patch)
tree56855952357fe5bb689504ed8a6348dc3c1f3718 /examples/shared-with-init.rs
parent14d63f496118f4243f28ddf3218523aa36a80322 (diff)
downloadrtic-9195038c87703fc94b6e99f6de593886d51c2b19.tar.gz
rtic-9195038c87703fc94b6e99f6de593886d51c2b19.tar.zst
rtic-9195038c87703fc94b6e99f6de593886d51c2b19.zip
implement RFC #212
Diffstat (limited to 'examples/shared-with-init.rs')
-rw-r--r--examples/shared-with-init.rs13
1 files changed, 8 insertions, 5 deletions
diff --git a/examples/shared-with-init.rs b/examples/shared-with-init.rs
index ed73c8ba..14fa54b7 100644
--- a/examples/shared-with-init.rs
+++ b/examples/shared-with-init.rs
@@ -14,20 +14,23 @@ pub struct MustBeSend;
#[app(device = lm3s6965)]
const APP: () = {
- static mut SHARED: Option<MustBeSend> = None;
+ struct Resources {
+ #[init(None)]
+ shared: Option<MustBeSend>,
+ }
- #[init(resources = [SHARED])]
+ #[init(resources = [shared])]
fn init(c: init::Context) {
// this `message` will be sent to task `UART0`
let message = MustBeSend;
- *c.resources.SHARED = Some(message);
+ *c.resources.shared = Some(message);
rtfm::pend(Interrupt::UART0);
}
- #[task(binds = UART0, resources = [SHARED])]
+ #[task(binds = UART0, resources = [shared])]
fn uart0(c: uart0::Context) {
- if let Some(message) = c.resources.SHARED.take() {
+ if let Some(message) = c.resources.shared.take() {
// `message` has been received
drop(message);