Cleanup interrupt package naming. Fixes #40
The `interrupt` package previously tried to be drop-in compatible with the `interrupt` package from PACs. THis meant that there was both a PAC-style enum value `UARTE0` and an embassy-style owned `UARTE0Interrupt` type. This made things VERY confusing. This drops compatibility with the PAC, improving the names for embassy interrupts.
This commit is contained in:
@ -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<Target = pac::uarte0::RegisterBlock> + 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:
|
||||
|
@ -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")))]
|
||||
|
@ -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))]
|
||||
|
@ -60,5 +60,3 @@ pub mod interrupt;
|
||||
pub mod qspi;
|
||||
pub mod rtc;
|
||||
pub mod uarte;
|
||||
|
||||
pub use cortex_m_rt::interrupt;
|
||||
|
@ -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()) };
|
||||
|
@ -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<Target = rtc0::RegisterBlock> + 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;
|
||||
}
|
||||
|
@ -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<Target = pac::uarte0::RegisterBlock> + 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
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user