diff --git a/embassy-macros/src/lib.rs b/embassy-macros/src/lib.rs index e77cd9bc..8276f0bb 100644 --- a/embassy-macros/src/lib.rs +++ b/embassy-macros/src/lib.rs @@ -114,17 +114,17 @@ pub fn task(args: TokenStream, item: TokenStream) -> TokenStream { pub fn interrupt_declare(item: TokenStream) -> TokenStream { let name = syn::parse_macro_input!(item as syn::Ident); let name = format_ident!("{}", name); - let name_interrupt = format_ident!("{}Interrupt", name); + let name_interrupt = format_ident!("{}", name); let name_handler = format!("__EMBASSY_{}_HANDLER", name); let result = quote! { #[allow(non_camel_case_types)] pub struct #name_interrupt(()); - unsafe impl OwnedInterrupt for #name_interrupt { - type Priority = Priority; + unsafe impl Interrupt for #name_interrupt { + type Priority = crate::interrupt::Priority; fn number(&self) -> u16 { use cortex_m::interrupt::InterruptNumber; - let irq = Interrupt::#name; + let irq = crate::pac::interrupt::#name; irq.number() as u16 } unsafe fn steal() -> Self { @@ -144,7 +144,7 @@ pub fn interrupt_declare(item: TokenStream) -> TokenStream { pub fn interrupt_take(item: TokenStream) -> TokenStream { let name = syn::parse_macro_input!(item as syn::Ident); let name = format!("{}", name); - let name_interrupt = format_ident!("{}Interrupt", name); + let name_interrupt = format_ident!("{}", name); let name_handler = format!("__EMBASSY_{}_HANDLER", name); let result = quote! { diff --git a/embassy-nrf-examples/src/bin/multiprio.rs b/embassy-nrf-examples/src/bin/multiprio.rs index 1791a85e..850ef8fc 100644 --- a/embassy-nrf-examples/src/bin/multiprio.rs +++ b/embassy-nrf-examples/src/bin/multiprio.rs @@ -68,7 +68,7 @@ use nrf52840_hal::clocks; use embassy::executor::{task, Executor, IrqExecutor}; use embassy::time::{Duration, Instant, Timer}; use embassy::util::Forever; -use embassy_nrf::interrupt::OwnedInterrupt; +use embassy_nrf::interrupt::Interrupt; use embassy_nrf::{interrupt, pac, rtc}; #[task] @@ -115,9 +115,9 @@ async fn run_low() { static RTC: Forever> = Forever::new(); static ALARM_HIGH: Forever> = Forever::new(); -static EXECUTOR_HIGH: Forever> = Forever::new(); +static EXECUTOR_HIGH: Forever> = Forever::new(); static ALARM_MED: Forever> = Forever::new(); -static EXECUTOR_MED: Forever> = Forever::new(); +static EXECUTOR_MED: Forever> = Forever::new(); static ALARM_LOW: Forever> = Forever::new(); static EXECUTOR_LOW: Forever = Forever::new(); diff --git a/embassy-nrf/src/buffered_uarte.rs b/embassy-nrf/src/buffered_uarte.rs index d1908cf0..26a40507 100644 --- a/embassy-nrf/src/buffered_uarte.rs +++ b/embassy-nrf/src/buffered_uarte.rs @@ -16,7 +16,7 @@ use embedded_hal::digital::v2::OutputPin; use crate::hal::gpio::Port as GpioPort; use crate::hal::ppi::ConfigurablePpi; -use crate::interrupt::{self, OwnedInterrupt}; +use crate::interrupt::{self, Interrupt}; use crate::pac; use crate::util::peripheral::{PeripheralMutex, PeripheralState}; use crate::util::ring_buffer::RingBuffer; @@ -449,16 +449,16 @@ mod sealed { } pub trait Instance: Deref + sealed::Instance { - type Interrupt: OwnedInterrupt; + type Interrupt: Interrupt; } impl Instance for pac::UARTE0 { - type Interrupt = interrupt::UARTE0_UART0Interrupt; + type Interrupt = interrupt::UARTE0_UART0; } #[cfg(any(feature = "52833", feature = "52840", feature = "9160"))] impl Instance for pac::UARTE1 { - type Interrupt = interrupt::UARTE1Interrupt; + type Interrupt = interrupt::UARTE1; } pub trait TimerInstance: diff --git a/embassy-nrf/src/gpiote.rs b/embassy-nrf/src/gpiote.rs index 0e48a716..592ca82a 100644 --- a/embassy-nrf/src/gpiote.rs +++ b/embassy-nrf/src/gpiote.rs @@ -9,7 +9,7 @@ use embassy::util::Signal; use crate::hal::gpio::{Input, Level, Output, Pin as GpioPin, Port}; use crate::interrupt; -use crate::interrupt::OwnedInterrupt; +use crate::interrupt::Interrupt; use crate::pac; use crate::pac::generic::Reg; use crate::pac::gpiote::_TASKS_OUT; @@ -102,7 +102,7 @@ pub struct Channels { } impl Gpiote { - pub fn new(gpiote: GPIOTE, irq: interrupt::GPIOTEInterrupt) -> (Self, Channels) { + pub fn new(gpiote: GPIOTE, irq: interrupt::GPIOTE) -> (Self, Channels) { #[cfg(any(feature = "52833", feature = "52840"))] let ports = unsafe { &[&*pac::P0::ptr(), &*pac::P1::ptr()] }; #[cfg(not(any(feature = "52833", feature = "52840")))] diff --git a/embassy-nrf/src/interrupt.rs b/embassy-nrf/src/interrupt.rs index 90b56857..741dbaee 100644 --- a/embassy-nrf/src/interrupt.rs +++ b/embassy-nrf/src/interrupt.rs @@ -8,10 +8,8 @@ use core::sync::atomic::{compiler_fence, Ordering}; use crate::pac::NVIC_PRIO_BITS; // Re-exports -pub use crate::pac::Interrupt; -pub use crate::pac::Interrupt::*; // needed for cortex-m-rt #[interrupt] pub use cortex_m::interrupt::{CriticalSection, Mutex}; -pub use embassy::interrupt::{declare, take, OwnedInterrupt}; +pub use embassy::interrupt::{declare, take, Interrupt}; #[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] #[cfg_attr(feature = "defmt", derive(defmt::Format))] diff --git a/embassy-nrf/src/lib.rs b/embassy-nrf/src/lib.rs index b137b80c..59bb0e0c 100644 --- a/embassy-nrf/src/lib.rs +++ b/embassy-nrf/src/lib.rs @@ -60,5 +60,3 @@ pub mod interrupt; pub mod qspi; pub mod rtc; pub mod uarte; - -pub use cortex_m_rt::interrupt; diff --git a/embassy-nrf/src/qspi.rs b/embassy-nrf/src/qspi.rs index a93b5e89..902d6511 100644 --- a/embassy-nrf/src/qspi.rs +++ b/embassy-nrf/src/qspi.rs @@ -2,7 +2,7 @@ use crate::fmt::{assert, assert_eq, *}; use core::future::Future; use crate::hal::gpio::{Output, Pin as GpioPin, Port as GpioPort, PushPull}; -use crate::interrupt::{OwnedInterrupt, QSPIInterrupt}; +use crate::interrupt::{self, Interrupt}; use crate::pac::QSPI; pub use crate::pac::qspi::ifconfig0::ADDRMODE_A as AddressMode; @@ -58,7 +58,7 @@ fn port_bit(port: GpioPort) -> bool { } impl Qspi { - pub fn new(qspi: QSPI, irq: QSPIInterrupt, config: Config) -> Self { + pub fn new(qspi: QSPI, irq: interrupt::QSPI, config: Config) -> Self { qspi.psel.sck.write(|w| { let pin = &config.pins.sck; let w = unsafe { w.pin().bits(pin.pin()) }; diff --git a/embassy-nrf/src/rtc.rs b/embassy-nrf/src/rtc.rs index 1ddc460e..867c710c 100644 --- a/embassy-nrf/src/rtc.rs +++ b/embassy-nrf/src/rtc.rs @@ -5,7 +5,7 @@ use core::sync::atomic::{compiler_fence, AtomicU32, Ordering}; use embassy::time::Clock; use crate::interrupt; -use crate::interrupt::{CriticalSection, Mutex, OwnedInterrupt}; +use crate::interrupt::{CriticalSection, Interrupt, Mutex}; use crate::pac::rtc0; // RTC timekeeping works with something we call "periods", which are time intervals @@ -271,18 +271,18 @@ pub trait Instance: sealed::Instance + Deref + Sized + 'static { /// The interrupt associated with this RTC instance. - type Interrupt: OwnedInterrupt; + type Interrupt: Interrupt; } impl Instance for crate::pac::RTC0 { - type Interrupt = interrupt::RTC0Interrupt; + type Interrupt = interrupt::RTC0; } impl Instance for crate::pac::RTC1 { - type Interrupt = interrupt::RTC1Interrupt; + type Interrupt = interrupt::RTC1; } #[cfg(any(feature = "52832", feature = "52833", feature = "52840"))] impl Instance for crate::pac::RTC2 { - type Interrupt = interrupt::RTC2Interrupt; + type Interrupt = interrupt::RTC2; } diff --git a/embassy-nrf/src/uarte.rs b/embassy-nrf/src/uarte.rs index 9daed2f4..f029276b 100644 --- a/embassy-nrf/src/uarte.rs +++ b/embassy-nrf/src/uarte.rs @@ -17,7 +17,7 @@ use crate::hal::gpio::Port as GpioPort; use crate::hal::pac; use crate::hal::prelude::*; use crate::hal::target_constants::EASY_DMA_SIZE; -use crate::interrupt::OwnedInterrupt; +use crate::interrupt::Interrupt; use crate::{interrupt, util}; pub use crate::hal::uarte::Pins; @@ -422,7 +422,7 @@ mod private { pub trait Instance: Deref + Sized + private::Sealed + 'static { - type Interrupt: OwnedInterrupt; + type Interrupt: Interrupt; #[doc(hidden)] fn state() -> &'static State; @@ -434,7 +434,7 @@ static UARTE0_STATE: State = State { }; impl private::Sealed for pac::UARTE0 {} impl Instance for pac::UARTE0 { - type Interrupt = interrupt::UARTE0_UART0Interrupt; + type Interrupt = interrupt::UARTE0_UART0; fn state() -> &'static State { &UARTE0_STATE @@ -450,7 +450,7 @@ static UARTE1_STATE: State = State { impl private::Sealed for pac::UARTE1 {} #[cfg(any(feature = "52833", feature = "52840", feature = "9160"))] impl Instance for pac::UARTE1 { - type Interrupt = interrupt::UARTE1Interrupt; + type Interrupt = interrupt::UARTE1; fn state() -> &'static State { &UARTE1_STATE diff --git a/embassy-nrf/src/util/peripheral.rs b/embassy-nrf/src/util/peripheral.rs index 6062c9d3..8cefaeef 100644 --- a/embassy-nrf/src/util/peripheral.rs +++ b/embassy-nrf/src/util/peripheral.rs @@ -4,10 +4,10 @@ use core::pin::Pin; use core::sync::atomic::{compiler_fence, Ordering}; use crate::fmt::*; -use crate::interrupt::OwnedInterrupt; +use crate::interrupt::Interrupt; pub trait PeripheralState { - type Interrupt: OwnedInterrupt; + type Interrupt: Interrupt; fn on_interrupt(&mut self); } diff --git a/embassy-stm32f4/src/exti.rs b/embassy-stm32f4/src/exti.rs index 5782b8eb..6a1e1300 100644 --- a/embassy-stm32f4/src/exti.rs +++ b/embassy-stm32f4/src/exti.rs @@ -3,7 +3,7 @@ use core::mem; use core::pin::Pin; use embassy::gpio::{WaitForFallingEdge, WaitForRisingEdge}; -use embassy::interrupt::OwnedInterrupt; +use embassy::interrupt::Interrupt; use embassy::util::InterruptFuture; use crate::hal::gpio; @@ -25,7 +25,7 @@ impl<'a> ExtiManager { pub fn new_pin(&'static mut self, mut pin: T, interrupt: I) -> ExtiPin where T: HalExtiPin + WithInterrupt, - I: OwnedInterrupt, + I: Interrupt, { pin.make_interrupt_source(&mut self.syscfg); @@ -37,7 +37,7 @@ impl<'a> ExtiManager { } } -pub struct ExtiPin { +pub struct ExtiPin { pin: T, interrupt: I, _mgr: &'static ExtiManager, @@ -54,7 +54,7 @@ pub struct ExtiPin { EXTI15_10_IRQn EXTI15_10_IRQHandler Handler for pins connected to line 10 to 15 */ -impl WaitForRisingEdge for ExtiPin { +impl WaitForRisingEdge for ExtiPin { type Future<'a> = impl Future + 'a; fn wait_for_rising_edge<'a>(self: Pin<&'a mut Self>) -> Self::Future<'a> { @@ -74,7 +74,7 @@ impl WaitForRisingEdge for } } -impl WaitForFallingEdge for ExtiPin { +impl WaitForFallingEdge for ExtiPin { type Future<'a> = impl Future + 'a; fn wait_for_falling_edge<'a>(self: Pin<&'a mut Self>) -> Self::Future<'a> { @@ -133,22 +133,22 @@ macro_rules! exti { feature = "stm32f479" ))] exti! { - EXTI0Interrupt => (gpioa, PA0), - EXTI1Interrupt => (gpioa, PA1), - EXTI2Interrupt => (gpioa, PA2), - EXTI3Interrupt => (gpioa, PA3), - EXTI4Interrupt => (gpioa, PA4), - EXTI9_5Interrupt => (gpioa, PA5), - EXTI9_5Interrupt => (gpioa, PA6), - EXTI9_5Interrupt => (gpioa, PA7), - EXTI9_5Interrupt => (gpioa, PA8), - EXTI9_5Interrupt => (gpioa, PA9), - EXTI15_10Interrupt => (gpioa, PA10), - EXTI15_10Interrupt => (gpioa, PA11), - EXTI15_10Interrupt => (gpioa, PA12), - EXTI15_10Interrupt => (gpioa, PA13), - EXTI15_10Interrupt => (gpioa, PA14), - EXTI15_10Interrupt => (gpioa, PA15), + EXTI0 => (gpioa, PA0), + EXTI1 => (gpioa, PA1), + EXTI2 => (gpioa, PA2), + EXTI3 => (gpioa, PA3), + EXTI4 => (gpioa, PA4), + EXTI9_5 => (gpioa, PA5), + EXTI9_5 => (gpioa, PA6), + EXTI9_5 => (gpioa, PA7), + EXTI9_5 => (gpioa, PA8), + EXTI9_5 => (gpioa, PA9), + EXTI15_10 => (gpioa, PA10), + EXTI15_10 => (gpioa, PA11), + EXTI15_10 => (gpioa, PA12), + EXTI15_10 => (gpioa, PA13), + EXTI15_10 => (gpioa, PA14), + EXTI15_10 => (gpioa, PA15), } #[cfg(any( @@ -171,22 +171,22 @@ exti! { feature = "stm32f479" ))] exti! { - EXTI0Interrupt => (gpiob, PB0), - EXTI1Interrupt => (gpiob, PB1), - EXTI2Interrupt => (gpiob, PB2), - EXTI3Interrupt => (gpiob, PB3), - EXTI4Interrupt => (gpiob, PB4), - EXTI9_5Interrupt => (gpiob, PB5), - EXTI9_5Interrupt => (gpiob, PB6), - EXTI9_5Interrupt => (gpiob, PB7), - EXTI9_5Interrupt => (gpiob, PB8), - EXTI9_5Interrupt => (gpiob, PB9), - EXTI15_10Interrupt => (gpiob, PB10), - EXTI15_10Interrupt => (gpiob, PB11), - EXTI15_10Interrupt => (gpiob, PB12), - EXTI15_10Interrupt => (gpiob, PB13), - EXTI15_10Interrupt => (gpiob, PB14), - EXTI15_10Interrupt => (gpiob, PB15), + EXTI0 => (gpiob, PB0), + EXTI1 => (gpiob, PB1), + EXTI2 => (gpiob, PB2), + EXTI3 => (gpiob, PB3), + EXTI4 => (gpiob, PB4), + EXTI9_5 => (gpiob, PB5), + EXTI9_5 => (gpiob, PB6), + EXTI9_5 => (gpiob, PB7), + EXTI9_5 => (gpiob, PB8), + EXTI9_5 => (gpiob, PB9), + EXTI15_10 => (gpiob, PB10), + EXTI15_10 => (gpiob, PB11), + EXTI15_10 => (gpiob, PB12), + EXTI15_10 => (gpiob, PB13), + EXTI15_10 => (gpiob, PB14), + EXTI15_10 => (gpiob, PB15), } #[cfg(any( @@ -209,22 +209,22 @@ exti! { feature = "stm32f479" ))] exti! { - EXTI0Interrupt => (gpioc, PC0), - EXTI1Interrupt => (gpioc, PC1), - EXTI2Interrupt => (gpioc, PC2), - EXTI3Interrupt => (gpioc, PC3), - EXTI4Interrupt => (gpioc, PC4), - EXTI9_5Interrupt => (gpioc, PC5), - EXTI9_5Interrupt => (gpioc, PC6), - EXTI9_5Interrupt => (gpioc, PC7), - EXTI9_5Interrupt => (gpioc, PC8), - EXTI9_5Interrupt => (gpioc, PC9), - EXTI15_10Interrupt => (gpioc, PC10), - EXTI15_10Interrupt => (gpioc, PC11), - EXTI15_10Interrupt => (gpioc, PC12), - EXTI15_10Interrupt => (gpioc, PC13), - EXTI15_10Interrupt => (gpioc, PC14), - EXTI15_10Interrupt => (gpioc, PC15), + EXTI0 => (gpioc, PC0), + EXTI1 => (gpioc, PC1), + EXTI2 => (gpioc, PC2), + EXTI3 => (gpioc, PC3), + EXTI4 => (gpioc, PC4), + EXTI9_5 => (gpioc, PC5), + EXTI9_5 => (gpioc, PC6), + EXTI9_5 => (gpioc, PC7), + EXTI9_5 => (gpioc, PC8), + EXTI9_5 => (gpioc, PC9), + EXTI15_10 => (gpioc, PC10), + EXTI15_10 => (gpioc, PC11), + EXTI15_10 => (gpioc, PC12), + EXTI15_10 => (gpioc, PC13), + EXTI15_10 => (gpioc, PC14), + EXTI15_10 => (gpioc, PC15), } #[cfg(any( @@ -246,22 +246,22 @@ exti! { feature = "stm32f479" ))] exti! { - EXTI0Interrupt => (gpiod, PD0), - EXTI1Interrupt => (gpiod, PD1), - EXTI2Interrupt => (gpiod, PD2), - EXTI3Interrupt => (gpiod, PD3), - EXTI4Interrupt => (gpiod, PD4), - EXTI9_5Interrupt => (gpiod, PD5), - EXTI9_5Interrupt => (gpiod, PD6), - EXTI9_5Interrupt => (gpiod, PD7), - EXTI9_5Interrupt => (gpiod, PD8), - EXTI9_5Interrupt => (gpiod, PD9), - EXTI15_10Interrupt => (gpiod, PD10), - EXTI15_10Interrupt => (gpiod, PD11), - EXTI15_10Interrupt => (gpiod, PD12), - EXTI15_10Interrupt => (gpiod, PD13), - EXTI15_10Interrupt => (gpiod, PD14), - EXTI15_10Interrupt => (gpiod, PD15), + EXTI0 => (gpiod, PD0), + EXTI1 => (gpiod, PD1), + EXTI2 => (gpiod, PD2), + EXTI3 => (gpiod, PD3), + EXTI4 => (gpiod, PD4), + EXTI9_5 => (gpiod, PD5), + EXTI9_5 => (gpiod, PD6), + EXTI9_5 => (gpiod, PD7), + EXTI9_5 => (gpiod, PD8), + EXTI9_5 => (gpiod, PD9), + EXTI15_10 => (gpiod, PD10), + EXTI15_10 => (gpiod, PD11), + EXTI15_10 => (gpiod, PD12), + EXTI15_10 => (gpiod, PD13), + EXTI15_10 => (gpiod, PD14), + EXTI15_10 => (gpiod, PD15), } #[cfg(any( @@ -283,22 +283,22 @@ exti! { feature = "stm32f479" ))] exti! { - EXTI0Interrupt => (gpioe, PE0), - EXTI1Interrupt => (gpioe, PE1), - EXTI2Interrupt => (gpioe, PE2), - EXTI3Interrupt => (gpioe, PE3), - EXTI4Interrupt => (gpioe, PE4), - EXTI9_5Interrupt => (gpioe, PE5), - EXTI9_5Interrupt => (gpioe, PE6), - EXTI9_5Interrupt => (gpioe, PE7), - EXTI9_5Interrupt => (gpioe, PE8), - EXTI9_5Interrupt => (gpioe, PE9), - EXTI15_10Interrupt => (gpioe, PE10), - EXTI15_10Interrupt => (gpioe, PE11), - EXTI15_10Interrupt => (gpioe, PE12), - EXTI15_10Interrupt => (gpioe, PE13), - EXTI15_10Interrupt => (gpioe, PE14), - EXTI15_10Interrupt => (gpioe, PE15), + EXTI0 => (gpioe, PE0), + EXTI1 => (gpioe, PE1), + EXTI2 => (gpioe, PE2), + EXTI3 => (gpioe, PE3), + EXTI4 => (gpioe, PE4), + EXTI9_5 => (gpioe, PE5), + EXTI9_5 => (gpioe, PE6), + EXTI9_5 => (gpioe, PE7), + EXTI9_5 => (gpioe, PE8), + EXTI9_5 => (gpioe, PE9), + EXTI15_10 => (gpioe, PE10), + EXTI15_10 => (gpioe, PE11), + EXTI15_10 => (gpioe, PE12), + EXTI15_10 => (gpioe, PE13), + EXTI15_10 => (gpioe, PE14), + EXTI15_10 => (gpioe, PE15), } #[cfg(any( @@ -318,22 +318,22 @@ exti! { feature = "stm32f479" ))] exti! { - EXTI0Interrupt => (gpiof, PF0), - EXTI1Interrupt => (gpiof, PF1), - EXTI2Interrupt => (gpiof, PF2), - EXTI3Interrupt => (gpiof, PF3), - EXTI4Interrupt => (gpiof, PF4), - EXTI9_5Interrupt => (gpiof, PF5), - EXTI9_5Interrupt => (gpiof, PF6), - EXTI9_5Interrupt => (gpiof, PF7), - EXTI9_5Interrupt => (gpiof, PF8), - EXTI9_5Interrupt => (gpiof, PF9), - EXTI15_10Interrupt => (gpiof, PF10), - EXTI15_10Interrupt => (gpiof, PF11), - EXTI15_10Interrupt => (gpiof, PF12), - EXTI15_10Interrupt => (gpiof, PF13), - EXTI15_10Interrupt => (gpiof, PF14), - EXTI15_10Interrupt => (gpiof, PF15), + EXTI0 => (gpiof, PF0), + EXTI1 => (gpiof, PF1), + EXTI2 => (gpiof, PF2), + EXTI3 => (gpiof, PF3), + EXTI4 => (gpiof, PF4), + EXTI9_5 => (gpiof, PF5), + EXTI9_5 => (gpiof, PF6), + EXTI9_5 => (gpiof, PF7), + EXTI9_5 => (gpiof, PF8), + EXTI9_5 => (gpiof, PF9), + EXTI15_10 => (gpiof, PF10), + EXTI15_10 => (gpiof, PF11), + EXTI15_10 => (gpiof, PF12), + EXTI15_10 => (gpiof, PF13), + EXTI15_10 => (gpiof, PF14), + EXTI15_10 => (gpiof, PF15), } #[cfg(any( @@ -353,22 +353,22 @@ exti! { feature = "stm32f479" ))] exti! { - EXTI0Interrupt => (gpiog, PG0), - EXTI1Interrupt => (gpiog, PG1), - EXTI2Interrupt => (gpiog, PG2), - EXTI3Interrupt => (gpiog, PG3), - EXTI4Interrupt => (gpiog, PG4), - EXTI9_5Interrupt => (gpiog, PG5), - EXTI9_5Interrupt => (gpiog, PG6), - EXTI9_5Interrupt => (gpiog, PG7), - EXTI9_5Interrupt => (gpiog, PG8), - EXTI9_5Interrupt => (gpiog, PG9), - EXTI15_10Interrupt => (gpiog, PG10), - EXTI15_10Interrupt => (gpiog, PG11), - EXTI15_10Interrupt => (gpiog, PG12), - EXTI15_10Interrupt => (gpiog, PG13), - EXTI15_10Interrupt => (gpiog, PG14), - EXTI15_10Interrupt => (gpiog, PG15), + EXTI0 => (gpiog, PG0), + EXTI1 => (gpiog, PG1), + EXTI2 => (gpiog, PG2), + EXTI3 => (gpiog, PG3), + EXTI4 => (gpiog, PG4), + EXTI9_5 => (gpiog, PG5), + EXTI9_5 => (gpiog, PG6), + EXTI9_5 => (gpiog, PG7), + EXTI9_5 => (gpiog, PG8), + EXTI9_5 => (gpiog, PG9), + EXTI15_10 => (gpiog, PG10), + EXTI15_10 => (gpiog, PG11), + EXTI15_10 => (gpiog, PG12), + EXTI15_10 => (gpiog, PG13), + EXTI15_10 => (gpiog, PG14), + EXTI15_10 => (gpiog, PG15), } #[cfg(any( @@ -390,28 +390,28 @@ exti! { feature = "stm32f479" ))] exti! { - EXTI0Interrupt => (gpioh, PH0), - EXTI1Interrupt => (gpioh, PH1), - EXTI2Interrupt => (gpioh, PH2), - EXTI3Interrupt => (gpioh, PH3), - EXTI4Interrupt => (gpioh, PH4), - EXTI9_5Interrupt => (gpioh, PH5), - EXTI9_5Interrupt => (gpioh, PH6), - EXTI9_5Interrupt => (gpioh, PH7), - EXTI9_5Interrupt => (gpioh, PH8), - EXTI9_5Interrupt => (gpioh, PH9), - EXTI15_10Interrupt => (gpioh, PH10), - EXTI15_10Interrupt => (gpioh, PH11), - EXTI15_10Interrupt => (gpioh, PH12), - EXTI15_10Interrupt => (gpioh, PH13), - EXTI15_10Interrupt => (gpioh, PH14), - EXTI15_10Interrupt => (gpioh, PH15), + EXTI0 => (gpioh, PH0), + EXTI1 => (gpioh, PH1), + EXTI2 => (gpioh, PH2), + EXTI3 => (gpioh, PH3), + EXTI4 => (gpioh, PH4), + EXTI9_5 => (gpioh, PH5), + EXTI9_5 => (gpioh, PH6), + EXTI9_5 => (gpioh, PH7), + EXTI9_5 => (gpioh, PH8), + EXTI9_5 => (gpioh, PH9), + EXTI15_10 => (gpioh, PH10), + EXTI15_10 => (gpioh, PH11), + EXTI15_10 => (gpioh, PH12), + EXTI15_10 => (gpioh, PH13), + EXTI15_10 => (gpioh, PH14), + EXTI15_10 => (gpioh, PH15), } #[cfg(any(feature = "stm32f401"))] exti! { - EXTI0Interrupt => (gpioh, PH0), - EXTI1Interrupt => (gpioh, PH1), + EXTI0 => (gpioh, PH0), + EXTI1 => (gpioh, PH1), } #[cfg(any( @@ -427,22 +427,22 @@ exti! { feature = "stm32f479" ))] exti! { - EXTI0Interrupt => (gpioi, PI0), - EXTI1Interrupt => (gpioi, PI1), - EXTI2Interrupt => (gpioi, PI2), - EXTI3Interrupt => (gpioi, PI3), - EXTI4Interrupt => (gpioi, PI4), - EXTI9_5Interrupt => (gpioi, PI5), - EXTI9_5Interrupt => (gpioi, PI6), - EXTI9_5Interrupt => (gpioi, PI7), - EXTI9_5Interrupt => (gpioi, PI8), - EXTI9_5Interrupt => (gpioi, PI9), - EXTI15_10Interrupt => (gpioi, PI10), - EXTI15_10Interrupt => (gpioi, PI11), - EXTI15_10Interrupt => (gpioi, PI12), - EXTI15_10Interrupt => (gpioi, PI13), - EXTI15_10Interrupt => (gpioi, PI14), - EXTI15_10Interrupt => (gpioi, PI15), + EXTI0 => (gpioi, PI0), + EXTI1 => (gpioi, PI1), + EXTI2 => (gpioi, PI2), + EXTI3 => (gpioi, PI3), + EXTI4 => (gpioi, PI4), + EXTI9_5 => (gpioi, PI5), + EXTI9_5 => (gpioi, PI6), + EXTI9_5 => (gpioi, PI7), + EXTI9_5 => (gpioi, PI8), + EXTI9_5 => (gpioi, PI9), + EXTI15_10 => (gpioi, PI10), + EXTI15_10 => (gpioi, PI11), + EXTI15_10 => (gpioi, PI12), + EXTI15_10 => (gpioi, PI13), + EXTI15_10 => (gpioi, PI14), + EXTI15_10 => (gpioi, PI15), } #[cfg(any( @@ -454,22 +454,22 @@ exti! { feature = "stm32f479" ))] exti! { - EXTI0Interrupt => (gpioj, PJ0), - EXTI1Interrupt => (gpioj, PJ1), - EXTI2Interrupt => (gpioj, PJ2), - EXTI3Interrupt => (gpioj, PJ3), - EXTI4Interrupt => (gpioj, PJ4), - EXTI9_5Interrupt => (gpioj, PJ5), - EXTI9_5Interrupt => (gpioj, PJ6), - EXTI9_5Interrupt => (gpioj, PJ7), - EXTI9_5Interrupt => (gpioj, PJ8), - EXTI9_5Interrupt => (gpioj, PJ9), - EXTI15_10Interrupt => (gpioj, PJ10), - EXTI15_10Interrupt => (gpioj, PJ11), - EXTI15_10Interrupt => (gpioj, PJ12), - EXTI15_10Interrupt => (gpioj, PJ13), - EXTI15_10Interrupt => (gpioj, PJ14), - EXTI15_10Interrupt => (gpioj, PJ15), + EXTI0 => (gpioj, PJ0), + EXTI1 => (gpioj, PJ1), + EXTI2 => (gpioj, PJ2), + EXTI3 => (gpioj, PJ3), + EXTI4 => (gpioj, PJ4), + EXTI9_5 => (gpioj, PJ5), + EXTI9_5 => (gpioj, PJ6), + EXTI9_5 => (gpioj, PJ7), + EXTI9_5 => (gpioj, PJ8), + EXTI9_5 => (gpioj, PJ9), + EXTI15_10 => (gpioj, PJ10), + EXTI15_10 => (gpioj, PJ11), + EXTI15_10 => (gpioj, PJ12), + EXTI15_10 => (gpioj, PJ13), + EXTI15_10 => (gpioj, PJ14), + EXTI15_10 => (gpioj, PJ15), } #[cfg(any( @@ -481,12 +481,12 @@ exti! { feature = "stm32f479" ))] exti! { - EXTI0Interrupt => (gpiok, PK0), - EXTI1Interrupt => (gpiok, PK1), - EXTI2Interrupt => (gpiok, PK2), - EXTI3Interrupt => (gpiok, PK3), - EXTI4Interrupt => (gpiok, PK4), - EXTI9_5Interrupt => (gpiok, PK5), - EXTI9_5Interrupt => (gpiok, PK6), - EXTI9_5Interrupt => (gpiok, PK7), + EXTI0 => (gpiok, PK0), + EXTI1 => (gpiok, PK1), + EXTI2 => (gpiok, PK2), + EXTI3 => (gpiok, PK3), + EXTI4 => (gpiok, PK4), + EXTI9_5 => (gpiok, PK5), + EXTI9_5 => (gpiok, PK6), + EXTI9_5 => (gpiok, PK7), } diff --git a/embassy-stm32f4/src/interrupt.rs b/embassy-stm32f4/src/interrupt.rs index 4ecc7625..402aee58 100644 --- a/embassy-stm32f4/src/interrupt.rs +++ b/embassy-stm32f4/src/interrupt.rs @@ -8,10 +8,8 @@ use core::sync::atomic::{compiler_fence, Ordering}; use crate::pac::NVIC_PRIO_BITS; // Re-exports -pub use crate::pac::Interrupt; -pub use crate::pac::Interrupt::*; // needed for cortex-m-rt #[interrupt] pub use cortex_m::interrupt::{CriticalSection, Mutex}; -pub use embassy::interrupt::{declare, take, OwnedInterrupt}; +pub use embassy::interrupt::{declare, take, Interrupt}; #[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] #[cfg_attr(feature = "defmt", derive(defmt::Format))] diff --git a/embassy-stm32f4/src/lib.rs b/embassy-stm32f4/src/lib.rs index b0616cb0..aa31951d 100644 --- a/embassy-stm32f4/src/lib.rs +++ b/embassy-stm32f4/src/lib.rs @@ -315,5 +315,3 @@ pub mod exti; pub mod interrupt; pub mod rtc; pub mod serial; - -pub use cortex_m_rt::interrupt; diff --git a/embassy-stm32f4/src/rtc.rs b/embassy-stm32f4/src/rtc.rs index 28344271..da770287 100644 --- a/embassy-stm32f4/src/rtc.rs +++ b/embassy-stm32f4/src/rtc.rs @@ -7,7 +7,7 @@ use stm32f4xx_hal::bb; use stm32f4xx_hal::rcc::Clocks; use crate::interrupt; -use crate::interrupt::{CriticalSection, Mutex, OwnedInterrupt}; +use crate::interrupt::{CriticalSection, Interrupt, Mutex}; // RTC timekeeping works with something we call "periods", which are time intervals // of 2^15 ticks. The RTC counter value is 16 bits, so one "overflow cycle" is 2 periods. @@ -236,7 +236,7 @@ mod sealed { } pub trait Instance: sealed::Sealed + Sized + 'static { - type Interrupt: OwnedInterrupt; + type Interrupt: Interrupt; const REAL_ALARM_COUNT: usize; fn enable_clock(&self); @@ -489,17 +489,17 @@ macro_rules! impl_timer { } #[cfg(not(feature = "stm32f410"))] -impl_timer!(tim2: (TIM2, TIM2Interrupt, apb1enr, 0, apb1rstr, 0, ppre1, pclk1), 3); +impl_timer!(tim2: (TIM2, TIM2, apb1enr, 0, apb1rstr, 0, ppre1, pclk1), 3); #[cfg(not(feature = "stm32f410"))] -impl_timer!(tim3: (TIM3, TIM3Interrupt, apb1enr, 1, apb1rstr, 1, ppre1, pclk1), 3); +impl_timer!(tim3: (TIM3, TIM3, apb1enr, 1, apb1rstr, 1, ppre1, pclk1), 3); #[cfg(not(feature = "stm32f410"))] -impl_timer!(tim4: (TIM4, TIM4Interrupt, apb1enr, 2, apb1rstr, 2, ppre1, pclk1), 3); +impl_timer!(tim4: (TIM4, TIM4, apb1enr, 2, apb1rstr, 2, ppre1, pclk1), 3); -impl_timer!(tim5: (TIM5, TIM5Interrupt, apb1enr, 3, apb1rstr, 3, ppre1, pclk1), 3); +impl_timer!(tim5: (TIM5, TIM5, apb1enr, 3, apb1rstr, 3, ppre1, pclk1), 3); -impl_timer!(tim9: (TIM9, TIM1_BRK_TIM9Interrupt, apb2enr, 16, apb2rstr, 16, ppre2, pclk2), 1); +impl_timer!(tim9: (TIM9, TIM1_BRK_TIM9, apb2enr, 16, apb2rstr, 16, ppre2, pclk2), 1); #[cfg(not(any(feature = "stm32f401", feature = "stm32f410", feature = "stm32f411")))] -impl_timer!(tim12: (TIM12, TIM8_BRK_TIM12Interrupt, apb1enr, 6, apb1rstr, 6, ppre1, pclk1), 1); +impl_timer!(tim12: (TIM12, TIM8_BRK_TIM12, apb1enr, 6, apb1rstr, 6, ppre1, pclk1), 1); diff --git a/embassy-stm32f4/src/serial.rs b/embassy-stm32f4/src/serial.rs index 57fa1417..d84d8cb0 100644 --- a/embassy-stm32f4/src/serial.rs +++ b/embassy-stm32f4/src/serial.rs @@ -8,7 +8,7 @@ use core::future::Future; use core::ptr; use core::sync::atomic::{self, Ordering}; -use embassy::interrupt::OwnedInterrupt; +use embassy::interrupt::Interrupt; use embassy::uart::{Error, Uart}; use embassy::util::Signal; @@ -29,9 +29,9 @@ pub struct Serial, TSTREAM: Stream, RSTREAM: St tx_stream: Option, rx_stream: Option, usart: Option, - tx_int: interrupt::DMA2_STREAM7Interrupt, - rx_int: interrupt::DMA2_STREAM2Interrupt, - usart_int: interrupt::USART1Interrupt, + tx_int: interrupt::DMA2_STREAM7, + rx_int: interrupt::DMA2_STREAM2, + usart_int: interrupt::USART1, } struct State { @@ -52,9 +52,9 @@ impl Serial, Stream2> { usart: USART1, dma: DMA2, pins: PINS, - tx_int: interrupt::DMA2_STREAM7Interrupt, - rx_int: interrupt::DMA2_STREAM2Interrupt, - usart_int: interrupt::USART1Interrupt, + tx_int: interrupt::DMA2_STREAM7, + rx_int: interrupt::DMA2_STREAM2, + usart_int: interrupt::USART1, mut config: SerialConfig, clocks: Clocks, ) -> Self diff --git a/embassy/src/executor/mod.rs b/embassy/src/executor/mod.rs index 592ab235..6c42764b 100644 --- a/embassy/src/executor/mod.rs +++ b/embassy/src/executor/mod.rs @@ -17,7 +17,7 @@ mod waker; use self::util::UninitCell; use crate::fmt::panic; -use crate::interrupt::OwnedInterrupt; +use crate::interrupt::Interrupt; use crate::time::Alarm; // repr(C) is needed to guarantee that the raw::Task is located at offset 0 @@ -215,13 +215,13 @@ fn pend_by_number(n: u16) { cortex_m::peripheral::NVIC::pend(N(n)) } -pub struct IrqExecutor { +pub struct IrqExecutor { irq: I, inner: raw::Executor, not_send: PhantomData<*mut ()>, } -impl IrqExecutor { +impl IrqExecutor { pub fn new(irq: I) -> Self { let ctx = irq.number() as *mut (); Self { diff --git a/embassy/src/interrupt.rs b/embassy/src/interrupt.rs index db75ffe9..9106def5 100644 --- a/embassy/src/interrupt.rs +++ b/embassy/src/interrupt.rs @@ -29,7 +29,7 @@ unsafe impl cortex_m::interrupt::InterruptNumber for NrWrap { } } -pub unsafe trait OwnedInterrupt { +pub unsafe trait Interrupt { type Priority: From + Into + Copy; fn number(&self) -> u16; unsafe fn steal() -> Self; diff --git a/embassy/src/util/signal.rs b/embassy/src/util/signal.rs index 75ac1298..9fcfa7ac 100644 --- a/embassy/src/util/signal.rs +++ b/embassy/src/util/signal.rs @@ -1,6 +1,6 @@ use crate::executor; use crate::fmt::panic; -use crate::interrupt::OwnedInterrupt; +use crate::interrupt::Interrupt; use core::cell::UnsafeCell; use core::future::Future; use core::mem; @@ -79,18 +79,18 @@ unsafe impl cortex_m::interrupt::Nr for NrWrap { } } -pub struct InterruptFuture<'a, I: OwnedInterrupt> { +pub struct InterruptFuture<'a, I: Interrupt> { interrupt: &'a mut I, } -impl<'a, I: OwnedInterrupt> Drop for InterruptFuture<'a, I> { +impl<'a, I: Interrupt> Drop for InterruptFuture<'a, I> { fn drop(&mut self) { self.interrupt.disable(); self.interrupt.remove_handler(); } } -impl<'a, I: OwnedInterrupt> InterruptFuture<'a, I> { +impl<'a, I: Interrupt> InterruptFuture<'a, I> { pub fn new(interrupt: &'a mut I) -> Self { interrupt.disable(); interrupt.set_handler(Self::interrupt_handler, ptr::null_mut()); @@ -114,9 +114,9 @@ impl<'a, I: OwnedInterrupt> InterruptFuture<'a, I> { } } -impl<'a, I: OwnedInterrupt> Unpin for InterruptFuture<'a, I> {} +impl<'a, I: Interrupt> Unpin for InterruptFuture<'a, I> {} -impl<'a, I: OwnedInterrupt> Future for InterruptFuture<'a, I> { +impl<'a, I: Interrupt> Future for InterruptFuture<'a, I> { type Output = (); fn poll(self: core::pin::Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<()> {