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>
This commit is contained in:
Damien George 2024-10-24 17:22:27 +11:00
parent ca6aed7649
commit 120ac0f8d2

View File

@ -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) {