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/eth/v2/mod.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-stm32/src/eth/v2/mod.rs')
| -rw-r--r-- | embassy-stm32/src/eth/v2/mod.rs | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/embassy-stm32/src/eth/v2/mod.rs b/embassy-stm32/src/eth/v2/mod.rs index 9efa436ac..3e45eafd5 100644 --- a/embassy-stm32/src/eth/v2/mod.rs +++ b/embassy-stm32/src/eth/v2/mod.rs | |||
| @@ -2,20 +2,20 @@ mod descriptors; | |||
| 2 | 2 | ||
| 3 | use core::sync::atomic::{fence, Ordering}; | 3 | use core::sync::atomic::{fence, Ordering}; |
| 4 | 4 | ||
| 5 | use embassy_cortex_m::interrupt::Interrupt; | ||
| 6 | use embassy_hal_common::{into_ref, PeripheralRef}; | 5 | use embassy_hal_common::{into_ref, PeripheralRef}; |
| 7 | 6 | ||
| 8 | pub(crate) use self::descriptors::{RDes, RDesRing, TDes, TDesRing}; | 7 | pub(crate) use self::descriptors::{RDes, RDesRing, TDes, TDesRing}; |
| 9 | use super::*; | 8 | use super::*; |
| 10 | use crate::gpio::sealed::{AFType, Pin as _}; | 9 | use crate::gpio::sealed::{AFType, Pin as _}; |
| 11 | use crate::gpio::{AnyPin, Speed}; | 10 | use crate::gpio::{AnyPin, Speed}; |
| 11 | use crate::interrupt::InterruptExt; | ||
| 12 | use crate::pac::ETH; | 12 | use crate::pac::ETH; |
| 13 | use crate::{interrupt, Peripheral}; | 13 | use crate::{interrupt, Peripheral}; |
| 14 | 14 | ||
| 15 | /// Interrupt handler. | 15 | /// Interrupt handler. |
| 16 | pub struct InterruptHandler {} | 16 | pub struct InterruptHandler {} |
| 17 | 17 | ||
| 18 | impl interrupt::Handler<interrupt::ETH> for InterruptHandler { | 18 | impl interrupt::typelevel::Handler<interrupt::typelevel::ETH> for InterruptHandler { |
| 19 | unsafe fn on_interrupt() { | 19 | unsafe fn on_interrupt() { |
| 20 | WAKER.wake(); | 20 | WAKER.wake(); |
| 21 | 21 | ||
| @@ -64,7 +64,7 @@ impl<'d, T: Instance, P: PHY> Ethernet<'d, T, P> { | |||
| 64 | pub fn new<const TX: usize, const RX: usize>( | 64 | pub fn new<const TX: usize, const RX: usize>( |
| 65 | queue: &'d mut PacketQueue<TX, RX>, | 65 | queue: &'d mut PacketQueue<TX, RX>, |
| 66 | peri: impl Peripheral<P = T> + 'd, | 66 | peri: impl Peripheral<P = T> + 'd, |
| 67 | _irq: impl interrupt::Binding<interrupt::ETH, InterruptHandler> + 'd, | 67 | _irq: impl interrupt::typelevel::Binding<interrupt::typelevel::ETH, InterruptHandler> + 'd, |
| 68 | ref_clk: impl Peripheral<P = impl RefClkPin<T>> + 'd, | 68 | ref_clk: impl Peripheral<P = impl RefClkPin<T>> + 'd, |
| 69 | mdio: impl Peripheral<P = impl MDIOPin<T>> + 'd, | 69 | mdio: impl Peripheral<P = impl MDIOPin<T>> + 'd, |
| 70 | mdc: impl Peripheral<P = impl MDCPin<T>> + 'd, | 70 | mdc: impl Peripheral<P = impl MDCPin<T>> + 'd, |
| @@ -238,8 +238,8 @@ impl<'d, T: Instance, P: PHY> Ethernet<'d, T, P> { | |||
| 238 | P::phy_reset(&mut this); | 238 | P::phy_reset(&mut this); |
| 239 | P::phy_init(&mut this); | 239 | P::phy_init(&mut this); |
| 240 | 240 | ||
| 241 | interrupt::ETH::unpend(); | 241 | interrupt::ETH.unpend(); |
| 242 | interrupt::ETH::enable(); | 242 | interrupt::ETH.enable(); |
| 243 | 243 | ||
| 244 | this | 244 | this |
| 245 | } | 245 | } |
