aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDinu Blanovschi <[email protected]>2024-10-22 15:43:28 +0200
committerDinu Blanovschi <[email protected]>2024-10-22 15:43:28 +0200
commitccd635f0dc5d9a21f7cec87e18368d70482b93ca (patch)
treecfff9bd32ac47ac23db47be1c6391d65694a136e
parent3279c19eeeb942d15805c7780bf3bcad6159286e (diff)
fix + allow both conditions on the irq and the handlers
-rw-r--r--embassy-stm32/src/lib.rs15
1 files changed, 12 insertions, 3 deletions
diff --git a/embassy-stm32/src/lib.rs b/embassy-stm32/src/lib.rs
index 3ff9dcb7e..2ce18c3c0 100644
--- a/embassy-stm32/src/lib.rs
+++ b/embassy-stm32/src/lib.rs
@@ -165,22 +165,31 @@ pub use crate::_generated::interrupt;
165// developer note: this macro can't be in `embassy-hal-internal` due to the use of `$crate`. 165// developer note: this macro can't be in `embassy-hal-internal` due to the use of `$crate`.
166#[macro_export] 166#[macro_export]
167macro_rules! bind_interrupts { 167macro_rules! bind_interrupts {
168 ($vis:vis struct $name:ident { $($(#[cfg($cond:meta)])? $irq:ident => $($handler:ty),*;)* }) => { 168 ($vis:vis struct $name:ident {
169 $(
170 $(#[cfg($cond_irq:meta)])?
171 $irq:ident => $(
172 $(#[cfg($cond_handler:meta)])?
173 $handler:ty
174 ),*;
175 )*
176 }) => {
169 #[derive(Copy, Clone)] 177 #[derive(Copy, Clone)]
170 $vis struct $name; 178 $vis struct $name;
171 179
172 $( 180 $(
173 #[allow(non_snake_case)] 181 #[allow(non_snake_case)]
174 #[no_mangle] 182 #[no_mangle]
183 $(#[cfg($cond_irq)])?
175 unsafe extern "C" fn $irq() { 184 unsafe extern "C" fn $irq() {
176 $( 185 $(
177 $(#[cfg($cond)])? 186 $(#[cfg($cond_handler)])?
178 <$handler as $crate::interrupt::typelevel::Handler<$crate::interrupt::typelevel::$irq>>::on_interrupt(); 187 <$handler as $crate::interrupt::typelevel::Handler<$crate::interrupt::typelevel::$irq>>::on_interrupt();
179 )* 188 )*
180 } 189 }
181 190
182 $( 191 $(
183 $(#[cfg($cond)])? 192 $(#[cfg(all($cond_irq, $cond_handler))])?
184 unsafe impl $crate::interrupt::typelevel::Binding<$crate::interrupt::typelevel::$irq, $handler> for $name {} 193 unsafe impl $crate::interrupt::typelevel::Binding<$crate::interrupt::typelevel::$irq, $handler> for $name {}
185 )* 194 )*
186 )* 195 )*