diff options
| author | Damien George <damien.p.george@gmail.com> | 2019-05-22 15:05:03 +1000 |
|---|---|---|
| committer | Damien George <damien.p.george@gmail.com> | 2019-05-24 15:37:34 +1000 |
| commit | 5357dad52efbe5773f4beda7ad014dc62ad8e44f (patch) | |
| tree | 777a3d888b3437f1b0aa5cb756fa3b1a47a5b586 /ports/esp8266/esp_mphal.c | |
| parent | c4a6d9c631a3e529aeedeaf5c24fa1bd748d493f (diff) | |
esp8266: Fix ticks_ms to correctly handle wraparound of system counter.
Fixes issue #4795.
Diffstat (limited to 'ports/esp8266/esp_mphal.c')
| -rw-r--r-- | ports/esp8266/esp_mphal.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/ports/esp8266/esp_mphal.c b/ports/esp8266/esp_mphal.c index df97a7343..351bf522c 100644 --- a/ports/esp8266/esp_mphal.c +++ b/ports/esp8266/esp_mphal.c @@ -120,7 +120,9 @@ void mp_hal_debug_tx_strn_cooked(void *env, const char *str, uint32_t len) { } uint32_t mp_hal_ticks_ms(void) { - return ((uint64_t)system_time_high_word << 32 | (uint64_t)system_get_time()) / 1000; + // Compute milliseconds from 64-bit microsecond counter + system_time_update(); + return ((uint64_t)system_time_high_word << 32 | (uint64_t)system_time_low_word) / 1000; } uint32_t mp_hal_ticks_us(void) { |
