diff options
| author | Dario Nieuwenhuis <[email protected]> | 2024-04-05 00:20:22 +0200 |
|---|---|---|
| committer | Dario Nieuwenhuis <[email protected]> | 2024-04-05 00:48:46 +0200 |
| commit | ab85eb4b60cd49ebcd43d2305f42327685f5e5a6 (patch) | |
| tree | 3c385a5703edcd1e791ec1934d3232dc4084ab2b /embassy-nrf/src/pdm.rs | |
| parent | 0e1208947e89ea60bd1b5c85e4deb79efb94d89a (diff) | |
nrf: remove mod sealed.
Diffstat (limited to 'embassy-nrf/src/pdm.rs')
| -rw-r--r-- | embassy-nrf/src/pdm.rs | 41 |
1 files changed, 19 insertions, 22 deletions
diff --git a/embassy-nrf/src/pdm.rs b/embassy-nrf/src/pdm.rs index 754d38310..ef2662c85 100644 --- a/embassy-nrf/src/pdm.rs +++ b/embassy-nrf/src/pdm.rs | |||
| @@ -9,11 +9,11 @@ use core::task::Poll; | |||
| 9 | 9 | ||
| 10 | use embassy_hal_internal::drop::OnDrop; | 10 | use embassy_hal_internal::drop::OnDrop; |
| 11 | use embassy_hal_internal::{into_ref, PeripheralRef}; | 11 | use embassy_hal_internal::{into_ref, PeripheralRef}; |
| 12 | use embassy_sync::waitqueue::AtomicWaker; | ||
| 12 | use fixed::types::I7F1; | 13 | use fixed::types::I7F1; |
| 13 | 14 | ||
| 14 | use crate::chip::EASY_DMA_SIZE; | 15 | use crate::chip::EASY_DMA_SIZE; |
| 15 | use crate::gpio::sealed::Pin; | 16 | use crate::gpio::{AnyPin, Pin as GpioPin, SealedPin}; |
| 16 | use crate::gpio::{AnyPin, Pin as GpioPin}; | ||
| 17 | use crate::interrupt::typelevel::Interrupt; | 17 | use crate::interrupt::typelevel::Interrupt; |
| 18 | use crate::pac::pdm::mode::{EDGE_A, OPERATION_A}; | 18 | use crate::pac::pdm::mode::{EDGE_A, OPERATION_A}; |
| 19 | pub use crate::pac::pdm::pdmclkctrl::FREQ_A as Frequency; | 19 | pub use crate::pac::pdm::pdmclkctrl::FREQ_A as Frequency; |
| @@ -451,42 +451,39 @@ impl<'d, T: Instance> Drop for Pdm<'d, T> { | |||
| 451 | } | 451 | } |
| 452 | } | 452 | } |
| 453 | 453 | ||
| 454 | pub(crate) mod sealed { | 454 | /// Peripheral static state |
| 455 | use embassy_sync::waitqueue::AtomicWaker; | 455 | pub(crate) struct State { |
| 456 | 456 | waker: AtomicWaker, | |
| 457 | /// Peripheral static state | 457 | } |
| 458 | pub struct State { | ||
| 459 | pub waker: AtomicWaker, | ||
| 460 | } | ||
| 461 | 458 | ||
| 462 | impl State { | 459 | impl State { |
| 463 | pub const fn new() -> Self { | 460 | pub(crate) const fn new() -> Self { |
| 464 | Self { | 461 | Self { |
| 465 | waker: AtomicWaker::new(), | 462 | waker: AtomicWaker::new(), |
| 466 | } | ||
| 467 | } | 463 | } |
| 468 | } | 464 | } |
| 465 | } | ||
| 469 | 466 | ||
| 470 | pub trait Instance { | 467 | pub(crate) trait SealedInstance { |
| 471 | fn regs() -> &'static crate::pac::pdm::RegisterBlock; | 468 | fn regs() -> &'static crate::pac::pdm::RegisterBlock; |
| 472 | fn state() -> &'static State; | 469 | fn state() -> &'static State; |
| 473 | } | ||
| 474 | } | 470 | } |
| 475 | 471 | ||
| 476 | /// PDM peripheral instance | 472 | /// PDM peripheral instance |
| 477 | pub trait Instance: Peripheral<P = Self> + sealed::Instance + 'static + Send { | 473 | #[allow(private_bounds)] |
| 474 | pub trait Instance: Peripheral<P = Self> + SealedInstance + 'static + Send { | ||
| 478 | /// Interrupt for this peripheral | 475 | /// Interrupt for this peripheral |
| 479 | type Interrupt: interrupt::typelevel::Interrupt; | 476 | type Interrupt: interrupt::typelevel::Interrupt; |
| 480 | } | 477 | } |
| 481 | 478 | ||
| 482 | macro_rules! impl_pdm { | 479 | macro_rules! impl_pdm { |
| 483 | ($type:ident, $pac_type:ident, $irq:ident) => { | 480 | ($type:ident, $pac_type:ident, $irq:ident) => { |
| 484 | impl crate::pdm::sealed::Instance for peripherals::$type { | 481 | impl crate::pdm::SealedInstance for peripherals::$type { |
| 485 | fn regs() -> &'static crate::pac::pdm::RegisterBlock { | 482 | fn regs() -> &'static crate::pac::pdm::RegisterBlock { |
| 486 | unsafe { &*pac::$pac_type::ptr() } | 483 | unsafe { &*pac::$pac_type::ptr() } |
| 487 | } | 484 | } |
| 488 | fn state() -> &'static crate::pdm::sealed::State { | 485 | fn state() -> &'static crate::pdm::State { |
| 489 | static STATE: crate::pdm::sealed::State = crate::pdm::sealed::State::new(); | 486 | static STATE: crate::pdm::State = crate::pdm::State::new(); |
| 490 | &STATE | 487 | &STATE |
| 491 | } | 488 | } |
| 492 | } | 489 | } |
