mimxrt/machine_rtc: Start RTC at boot and set datetime if not set.

Changes in this commit:
- Start the RTC Timer at system boot.  Otherwise time.time() will advance
  only if an RTC() object was created.
- Set the time to a more recent date than Jan 1, 1970, if not set.  That is
  2013/10/14, 19:53:11, MicroPython's first commit.
- Compensate an underflow in in timeutils_seconds_since_2000(), called by
  time.time(), if the time is set to a pre-2000 date.
This commit is contained in:
robert-hh
2022-03-14 20:38:46 +01:00
committed by Damien George
parent e3030f7436
commit b70b8ce3e4
5 changed files with 35 additions and 4 deletions

View File

@@ -69,6 +69,7 @@ static inline uint64_t timeutils_mktime(mp_uint_t year, mp_int_t month, mp_int_t
static inline uint64_t timeutils_seconds_since_epoch(mp_uint_t year, mp_uint_t month,
mp_uint_t date, mp_uint_t hour, mp_uint_t minute, mp_uint_t second) {
// TODO this will give incorrect results for dates before 2000/1/1
return timeutils_seconds_since_2000(year, month, date, hour, minute, second) + TIMEUTILS_SECONDS_1970_TO_2000;
}