Module rp2040_hal::rtc
source · Expand description
Real time clock functionality
A RealTimeClock
can be configured with an initial DateTime
. Afterwards the clock will track time automatically. The current DateTime
can be retrieved by RealTimeClock::now()
.
With the chrono feature enabled, the following types will be alias for chrono types:
DateTime
:chrono::NaiveDateTime
DayOfWeek
:chrono::Weekday
Notes
There are some things to take into account. As per the datasheet:
- Day of week: The RTC will not compute the correct day of the week; it will only increment the existing value.
- With the
chrono
feature, the day of week is calculated by chrono and should be correct. The value from the rp2040 itself is not used.
- With the
- Leap year: If the current year is evenly divisible by 4, a leap year is detected, then Feb 28th is followed by Feb 29th instead of March 1st.
- There are cases where this is incorrect, e.g. century years have no leap day, but the chip will still add a Feb 29th.
- To disable leap year checking and never have a Feb 29th, call
RealTimeClock::set_leap_year_check(false)
.
Other limitations:
- Leap seconds: The rp2040 will not take leap seconds into account
- With the
chrono
feature, leap seconds will be silently handled bychrono
. This means there might be a slight difference between the value ofRealTimeClock::now()
and adding 2 times together in code.
- With the
Structs
Structure containing date and time information
A filter used for
RealTimeClock::schedule_alarm
.A reference to the real time clock of the system
Enums
Errors regarding the
DateTime
and DateTimeFilter
structs.A day of the week