mirror of
https://github.com/embassy-rs/embassy.git
synced 2024-11-22 06:42:32 +00:00
fix: review comments
This commit is contained in:
parent
e9f2e63796
commit
c797915525
@ -177,22 +177,31 @@ mod chip;
|
|||||||
// 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_irq:meta)])?
|
||||||
|
$irq:ident => $(
|
||||||
|
$(#[cfg($cond_handler:meta)])?
|
||||||
|
$handler:ty
|
||||||
|
),*;
|
||||||
|
)*
|
||||||
|
}) => {
|
||||||
#[derive(Copy, Clone)]
|
#[derive(Copy, Clone)]
|
||||||
$vis struct $name;
|
$vis struct $name;
|
||||||
|
|
||||||
$(
|
$(
|
||||||
#[allow(non_snake_case)]
|
#[allow(non_snake_case)]
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
|
$(#[cfg($cond_irq)])?
|
||||||
unsafe extern "C" fn $irq() {
|
unsafe extern "C" fn $irq() {
|
||||||
$(
|
$(
|
||||||
|
$(#[cfg($cond_handler)])?
|
||||||
<$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_handler)])?
|
||||||
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 {}
|
||||||
)*
|
)*
|
||||||
|
}
|
||||||
)*
|
)*
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -165,22 +165,31 @@ embassy_hal_internal::interrupt_mod!(
|
|||||||
// 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_irq:meta)])?
|
||||||
|
$irq:ident => $(
|
||||||
|
$(#[cfg($cond_handler:meta)])?
|
||||||
|
$handler:ty
|
||||||
|
),*;
|
||||||
|
)*
|
||||||
|
}) => {
|
||||||
#[derive(Copy, Clone)]
|
#[derive(Copy, Clone)]
|
||||||
$vis struct $name;
|
$vis struct $name;
|
||||||
|
|
||||||
$(
|
$(
|
||||||
#[allow(non_snake_case)]
|
#[allow(non_snake_case)]
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
|
$(#[cfg($cond_irq)])?
|
||||||
unsafe extern "C" fn $irq() {
|
unsafe extern "C" fn $irq() {
|
||||||
$(
|
$(
|
||||||
|
$(#[cfg($cond_handler)])?
|
||||||
<$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_handler)])?
|
||||||
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 {}
|
||||||
)*
|
)*
|
||||||
|
}
|
||||||
)*
|
)*
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -185,33 +185,13 @@ macro_rules! bind_interrupts {
|
|||||||
$(
|
$(
|
||||||
$(#[cfg($cond_handler)])?
|
$(#[cfg($cond_handler)])?
|
||||||
<$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_handler)])?
|
||||||
|
unsafe impl $crate::interrupt::typelevel::Binding<$crate::interrupt::typelevel::$irq, $handler> for $name {}
|
||||||
)*
|
)*
|
||||||
}
|
}
|
||||||
|
|
||||||
$crate::bind_interrupts!(@__generate_impls $name $(#[cfg($cond_irq)])? $irq => $(
|
|
||||||
$(#[cfg($cond_handler)])?
|
|
||||||
$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; $($(#[cfg($cond_rest:meta)])? $handler_rest:ty;)+) => {
|
|
||||||
$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 => $($(#[cfg($cond_rest)])? $handler_rest;)+);
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reexports
|
// Reexports
|
||||||
|
Loading…
Reference in New Issue
Block a user