diff options
author | Damien George <damien@micropython.org> | 2022-09-14 14:03:37 +1000 |
---|---|---|
committer | Damien George <damien@micropython.org> | 2022-09-14 14:03:37 +1000 |
commit | 0e8c2204da377e95b5000a3c708891d98cdeb69c (patch) | |
tree | 49354c1bd1a619855dfa3db08a1561e949d27ae8 | |
parent | 74805435f9459ceae4ea6044a767de4a5479e6c8 (diff) | |
download | micropython-0e8c2204da377e95b5000a3c708891d98cdeb69c.tar.gz micropython-0e8c2204da377e95b5000a3c708891d98cdeb69c.zip |
esp32/mphalport: Fix calculation of large sleep by using 64-bit arith.
Fixes issue #9304.
Signed-off-by: Damien George <damien@micropython.org>
-rw-r--r-- | ports/esp32/mphalport.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/ports/esp32/mphalport.c b/ports/esp32/mphalport.c index aab534937e..2aaeb9755f 100644 --- a/ports/esp32/mphalport.c +++ b/ports/esp32/mphalport.c @@ -130,7 +130,7 @@ uint32_t mp_hal_ticks_us(void) { } void mp_hal_delay_ms(uint32_t ms) { - uint64_t us = ms * 1000; + uint64_t us = (uint64_t)ms * 1000ULL; uint64_t dt; uint64_t t0 = esp_timer_get_time(); for (;;) { @@ -139,7 +139,7 @@ void mp_hal_delay_ms(uint32_t ms) { MP_THREAD_GIL_EXIT(); uint64_t t1 = esp_timer_get_time(); dt = t1 - t0; - if (dt + portTICK_PERIOD_MS * 1000 >= us) { + if (dt + portTICK_PERIOD_MS * 1000ULL >= us) { // doing a vTaskDelay would take us beyond requested delay time taskYIELD(); MP_THREAD_GIL_ENTER(); |