Struct rp2040_hal::rtc::RealTimeClock
source · pub struct RealTimeClock { /* private fields */ }
Expand description
A reference to the real time clock of the system
Implementations§
source§impl RealTimeClock
impl RealTimeClock
sourcepub fn new(
rtc: RTC,
clock: RtcClock,
resets: &mut RESETS,
initial_date: DateTime
) -> Result<Self, RtcError>
pub fn new( rtc: RTC, clock: RtcClock, resets: &mut RESETS, initial_date: DateTime ) -> Result<Self, RtcError>
Create a new instance of the real time clock, with the given date as an initial value.
Note that the ClocksManager
should be enabled first. See the clocks
module for more information.
§Errors
Will return RtcError::InvalidDateTime
if the datetime is not a valid range.
sourcepub fn set_leap_year_check(&mut self, leap_year_check_enabled: bool)
pub fn set_leap_year_check(&mut self, leap_year_check_enabled: bool)
Enable or disable the leap year check. The rp2040 chip will always add a Feb 29th on every year that is divisible by 4, but this may be incorrect (e.g. on century years). This function allows you to disable this check.
Leap year checking is enabled by default.
sourcepub fn is_running(&self) -> bool
pub fn is_running(&self) -> bool
Checks to see if this RealTimeClock is running
sourcepub fn set_datetime(&mut self, t: DateTime) -> Result<(), RtcError>
pub fn set_datetime(&mut self, t: DateTime) -> Result<(), RtcError>
Set the datetime to a new value.
§Errors
Will return RtcError::InvalidDateTime
if the datetime is not a valid range.
sourcepub fn disable_alarm(&mut self)
pub fn disable_alarm(&mut self)
Disable the alarm that was scheduled with schedule_alarm
.
sourcepub fn schedule_alarm(&mut self, filter: DateTimeFilter)
pub fn schedule_alarm(&mut self, filter: DateTimeFilter)
Schedule an alarm. The filter
determines at which point in time this alarm is set.
If not all fields are set, the alarm will repeat each time the RTC reaches these values. For example, to fire every minute, set:
real_time_clock.schedule_alarm(DateTimeFilter::default().second(0));
It is worth nothing that the alarm will not fire on schedule if the current time matches.
sourcepub fn enable_interrupt(&mut self)
pub fn enable_interrupt(&mut self)
Enable the propagation of alarm to the NVIC.
sourcepub fn disable_interrupt(&mut self)
pub fn disable_interrupt(&mut self)
Disable the propagation of the alarm to the NVIC.
sourcepub fn clear_interrupt(&mut self)
pub fn clear_interrupt(&mut self)
Clear the interrupt.
This should be called every time the RTC_IRQ
interrupt is triggered or the interrupt will
continually fire..
Auto Trait Implementations§
impl Freeze for RealTimeClock
impl RefUnwindSafe for RealTimeClock
impl Send for RealTimeClock
impl !Sync for RealTimeClock
impl Unpin for RealTimeClock
impl UnwindSafe for RealTimeClock
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<Choices> CoproductSubsetter<CNil, HNil> for Choices
impl<Choices> CoproductSubsetter<CNil, HNil> for Choices
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more