diff options
author | 2023-01-22 03:03:24 +0100 | |
---|---|---|
committer | 2023-01-22 12:00:08 +0100 | |
commit | be74469ab71341da9a564ce1bc3e0e3f17009688 (patch) | |
tree | f4a8c431fb449c394ef80cb171002ba6e58913e8 /macros/src/codegen/post_init.rs | |
parent | 3240fb332a7b1b17333ac1c589b303909bde1dc9 (diff) | |
download | rtic-be74469ab71341da9a564ce1bc3e0e3f17009688.tar.gz rtic-be74469ab71341da9a564ce1bc3e0e3f17009688.tar.zst rtic-be74469ab71341da9a564ce1bc3e0e3f17009688.zip |
Enable at least masking out a Monotonic
Simplest case working, but leaves a lot to ask
as shown by examples/cfg-monotonic.rs
Current `rtic-syntax` is unable to validate and
handle the `cfgs[]` which limits the usefulness
of this.
Diffstat (limited to 'macros/src/codegen/post_init.rs')
-rw-r--r-- | macros/src/codegen/post_init.rs | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/macros/src/codegen/post_init.rs b/macros/src/codegen/post_init.rs index 9531254c..460b4e21 100644 --- a/macros/src/codegen/post_init.rs +++ b/macros/src/codegen/post_init.rs @@ -43,21 +43,28 @@ pub fn codegen(app: &App, analysis: &Analysis) -> Vec<TokenStream2> { } } - for (i, (monotonic, _)) in app.monotonics.iter().enumerate() { + for (i, (monotonic_ident, monotonic)) in app.monotonics.iter().enumerate() { // For future use // let doc = format!(" RTIC internal: {}:{}", file!(), line!()); // stmts.push(quote!(#[doc = #doc])); + let cfgs = &monotonic.cfgs; #[allow(clippy::cast_possible_truncation)] let idx = Index { index: i as u32, span: Span::call_site(), }; - stmts.push(quote!(monotonics.#idx.reset();)); + stmts.push(quote!( + #(#cfgs)* + monotonics.#idx.reset(); + )); // Store the monotonic - let name = util::monotonic_ident(&monotonic.to_string()); - stmts.push(quote!(#name.get_mut().write(Some(monotonics.#idx));)); + let name = util::monotonic_ident(&monotonic_ident.to_string()); + stmts.push(quote!( + #(#cfgs)* + #name.get_mut().write(Some(monotonics.#idx)); + )); } // Enable the interrupts -- this completes the `init`-ialization phase |