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/twim.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/twim.rs')
| -rw-r--r-- | embassy-nrf/src/twim.rs | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/embassy-nrf/src/twim.rs b/embassy-nrf/src/twim.rs index dea398a67..2ad0d19b1 100644 --- a/embassy-nrf/src/twim.rs +++ b/embassy-nrf/src/twim.rs | |||
| @@ -16,9 +16,9 @@ use embassy_time::{Duration, Instant}; | |||
| 16 | 16 | ||
| 17 | use crate::chip::{EASY_DMA_SIZE, FORCE_COPY_BUFFER_SIZE}; | 17 | use crate::chip::{EASY_DMA_SIZE, FORCE_COPY_BUFFER_SIZE}; |
| 18 | use crate::gpio::Pin as GpioPin; | 18 | use crate::gpio::Pin as GpioPin; |
| 19 | use crate::interrupt::{self, Interrupt}; | 19 | use crate::interrupt::typelevel::Interrupt; |
| 20 | use crate::util::{slice_in_ram, slice_in_ram_or}; | 20 | use crate::util::{slice_in_ram, slice_in_ram_or}; |
| 21 | use crate::{gpio, pac, Peripheral}; | 21 | use crate::{gpio, interrupt, pac, Peripheral}; |
| 22 | 22 | ||
| 23 | /// TWI frequency | 23 | /// TWI frequency |
| 24 | #[derive(Clone, Copy)] | 24 | #[derive(Clone, Copy)] |
| @@ -98,7 +98,7 @@ pub struct InterruptHandler<T: Instance> { | |||
| 98 | _phantom: PhantomData<T>, | 98 | _phantom: PhantomData<T>, |
| 99 | } | 99 | } |
| 100 | 100 | ||
| 101 | impl<T: Instance> interrupt::Handler<T::Interrupt> for InterruptHandler<T> { | 101 | impl<T: Instance> interrupt::typelevel::Handler<T::Interrupt> for InterruptHandler<T> { |
| 102 | unsafe fn on_interrupt() { | 102 | unsafe fn on_interrupt() { |
| 103 | let r = T::regs(); | 103 | let r = T::regs(); |
| 104 | let s = T::state(); | 104 | let s = T::state(); |
| @@ -123,7 +123,7 @@ impl<'d, T: Instance> Twim<'d, T> { | |||
| 123 | /// Create a new TWI driver. | 123 | /// Create a new TWI driver. |
| 124 | pub fn new( | 124 | pub fn new( |
| 125 | twim: impl Peripheral<P = T> + 'd, | 125 | twim: impl Peripheral<P = T> + 'd, |
| 126 | _irq: impl interrupt::Binding<T::Interrupt, InterruptHandler<T>> + 'd, | 126 | _irq: impl interrupt::typelevel::Binding<T::Interrupt, InterruptHandler<T>> + 'd, |
| 127 | sda: impl Peripheral<P = impl GpioPin> + 'd, | 127 | sda: impl Peripheral<P = impl GpioPin> + 'd, |
| 128 | scl: impl Peripheral<P = impl GpioPin> + 'd, | 128 | scl: impl Peripheral<P = impl GpioPin> + 'd, |
| 129 | config: Config, | 129 | config: Config, |
| @@ -750,7 +750,7 @@ pub(crate) mod sealed { | |||
| 750 | /// TWIM peripheral instance. | 750 | /// TWIM peripheral instance. |
| 751 | pub trait Instance: Peripheral<P = Self> + sealed::Instance + 'static { | 751 | pub trait Instance: Peripheral<P = Self> + sealed::Instance + 'static { |
| 752 | /// Interrupt for this peripheral. | 752 | /// Interrupt for this peripheral. |
| 753 | type Interrupt: Interrupt; | 753 | type Interrupt: interrupt::typelevel::Interrupt; |
| 754 | } | 754 | } |
| 755 | 755 | ||
| 756 | macro_rules! impl_twim { | 756 | macro_rules! impl_twim { |
| @@ -765,7 +765,7 @@ macro_rules! impl_twim { | |||
| 765 | } | 765 | } |
| 766 | } | 766 | } |
| 767 | impl crate::twim::Instance for peripherals::$type { | 767 | impl crate::twim::Instance for peripherals::$type { |
| 768 | type Interrupt = crate::interrupt::$irq; | 768 | type Interrupt = crate::interrupt::typelevel::$irq; |
| 769 | } | 769 | } |
| 770 | }; | 770 | }; |
| 771 | } | 771 | } |
