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/temp.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/temp.rs')
| -rw-r--r-- | embassy-nrf/src/temp.rs | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/embassy-nrf/src/temp.rs b/embassy-nrf/src/temp.rs index 8a127efc5..491e92c04 100644 --- a/embassy-nrf/src/temp.rs +++ b/embassy-nrf/src/temp.rs | |||
| @@ -8,7 +8,7 @@ use embassy_hal_common::{into_ref, PeripheralRef}; | |||
| 8 | use embassy_sync::waitqueue::AtomicWaker; | 8 | use embassy_sync::waitqueue::AtomicWaker; |
| 9 | use fixed::types::I30F2; | 9 | use fixed::types::I30F2; |
| 10 | 10 | ||
| 11 | use crate::interrupt::Interrupt; | 11 | use crate::interrupt::InterruptExt; |
| 12 | use crate::peripherals::TEMP; | 12 | use crate::peripherals::TEMP; |
| 13 | use crate::{interrupt, pac, Peripheral}; | 13 | use crate::{interrupt, pac, Peripheral}; |
| 14 | 14 | ||
| @@ -17,7 +17,7 @@ pub struct InterruptHandler { | |||
| 17 | _private: (), | 17 | _private: (), |
| 18 | } | 18 | } |
| 19 | 19 | ||
| 20 | impl interrupt::Handler<interrupt::TEMP> for InterruptHandler { | 20 | impl interrupt::typelevel::Handler<interrupt::typelevel::TEMP> for InterruptHandler { |
| 21 | unsafe fn on_interrupt() { | 21 | unsafe fn on_interrupt() { |
| 22 | let r = unsafe { &*pac::TEMP::PTR }; | 22 | let r = unsafe { &*pac::TEMP::PTR }; |
| 23 | r.intenclr.write(|w| w.datardy().clear()); | 23 | r.intenclr.write(|w| w.datardy().clear()); |
| @@ -36,13 +36,13 @@ impl<'d> Temp<'d> { | |||
| 36 | /// Create a new temperature sensor driver. | 36 | /// Create a new temperature sensor driver. |
| 37 | pub fn new( | 37 | pub fn new( |
| 38 | _peri: impl Peripheral<P = TEMP> + 'd, | 38 | _peri: impl Peripheral<P = TEMP> + 'd, |
| 39 | _irq: impl interrupt::Binding<interrupt::TEMP, InterruptHandler> + 'd, | 39 | _irq: impl interrupt::typelevel::Binding<interrupt::typelevel::TEMP, InterruptHandler> + 'd, |
| 40 | ) -> Self { | 40 | ) -> Self { |
| 41 | into_ref!(_peri); | 41 | into_ref!(_peri); |
| 42 | 42 | ||
| 43 | // Enable interrupt that signals temperature values | 43 | // Enable interrupt that signals temperature values |
| 44 | interrupt::TEMP::unpend(); | 44 | interrupt::TEMP.unpend(); |
| 45 | unsafe { interrupt::TEMP::enable() }; | 45 | unsafe { interrupt::TEMP.enable() }; |
| 46 | 46 | ||
| 47 | Self { _peri } | 47 | Self { _peri } |
| 48 | } | 48 | } |
