aboutsummaryrefslogtreecommitdiff
path: root/macros/src/codegen/post_init.rs
diff options
context:
space:
mode:
authorGravatar bors[bot] <26634292+bors[bot]@users.noreply.github.com> 2023-01-25 20:15:31 +0000
committerGravatar GitHub <noreply@github.com> 2023-01-25 20:15:31 +0000
commita601c6e449e7222dcfe73bc2f2c41c95b99b46d7 (patch)
treed7d079786f98a0b1c9d4e698607236adc3fde6d3 /macros/src/codegen/post_init.rs
parenta5e18cd5294870be824f90bdd1d586586c37a153 (diff)
parent259be7bbf9cfa0ac24c276190515e988d98770b7 (diff)
downloadrtic-a601c6e449e7222dcfe73bc2f2c41c95b99b46d7.tar.gz
rtic-a601c6e449e7222dcfe73bc2f2c41c95b99b46d7.tar.zst
rtic-a601c6e449e7222dcfe73bc2f2c41c95b99b46d7.zip
Merge #691
691: Basic cfg support, kind of, for Monotonics r=korken89 a=AfoHT - Enable at least masking out a Monotonic - Add example cfg-ing a Monotonic, showing limitations imposed by rtic-syntax - Update changelog The use case detailed in linked issue seems to be covered: Fixes #664 Co-authored-by: Henrik Tjäder <henrik@tjaders.com>
Diffstat (limited to 'macros/src/codegen/post_init.rs')
-rw-r--r--macros/src/codegen/post_init.rs15
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