Skip to content

Commit

Permalink
Merge #340
Browse files Browse the repository at this point in the history
340:  rtic::export::Peripherals created by into instead of transmute r=korken89 a=perlindgren



Co-authored-by: Per Lindgren <[email protected]>
  • Loading branch information
bors[bot] and perlindgren authored Jul 21, 2020
2 parents 6ea8f6a + e297ceb commit f77226a
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions macros/src/codegen/pre_init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(());
));
}

Expand Down

0 comments on commit f77226a

Please sign in to comment.