Move exti setup into pac module

This commit is contained in:
Ulf Lilleengen 2021-05-20 10:44:58 +02:00 committed by Dario Nieuwenhuis
parent a95c78b8bd
commit 32fbb32a84
3 changed files with 14 additions and 13 deletions

View file

@ -197,6 +197,17 @@ for chip in chips.values():
peripherals!({','.join(peripheral_names)});
""")
# ========= exti interrupts
f.write(f"""
use embassy::interrupt::Interrupt;
use embassy::interrupt::InterruptExt;
impl_exti_irq!({','.join(exti_interrupts)});
""")
# ========= interrupts
irq_variants = []
@ -235,14 +246,6 @@ for chip in chips.values():
}}
{''.join(irq_declares)}
pub mod exti {{
use embassy::interrupt::InterruptExt;
use crate::interrupt;
use super::*;
impl_exti_irq!({','.join(exti_interrupts)});
}}
}}
mod interrupt_vector {{
extern "C" {{

View file

@ -4,7 +4,6 @@ use core::future::Future;
use core::marker::PhantomData;
use core::pin::Pin;
use core::task::{Context, Poll};
use embassy::interrupt::{Interrupt, InterruptExt};
use embassy::traits::gpio::{WaitForAnyEdge, WaitForFallingEdge, WaitForRisingEdge};
use embassy::util::{AtomicWaker, Unborrow};
use embassy_extras::unsafe_impl_unborrow;
@ -12,7 +11,6 @@ use embedded_hal::digital::v2::InputPin;
use pac::exti::{regs, vals};
use crate::gpio::{AnyPin, Input, Pin as GpioPin};
use crate::interrupt;
use crate::pac;
use crate::pac::{EXTI, SYSCFG};
use crate::peripherals;
@ -217,14 +215,14 @@ impl_exti!(EXTI15, 15);
macro_rules! impl_exti_irq {
($($e:ident),+) => {
/// safety: must be called only once
pub(crate) unsafe fn init() {
pub(crate) unsafe fn init_exti() {
$(
crate::interrupt::$e::steal().enable();
)+
}
$(
#[interrupt]
#[crate::interrupt]
unsafe fn $e() {
crate::exti::on_irq()
}

View file

@ -50,7 +50,7 @@ pub fn init(_config: Config) -> Peripherals {
unsafe {
dma::init();
interrupt::exti::init();
pac::init_exti();
}
p