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-stm32/src/usb | |
| 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-stm32/src/usb')
| -rw-r--r-- | embassy-stm32/src/usb/mod.rs | 6 | ||||
| -rw-r--r-- | embassy-stm32/src/usb/usb.rs | 6 |
2 files changed, 6 insertions, 6 deletions
diff --git a/embassy-stm32/src/usb/mod.rs b/embassy-stm32/src/usb/mod.rs index fbd1fa823..bee287fe6 100644 --- a/embassy-stm32/src/usb/mod.rs +++ b/embassy-stm32/src/usb/mod.rs | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | use crate::interrupt::Interrupt; | 1 | use crate::interrupt; |
| 2 | use crate::rcc::RccPeripheral; | 2 | use crate::rcc::RccPeripheral; |
| 3 | 3 | ||
| 4 | #[cfg(feature = "nightly")] | 4 | #[cfg(feature = "nightly")] |
| @@ -13,7 +13,7 @@ pub(crate) mod sealed { | |||
| 13 | } | 13 | } |
| 14 | 14 | ||
| 15 | pub trait Instance: sealed::Instance + RccPeripheral + 'static { | 15 | pub trait Instance: sealed::Instance + RccPeripheral + 'static { |
| 16 | type Interrupt: Interrupt; | 16 | type Interrupt: interrupt::typelevel::Interrupt; |
| 17 | } | 17 | } |
| 18 | 18 | ||
| 19 | // Internal PHY pins | 19 | // Internal PHY pins |
| @@ -29,7 +29,7 @@ foreach_interrupt!( | |||
| 29 | } | 29 | } |
| 30 | 30 | ||
| 31 | impl Instance for crate::peripherals::$inst { | 31 | impl Instance for crate::peripherals::$inst { |
| 32 | type Interrupt = crate::interrupt::$irq; | 32 | type Interrupt = crate::interrupt::typelevel::$irq; |
| 33 | } | 33 | } |
| 34 | }; | 34 | }; |
| 35 | ); | 35 | ); |
diff --git a/embassy-stm32/src/usb/usb.rs b/embassy-stm32/src/usb/usb.rs index 134107978..7486bd376 100644 --- a/embassy-stm32/src/usb/usb.rs +++ b/embassy-stm32/src/usb/usb.rs | |||
| @@ -14,7 +14,7 @@ use embassy_usb_driver::{ | |||
| 14 | 14 | ||
| 15 | use super::{DmPin, DpPin, Instance}; | 15 | use super::{DmPin, DpPin, Instance}; |
| 16 | use crate::gpio::sealed::AFType; | 16 | use crate::gpio::sealed::AFType; |
| 17 | use crate::interrupt::Interrupt; | 17 | use crate::interrupt::typelevel::Interrupt; |
| 18 | use crate::pac::usb::regs; | 18 | use crate::pac::usb::regs; |
| 19 | use crate::pac::usb::vals::{EpType, Stat}; | 19 | use crate::pac::usb::vals::{EpType, Stat}; |
| 20 | use crate::pac::USBRAM; | 20 | use crate::pac::USBRAM; |
| @@ -26,7 +26,7 @@ pub struct InterruptHandler<T: Instance> { | |||
| 26 | _phantom: PhantomData<T>, | 26 | _phantom: PhantomData<T>, |
| 27 | } | 27 | } |
| 28 | 28 | ||
| 29 | impl<T: Instance> interrupt::Handler<T::Interrupt> for InterruptHandler<T> { | 29 | impl<T: Instance> interrupt::typelevel::Handler<T::Interrupt> for InterruptHandler<T> { |
| 30 | unsafe fn on_interrupt() { | 30 | unsafe fn on_interrupt() { |
| 31 | unsafe { | 31 | unsafe { |
| 32 | let regs = T::regs(); | 32 | let regs = T::regs(); |
| @@ -255,7 +255,7 @@ pub struct Driver<'d, T: Instance> { | |||
| 255 | impl<'d, T: Instance> Driver<'d, T> { | 255 | impl<'d, T: Instance> Driver<'d, T> { |
| 256 | pub fn new( | 256 | pub fn new( |
| 257 | _usb: impl Peripheral<P = T> + 'd, | 257 | _usb: impl Peripheral<P = T> + 'd, |
| 258 | _irq: impl interrupt::Binding<T::Interrupt, InterruptHandler<T>> + 'd, | 258 | _irq: impl interrupt::typelevel::Binding<T::Interrupt, InterruptHandler<T>> + 'd, |
| 259 | dp: impl Peripheral<P = impl DpPin<T>> + 'd, | 259 | dp: impl Peripheral<P = impl DpPin<T>> + 'd, |
| 260 | dm: impl Peripheral<P = impl DmPin<T>> + 'd, | 260 | dm: impl Peripheral<P = impl DmPin<T>> + 'd, |
| 261 | ) -> Self { | 261 | ) -> Self { |
