Skip to content

Commit 120ac0f

Browse files
committed
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 <[email protected]>
1 parent ca6aed7 commit 120ac0f

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

ports/rp2/modmachine.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,9 @@ static void mp_machine_lightsleep(size_t n_args, const mp_obj_t *args) {
261261
// Bring back all clocks.
262262
runtime_init_clocks_optional_usb(disable_usb);
263263
MICROPY_END_ATOMIC_SECTION(my_interrupts);
264+
265+
// Re-sync mp_hal_time_ns() counter with aon timer.
266+
mp_hal_time_ns_set_from_rtc();
264267
}
265268

266269
NORETURN static void mp_machine_deepsleep(size_t n_args, const mp_obj_t *args) {

0 commit comments

Comments
 (0)