aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Jorge Aparicio <jorge@japaric.io> 2017-10-02 14:49:40 +0200
committerGravatar Jorge Aparicio <jorge@japaric.io> 2017-10-02 14:49:40 +0200
commit2415a640af49666799bb4cd09a40f16853bdd687 (patch)
treec8757ae7905dd2fa3063a6c085b9152d19121422
parenta190da3e3ff63a25a33ac30fc99421ab0decce57 (diff)
downloadrtic-2415a640af49666799bb4cd09a40f16853bdd687.tar.gz
rtic-2415a640af49666799bb4cd09a40f16853bdd687.tar.zst
rtic-2415a640af49666799bb4cd09a40f16853bdd687.zip
fix `idle::Resources::new`
it assumed that all resources were "early" resources
-rw-r--r--examples/late-resources.rs5
-rw-r--r--macros/src/trans.rs10
2 files changed, 13 insertions, 2 deletions
diff --git a/examples/late-resources.rs b/examples/late-resources.rs
index b5dba146..b60c7740 100644
--- a/examples/late-resources.rs
+++ b/examples/late-resources.rs
@@ -32,6 +32,11 @@ app! {
static PORT: u16;
},
+ idle: {
+ // Test that late resources can be used in idle
+ resources: [IP_ADDRESS],
+ }
+
tasks: {
SYS_TICK: {
priority: 1,
diff --git a/macros/src/trans.rs b/macros/src/trans.rs
index 45841e73..96ff770b 100644
--- a/macros/src/trans.rs
+++ b/macros/src/trans.rs
@@ -74,8 +74,14 @@ fn idle(
});
let _name = Ident::new(format!("_{}", name.as_ref()));
- rexprs.push(quote! {
- #name: &mut #super_::#_name,
+ rexprs.push(if resource.expr.is_some() {
+ quote! {
+ #name: &mut #super_::#_name,
+ }
+ } else {
+ quote! {
+ #name: #super_::#_name.as_mut(),
+ }
});
} else {
rfields.push(quote! {