From 57ed0963ff3f64754935913943e6c7b20591a905 Mon Sep 17 00:00:00 2001 From: Jonas Schievink Date: Wed, 6 Sep 2017 19:06:43 +0200 Subject: [PATCH] Use `untagged_option` crate --- Cargo.toml | 5 ++--- macros/src/trans.rs | 6 +++--- src/lib.rs | 4 +++- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 448282d2ba..8760d307b9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,10 +14,9 @@ version = "0.2.1" [dependencies] cortex-m = "0.3.1" -# TODO should this have been a `path` dep all along? +untagged-option = "0.1.1" +rtfm-core = "0.1.0" cortex-m-rtfm-macros = { path = "macros" } -# TODO revert before merging -rtfm-core = { git = "https://github.com/jonas-schievink/rtfm-core.git", branch = "init-resources" } [target.'cfg(target_arch = "x86_64")'.dev-dependencies] compiletest_rs = "0.2.8" diff --git a/macros/src/trans.rs b/macros/src/trans.rs index ef23aa5fd7..0ab6f53fee 100644 --- a/macros/src/trans.rs +++ b/macros/src/trans.rs @@ -233,7 +233,7 @@ fn init(app: &App, main: &mut Vec, root: &mut Vec) { }); late_resources.push(quote! { - #_name = #krate::LateResource { init: _late_resources.#name }; + #_name = #krate::UntaggedOption { some: _late_resources.#name }; }); } @@ -344,7 +344,7 @@ fn resources(app: &App, ownerships: &Ownerships, root: &mut Vec) { }, None => quote! { // Resource initialized in `init` - static mut #_name: #krate::LateResource<#ty> = #krate::LateResource { uninit: () }; + static mut #_name: #krate::UntaggedOption<#ty> = #krate::UntaggedOption { none: () }; }, }); } @@ -587,7 +587,7 @@ fn tasks(app: &App, ownerships: &Ownerships, root: &mut Vec) { } } else { quote! { - #name: ::#krate::Static::ref_mut(&mut ::#_name.init), + #name: ::#krate::Static::ref_mut(::#_name.as_mut()), } }); } else { diff --git a/src/lib.rs b/src/lib.rs index 072e635969..ac955441ee 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -80,12 +80,14 @@ extern crate cortex_m; extern crate cortex_m_rtfm_macros; extern crate rtfm_core; +extern crate untagged_option; use core::u8; -pub use rtfm_core::{Resource, LateResource, Static, Threshold}; +pub use rtfm_core::{Resource, Static, Threshold}; pub use cortex_m::asm::{bkpt, wfi}; pub use cortex_m_rtfm_macros::app; +pub use untagged_option::UntaggedOption; use cortex_m::interrupt::{self, Nr}; #[cfg(not(armv6m))] use cortex_m::register::basepri;