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.
  • 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 by chrono. This means there might be a slight difference between the value of RealTimeClock::now() and adding 2 times together in code.

Structs§

Enums§