diff --git a/embassy-stm32/src/exti.rs b/embassy-stm32/src/exti.rs index a8875fb5..0ee93bed 100644 --- a/embassy-stm32/src/exti.rs +++ b/embassy-stm32/src/exti.rs @@ -237,22 +237,63 @@ macro_rules! impl_exti_irq { } */ +macro_rules! foreach_exti_irq { + ($action:ident) => { + crate::pac::interrupts!( + (EXTI0) => { $action!(EXTI0); }; + (EXTI1) => { $action!(EXTI1); }; + (EXTI2) => { $action!(EXTI2); }; + (EXTI3) => { $action!(EXTI3); }; + (EXTI4) => { $action!(EXTI4); }; + (EXTI5) => { $action!(EXTI5); }; + (EXTI6) => { $action!(EXTI6); }; + (EXTI7) => { $action!(EXTI7); }; + (EXTI8) => { $action!(EXTI8); }; + (EXTI9) => { $action!(EXTI9); }; + (EXTI10) => { $action!(EXTI10); }; + (EXTI11) => { $action!(EXTI11); }; + (EXTI12) => { $action!(EXTI12); }; + (EXTI13) => { $action!(EXTI13); }; + (EXTI14) => { $action!(EXTI14); }; + (EXTI15) => { $action!(EXTI15); }; + + // plus the weird ones + (EXTI0_1) => { $action!( EXTI0_1 ); }; + (EXTI15_10) => { $action!(EXTI15_10); }; + (EXTI15_4) => { $action!(EXTI15_4); }; + (EXTI1_0) => { $action!(EXTI1_0); }; + (EXTI2_3) => { $action!(EXTI2_3); }; + (EXTI2_TSC) => { $action!(EXTI2_TSC); }; + (EXTI3_2) => { $action!(EXTI3_2); }; + (EXTI4_15) => { $action!(EXTI4_15); }; + (EXTI9_5) => { $action!(EXTI9_5); }; + ); + }; +} + +macro_rules! enable_irq { + ($e:ident) => { + crate::interrupt::$e::steal().enable(); + }; +} + /// safety: must be called only once pub(crate) unsafe fn init_exti() { use embassy::interrupt::Interrupt; use embassy::interrupt::InterruptExt; - crate::pac::exti_interrupts!( - ($e:ident) => { - crate::interrupt::$e::steal().enable(); - }; - ); + foreach_exti_irq!(enable_irq); } -crate::pac::exti_interrupts!( +use crate::interrupt; + +macro_rules! impl_irq { ($e:ident) => { + #[interrupt] unsafe fn $e() { on_irq() } }; -); +} + +foreach_exti_irq!(impl_irq); diff --git a/stm32-metapac/build.rs b/stm32-metapac/build.rs index b19906ea..ef95f331 100644 --- a/stm32-metapac/build.rs +++ b/stm32-metapac/build.rs @@ -255,15 +255,8 @@ fn main() { .map(|(kind, version)| vec![kind.clone(), version.clone()]) .collect(); - let exti_interrupt_table = &interrupt_table - .iter() - .filter(|row| row[0].contains("EXTI")) - .map(|row| row.clone()) - .collect(); - make_table(&mut extra, "pins", &pin_table); make_table(&mut extra, "interrupts", &interrupt_table); - make_table(&mut extra, "exti_interrupts", &exti_interrupt_table); make_table(&mut extra, "peripherals", &peripherals_table); make_table(&mut extra, "peripheral_versions", &peripheral_version_table); make_table(&mut extra, "peripheral_pins", &peripheral_pins_table);