feat(stm32): allow bind_interrupts! to accept conditional compilation attrs

This commit is contained in:
Dinu Blanovschi 2024-10-22 12:30:37 +02:00
parent eb91089a6c
commit 3279c19eee

View File

@ -165,7 +165,7 @@ pub use crate::_generated::interrupt;
// developer note: this macro can't be in `embassy-hal-internal` due to the use of `$crate`. // developer note: this macro can't be in `embassy-hal-internal` due to the use of `$crate`.
#[macro_export] #[macro_export]
macro_rules! bind_interrupts { macro_rules! bind_interrupts {
($vis:vis struct $name:ident { $($irq:ident => $($handler:ty),*;)* }) => { ($vis:vis struct $name:ident { $($(#[cfg($cond:meta)])? $irq:ident => $($handler:ty),*;)* }) => {
#[derive(Copy, Clone)] #[derive(Copy, Clone)]
$vis struct $name; $vis struct $name;
@ -174,11 +174,13 @@ macro_rules! bind_interrupts {
#[no_mangle] #[no_mangle]
unsafe extern "C" fn $irq() { unsafe extern "C" fn $irq() {
$( $(
$(#[cfg($cond)])?
<$handler as $crate::interrupt::typelevel::Handler<$crate::interrupt::typelevel::$irq>>::on_interrupt(); <$handler as $crate::interrupt::typelevel::Handler<$crate::interrupt::typelevel::$irq>>::on_interrupt();
)* )*
} }
$( $(
$(#[cfg($cond)])?
unsafe impl $crate::interrupt::typelevel::Binding<$crate::interrupt::typelevel::$irq, $handler> for $name {} unsafe impl $crate::interrupt::typelevel::Binding<$crate::interrupt::typelevel::$irq, $handler> for $name {}
)* )*
)* )*