Dario Nieuwenhuis 921780e6bf 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`.
2023-06-08 18:00:48 +02:00

36 lines
823 B
Rust

use crate::interrupt;
use crate::rcc::RccPeripheral;
#[cfg(feature = "nightly")]
mod usb;
#[cfg(feature = "nightly")]
pub use usb::*;
pub(crate) mod sealed {
pub trait Instance {
fn regs() -> crate::pac::usb::Usb;
}
}
pub trait Instance: sealed::Instance + RccPeripheral + 'static {
type Interrupt: interrupt::typelevel::Interrupt;
}
// Internal PHY pins
pin_trait!(DpPin, Instance);
pin_trait!(DmPin, Instance);
foreach_interrupt!(
($inst:ident, usb, $block:ident, LP, $irq:ident) => {
impl sealed::Instance for crate::peripherals::$inst {
fn regs() -> crate::pac::usb::Usb {
crate::pac::$inst
}
}
impl Instance for crate::peripherals::$inst {
type Interrupt = crate::interrupt::typelevel::$irq;
}
};
);