Merge exti macros into one and use simpler recursion

This commit is contained in:
Ulf Lilleengen 2021-05-20 09:35:56 +02:00 committed by Dario Nieuwenhuis
parent 56a902c19f
commit a95c78b8bd
2 changed files with 11 additions and 22 deletions

View File

@ -242,7 +242,6 @@ for chip in chips.values():
use super::*;
impl_exti_irq!({','.join(exti_interrupts)});
impl_exti_init!({','.join(exti_interrupts)});
}}
}}
mod interrupt_vector {{

View File

@ -215,29 +215,19 @@ impl_exti!(EXTI14, 14);
impl_exti!(EXTI15, 15);
macro_rules! impl_exti_irq {
($e:ident) => {
($($e:ident),+) => {
/// safety: must be called only once
pub(crate) unsafe fn init() {
$(
crate::interrupt::$e::steal().enable();
)+
}
$(
#[interrupt]
unsafe fn $e() {
crate::exti::on_irq()
}
};
($e:ident, $($es:ident),+) => {
impl_exti_irq! { $e }
impl_exti_irq! { $($es),+ }
};
}
macro_rules! impl_exti_init {
($e:ident) => {
crate::interrupt::$e::steal().enable();
};
($e:ident, $($es:ident),+) => {
/// safety: must be called only once
pub(crate) unsafe fn init() {
impl_exti_init! { $e }
impl_exti_init! { $($es),+ }
}
)+
};
}