diff --git a/embassy-cortex-m/src/interrupt.rs b/embassy-cortex-m/src/interrupt.rs index 8e45c36c..e9fa43e8 100644 --- a/embassy-cortex-m/src/interrupt.rs +++ b/embassy-cortex-m/src/interrupt.rs @@ -9,12 +9,13 @@ use cortex_m::peripheral::NVIC; #[macro_export] macro_rules! interrupt_mod { ($($irqs:ident),* $(,)?) => { + #[cfg(feature = "rt")] pub use cortex_m_rt::interrupt; /// Interrupt definitions. pub mod interrupt { pub use embassy_cortex_m::interrupt::{InterruptExt, Priority}; - pub use crate::pac::interrupt::*; + pub use crate::pac::Interrupt::*; pub use crate::pac::Interrupt; /// Type-level interrupt infrastructure. diff --git a/embassy-nrf/Cargo.toml b/embassy-nrf/Cargo.toml index 83900d4d..5fab11f3 100644 --- a/embassy-nrf/Cargo.toml +++ b/embassy-nrf/Cargo.toml @@ -16,7 +16,8 @@ flavors = [ ] [features] -default = [ +default = ["rt"] +rt = [ "nrf52805-pac?/rt", "nrf52810-pac?/rt", "nrf52811-pac?/rt", diff --git a/embassy-nrf/src/gpiote.rs b/embassy-nrf/src/gpiote.rs index 1d7725bd..21d0d956 100644 --- a/embassy-nrf/src/gpiote.rs +++ b/embassy-nrf/src/gpiote.rs @@ -91,18 +91,21 @@ pub(crate) fn init(irq_prio: crate::interrupt::Priority) { } #[cfg(any(feature = "nrf5340-app-s", feature = "nrf9160-s"))] +#[cfg(feature = "rt")] #[interrupt] fn GPIOTE0() { unsafe { handle_gpiote_interrupt() }; } #[cfg(any(feature = "nrf5340-app-ns", feature = "nrf9160-ns"))] +#[cfg(feature = "rt")] #[interrupt] fn GPIOTE1() { unsafe { handle_gpiote_interrupt() }; } #[cfg(any(feature = "_nrf52", feature = "nrf5340-net"))] +#[cfg(feature = "rt")] #[interrupt] fn GPIOTE() { unsafe { handle_gpiote_interrupt() }; diff --git a/embassy-nrf/src/time_driver.rs b/embassy-nrf/src/time_driver.rs index f993d7b2..f1ab4f8f 100644 --- a/embassy-nrf/src/time_driver.rs +++ b/embassy-nrf/src/time_driver.rs @@ -295,6 +295,7 @@ impl Driver for RtcDriver { } } +#[cfg(feature = "rt")] #[interrupt] fn RTC1() { DRIVER.on_interrupt() diff --git a/embassy-rp/Cargo.toml b/embassy-rp/Cargo.toml index ddada655..ee06e99c 100644 --- a/embassy-rp/Cargo.toml +++ b/embassy-rp/Cargo.toml @@ -13,7 +13,8 @@ flavors = [ ] [features] -default = [ "rp-pac/rt" ] +default = [ "rt" ] +rt = [ "rp-pac/rt" ] defmt = ["dep:defmt", "embassy-usb-driver?/defmt", "embassy-hal-common/defmt"] diff --git a/embassy-rp/src/dma.rs b/embassy-rp/src/dma.rs index 042ca99a..25819f03 100644 --- a/embassy-rp/src/dma.rs +++ b/embassy-rp/src/dma.rs @@ -12,6 +12,7 @@ use crate::interrupt::InterruptExt; use crate::pac::dma::vals; use crate::{interrupt, pac, peripherals}; +#[cfg(feature = "rt")] #[interrupt] unsafe fn DMA_IRQ_0() { let ints0 = pac::DMA.ints0().read().ints0(); diff --git a/embassy-rp/src/gpio.rs b/embassy-rp/src/gpio.rs index ebd932f5..66faa248 100644 --- a/embassy-rp/src/gpio.rs +++ b/embassy-rp/src/gpio.rs @@ -142,6 +142,7 @@ pub(crate) unsafe fn init() { interrupt::IO_IRQ_BANK0.enable(); } +#[cfg(feature = "rt")] #[interrupt] unsafe fn IO_IRQ_BANK0() { let cpu = SIO.cpuid().read() as usize; diff --git a/embassy-rp/src/lib.rs b/embassy-rp/src/lib.rs index 5e3e5969..4e4b7614 100644 --- a/embassy-rp/src/lib.rs +++ b/embassy-rp/src/lib.rs @@ -43,6 +43,7 @@ pub use rp_pac as pac; #[cfg(not(feature = "unstable-pac"))] pub(crate) use rp_pac as pac; +#[cfg(feature = "rt")] pub use crate::pac::NVIC_PRIO_BITS; embassy_cortex_m::interrupt_mod!( diff --git a/embassy-rp/src/multicore.rs b/embassy-rp/src/multicore.rs index e1246ce8..2a7e4822 100644 --- a/embassy-rp/src/multicore.rs +++ b/embassy-rp/src/multicore.rs @@ -106,6 +106,7 @@ impl Stack { } } +#[cfg(feature = "rt")] #[interrupt] #[link_section = ".data.ram_func"] unsafe fn SIO_IRQ_PROC1() { @@ -297,6 +298,7 @@ fn fifo_read() -> u32 { // Pop a value from inter-core FIFO, `wfe` until available #[inline(always)] +#[allow(unused)] fn fifo_read_wfe() -> u32 { unsafe { let sio = pac::SIO; diff --git a/embassy-rp/src/pio.rs b/embassy-rp/src/pio.rs index f0a5c17a..0fa3bd77 100644 --- a/embassy-rp/src/pio.rs +++ b/embassy-rp/src/pio.rs @@ -85,6 +85,7 @@ const RXNEMPTY_MASK: u32 = 1 << 0; const TXNFULL_MASK: u32 = 1 << 4; const SMIRQ_MASK: u32 = 1 << 8; +#[cfg(feature = "rt")] #[interrupt] unsafe fn PIO0_IRQ_0() { use crate::pac; @@ -97,6 +98,7 @@ unsafe fn PIO0_IRQ_0() { pac::PIO0.irqs(0).inte().write_clear(|m| m.0 = ints); } +#[cfg(feature = "rt")] #[interrupt] unsafe fn PIO1_IRQ_0() { use crate::pac; diff --git a/embassy-rp/src/timer.rs b/embassy-rp/src/timer.rs index 37f86c93..ca8c96c0 100644 --- a/embassy-rp/src/timer.rs +++ b/embassy-rp/src/timer.rs @@ -151,21 +151,25 @@ pub unsafe fn init() { interrupt::TIMER_IRQ_3.enable(); } +#[cfg(feature = "rt")] #[interrupt] unsafe fn TIMER_IRQ_0() { DRIVER.check_alarm(0) } +#[cfg(feature = "rt")] #[interrupt] unsafe fn TIMER_IRQ_1() { DRIVER.check_alarm(1) } +#[cfg(feature = "rt")] #[interrupt] unsafe fn TIMER_IRQ_2() { DRIVER.check_alarm(2) } +#[cfg(feature = "rt")] #[interrupt] unsafe fn TIMER_IRQ_3() { DRIVER.check_alarm(3) diff --git a/embassy-stm32/Cargo.toml b/embassy-stm32/Cargo.toml index 4e29bb32..f1f894c6 100644 --- a/embassy-stm32/Cargo.toml +++ b/embassy-stm32/Cargo.toml @@ -79,7 +79,9 @@ quote = "1.0.15" stm32-metapac = { version = "9", default-features = false, features = ["metadata"]} [features] -default = ["stm32-metapac/rt"] +default = ["rt"] +rt = ["stm32-metapac/rt"] + defmt = ["dep:defmt", "bxcan/unstable-defmt", "embassy-sync/defmt", "embassy-executor/defmt", "embassy-embedded-hal/defmt", "embassy-hal-common/defmt", "embedded-io?/defmt", "embassy-usb-driver?/defmt", "embassy-net-driver/defmt"] memory-x = ["stm32-metapac/memory-x"] exti = [] diff --git a/embassy-stm32/build.rs b/embassy-stm32/build.rs index 267fec38..ba5f91cc 100644 --- a/embassy-stm32/build.rs +++ b/embassy-stm32/build.rs @@ -295,6 +295,7 @@ fn main() { let channels = channels.iter().map(|(_, dma, ch)| format_ident!("{}_{}", dma, ch)); g.extend(quote! { + #[cfg(feature = "rt")] #[crate::interrupt] unsafe fn #irq () { #( diff --git a/embassy-stm32/src/exti.rs b/embassy-stm32/src/exti.rs index a2ed0709..0631ae47 100644 --- a/embassy-stm32/src/exti.rs +++ b/embassy-stm32/src/exti.rs @@ -291,6 +291,7 @@ macro_rules! foreach_exti_irq { macro_rules! impl_irq { ($e:ident) => { + #[cfg(feature = "rt")] #[interrupt] unsafe fn $e() { on_irq() diff --git a/embassy-stm32/src/lib.rs b/embassy-stm32/src/lib.rs index 565d6817..f8857fdd 100644 --- a/embassy-stm32/src/lib.rs +++ b/embassy-stm32/src/lib.rs @@ -111,6 +111,7 @@ pub use stm32_metapac as pac; #[cfg(not(feature = "unstable-pac"))] pub(crate) use stm32_metapac as pac; +#[cfg(feature = "rt")] pub use crate::pac::NVIC_PRIO_BITS; #[non_exhaustive] diff --git a/embassy-stm32/src/rng.rs b/embassy-stm32/src/rng.rs index 1e16b847..c657bf70 100644 --- a/embassy-stm32/src/rng.rs +++ b/embassy-stm32/src/rng.rs @@ -149,6 +149,7 @@ foreach_peripheral!( }; ); +#[cfg(feature = "rt")] macro_rules! irq { ($irq:ident) => { mod rng_irq { @@ -166,6 +167,7 @@ macro_rules! irq { }; } +#[cfg(feature = "rt")] foreach_interrupt!( (RNG) => { irq!(RNG); diff --git a/embassy-stm32/src/time_driver.rs b/embassy-stm32/src/time_driver.rs index 8f282baf..e82501a4 100644 --- a/embassy-stm32/src/time_driver.rs +++ b/embassy-stm32/src/time_driver.rs @@ -40,6 +40,7 @@ type T = peripherals::TIM15; foreach_interrupt! { (TIM2, timer, $block:ident, UP, $irq:ident) => { #[cfg(time_driver_tim2)] + #[cfg(feature = "rt")] #[interrupt] fn $irq() { DRIVER.on_interrupt() @@ -47,6 +48,7 @@ foreach_interrupt! { }; (TIM3, timer, $block:ident, UP, $irq:ident) => { #[cfg(time_driver_tim3)] + #[cfg(feature = "rt")] #[interrupt] fn $irq() { DRIVER.on_interrupt() @@ -54,6 +56,7 @@ foreach_interrupt! { }; (TIM4, timer, $block:ident, UP, $irq:ident) => { #[cfg(time_driver_tim4)] + #[cfg(feature = "rt")] #[interrupt] fn $irq() { DRIVER.on_interrupt() @@ -61,6 +64,7 @@ foreach_interrupt! { }; (TIM5, timer, $block:ident, UP, $irq:ident) => { #[cfg(time_driver_tim5)] + #[cfg(feature = "rt")] #[interrupt] fn $irq() { DRIVER.on_interrupt() @@ -68,6 +72,7 @@ foreach_interrupt! { }; (TIM12, timer, $block:ident, UP, $irq:ident) => { #[cfg(time_driver_tim12)] + #[cfg(feature = "rt")] #[interrupt] fn $irq() { DRIVER.on_interrupt() @@ -75,6 +80,7 @@ foreach_interrupt! { }; (TIM15, timer, $block:ident, UP, $irq:ident) => { #[cfg(time_driver_tim15)] + #[cfg(feature = "rt")] #[interrupt] fn $irq() { DRIVER.on_interrupt()