diff options
| author | Roman Valls Guimera <[email protected]> | 2022-11-09 21:58:56 +0100 |
|---|---|---|
| committer | Roman Valls Guimera <[email protected]> | 2022-11-09 22:31:19 +0100 |
| commit | 3760b60db382c8c4f8d7067a8d472affa6db928b (patch) | |
| tree | b728d220cf2b4b584515b1d3bd8940d6bd3828c4 /embassy-nrf/src | |
| parent | cecd77938c694ff2bad2a259ff64f2f468dcb04a (diff) | |
Make bors grin ;)
Diffstat (limited to 'embassy-nrf/src')
| -rw-r--r-- | embassy-nrf/src/i2s.rs | 47 |
1 files changed, 27 insertions, 20 deletions
diff --git a/embassy-nrf/src/i2s.rs b/embassy-nrf/src/i2s.rs index 0199ac615..e0fe6a6eb 100644 --- a/embassy-nrf/src/i2s.rs +++ b/embassy-nrf/src/i2s.rs | |||
| @@ -2,18 +2,19 @@ | |||
| 2 | 2 | ||
| 3 | //! I2S | 3 | //! I2S |
| 4 | 4 | ||
| 5 | use core::future::poll_fn; | 5 | //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_hal_common::drop::OnDrop; | 9 | //use embassy_hal_common::drop::OnDrop; |
| 10 | use embassy_hal_common::{into_ref, PeripheralRef}; | 10 | use embassy_hal_common::{into_ref, PeripheralRef}; |
| 11 | use pac::i2s::config::mcken; | ||
| 12 | 11 | ||
| 13 | use crate::{pac, Peripheral}; | 12 | //use crate::pac::i2s::config::mcken; |
| 14 | use crate::interrupt::{Interrupt, InterruptExt}; | 13 | |
| 15 | use crate::gpio::{self, AnyPin, Pin as GpioPin, PselBits}; | 14 | //use crate::gpio::sealed::Pin as _; |
| 16 | use crate::gpio::sealed::Pin as _; | 15 | use crate::gpio::{AnyPin, Pin as GpioPin}; |
| 16 | use crate::interrupt::Interrupt; | ||
| 17 | use crate::Peripheral; | ||
| 17 | 18 | ||
| 18 | // TODO: Define those in lib.rs somewhere else | 19 | // TODO: Define those in lib.rs somewhere else |
| 19 | // | 20 | // |
| @@ -161,13 +162,12 @@ pub enum Mode { | |||
| 161 | // _32MDiv125 = 0x020C0000, | 162 | // _32MDiv125 = 0x020C0000, |
| 162 | // } | 163 | // } |
| 163 | 164 | ||
| 164 | |||
| 165 | /// Interface to the UARTE peripheral using EasyDMA to offload the transmission and reception workload. | 165 | /// Interface to the UARTE peripheral using EasyDMA to offload the transmission and reception workload. |
| 166 | /// | 166 | /// |
| 167 | /// For more details about EasyDMA, consult the module documentation. | 167 | /// For more details about EasyDMA, consult the module documentation. |
| 168 | pub struct I2s<'d, T: Instance> { | 168 | pub struct I2s<'d, T: Instance> { |
| 169 | output: I2sOutput<'d, T>, | 169 | output: I2sOutput<'d, T>, |
| 170 | input: I2sInput<'d, T>, | 170 | _input: I2sInput<'d, T>, |
| 171 | } | 171 | } |
| 172 | 172 | ||
| 173 | /// Transmitter interface to the UARTE peripheral obtained | 173 | /// Transmitter interface to the UARTE peripheral obtained |
| @@ -198,7 +198,13 @@ impl<'d, T: Instance> I2s<'d, T> { | |||
| 198 | Self::new_inner( | 198 | Self::new_inner( |
| 199 | i2s, | 199 | i2s, |
| 200 | // irq, | 200 | // irq, |
| 201 | mck.map_into(), sck.map_into(), lrck.map_into(), sdin.map_into(), sdout.map_into(), config) | 201 | mck.map_into(), |
| 202 | sck.map_into(), | ||
| 203 | lrck.map_into(), | ||
| 204 | sdin.map_into(), | ||
| 205 | sdout.map_into(), | ||
| 206 | config, | ||
| 207 | ) | ||
| 202 | } | 208 | } |
| 203 | 209 | ||
| 204 | fn new_inner( | 210 | fn new_inner( |
| @@ -209,12 +215,12 @@ impl<'d, T: Instance> I2s<'d, T> { | |||
| 209 | lrck: PeripheralRef<'d, AnyPin>, | 215 | lrck: PeripheralRef<'d, AnyPin>, |
| 210 | sdin: PeripheralRef<'d, AnyPin>, | 216 | sdin: PeripheralRef<'d, AnyPin>, |
| 211 | sdout: PeripheralRef<'d, AnyPin>, | 217 | sdout: PeripheralRef<'d, AnyPin>, |
| 212 | config: Config, | 218 | _config: Config, |
| 213 | ) -> Self { | 219 | ) -> Self { |
| 214 | into_ref!( | 220 | into_ref!( |
| 215 | i2s, | 221 | i2s, // irq, |
| 216 | // irq, | 222 | mck, sck, lrck, sdin, sdout |
| 217 | mck, sck, lrck, sdin, sdout); | 223 | ); |
| 218 | 224 | ||
| 219 | let r = T::regs(); | 225 | let r = T::regs(); |
| 220 | 226 | ||
| @@ -260,7 +266,7 @@ impl<'d, T: Instance> I2s<'d, T> { | |||
| 260 | output: I2sOutput { | 266 | output: I2sOutput { |
| 261 | _p: unsafe { i2s.clone_unchecked() }, | 267 | _p: unsafe { i2s.clone_unchecked() }, |
| 262 | }, | 268 | }, |
| 263 | input: I2sInput { _p: i2s }, | 269 | _input: I2sInput { _p: i2s }, |
| 264 | } | 270 | } |
| 265 | } | 271 | } |
| 266 | 272 | ||
| @@ -357,7 +363,7 @@ pub(crate) mod sealed { | |||
| 357 | 363 | ||
| 358 | use embassy_sync::waitqueue::AtomicWaker; | 364 | use embassy_sync::waitqueue::AtomicWaker; |
| 359 | 365 | ||
| 360 | use super::*; | 366 | //use super::*; |
| 361 | 367 | ||
| 362 | pub struct State { | 368 | pub struct State { |
| 363 | pub input_waker: AtomicWaker, | 369 | pub input_waker: AtomicWaker, |
| @@ -375,7 +381,7 @@ pub(crate) mod sealed { | |||
| 375 | } | 381 | } |
| 376 | 382 | ||
| 377 | pub trait Instance { | 383 | pub trait Instance { |
| 378 | fn regs() -> &'static pac::i2s::RegisterBlock; | 384 | fn regs() -> &'static crate::pac::i2s::RegisterBlock; |
| 379 | fn state() -> &'static State; | 385 | fn state() -> &'static State; |
| 380 | } | 386 | } |
| 381 | } | 387 | } |
| @@ -384,6 +390,8 @@ pub trait Instance: Peripheral<P = Self> + sealed::Instance + 'static + Send { | |||
| 384 | type Interrupt: Interrupt; | 390 | type Interrupt: Interrupt; |
| 385 | } | 391 | } |
| 386 | 392 | ||
| 393 | // TODO: Unsure why this macro is flagged as unused by CI when in fact it's used elsewhere? | ||
| 394 | #[allow(unused_macros)] | ||
| 387 | macro_rules! impl_i2s { | 395 | macro_rules! impl_i2s { |
| 388 | ($type:ident, $pac_type:ident, $irq:ident) => { | 396 | ($type:ident, $pac_type:ident, $irq:ident) => { |
| 389 | impl crate::i2s::sealed::Instance for peripherals::$type { | 397 | impl crate::i2s::sealed::Instance for peripherals::$type { |
| @@ -400,4 +408,3 @@ macro_rules! impl_i2s { | |||
| 400 | } | 408 | } |
| 401 | }; | 409 | }; |
| 402 | } | 410 | } |
| 403 | |||
