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/saadc.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/saadc.rs')
| -rw-r--r-- | embassy-nrf/src/saadc.rs | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/embassy-nrf/src/saadc.rs b/embassy-nrf/src/saadc.rs index 39764e380..cf3fb9993 100644 --- a/embassy-nrf/src/saadc.rs +++ b/embassy-nrf/src/saadc.rs | |||
| @@ -6,7 +6,6 @@ use core::future::poll_fn; | |||
| 6 | use core::sync::atomic::{compiler_fence, Ordering}; | 6 | use core::sync::atomic::{compiler_fence, Ordering}; |
| 7 | use core::task::Poll; | 7 | use core::task::Poll; |
| 8 | 8 | ||
| 9 | use embassy_cortex_m::interrupt::Interrupt; | ||
| 10 | use embassy_hal_common::drop::OnDrop; | 9 | use embassy_hal_common::drop::OnDrop; |
| 11 | use embassy_hal_common::{impl_peripheral, into_ref, PeripheralRef}; | 10 | use embassy_hal_common::{impl_peripheral, into_ref, PeripheralRef}; |
| 12 | use embassy_sync::waitqueue::AtomicWaker; | 11 | use embassy_sync::waitqueue::AtomicWaker; |
| @@ -18,6 +17,7 @@ use saadc::oversample::OVERSAMPLE_A; | |||
| 18 | use saadc::resolution::VAL_A; | 17 | use saadc::resolution::VAL_A; |
| 19 | 18 | ||
| 20 | use self::sealed::Input as _; | 19 | use self::sealed::Input as _; |
| 20 | use crate::interrupt::InterruptExt; | ||
| 21 | use crate::ppi::{ConfigurableChannel, Event, Ppi, Task}; | 21 | use crate::ppi::{ConfigurableChannel, Event, Ppi, Task}; |
| 22 | use crate::timer::{Frequency, Instance as TimerInstance, Timer}; | 22 | use crate::timer::{Frequency, Instance as TimerInstance, Timer}; |
| 23 | use crate::{interrupt, pac, peripherals, Peripheral}; | 23 | use crate::{interrupt, pac, peripherals, Peripheral}; |
| @@ -33,7 +33,7 @@ pub struct InterruptHandler { | |||
| 33 | _private: (), | 33 | _private: (), |
| 34 | } | 34 | } |
| 35 | 35 | ||
| 36 | impl interrupt::Handler<interrupt::SAADC> for InterruptHandler { | 36 | impl interrupt::typelevel::Handler<interrupt::typelevel::SAADC> for InterruptHandler { |
| 37 | unsafe fn on_interrupt() { | 37 | unsafe fn on_interrupt() { |
| 38 | let r = unsafe { &*SAADC::ptr() }; | 38 | let r = unsafe { &*SAADC::ptr() }; |
| 39 | 39 | ||
| @@ -144,7 +144,7 @@ impl<'d, const N: usize> Saadc<'d, N> { | |||
| 144 | /// Create a new SAADC driver. | 144 | /// Create a new SAADC driver. |
| 145 | pub fn new( | 145 | pub fn new( |
| 146 | saadc: impl Peripheral<P = peripherals::SAADC> + 'd, | 146 | saadc: impl Peripheral<P = peripherals::SAADC> + 'd, |
| 147 | _irq: impl interrupt::Binding<interrupt::SAADC, InterruptHandler> + 'd, | 147 | _irq: impl interrupt::typelevel::Binding<interrupt::typelevel::SAADC, InterruptHandler> + 'd, |
| 148 | config: Config, | 148 | config: Config, |
| 149 | channel_configs: [ChannelConfig; N], | 149 | channel_configs: [ChannelConfig; N], |
| 150 | ) -> Self { | 150 | ) -> Self { |
| @@ -189,8 +189,8 @@ impl<'d, const N: usize> Saadc<'d, N> { | |||
| 189 | // Disable all events interrupts | 189 | // Disable all events interrupts |
| 190 | r.intenclr.write(|w| unsafe { w.bits(0x003F_FFFF) }); | 190 | r.intenclr.write(|w| unsafe { w.bits(0x003F_FFFF) }); |
| 191 | 191 | ||
| 192 | interrupt::SAADC::unpend(); | 192 | interrupt::SAADC.unpend(); |
| 193 | unsafe { interrupt::SAADC::enable() }; | 193 | unsafe { interrupt::SAADC.enable() }; |
| 194 | 194 | ||
| 195 | Self { _p: saadc } | 195 | Self { _p: saadc } |
| 196 | } | 196 | } |
