From 5c23c789ee2776ea022957b82480dad6d0d0f660 Mon Sep 17 00:00:00 2001 From: Dinu Blanovschi Date: Tue, 22 Oct 2024 16:23:17 +0200 Subject: [PATCH] fix --- embassy-stm32/src/lib.rs | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/embassy-stm32/src/lib.rs b/embassy-stm32/src/lib.rs index c59174988..de68c54dc 100644 --- a/embassy-stm32/src/lib.rs +++ b/embassy-stm32/src/lib.rs @@ -188,13 +188,30 @@ macro_rules! bind_interrupts { )* } - $( - $(#[cfg($cond_irq)])? + $crate::bind_interrupts!(@__generate_impls $name $(#[cfg($cond_irq)])? $irq => $( $(#[cfg($cond_handler)])? - unsafe impl $crate::interrupt::typelevel::Binding<$crate::interrupt::typelevel::$irq, $handler> for $name {} - )* + $handler; + )*); )* }; + + (@__generate_single_impl $name:ident $(#[cfg($cond_irq:meta)])? $irq:ident => $(#[cfg($cond_handler:meta)])? $handler:ty;) => { + #[cfg(all( + $($cond_irq,)? + $($cond_handler,)? + ))] + unsafe impl $crate::interrupt::typelevel::Binding<$crate::interrupt::typelevel::$irq, $handler> for $name {} + }; + + (@__generate_impls $name:ident $(#[cfg($cond_irq:meta)])? $irq:ident => $(#[cfg($cond_handler:meta)])? $handler:ty;) => { + $crate::bind_interrupts!(@__generate_single_impl $name $(#[cfg($cond_irq)])? $irq => $(#[cfg($cond_handler)])? $handler;); + }; + + (@__generate_impls $name:ident $(#[cfg($cond_irq:meta)])? $irq:ident => $(#[cfg($cond_handler:meta)])? $handler:ty; $(tail:tt)*) => { + $crate::bind_interrupts!(@__generate_single_impl $name $(#[cfg($cond_irq)])? $irq => $(#[cfg($cond_handler)])? $handler;); + + $crate::bind_interrupts!(@__generate_impls $name $(#[cfg($cond_irq)])? $irq => $(tail)*); + }; } // Reexports