diff options
author | 2020-07-09 18:47:15 +0200 | |
---|---|---|
committer | 2020-07-09 19:37:04 +0200 | |
commit | e297ceb1adee93f7720eedc4a4fb24815cd6b74e (patch) | |
tree | 134f0e7e7d7d80343eece885fb582d3bf8668fd0 /macros/src/codegen/pre_init.rs | |
parent | bfb498e722dbe68c00ea8aab73d910561bab257c (diff) | |
download | rtic-e297ceb1adee93f7720eedc4a4fb24815cd6b74e.tar.gz rtic-e297ceb1adee93f7720eedc4a4fb24815cd6b74e.tar.zst rtic-e297ceb1adee93f7720eedc4a4fb24815cd6b74e.zip |
rtic::export::Peripherals created by into instead of transmute
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(()); )); } |