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/sdmmc | |
| 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/sdmmc')
| -rw-r--r-- | embassy-stm32/src/sdmmc/mod.rs | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/embassy-stm32/src/sdmmc/mod.rs b/embassy-stm32/src/sdmmc/mod.rs index 3cc17aa68..28eb49ab6 100644 --- a/embassy-stm32/src/sdmmc/mod.rs +++ b/embassy-stm32/src/sdmmc/mod.rs | |||
| @@ -14,7 +14,7 @@ use sdio_host::{BusWidth, CardCapacity, CardStatus, CurrentState, SDStatus, CID, | |||
| 14 | use crate::dma::NoDma; | 14 | use crate::dma::NoDma; |
| 15 | use crate::gpio::sealed::{AFType, Pin}; | 15 | use crate::gpio::sealed::{AFType, Pin}; |
| 16 | use crate::gpio::{AnyPin, Pull, Speed}; | 16 | use crate::gpio::{AnyPin, Pull, Speed}; |
| 17 | use crate::interrupt::Interrupt; | 17 | use crate::interrupt::typelevel::Interrupt; |
| 18 | use crate::pac::sdmmc::Sdmmc as RegBlock; | 18 | use crate::pac::sdmmc::Sdmmc as RegBlock; |
| 19 | use crate::rcc::RccPeripheral; | 19 | use crate::rcc::RccPeripheral; |
| 20 | use crate::time::Hertz; | 20 | use crate::time::Hertz; |
| @@ -42,7 +42,7 @@ impl<T: Instance> InterruptHandler<T> { | |||
| 42 | } | 42 | } |
| 43 | } | 43 | } |
| 44 | 44 | ||
| 45 | impl<T: Instance> interrupt::Handler<T::Interrupt> for InterruptHandler<T> { | 45 | impl<T: Instance> interrupt::typelevel::Handler<T::Interrupt> for InterruptHandler<T> { |
| 46 | unsafe fn on_interrupt() { | 46 | unsafe fn on_interrupt() { |
| 47 | Self::data_interrupts(false); | 47 | Self::data_interrupts(false); |
| 48 | T::state().wake(); | 48 | T::state().wake(); |
| @@ -276,7 +276,7 @@ pub struct Sdmmc<'d, T: Instance, Dma: SdmmcDma<T> = NoDma> { | |||
| 276 | impl<'d, T: Instance, Dma: SdmmcDma<T>> Sdmmc<'d, T, Dma> { | 276 | impl<'d, T: Instance, Dma: SdmmcDma<T>> Sdmmc<'d, T, Dma> { |
| 277 | pub fn new_1bit( | 277 | pub fn new_1bit( |
| 278 | sdmmc: impl Peripheral<P = T> + 'd, | 278 | sdmmc: impl Peripheral<P = T> + 'd, |
| 279 | _irq: impl interrupt::Binding<T::Interrupt, InterruptHandler<T>> + 'd, | 279 | _irq: impl interrupt::typelevel::Binding<T::Interrupt, InterruptHandler<T>> + 'd, |
| 280 | dma: impl Peripheral<P = Dma> + 'd, | 280 | dma: impl Peripheral<P = Dma> + 'd, |
| 281 | clk: impl Peripheral<P = impl CkPin<T>> + 'd, | 281 | clk: impl Peripheral<P = impl CkPin<T>> + 'd, |
| 282 | cmd: impl Peripheral<P = impl CmdPin<T>> + 'd, | 282 | cmd: impl Peripheral<P = impl CmdPin<T>> + 'd, |
| @@ -310,7 +310,7 @@ impl<'d, T: Instance, Dma: SdmmcDma<T>> Sdmmc<'d, T, Dma> { | |||
| 310 | 310 | ||
| 311 | pub fn new_4bit( | 311 | pub fn new_4bit( |
| 312 | sdmmc: impl Peripheral<P = T> + 'd, | 312 | sdmmc: impl Peripheral<P = T> + 'd, |
| 313 | _irq: impl interrupt::Binding<T::Interrupt, InterruptHandler<T>> + 'd, | 313 | _irq: impl interrupt::typelevel::Binding<T::Interrupt, InterruptHandler<T>> + 'd, |
| 314 | dma: impl Peripheral<P = Dma> + 'd, | 314 | dma: impl Peripheral<P = Dma> + 'd, |
| 315 | clk: impl Peripheral<P = impl CkPin<T>> + 'd, | 315 | clk: impl Peripheral<P = impl CkPin<T>> + 'd, |
| 316 | cmd: impl Peripheral<P = impl CmdPin<T>> + 'd, | 316 | cmd: impl Peripheral<P = impl CmdPin<T>> + 'd, |
| @@ -356,7 +356,7 @@ impl<'d, T: Instance, Dma: SdmmcDma<T>> Sdmmc<'d, T, Dma> { | |||
| 356 | impl<'d, T: Instance> Sdmmc<'d, T, NoDma> { | 356 | impl<'d, T: Instance> Sdmmc<'d, T, NoDma> { |
| 357 | pub fn new_1bit( | 357 | pub fn new_1bit( |
| 358 | sdmmc: impl Peripheral<P = T> + 'd, | 358 | sdmmc: impl Peripheral<P = T> + 'd, |
| 359 | _irq: impl interrupt::Binding<T::Interrupt, InterruptHandler<T>> + 'd, | 359 | _irq: impl interrupt::typelevel::Binding<T::Interrupt, InterruptHandler<T>> + 'd, |
| 360 | clk: impl Peripheral<P = impl CkPin<T>> + 'd, | 360 | clk: impl Peripheral<P = impl CkPin<T>> + 'd, |
| 361 | cmd: impl Peripheral<P = impl CmdPin<T>> + 'd, | 361 | cmd: impl Peripheral<P = impl CmdPin<T>> + 'd, |
| 362 | d0: impl Peripheral<P = impl D0Pin<T>> + 'd, | 362 | d0: impl Peripheral<P = impl D0Pin<T>> + 'd, |
| @@ -389,7 +389,7 @@ impl<'d, T: Instance> Sdmmc<'d, T, NoDma> { | |||
| 389 | 389 | ||
| 390 | pub fn new_4bit( | 390 | pub fn new_4bit( |
| 391 | sdmmc: impl Peripheral<P = T> + 'd, | 391 | sdmmc: impl Peripheral<P = T> + 'd, |
| 392 | _irq: impl interrupt::Binding<T::Interrupt, InterruptHandler<T>> + 'd, | 392 | _irq: impl interrupt::typelevel::Binding<T::Interrupt, InterruptHandler<T>> + 'd, |
| 393 | clk: impl Peripheral<P = impl CkPin<T>> + 'd, | 393 | clk: impl Peripheral<P = impl CkPin<T>> + 'd, |
| 394 | cmd: impl Peripheral<P = impl CmdPin<T>> + 'd, | 394 | cmd: impl Peripheral<P = impl CmdPin<T>> + 'd, |
| 395 | d0: impl Peripheral<P = impl D0Pin<T>> + 'd, | 395 | d0: impl Peripheral<P = impl D0Pin<T>> + 'd, |
| @@ -1401,7 +1401,7 @@ pub(crate) mod sealed { | |||
| 1401 | use super::*; | 1401 | use super::*; |
| 1402 | 1402 | ||
| 1403 | pub trait Instance { | 1403 | pub trait Instance { |
| 1404 | type Interrupt: Interrupt; | 1404 | type Interrupt: interrupt::typelevel::Interrupt; |
| 1405 | 1405 | ||
| 1406 | fn regs() -> RegBlock; | 1406 | fn regs() -> RegBlock; |
| 1407 | fn state() -> &'static AtomicWaker; | 1407 | fn state() -> &'static AtomicWaker; |
| @@ -1490,7 +1490,7 @@ cfg_if::cfg_if! { | |||
| 1490 | foreach_peripheral!( | 1490 | foreach_peripheral!( |
| 1491 | (sdmmc, $inst:ident) => { | 1491 | (sdmmc, $inst:ident) => { |
| 1492 | impl sealed::Instance for peripherals::$inst { | 1492 | impl sealed::Instance for peripherals::$inst { |
| 1493 | type Interrupt = crate::interrupt::$inst; | 1493 | type Interrupt = crate::interrupt::typelevel::$inst; |
| 1494 | 1494 | ||
| 1495 | fn regs() -> RegBlock { | 1495 | fn regs() -> RegBlock { |
| 1496 | crate::pac::$inst | 1496 | crate::pac::$inst |
