From feaeee1e835bf3e2a6b36fc8d2d45d4cbc5c27a3 Mon Sep 17 00:00:00 2001 From: xoviat Date: Sun, 17 Sep 2023 18:47:22 -0500 Subject: [PATCH] stm32: misc. cleanup --- embassy-stm32-wpan/src/sub/ble.rs | 5 ++--- embassy-stm32-wpan/src/sub/mac.rs | 5 ++--- embassy-stm32-wpan/src/sub/mm.rs | 5 ++--- embassy-stm32-wpan/src/sub/sys.rs | 5 ++--- embassy-stm32/src/rtc/mod.rs | 11 ++++++----- 5 files changed, 14 insertions(+), 17 deletions(-) diff --git a/embassy-stm32-wpan/src/sub/ble.rs b/embassy-stm32-wpan/src/sub/ble.rs index cd32692e1..c5f2334f4 100644 --- a/embassy-stm32-wpan/src/sub/ble.rs +++ b/embassy-stm32-wpan/src/sub/ble.rs @@ -1,4 +1,3 @@ -use core::marker::PhantomData; use core::ptr; use embassy_stm32::ipcc::Ipcc; @@ -13,7 +12,7 @@ use crate::unsafe_linked_list::LinkedListNode; use crate::{channels, evt}; pub struct Ble { - phantom: PhantomData, + _private: (), } impl Ble { @@ -29,7 +28,7 @@ impl Ble { }); } - Self { phantom: PhantomData } + Self { _private: () } } /// `HW_IPCC_BLE_EvtNot` pub async fn tl_read(&self) -> EvtBox { diff --git a/embassy-stm32-wpan/src/sub/mac.rs b/embassy-stm32-wpan/src/sub/mac.rs index b0cf0248a..baf4da979 100644 --- a/embassy-stm32-wpan/src/sub/mac.rs +++ b/embassy-stm32-wpan/src/sub/mac.rs @@ -1,5 +1,4 @@ use core::future::poll_fn; -use core::marker::PhantomData; use core::ptr; use core::sync::atomic::{AtomicBool, Ordering}; use core::task::Poll; @@ -21,12 +20,12 @@ static MAC_WAKER: AtomicWaker = AtomicWaker::new(); static MAC_EVT_OUT: AtomicBool = AtomicBool::new(false); pub struct Mac { - phantom: PhantomData, + _private: (), } impl Mac { pub(crate) fn new() -> Self { - Self { phantom: PhantomData } + Self { _private: () } } /// `HW_IPCC_MAC_802_15_4_EvtNot` diff --git a/embassy-stm32-wpan/src/sub/mm.rs b/embassy-stm32-wpan/src/sub/mm.rs index da05ad1dd..4e4d2f854 100644 --- a/embassy-stm32-wpan/src/sub/mm.rs +++ b/embassy-stm32-wpan/src/sub/mm.rs @@ -1,6 +1,5 @@ //! Memory manager routines use core::future::poll_fn; -use core::marker::PhantomData; use core::mem::MaybeUninit; use core::task::Poll; @@ -21,7 +20,7 @@ static MM_WAKER: AtomicWaker = AtomicWaker::new(); static mut LOCAL_FREE_BUF_QUEUE: Aligned> = Aligned(MaybeUninit::uninit()); pub struct MemoryManager { - phantom: PhantomData, + _private: (), } impl MemoryManager { @@ -44,7 +43,7 @@ impl MemoryManager { }); } - Self { phantom: PhantomData } + Self { _private: () } } pub async fn run_queue(&self) { diff --git a/embassy-stm32-wpan/src/sub/sys.rs b/embassy-stm32-wpan/src/sub/sys.rs index c17fd531d..bd2ea3f74 100644 --- a/embassy-stm32-wpan/src/sub/sys.rs +++ b/embassy-stm32-wpan/src/sub/sys.rs @@ -1,4 +1,3 @@ -use core::marker::PhantomData; use core::ptr; use crate::cmd::CmdPacket; @@ -12,7 +11,7 @@ use crate::unsafe_linked_list::LinkedListNode; use crate::{channels, Ipcc, SYSTEM_EVT_QUEUE, SYS_CMD_BUF, TL_DEVICE_INFO_TABLE, TL_SYS_TABLE}; pub struct Sys { - phantom: PhantomData, + _private: (), } impl Sys { @@ -27,7 +26,7 @@ impl Sys { }); } - Self { phantom: PhantomData } + Self { _private: () } } /// Returns CPU2 wireless firmware information (if present). diff --git a/embassy-stm32/src/rtc/mod.rs b/embassy-stm32/src/rtc/mod.rs index a588c8b18..07b4fe1f0 100644 --- a/embassy-stm32/src/rtc/mod.rs +++ b/embassy-stm32/src/rtc/mod.rs @@ -82,8 +82,9 @@ impl core::ops::Sub for RtcInstant { } } -#[non_exhaustive] -pub struct RtcTimeProvider; +pub struct RtcTimeProvider { + _private: (), +} impl RtcTimeProvider { /// Return the current datetime. @@ -186,8 +187,8 @@ impl Rtc { } /// Acquire a [`RtcTimeProvider`] instance. - pub fn time_provider(&self) -> RtcTimeProvider { - RtcTimeProvider + pub const fn time_provider(&self) -> RtcTimeProvider { + RtcTimeProvider { _private: () } } /// Set the datetime to a new value. @@ -222,7 +223,7 @@ impl Rtc { /// /// Will return an `RtcError::InvalidDateTime` if the stored value in the system is not a valid [`DayOfWeek`]. pub fn now(&self) -> Result { - RtcTimeProvider.now() + self.time_provider().now() } /// Check if daylight savings time is active.