From 32fbb32a846e1572a5bce9f394e8589ef9f0ec29 Mon Sep 17 00:00:00 2001 From: Ulf Lilleengen Date: Thu, 20 May 2021 10:44:58 +0200 Subject: [PATCH] Move exti setup into pac module --- embassy-stm32/gen.py | 19 +++++++++++-------- embassy-stm32/src/exti.rs | 6 ++---- embassy-stm32/src/lib.rs | 2 +- 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/embassy-stm32/gen.py b/embassy-stm32/gen.py index 6cbcde7b..7bbf0b52 100644 --- a/embassy-stm32/gen.py +++ b/embassy-stm32/gen.py @@ -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" {{ diff --git a/embassy-stm32/src/exti.rs b/embassy-stm32/src/exti.rs index ce6673ba..83245f84 100644 --- a/embassy-stm32/src/exti.rs +++ b/embassy-stm32/src/exti.rs @@ -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() } diff --git a/embassy-stm32/src/lib.rs b/embassy-stm32/src/lib.rs index 0751ac0b..860962f5 100644 --- a/embassy-stm32/src/lib.rs +++ b/embassy-stm32/src/lib.rs @@ -50,7 +50,7 @@ pub fn init(_config: Config) -> Peripherals { unsafe { dma::init(); - interrupt::exti::init(); + pac::init_exti(); } p