From 94809ce38bd5fe0087d865244f177a084c4d33cb Mon Sep 17 00:00:00 2001 From: Lori Date: Mon, 23 Aug 2021 16:19:37 +0200 Subject: [PATCH] fix: timerRead() is returning the last read value, not the actual #3434 (#5498) --- cores/esp32/esp32-hal-timer.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cores/esp32/esp32-hal-timer.c b/cores/esp32/esp32-hal-timer.c index 12555fd3..13669efc 100644 --- a/cores/esp32/esp32-hal-timer.c +++ b/cores/esp32/esp32-hal-timer.c @@ -119,8 +119,9 @@ void ARDUINO_ISR_ATTR __timerISR(void * arg){ } } -uint64_t timerRead(hw_timer_t *timer){ +uint64_t inline timerRead(hw_timer_t *timer){ timer->dev->update = 1; + while (timer->dev->update) {}; uint64_t h = timer->dev->cnt_high; uint64_t l = timer->dev->cnt_low; return (h << 32) | l;