diff options
| author | Felipe Balbi <[email protected]> | 2025-11-07 10:06:55 -0800 |
|---|---|---|
| committer | Felipe Balbi <[email protected]> | 2025-11-07 10:06:55 -0800 |
| commit | cb2ac2790f4b037056f9571abeb4d62360199426 (patch) | |
| tree | f9f163e4340d11ddc54c24ab8cf7624e83f1fd18 /src/rtc.rs | |
| parent | a71eff2e1cea55b393e793c023b8e51e5cc369a1 (diff) | |
Reduce number of features
We don't need features for drivers that always exist.
Signed-off-by: Felipe Balbi <[email protected]>
Diffstat (limited to 'src/rtc.rs')
| -rw-r--r-- | src/rtc.rs | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/src/rtc.rs b/src/rtc.rs index f83baab5e..5e3dfe6c1 100644 --- a/src/rtc.rs +++ b/src/rtc.rs | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | //! RTC DateTime driver. | 1 | //! RTC DateTime driver. |
| 2 | use crate::pac; | 2 | use crate::pac; |
| 3 | use crate::pac::rtc0::cr::{Um}; | 3 | use crate::pac::rtc0::cr::Um; |
| 4 | use core::sync::atomic::{AtomicBool, Ordering}; | 4 | use core::sync::atomic::{AtomicBool, Ordering}; |
| 5 | 5 | ||
| 6 | type Regs = pac::rtc0::RegisterBlock; | 6 | type Regs = pac::rtc0::RegisterBlock; |
| @@ -13,9 +13,7 @@ pub trait Instance { | |||
| 13 | } | 13 | } |
| 14 | 14 | ||
| 15 | /// Token for RTC0 | 15 | /// Token for RTC0 |
| 16 | #[cfg(feature = "rtc0")] | ||
| 17 | pub type Rtc0 = crate::peripherals::RTC0; | 16 | pub type Rtc0 = crate::peripherals::RTC0; |
| 18 | #[cfg(feature = "rtc0")] | ||
| 19 | impl Instance for crate::peripherals::RTC0 { | 17 | impl Instance for crate::peripherals::RTC0 { |
| 20 | #[inline(always)] | 18 | #[inline(always)] |
| 21 | fn ptr() -> *const Regs { | 19 | fn ptr() -> *const Regs { |
| @@ -24,7 +22,6 @@ impl Instance for crate::peripherals::RTC0 { | |||
| 24 | } | 22 | } |
| 25 | 23 | ||
| 26 | // Also implement Instance for the Peri wrapper type | 24 | // Also implement Instance for the Peri wrapper type |
| 27 | #[cfg(feature = "rtc0")] | ||
| 28 | impl Instance for embassy_hal_internal::Peri<'_, crate::peripherals::RTC0> { | 25 | impl Instance for embassy_hal_internal::Peri<'_, crate::peripherals::RTC0> { |
| 29 | #[inline(always)] | 26 | #[inline(always)] |
| 30 | fn ptr() -> *const Regs { | 27 | fn ptr() -> *const Regs { |
| @@ -87,7 +84,6 @@ pub fn convert_datetime_to_seconds(datetime: &RtcDateTime) -> u32 { | |||
| 87 | seconds | 84 | seconds |
| 88 | } | 85 | } |
| 89 | 86 | ||
| 90 | |||
| 91 | pub fn convert_seconds_to_datetime(seconds: u32) -> RtcDateTime { | 87 | pub fn convert_seconds_to_datetime(seconds: u32) -> RtcDateTime { |
| 92 | let mut seconds_remaining = seconds; | 88 | let mut seconds_remaining = seconds; |
| 93 | let mut days = seconds_remaining / SECONDS_IN_A_DAY + 1; | 89 | let mut days = seconds_remaining / SECONDS_IN_A_DAY + 1; |
| @@ -166,11 +162,15 @@ impl<I: Instance> Rtc<I> { | |||
| 166 | rtc.cr().modify(|_, w| w.um().variant(config.update_mode)); | 162 | rtc.cr().modify(|_, w| w.um().variant(config.update_mode)); |
| 167 | 163 | ||
| 168 | rtc.tcr().modify(|_, w| unsafe { | 164 | rtc.tcr().modify(|_, w| unsafe { |
| 169 | w.cir().bits(config.compensation_interval) | 165 | w.cir() |
| 170 | .tcr().bits(config.compensation_time) | 166 | .bits(config.compensation_interval) |
| 167 | .tcr() | ||
| 168 | .bits(config.compensation_time) | ||
| 171 | }); | 169 | }); |
| 172 | 170 | ||
| 173 | Self { _inst: core::marker::PhantomData } | 171 | Self { |
| 172 | _inst: core::marker::PhantomData, | ||
| 173 | } | ||
| 174 | } | 174 | } |
| 175 | 175 | ||
| 176 | pub fn set_datetime(&self, datetime: RtcDateTime) { | 176 | pub fn set_datetime(&self, datetime: RtcDateTime) { |
| @@ -178,7 +178,7 @@ impl<I: Instance> Rtc<I> { | |||
| 178 | let seconds = convert_datetime_to_seconds(&datetime); | 178 | let seconds = convert_datetime_to_seconds(&datetime); |
| 179 | rtc.tsr().write(|w| unsafe { w.bits(seconds) }); | 179 | rtc.tsr().write(|w| unsafe { w.bits(seconds) }); |
| 180 | } | 180 | } |
| 181 | 181 | ||
| 182 | pub fn get_datetime(&self) -> RtcDateTime { | 182 | pub fn get_datetime(&self) -> RtcDateTime { |
| 183 | let rtc = unsafe { &*I::ptr() }; | 183 | let rtc = unsafe { &*I::ptr() }; |
| 184 | let seconds = rtc.tsr().read().bits(); | 184 | let seconds = rtc.tsr().read().bits(); |
| @@ -203,7 +203,7 @@ impl<I: Instance> Rtc<I> { | |||
| 203 | } | 203 | } |
| 204 | } | 204 | } |
| 205 | 205 | ||
| 206 | pub fn get_alarm(&self) -> RtcDateTime{ | 206 | pub fn get_alarm(&self) -> RtcDateTime { |
| 207 | let rtc = unsafe { &*I::ptr() }; | 207 | let rtc = unsafe { &*I::ptr() }; |
| 208 | let alarm_seconds = rtc.tar().read().bits(); | 208 | let alarm_seconds = rtc.tar().read().bits(); |
| 209 | convert_seconds_to_datetime(alarm_seconds) | 209 | convert_seconds_to_datetime(alarm_seconds) |
| @@ -264,7 +264,7 @@ impl<I: Instance> Rtc<I> { | |||
| 264 | ALARM_TRIGGERED.load(Ordering::Relaxed) | 264 | ALARM_TRIGGERED.load(Ordering::Relaxed) |
| 265 | } | 265 | } |
| 266 | } | 266 | } |
| 267 | 267 | ||
| 268 | pub fn on_interrupt() { | 268 | pub fn on_interrupt() { |
| 269 | let rtc = unsafe { &*pac::Rtc0::ptr() }; | 269 | let rtc = unsafe { &*pac::Rtc0::ptr() }; |
| 270 | // Check if this is actually a time alarm interrupt | 270 | // Check if this is actually a time alarm interrupt |
| @@ -277,5 +277,7 @@ pub fn on_interrupt() { | |||
| 277 | 277 | ||
| 278 | pub struct RtcHandler; | 278 | pub struct RtcHandler; |
| 279 | impl crate::interrupt::typelevel::Handler<crate::interrupt::typelevel::RTC> for RtcHandler { | 279 | impl crate::interrupt::typelevel::Handler<crate::interrupt::typelevel::RTC> for RtcHandler { |
| 280 | unsafe fn on_interrupt() { on_interrupt(); } | 280 | unsafe fn on_interrupt() { |
| 281 | } \ No newline at end of file | 281 | on_interrupt(); |
| 282 | } | ||
| 283 | } | ||
