diff options
author | 2020-07-21 06:36:18 +0000 | |
---|---|---|
committer | 2020-07-21 06:36:18 +0000 | |
commit | f77226af16ac3da8012fba8c1f3cb1f424997706 (patch) | |
tree | b146e872560500c5eeae1e8ea35a53c3912ea913 /macros/src/codegen/pre_init.rs | |
parent | 6ea8f6a06a9b144ec7a427cd142adddf169dc7f7 (diff) | |
parent | e297ceb1adee93f7720eedc4a4fb24815cd6b74e (diff) | |
download | rtic-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.rs | 14 |
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(()); )); } |