aboutsummaryrefslogtreecommitdiff
path: root/macros/src/codegen/pre_init.rs
diff options
context:
space:
mode:
authorGravatar bors[bot] <26634292+bors[bot]@users.noreply.github.com> 2020-07-21 06:36:18 +0000
committerGravatar GitHub <noreply@github.com> 2020-07-21 06:36:18 +0000
commitf77226af16ac3da8012fba8c1f3cb1f424997706 (patch)
treeb146e872560500c5eeae1e8ea35a53c3912ea913 /macros/src/codegen/pre_init.rs
parent6ea8f6a06a9b144ec7a427cd142adddf169dc7f7 (diff)
parente297ceb1adee93f7720eedc4a4fb24815cd6b74e (diff)
downloadrtic-f77226af16ac3da8012fba8c1f3cb1f424997706.tar.gz
rtic-f77226af16ac3da8012fba8c1f3cb1f424997706.tar.zst
rtic-f77226af16ac3da8012fba8c1f3cb1f424997706.zip
Merge #340
340: rtic::export::Peripherals created by into instead of transmute r=korken89 a=perlindgren Co-authored-by: Per Lindgren <per.lindgren@ltu.se>
Diffstat (limited to 'macros/src/codegen/pre_init.rs')
-rw-r--r--macros/src/codegen/pre_init.rs14
1 files changed, 8 insertions, 6 deletions
diff --git a/macros/src/codegen/pre_init.rs b/macros/src/codegen/pre_init.rs
index c6bd61e8..8aae5998 100644
--- a/macros/src/codegen/pre_init.rs
+++ b/macros/src/codegen/pre_init.rs
@@ -38,15 +38,17 @@ pub fn codegen(
}
}
- stmts.push(quote!(
- // NOTE(transmute) to avoid debug_assertion in multi-core mode
- let mut core: rtic::export::Peripherals = core::mem::transmute(());
- ));
-
if app.args.cores == 1 {
stmts.push(quote!(
// To set the variable in cortex_m so the peripherals cannot be taken multiple times
- let _ = cortex_m::Peripherals::steal();
+ let peripherals = cortex_m::Peripherals::steal();
+ let mut core: rtic::export::Peripherals = peripherals.into();
+ ));
+ } else {
+ stmts.push(quote!(
+ // NOTE(transmute) to avoid debug_assertion in multi-core mode
+ // (This code will go away when we drop multi-core mode)
+ let mut core: rtic::export::Peripherals = core::mem::transmute(());
));
}