summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDamien George <damien@micropython.org>2024-10-24 17:22:27 +1100
committerDamien George <damien@micropython.org>2024-10-24 23:24:09 +1100
commit120ac0f8d25fe6ee6269c31b11690373c5b55653 (patch)
treed700210024f3d48c4084f2dac823ed2b413ada1d
parentca6aed7649adcc25445e3da73a65bfbbca209728 (diff)
rp2/modmachine: Re-sync time_ns offset when coming out of lightsleep.
Prior to this fix, `tests/extmod/vfs_lfs_mtime.py` would fail when run after the `tests/ports/rp2/rp2_lightsleep.py` test, because `time.time_ns()` would have a large and constant offset from `time.time()`. Fix this by re-syncing the time-ns offset when coming out of lightsleep. Signed-off-by: Damien George <damien@micropython.org>
-rw-r--r--ports/rp2/modmachine.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/ports/rp2/modmachine.c b/ports/rp2/modmachine.c
index 2faf0bc6f..cd73552dd 100644
--- a/ports/rp2/modmachine.c
+++ b/ports/rp2/modmachine.c
@@ -261,6 +261,9 @@ static void mp_machine_lightsleep(size_t n_args, const mp_obj_t *args) {
// Bring back all clocks.
runtime_init_clocks_optional_usb(disable_usb);
MICROPY_END_ATOMIC_SECTION(my_interrupts);
+
+ // Re-sync mp_hal_time_ns() counter with aon timer.
+ mp_hal_time_ns_set_from_rtc();
}
NORETURN static void mp_machine_deepsleep(size_t n_args, const mp_obj_t *args) {