diff --git a/embassy-stm32/build.rs b/embassy-stm32/build.rs index c476420d2..8889b0d01 100644 --- a/embassy-stm32/build.rs +++ b/embassy-stm32/build.rs @@ -84,6 +84,23 @@ fn main() { embassy_hal_common::peripherals!(#(#singleton_tokens),*); }); + // ======== + // Generate interrupt declarations + + let mut irqs = Vec::new(); + for irq in METADATA.interrupts { + irqs.push(format_ident!("{}", irq.name)); + } + + g.extend(quote! { + pub mod interrupt { + use crate::pac::Interrupt as InterruptEnum; + #( + embassy::interrupt::declare!(#irqs); + )* + } + }); + // ======== // Generate DMA IRQs. diff --git a/embassy-stm32/src/interrupt.rs b/embassy-stm32/src/interrupt.rs index 27e441644..c757b790c 100644 --- a/embassy-stm32/src/interrupt.rs +++ b/embassy-stm32/src/interrupt.rs @@ -3,11 +3,4 @@ pub use critical_section::CriticalSection; pub use embassy::interrupt::{take, Interrupt}; pub use embassy_hal_common::interrupt::Priority4 as Priority; -use crate::pac::Interrupt as InterruptEnum; -use embassy::interrupt::declare; - -crate::pac::interrupts!( - ($name:ident) => { - declare!($name); - }; -); +pub use crate::generated::interrupt::*; diff --git a/embassy-stm32/src/lib.rs b/embassy-stm32/src/lib.rs index 75a4d22d8..89b2be582 100644 --- a/embassy-stm32/src/lib.rs +++ b/embassy-stm32/src/lib.rs @@ -63,8 +63,6 @@ mod generated { #![allow(unused_imports)] #![allow(non_snake_case)] - use crate::interrupt; - include!(concat!(env!("OUT_DIR"), "/generated.rs")); } pub use embassy_macros::interrupt;