aboutsummaryrefslogtreecommitdiff
path: root/macros/src/codegen/pre_init.rs
diff options
context:
space:
mode:
authorGravatar Jorge Aparicio <jorge@japaric.io> 2019-06-18 10:31:31 +0200
committerGravatar Jorge Aparicio <jorge@japaric.io> 2019-06-18 10:31:31 +0200
commit9897728709528a02545523bea72576abce89dc4c (patch)
tree49619bfb8e3e09cccbc9c2bd1854abfe1618c8fd /macros/src/codegen/pre_init.rs
parent81275bfa4f41e2066770087f3a33cad4227eab41 (diff)
downloadrtic-9897728709528a02545523bea72576abce89dc4c.tar.gz
rtic-9897728709528a02545523bea72576abce89dc4c.tar.zst
rtic-9897728709528a02545523bea72576abce89dc4c.zip
add homogeneous multi-core support
Diffstat (limited to 'macros/src/codegen/pre_init.rs')
-rw-r--r--macros/src/codegen/pre_init.rs17
1 files changed, 13 insertions, 4 deletions
diff --git a/macros/src/codegen/pre_init.rs b/macros/src/codegen/pre_init.rs
index 3ba17dcf..19fc6461 100644
--- a/macros/src/codegen/pre_init.rs
+++ b/macros/src/codegen/pre_init.rs
@@ -39,7 +39,8 @@ pub fn codegen(
}
stmts.push(quote!(
- let mut core = rtfm::export::Peripherals::steal();
+ // NOTE(transmute) to avoid debug_assertion in multi-core mode
+ let mut core: rtfm::export::Peripherals = core::mem::transmute(());
));
let device = extra.device;
@@ -64,25 +65,33 @@ pub fn codegen(
stmts.push(quote!(let _ = [(); ((1 << #nvic_prio_bits) - #priority as usize)];));
// NOTE this also checks that the interrupt exists in the `Interrupt` enumeration
+ let interrupt = util::interrupt_ident(core, app.args.cores);
stmts.push(quote!(
core.NVIC.set_priority(
- #device::Interrupt::#name,
+ #device::#interrupt::#name,
rtfm::export::logical2hw(#priority, #nvic_prio_bits),
);
));
// NOTE unmask the interrupt *after* setting its priority: changing the priority of a pended
// interrupt is implementation defined
- stmts.push(quote!(core.NVIC.enable(#device::Interrupt::#name);));
+ stmts.push(quote!(core.NVIC.enable(#device::#interrupt::#name);));
}
// cross-spawn barriers: now that priorities have been set and the interrupts have been unmasked
// we are ready to receive messages from *other* cores
if analysis.spawn_barriers.contains_key(&core) {
let sb = util::spawn_barrier(core);
+ let shared = if cfg!(feature = "heterogeneous") {
+ Some(quote!(
+ #[rtfm::export::shared]
+ ))
+ } else {
+ None
+ };
const_app.push(quote!(
- #[rtfm::export::shared]
+ #shared
static #sb: rtfm::export::Barrier = rtfm::export::Barrier::new();
));