From e297ceb1adee93f7720eedc4a4fb24815cd6b74e Mon Sep 17 00:00:00 2001 From: Per Lindgren Date: Thu, 9 Jul 2020 18:47:15 +0200 Subject: [PATCH] rtic::export::Peripherals created by into instead of transmute --- macros/src/codegen/pre_init.rs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/macros/src/codegen/pre_init.rs b/macros/src/codegen/pre_init.rs index c6bd61e86a..8aae5998b2 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(()); )); }