diff options
| author | Dario Nieuwenhuis <[email protected]> | 2023-06-08 16:08:40 +0200 |
|---|---|---|
| committer | Dario Nieuwenhuis <[email protected]> | 2023-06-08 18:00:48 +0200 |
| commit | 921780e6bfb9bcb2cd087b8aa8b094d792c99fa2 (patch) | |
| tree | bd21fba9800471b860ca44e05567588dcc1afef7 /embassy-rp/src/uart | |
| parent | 87ad66f2b4a5bfd36dfc8d8aad5492e9e3f915e6 (diff) | |
Make interrupt module more standard.
- Move typelevel interrupts to a special-purpose mod: `embassy_xx::interrupt::typelevel`.
- Reexport the PAC interrupt enum in `embassy_xx::interrupt`.
This has a few advantages:
- The `embassy_xx::interrupt` module is now more "standard".
- It works with `cortex-m` functions for manipulating interrupts, for example.
- It works with RTIC.
- the interrupt enum allows holding value that can be "any interrupt at runtime", this can't be done with typelevel irqs.
- When "const-generics on enums" is stable, we can remove the typelevel interrupts without disruptive changes to `embassy_xx::interrupt`.
Diffstat (limited to 'embassy-rp/src/uart')
| -rw-r--r-- | embassy-rp/src/uart/buffered.rs | 6 | ||||
| -rw-r--r-- | embassy-rp/src/uart/mod.rs | 10 |
2 files changed, 8 insertions, 8 deletions
diff --git a/embassy-rp/src/uart/buffered.rs b/embassy-rp/src/uart/buffered.rs index bb808c467..6660d5dc9 100644 --- a/embassy-rp/src/uart/buffered.rs +++ b/embassy-rp/src/uart/buffered.rs | |||
| @@ -3,14 +3,14 @@ use core::slice; | |||
| 3 | use core::task::Poll; | 3 | use core::task::Poll; |
| 4 | 4 | ||
| 5 | use atomic_polyfill::{AtomicU8, Ordering}; | 5 | use atomic_polyfill::{AtomicU8, Ordering}; |
| 6 | use embassy_cortex_m::interrupt::{self, Binding, Interrupt}; | ||
| 7 | use embassy_hal_common::atomic_ring_buffer::RingBuffer; | 6 | use embassy_hal_common::atomic_ring_buffer::RingBuffer; |
| 8 | use embassy_sync::waitqueue::AtomicWaker; | 7 | use embassy_sync::waitqueue::AtomicWaker; |
| 9 | use embassy_time::{Duration, Timer}; | 8 | use embassy_time::{Duration, Timer}; |
| 10 | 9 | ||
| 11 | use super::*; | 10 | use super::*; |
| 12 | use crate::clocks::clk_peri_freq; | 11 | use crate::clocks::clk_peri_freq; |
| 13 | use crate::RegExt; | 12 | use crate::interrupt::typelevel::{Binding, Interrupt}; |
| 13 | use crate::{interrupt, RegExt}; | ||
| 14 | 14 | ||
| 15 | pub struct State { | 15 | pub struct State { |
| 16 | tx_waker: AtomicWaker, | 16 | tx_waker: AtomicWaker, |
| @@ -485,7 +485,7 @@ pub struct BufferedInterruptHandler<T: Instance> { | |||
| 485 | _uart: PhantomData<T>, | 485 | _uart: PhantomData<T>, |
| 486 | } | 486 | } |
| 487 | 487 | ||
| 488 | impl<T: Instance> interrupt::Handler<T::Interrupt> for BufferedInterruptHandler<T> { | 488 | impl<T: Instance> interrupt::typelevel::Handler<T::Interrupt> for BufferedInterruptHandler<T> { |
| 489 | unsafe fn on_interrupt() { | 489 | unsafe fn on_interrupt() { |
| 490 | let r = T::regs(); | 490 | let r = T::regs(); |
| 491 | if r.uartdmacr().read().rxdmae() { | 491 | if r.uartdmacr().read().rxdmae() { |
diff --git a/embassy-rp/src/uart/mod.rs b/embassy-rp/src/uart/mod.rs index a83d94e49..5e3ae8a25 100644 --- a/embassy-rp/src/uart/mod.rs +++ b/embassy-rp/src/uart/mod.rs | |||
| @@ -3,7 +3,6 @@ use core::marker::PhantomData; | |||
| 3 | use core::task::Poll; | 3 | use core::task::Poll; |
| 4 | 4 | ||
| 5 | use atomic_polyfill::{AtomicU16, Ordering}; | 5 | use atomic_polyfill::{AtomicU16, Ordering}; |
| 6 | use embassy_cortex_m::interrupt::{self, Binding, Interrupt}; | ||
| 7 | use embassy_futures::select::{select, Either}; | 6 | use embassy_futures::select::{select, Either}; |
| 8 | use embassy_hal_common::{into_ref, PeripheralRef}; | 7 | use embassy_hal_common::{into_ref, PeripheralRef}; |
| 9 | use embassy_sync::waitqueue::AtomicWaker; | 8 | use embassy_sync::waitqueue::AtomicWaker; |
| @@ -14,8 +13,9 @@ use crate::clocks::clk_peri_freq; | |||
| 14 | use crate::dma::{AnyChannel, Channel}; | 13 | use crate::dma::{AnyChannel, Channel}; |
| 15 | use crate::gpio::sealed::Pin; | 14 | use crate::gpio::sealed::Pin; |
| 16 | use crate::gpio::AnyPin; | 15 | use crate::gpio::AnyPin; |
| 16 | use crate::interrupt::typelevel::{Binding, Interrupt}; | ||
| 17 | use crate::pac::io::vals::{Inover, Outover}; | 17 | use crate::pac::io::vals::{Inover, Outover}; |
| 18 | use crate::{pac, peripherals, Peripheral, RegExt}; | 18 | use crate::{interrupt, pac, peripherals, Peripheral, RegExt}; |
| 19 | 19 | ||
| 20 | #[cfg(feature = "nightly")] | 20 | #[cfg(feature = "nightly")] |
| 21 | mod buffered; | 21 | mod buffered; |
| @@ -332,7 +332,7 @@ pub struct InterruptHandler<T: Instance> { | |||
| 332 | _uart: PhantomData<T>, | 332 | _uart: PhantomData<T>, |
| 333 | } | 333 | } |
| 334 | 334 | ||
| 335 | impl<T: Instance> interrupt::Handler<T::Interrupt> for InterruptHandler<T> { | 335 | impl<T: Instance> interrupt::typelevel::Handler<T::Interrupt> for InterruptHandler<T> { |
| 336 | unsafe fn on_interrupt() { | 336 | unsafe fn on_interrupt() { |
| 337 | let uart = T::regs(); | 337 | let uart = T::regs(); |
| 338 | if !uart.uartdmacr().read().rxdmae() { | 338 | if !uart.uartdmacr().read().rxdmae() { |
| @@ -930,7 +930,7 @@ mod sealed { | |||
| 930 | const TX_DREQ: u8; | 930 | const TX_DREQ: u8; |
| 931 | const RX_DREQ: u8; | 931 | const RX_DREQ: u8; |
| 932 | 932 | ||
| 933 | type Interrupt: crate::interrupt::Interrupt; | 933 | type Interrupt: interrupt::typelevel::Interrupt; |
| 934 | 934 | ||
| 935 | fn regs() -> pac::uart::Uart; | 935 | fn regs() -> pac::uart::Uart; |
| 936 | 936 | ||
| @@ -968,7 +968,7 @@ macro_rules! impl_instance { | |||
| 968 | const TX_DREQ: u8 = $tx_dreq; | 968 | const TX_DREQ: u8 = $tx_dreq; |
| 969 | const RX_DREQ: u8 = $rx_dreq; | 969 | const RX_DREQ: u8 = $rx_dreq; |
| 970 | 970 | ||
| 971 | type Interrupt = crate::interrupt::$irq; | 971 | type Interrupt = crate::interrupt::typelevel::$irq; |
| 972 | 972 | ||
| 973 | fn regs() -> pac::uart::Uart { | 973 | fn regs() -> pac::uart::Uart { |
| 974 | pac::$inst | 974 | pac::$inst |
