From 1565347f6fa7328705c215aaf9884b215253fce2 Mon Sep 17 00:00:00 2001 From: Brian Bulkowski Date: Mon, 21 Sep 2020 19:12:15 -0700 Subject: [PATCH] Recode another delay in an esp32 specific fashion that should be faster --- components/FastLED-idf/hal/esp32-hal-misc.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/components/FastLED-idf/hal/esp32-hal-misc.c b/components/FastLED-idf/hal/esp32-hal-misc.c index bae5a75..56a98a7 100644 --- a/components/FastLED-idf/hal/esp32-hal-misc.c +++ b/components/FastLED-idf/hal/esp32-hal-misc.c @@ -153,17 +153,11 @@ void delay(uint32_t ms) void IRAM_ATTR delayMicroseconds(uint32_t us) { - uint32_t m = micros(); + uint64_t now = esp_timer_get_time(); if(us){ - uint32_t e = (m + us); - if(m > e){ //overflow - while(micros() > e){ - NOP(); - } - } - while(micros() < e){ + do { NOP(); - } + } while ((esp_timer_get_time() - now) < us); } }