aboutsummaryrefslogtreecommitdiff
path: root/embassy-nrf/src/i2s.rs
diff options
context:
space:
mode:
authorDario Nieuwenhuis <[email protected]>2023-06-08 16:08:40 +0200
committerDario Nieuwenhuis <[email protected]>2023-06-08 18:00:48 +0200
commit921780e6bfb9bcb2cd087b8aa8b094d792c99fa2 (patch)
treebd21fba9800471b860ca44e05567588dcc1afef7 /embassy-nrf/src/i2s.rs
parent87ad66f2b4a5bfd36dfc8d8aad5492e9e3f915e6 (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/i2s.rs')
-rw-r--r--embassy-nrf/src/i2s.rs14
1 files changed, 7 insertions, 7 deletions
diff --git a/embassy-nrf/src/i2s.rs b/embassy-nrf/src/i2s.rs
index 13db77d3b..fea38c4c0 100644
--- a/embassy-nrf/src/i2s.rs
+++ b/embassy-nrf/src/i2s.rs
@@ -13,10 +13,10 @@ use embassy_hal_common::drop::OnDrop;
13use embassy_hal_common::{into_ref, PeripheralRef}; 13use embassy_hal_common::{into_ref, PeripheralRef};
14 14
15use crate::gpio::{AnyPin, Pin as GpioPin}; 15use crate::gpio::{AnyPin, Pin as GpioPin};
16use crate::interrupt::{self, Interrupt}; 16use crate::interrupt::typelevel::Interrupt;
17use crate::pac::i2s::RegisterBlock; 17use crate::pac::i2s::RegisterBlock;
18use crate::util::{slice_in_ram_or, slice_ptr_parts}; 18use crate::util::{slice_in_ram_or, slice_ptr_parts};
19use crate::{Peripheral, EASY_DMA_SIZE}; 19use crate::{interrupt, Peripheral, EASY_DMA_SIZE};
20 20
21/// Type alias for `MultiBuffering` with 2 buffers. 21/// Type alias for `MultiBuffering` with 2 buffers.
22pub type DoubleBuffering<S, const NS: usize> = MultiBuffering<S, 2, NS>; 22pub type DoubleBuffering<S, const NS: usize> = MultiBuffering<S, 2, NS>;
@@ -367,7 +367,7 @@ pub struct InterruptHandler<T: Instance> {
367 _phantom: PhantomData<T>, 367 _phantom: PhantomData<T>,
368} 368}
369 369
370impl<T: Instance> interrupt::Handler<T::Interrupt> for InterruptHandler<T> { 370impl<T: Instance> interrupt::typelevel::Handler<T::Interrupt> for InterruptHandler<T> {
371 unsafe fn on_interrupt() { 371 unsafe fn on_interrupt() {
372 let device = Device::<T>::new(); 372 let device = Device::<T>::new();
373 let s = T::state(); 373 let s = T::state();
@@ -408,7 +408,7 @@ impl<'d, T: Instance> I2S<'d, T> {
408 /// Create a new I2S in master mode 408 /// Create a new I2S in master mode
409 pub fn new_master( 409 pub fn new_master(
410 i2s: impl Peripheral<P = T> + 'd, 410 i2s: impl Peripheral<P = T> + 'd,
411 _irq: impl interrupt::Binding<T::Interrupt, InterruptHandler<T>> + 'd, 411 _irq: impl interrupt::typelevel::Binding<T::Interrupt, InterruptHandler<T>> + 'd,
412 mck: impl Peripheral<P = impl GpioPin> + 'd, 412 mck: impl Peripheral<P = impl GpioPin> + 'd,
413 sck: impl Peripheral<P = impl GpioPin> + 'd, 413 sck: impl Peripheral<P = impl GpioPin> + 'd,
414 lrck: impl Peripheral<P = impl GpioPin> + 'd, 414 lrck: impl Peripheral<P = impl GpioPin> + 'd,
@@ -431,7 +431,7 @@ impl<'d, T: Instance> I2S<'d, T> {
431 /// Create a new I2S in slave mode 431 /// Create a new I2S in slave mode
432 pub fn new_slave( 432 pub fn new_slave(
433 i2s: impl Peripheral<P = T> + 'd, 433 i2s: impl Peripheral<P = T> + 'd,
434 _irq: impl interrupt::Binding<T::Interrupt, InterruptHandler<T>> + 'd, 434 _irq: impl interrupt::typelevel::Binding<T::Interrupt, InterruptHandler<T>> + 'd,
435 sck: impl Peripheral<P = impl GpioPin> + 'd, 435 sck: impl Peripheral<P = impl GpioPin> + 'd,
436 lrck: impl Peripheral<P = impl GpioPin> + 'd, 436 lrck: impl Peripheral<P = impl GpioPin> + 'd,
437 config: Config, 437 config: Config,
@@ -1173,7 +1173,7 @@ pub(crate) mod sealed {
1173/// I2S peripheral instance. 1173/// I2S peripheral instance.
1174pub trait Instance: Peripheral<P = Self> + sealed::Instance + 'static + Send { 1174pub trait Instance: Peripheral<P = Self> + sealed::Instance + 'static + Send {
1175 /// Interrupt for this peripheral. 1175 /// Interrupt for this peripheral.
1176 type Interrupt: Interrupt; 1176 type Interrupt: interrupt::typelevel::Interrupt;
1177} 1177}
1178 1178
1179macro_rules! impl_i2s { 1179macro_rules! impl_i2s {
@@ -1188,7 +1188,7 @@ macro_rules! impl_i2s {
1188 } 1188 }
1189 } 1189 }
1190 impl crate::i2s::Instance for peripherals::$type { 1190 impl crate::i2s::Instance for peripherals::$type {
1191 type Interrupt = crate::interrupt::$irq; 1191 type Interrupt = crate::interrupt::typelevel::$irq;
1192 } 1192 }
1193 }; 1193 };
1194} 1194}