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/rng.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/rng.rs')
| -rw-r--r-- | embassy-nrf/src/rng.rs | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/embassy-nrf/src/rng.rs b/embassy-nrf/src/rng.rs index 7e9b35481..923b8b467 100644 --- a/embassy-nrf/src/rng.rs +++ b/embassy-nrf/src/rng.rs | |||
| @@ -12,7 +12,7 @@ use embassy_hal_common::drop::OnDrop; | |||
| 12 | use embassy_hal_common::{into_ref, PeripheralRef}; | 12 | use embassy_hal_common::{into_ref, PeripheralRef}; |
| 13 | use embassy_sync::waitqueue::AtomicWaker; | 13 | use embassy_sync::waitqueue::AtomicWaker; |
| 14 | 14 | ||
| 15 | use crate::interrupt::Interrupt; | 15 | use crate::interrupt::typelevel::Interrupt; |
| 16 | use crate::{interrupt, Peripheral}; | 16 | use crate::{interrupt, Peripheral}; |
| 17 | 17 | ||
| 18 | /// Interrupt handler. | 18 | /// Interrupt handler. |
| @@ -20,7 +20,7 @@ pub struct InterruptHandler<T: Instance> { | |||
| 20 | _phantom: PhantomData<T>, | 20 | _phantom: PhantomData<T>, |
| 21 | } | 21 | } |
| 22 | 22 | ||
| 23 | impl<T: Instance> interrupt::Handler<T::Interrupt> for InterruptHandler<T> { | 23 | impl<T: Instance> interrupt::typelevel::Handler<T::Interrupt> for InterruptHandler<T> { |
| 24 | unsafe fn on_interrupt() { | 24 | unsafe fn on_interrupt() { |
| 25 | let s = T::state(); | 25 | let s = T::state(); |
| 26 | let r = T::regs(); | 26 | let r = T::regs(); |
| @@ -89,7 +89,7 @@ impl<'d, T: Instance> Rng<'d, T> { | |||
| 89 | /// The synchronous API is safe. | 89 | /// The synchronous API is safe. |
| 90 | pub fn new( | 90 | pub fn new( |
| 91 | rng: impl Peripheral<P = T> + 'd, | 91 | rng: impl Peripheral<P = T> + 'd, |
| 92 | _irq: impl interrupt::Binding<T::Interrupt, InterruptHandler<T>> + 'd, | 92 | _irq: impl interrupt::typelevel::Binding<T::Interrupt, InterruptHandler<T>> + 'd, |
| 93 | ) -> Self { | 93 | ) -> Self { |
| 94 | into_ref!(rng); | 94 | into_ref!(rng); |
| 95 | 95 | ||
| @@ -255,7 +255,7 @@ pub(crate) mod sealed { | |||
| 255 | /// RNG peripheral instance. | 255 | /// RNG peripheral instance. |
| 256 | pub trait Instance: Peripheral<P = Self> + sealed::Instance + 'static + Send { | 256 | pub trait Instance: Peripheral<P = Self> + sealed::Instance + 'static + Send { |
| 257 | /// Interrupt for this peripheral. | 257 | /// Interrupt for this peripheral. |
| 258 | type Interrupt: Interrupt; | 258 | type Interrupt: interrupt::typelevel::Interrupt; |
| 259 | } | 259 | } |
| 260 | 260 | ||
| 261 | macro_rules! impl_rng { | 261 | macro_rules! impl_rng { |
| @@ -270,7 +270,7 @@ macro_rules! impl_rng { | |||
| 270 | } | 270 | } |
| 271 | } | 271 | } |
| 272 | impl crate::rng::Instance for peripherals::$type { | 272 | impl crate::rng::Instance for peripherals::$type { |
| 273 | type Interrupt = crate::interrupt::$irq; | 273 | type Interrupt = crate::interrupt::typelevel::$irq; |
| 274 | } | 274 | } |
| 275 | }; | 275 | }; |
| 276 | } | 276 | } |
