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-nrf/src/qdec.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-nrf/src/qdec.rs')
| -rw-r--r-- | embassy-nrf/src/qdec.rs | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/embassy-nrf/src/qdec.rs b/embassy-nrf/src/qdec.rs index 5761d04e1..8bac87d37 100644 --- a/embassy-nrf/src/qdec.rs +++ b/embassy-nrf/src/qdec.rs | |||
| @@ -10,7 +10,7 @@ use embassy_hal_common::{into_ref, PeripheralRef}; | |||
| 10 | 10 | ||
| 11 | use crate::gpio::sealed::Pin as _; | 11 | use crate::gpio::sealed::Pin as _; |
| 12 | use crate::gpio::{AnyPin, Pin as GpioPin}; | 12 | use crate::gpio::{AnyPin, Pin as GpioPin}; |
| 13 | use crate::interrupt::Interrupt; | 13 | use crate::interrupt::typelevel::Interrupt; |
| 14 | use crate::{interrupt, Peripheral}; | 14 | use crate::{interrupt, Peripheral}; |
| 15 | 15 | ||
| 16 | /// Quadrature decoder driver. | 16 | /// Quadrature decoder driver. |
| @@ -50,7 +50,7 @@ pub struct InterruptHandler<T: Instance> { | |||
| 50 | _phantom: PhantomData<T>, | 50 | _phantom: PhantomData<T>, |
| 51 | } | 51 | } |
| 52 | 52 | ||
| 53 | impl<T: Instance> interrupt::Handler<T::Interrupt> for InterruptHandler<T> { | 53 | impl<T: Instance> interrupt::typelevel::Handler<T::Interrupt> for InterruptHandler<T> { |
| 54 | unsafe fn on_interrupt() { | 54 | unsafe fn on_interrupt() { |
| 55 | T::regs().intenclr.write(|w| w.reportrdy().clear()); | 55 | T::regs().intenclr.write(|w| w.reportrdy().clear()); |
| 56 | T::state().waker.wake(); | 56 | T::state().waker.wake(); |
| @@ -61,7 +61,7 @@ impl<'d, T: Instance> Qdec<'d, T> { | |||
| 61 | /// Create a new QDEC. | 61 | /// Create a new QDEC. |
| 62 | pub fn new( | 62 | pub fn new( |
| 63 | qdec: impl Peripheral<P = T> + 'd, | 63 | qdec: impl Peripheral<P = T> + 'd, |
| 64 | _irq: impl interrupt::Binding<T::Interrupt, InterruptHandler<T>> + 'd, | 64 | _irq: impl interrupt::typelevel::Binding<T::Interrupt, InterruptHandler<T>> + 'd, |
| 65 | a: impl Peripheral<P = impl GpioPin> + 'd, | 65 | a: impl Peripheral<P = impl GpioPin> + 'd, |
| 66 | b: impl Peripheral<P = impl GpioPin> + 'd, | 66 | b: impl Peripheral<P = impl GpioPin> + 'd, |
| 67 | config: Config, | 67 | config: Config, |
| @@ -73,7 +73,7 @@ impl<'d, T: Instance> Qdec<'d, T> { | |||
| 73 | /// Create a new QDEC, with a pin for LED output. | 73 | /// Create a new QDEC, with a pin for LED output. |
| 74 | pub fn new_with_led( | 74 | pub fn new_with_led( |
| 75 | qdec: impl Peripheral<P = T> + 'd, | 75 | qdec: impl Peripheral<P = T> + 'd, |
| 76 | _irq: impl interrupt::Binding<T::Interrupt, InterruptHandler<T>> + 'd, | 76 | _irq: impl interrupt::typelevel::Binding<T::Interrupt, InterruptHandler<T>> + 'd, |
| 77 | a: impl Peripheral<P = impl GpioPin> + 'd, | 77 | a: impl Peripheral<P = impl GpioPin> + 'd, |
| 78 | b: impl Peripheral<P = impl GpioPin> + 'd, | 78 | b: impl Peripheral<P = impl GpioPin> + 'd, |
| 79 | led: impl Peripheral<P = impl GpioPin> + 'd, | 79 | led: impl Peripheral<P = impl GpioPin> + 'd, |
| @@ -271,7 +271,7 @@ pub(crate) mod sealed { | |||
| 271 | /// qdec peripheral instance. | 271 | /// qdec peripheral instance. |
| 272 | pub trait Instance: Peripheral<P = Self> + sealed::Instance + 'static + Send { | 272 | pub trait Instance: Peripheral<P = Self> + sealed::Instance + 'static + Send { |
| 273 | /// Interrupt for this peripheral. | 273 | /// Interrupt for this peripheral. |
| 274 | type Interrupt: Interrupt; | 274 | type Interrupt: interrupt::typelevel::Interrupt; |
| 275 | } | 275 | } |
| 276 | 276 | ||
| 277 | macro_rules! impl_qdec { | 277 | macro_rules! impl_qdec { |
| @@ -286,7 +286,7 @@ macro_rules! impl_qdec { | |||
| 286 | } | 286 | } |
| 287 | } | 287 | } |
| 288 | impl crate::qdec::Instance for peripherals::$type { | 288 | impl crate::qdec::Instance for peripherals::$type { |
| 289 | type Interrupt = crate::interrupt::$irq; | 289 | type Interrupt = crate::interrupt::typelevel::$irq; |
| 290 | } | 290 | } |
| 291 | }; | 291 | }; |
| 292 | } | 292 | } |
