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/usb.rs | |
| 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/usb.rs')
| -rw-r--r-- | embassy-rp/src/usb.rs | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/embassy-rp/src/usb.rs b/embassy-rp/src/usb.rs index cc88226df..9fb0dfb70 100644 --- a/embassy-rp/src/usb.rs +++ b/embassy-rp/src/usb.rs | |||
| @@ -4,15 +4,14 @@ use core::slice; | |||
| 4 | use core::sync::atomic::{compiler_fence, Ordering}; | 4 | use core::sync::atomic::{compiler_fence, Ordering}; |
| 5 | use core::task::Poll; | 5 | use core::task::Poll; |
| 6 | 6 | ||
| 7 | use embassy_cortex_m::interrupt::{self, Binding}; | ||
| 8 | use embassy_sync::waitqueue::AtomicWaker; | 7 | use embassy_sync::waitqueue::AtomicWaker; |
| 9 | use embassy_usb_driver as driver; | 8 | use embassy_usb_driver as driver; |
| 10 | use embassy_usb_driver::{ | 9 | use embassy_usb_driver::{ |
| 11 | Direction, EndpointAddress, EndpointAllocError, EndpointError, EndpointInfo, EndpointType, Event, Unsupported, | 10 | Direction, EndpointAddress, EndpointAllocError, EndpointError, EndpointInfo, EndpointType, Event, Unsupported, |
| 12 | }; | 11 | }; |
| 13 | 12 | ||
| 14 | use crate::interrupt::Interrupt; | 13 | use crate::interrupt::typelevel::{Binding, Interrupt}; |
| 15 | use crate::{pac, peripherals, Peripheral, RegExt}; | 14 | use crate::{interrupt, pac, peripherals, Peripheral, RegExt}; |
| 16 | 15 | ||
| 17 | pub(crate) mod sealed { | 16 | pub(crate) mod sealed { |
| 18 | pub trait Instance { | 17 | pub trait Instance { |
| @@ -22,7 +21,7 @@ pub(crate) mod sealed { | |||
| 22 | } | 21 | } |
| 23 | 22 | ||
| 24 | pub trait Instance: sealed::Instance + 'static { | 23 | pub trait Instance: sealed::Instance + 'static { |
| 25 | type Interrupt: Interrupt; | 24 | type Interrupt: interrupt::typelevel::Interrupt; |
| 26 | } | 25 | } |
| 27 | 26 | ||
| 28 | impl crate::usb::sealed::Instance for peripherals::USB { | 27 | impl crate::usb::sealed::Instance for peripherals::USB { |
| @@ -35,7 +34,7 @@ impl crate::usb::sealed::Instance for peripherals::USB { | |||
| 35 | } | 34 | } |
| 36 | 35 | ||
| 37 | impl crate::usb::Instance for peripherals::USB { | 36 | impl crate::usb::Instance for peripherals::USB { |
| 38 | type Interrupt = crate::interrupt::USBCTRL_IRQ; | 37 | type Interrupt = crate::interrupt::typelevel::USBCTRL_IRQ; |
| 39 | } | 38 | } |
| 40 | 39 | ||
| 41 | const EP_COUNT: usize = 16; | 40 | const EP_COUNT: usize = 16; |
| @@ -249,7 +248,7 @@ pub struct InterruptHandler<T: Instance> { | |||
| 249 | _uart: PhantomData<T>, | 248 | _uart: PhantomData<T>, |
| 250 | } | 249 | } |
| 251 | 250 | ||
| 252 | impl<T: Instance> interrupt::Handler<T::Interrupt> for InterruptHandler<T> { | 251 | impl<T: Instance> interrupt::typelevel::Handler<T::Interrupt> for InterruptHandler<T> { |
| 253 | unsafe fn on_interrupt() { | 252 | unsafe fn on_interrupt() { |
| 254 | let regs = T::regs(); | 253 | let regs = T::regs(); |
| 255 | //let x = regs.istr().read().0; | 254 | //let x = regs.istr().read().0; |
