From 33174ac65baf0d671a81b870b036056fcfe95ea7 Mon Sep 17 00:00:00 2001 From: Per Lindgren Date: Thu, 14 Apr 2022 11:33:26 +0200 Subject: [PATCH] MASK behind cfg --- examples/hardware_hi_irq.rs | 62 ++++++++++++++++++++++++++ macros/src/codegen/shared_resources.rs | 1 + src/export.rs | 1 - 3 files changed, 63 insertions(+), 1 deletion(-) create mode 100644 examples/hardware_hi_irq.rs diff --git a/examples/hardware_hi_irq.rs b/examples/hardware_hi_irq.rs new file mode 100644 index 0000000000..034f1c9550 --- /dev/null +++ b/examples/hardware_hi_irq.rs @@ -0,0 +1,62 @@ +//! examples/hardware.rs + +#![deny(unsafe_code)] +#![deny(warnings)] +#![allow(const_err)] +#![no_main] +#![no_std] + +use panic_semihosting as _; + +#[rtic::app(device = lm3s6965)] +mod app { + use cortex_m_semihosting::{debug, hprintln}; + use lm3s6965::Interrupt; + + #[shared] + struct Shared {} + + #[local] + struct Local {} + + #[init] + fn init(_: init::Context) -> (Shared, Local, init::Monotonics) { + // Pends the I2C1 interrupt but its handler won't run until *after* + // `init` returns because interrupts are disabled + rtic::pend(Interrupt::I2C1); // equivalent to NVIC::pend + + hprintln!("init").unwrap(); + + (Shared {}, Local {}, init::Monotonics()) + } + + #[idle] + fn idle(_: idle::Context) -> ! { + // interrupts are enabled again; the `UART0` handler runs at this point + + hprintln!("idle").unwrap(); + + rtic::pend(Interrupt::I2C1); + + debug::exit(debug::EXIT_SUCCESS); // Exit QEMU simulator + + loop { + cortex_m::asm::nop(); + } + } + + // ETHERNET has an interrupt vector index > 31 + // This is a test to check codegen for such cases + #[task(binds = I2C1, local = [times: u32 = 0])] + fn t1(cx: t1::Context) { + // Safe access to local `static mut` variable + *cx.local.times += 1; + + hprintln!( + "t1 called {} time{}", + *cx.local.times, + if *cx.local.times > 1 { "s" } else { "" } + ) + .unwrap(); + } +} diff --git a/macros/src/codegen/shared_resources.rs b/macros/src/codegen/shared_resources.rs index a016e4538d..ce3337816e 100644 --- a/macros/src/codegen/shared_resources.rs +++ b/macros/src/codegen/shared_resources.rs @@ -135,6 +135,7 @@ pub fn codegen( let mask_arr: Vec<_> = mask_arr.iter().map(|(_, v)| v).collect(); mod_app.push(quote!( + #[cfg(not(armv7m))] const MASKS: [u32; 3] = [#(#mask_arr),*]; )); diff --git a/src/export.rs b/src/export.rs index ed51a9e9f7..8ab74e1a8f 100644 --- a/src/export.rs +++ b/src/export.rs @@ -177,7 +177,6 @@ pub unsafe fn lock( priority: &Priority, ceiling: u8, nvic_prio_bits: u8, - _mask: &[u32; 3], f: impl FnOnce(&mut T) -> R, ) -> R { let current = priority.get();