Use untagged_option crate

This commit is contained in:
Jonas Schievink 2017-09-06 19:06:43 +02:00
parent c8bdb7329f
commit 57ed0963ff
3 changed files with 8 additions and 7 deletions

View file

@ -14,10 +14,9 @@ version = "0.2.1"
[dependencies] [dependencies]
cortex-m = "0.3.1" 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" } 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] [target.'cfg(target_arch = "x86_64")'.dev-dependencies]
compiletest_rs = "0.2.8" compiletest_rs = "0.2.8"

View file

@ -233,7 +233,7 @@ fn init(app: &App, main: &mut Vec<Tokens>, root: &mut Vec<Tokens>) {
}); });
late_resources.push(quote! { 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! { None => quote! {
// Resource initialized in `init` // 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 { } else {
quote! { quote! {
#name: ::#krate::Static::ref_mut(&mut ::#_name.init), #name: ::#krate::Static::ref_mut(::#_name.as_mut()),
} }
}); });
} else { } else {

View file

@ -80,12 +80,14 @@
extern crate cortex_m; extern crate cortex_m;
extern crate cortex_m_rtfm_macros; extern crate cortex_m_rtfm_macros;
extern crate rtfm_core; extern crate rtfm_core;
extern crate untagged_option;
use core::u8; 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::asm::{bkpt, wfi};
pub use cortex_m_rtfm_macros::app; pub use cortex_m_rtfm_macros::app;
pub use untagged_option::UntaggedOption;
use cortex_m::interrupt::{self, Nr}; use cortex_m::interrupt::{self, Nr};
#[cfg(not(armv6m))] #[cfg(not(armv6m))]
use cortex_m::register::basepri; use cortex_m::register::basepri;