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

View File

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

View File

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