From 913f9ad5ad9bb446c6e4310b6b5eda310098a1cf Mon Sep 17 00:00:00 2001 From: robert-hh Date: Mon, 28 Nov 2022 20:56:14 +0100 Subject: [PATCH] mimxrt/machine_rtc: Set the microsecond value to 0. Set the subsecond value reported by rtc.datetime() and rtc.now() to 0. Synchronizing the roll-over with the second change was not precise. --- ports/mimxrt/machine_rtc.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/ports/mimxrt/machine_rtc.c b/ports/mimxrt/machine_rtc.c index da7a437491f7..702c1b903e50 100644 --- a/ports/mimxrt/machine_rtc.c +++ b/ports/mimxrt/machine_rtc.c @@ -38,7 +38,6 @@ typedef struct _machine_rtc_obj_t { // Singleton RTC object. STATIC const machine_rtc_obj_t machine_rtc_obj = {{&machine_rtc_type}}; -uint32_t us_offset = 0; // Start the RTC Timer. void machine_rtc_start(void) { @@ -83,7 +82,7 @@ STATIC mp_obj_t machine_rtc_datetime_helper(size_t n_args, const mp_obj_t *args) mp_obj_new_int(srtc_date.hour), mp_obj_new_int(srtc_date.minute), mp_obj_new_int(srtc_date.second), - mp_obj_new_int((ticks_us64() + us_offset) % 1000000), + mp_obj_new_int(0), }; return mp_obj_new_tuple(8, tuple); } else { @@ -104,7 +103,6 @@ STATIC mp_obj_t machine_rtc_datetime_helper(size_t n_args, const mp_obj_t *args) if (SNVS_LP_SRTC_SetDatetime(SNVS, &srtc_date) != kStatus_Success) { mp_raise_ValueError(NULL); } - us_offset = (1000000 + mp_obj_get_int(items[7]) - ticks_us64() % 1000000) % 1000000; return mp_const_none; } @@ -127,7 +125,7 @@ STATIC mp_obj_t machine_rtc_now(mp_obj_t self_in) { mp_obj_new_int(srtc_date.hour), mp_obj_new_int(srtc_date.minute), mp_obj_new_int(srtc_date.second), - mp_obj_new_int((ticks_us64() + us_offset) % 1000000), + mp_obj_new_int(0), mp_const_none, }; return mp_obj_new_tuple(8, tuple);