pub struct Rtc<'d> {
pub rwdt: Rwdt,
/* private fields */
}
unstable
only.Expand description
Low-power Management
Fields§
§rwdt: Rwdt
Reset Watchdog Timer.
Implementations§
Source§impl<'d> Rtc<'d>
impl<'d> Rtc<'d>
Sourcepub fn new(rtc_cntl: LPWR<'d>) -> Self
pub fn new(rtc_cntl: LPWR<'d>) -> Self
Create a new instance in crate::Blocking mode.
Optionally an interrupt handler can be bound.
Sourcepub fn estimate_xtal_frequency(&mut self) -> u32
pub fn estimate_xtal_frequency(&mut self) -> u32
Return estimated XTAL frequency in MHz.
Sourcepub fn time_since_boot(&self) -> Duration
pub fn time_since_boot(&self) -> Duration
Get the time since boot.
Sourcepub fn current_time_us(&self) -> u64
pub fn current_time_us(&self) -> u64
Get the current time in microseconds.
§Example
This example shows how to get the weekday of the current time in
New York using the jiff
crate. This example works in core-only
environments without dynamic memory allocation.
use jiff::{Timestamp, tz::{self, TimeZone}};
static TZ: TimeZone = tz::get!("America/New_York");
let rtc = Rtc::new(peripherals.LPWR);
let now = Timestamp::from_microsecond(
rtc.current_time_us() as i64,
)?;
let weekday_in_new_york = now.to_zoned(TZ.clone()).weekday();
Sourcepub fn set_current_time_us(&self, current_time_us: u64)
pub fn set_current_time_us(&self, current_time_us: u64)
Set the current time in microseconds.
Sourcepub fn sleep_deep(&mut self, wake_sources: &[&dyn WakeSource]) -> !
pub fn sleep_deep(&mut self, wake_sources: &[&dyn WakeSource]) -> !
Enter deep sleep and wake with the provided wake_sources
.
Sourcepub fn sleep_light(&mut self, wake_sources: &[&dyn WakeSource])
pub fn sleep_light(&mut self, wake_sources: &[&dyn WakeSource])
Enter light sleep and wake with the provided wake_sources
.
Sourcepub fn sleep(
&mut self,
config: &RtcSleepConfig,
wake_sources: &[&dyn WakeSource],
)
pub fn sleep( &mut self, config: &RtcSleepConfig, wake_sources: &[&dyn WakeSource], )
Enter sleep with the provided config
and wake with the provided
wake_sources
.
Sourcepub fn set_interrupt_handler(&mut self, handler: InterruptHandler)
pub fn set_interrupt_handler(&mut self, handler: InterruptHandler)
Register an interrupt handler for the RTC.
Note that this will replace any previously registered interrupt handlers.
§Stability
This API is marked as unstable and is only available when the unstable
crate feature is enabled. This comes with no stability guarantees, and could be changed
or removed at any time.
Trait Implementations§
Source§impl InterruptConfigurable for Rtc<'_>
§Stability
This API is marked as unstable and is only available when the unstable
crate feature is enabled. This comes with no stability guarantees, and could be changed
or removed at any time.
impl InterruptConfigurable for Rtc<'_>
§Stability
This API is marked as unstable and is only available when the unstable
crate feature is enabled. This comes with no stability guarantees, and could be changed
or removed at any time.