diff options
| author | Jonas Schievink <jonasschievink@gmail.com> | 2017-09-06 19:06:43 +0200 |
|---|---|---|
| committer | Jonas Schievink <jonasschievink@gmail.com> | 2017-09-06 19:06:43 +0200 |
| commit | 57ed0963ff3f64754935913943e6c7b20591a905 (patch) | |
| tree | 006e862de2ccdb992d88093d455a9ed96b8726d4 | |
| parent | c8bdb7329f860697602f98983917aaf84d8741d4 (diff) | |
Use `untagged_option` crate
| -rw-r--r-- | Cargo.toml | 5 | ||||
| -rw-r--r-- | macros/src/trans.rs | 6 | ||||
| -rw-r--r-- | src/lib.rs | 4 |
3 files changed, 8 insertions, 7 deletions
@@ -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 ef23aa5..0ab6f53 100644 --- a/macros/src/trans.rs +++ b/macros/src/trans.rs @@ -233,7 +233,7 @@ fn init(app: &App, main: &mut Vec<Tokens>, root: &mut Vec<Tokens>) { }); 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<Tokens>) { }, 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<Tokens>) { } } else { quote! { - #name: ::#krate::Static::ref_mut(&mut ::#_name.init), + #name: ::#krate::Static::ref_mut(::#_name.as_mut()), } }); } else { @@ -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; |
