From d1a968042279152fd8f342406fe89cbe7ad6ce48 Mon Sep 17 00:00:00 2001 From: Dario Nieuwenhuis Date: Wed, 9 Feb 2022 00:45:52 +0100 Subject: [PATCH] stm32: change interrupt declarations from macrotables to build.rs. --- embassy-stm32/build.rs | 17 +++++++++++++++++ embassy-stm32/src/interrupt.rs | 9 +-------- embassy-stm32/src/lib.rs | 2 -- 3 files changed, 18 insertions(+), 10 deletions(-) diff --git a/embassy-stm32/build.rs b/embassy-stm32/build.rs index c476420d..8889b0d0 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 27e44164..c757b790 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 75a4d22d..89b2be58 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;