diff --git a/cores/esp32/esp32-hal-timer.c b/cores/esp32/esp32-hal-timer.c index d6570383..12555fd3 100644 --- a/cores/esp32/esp32-hal-timer.c +++ b/cores/esp32/esp32-hal-timer.c @@ -47,7 +47,7 @@ #define HWTIMER_LOCK() portENTER_CRITICAL(timer->lock) #define HWTIMER_UNLOCK() portEXIT_CRITICAL(timer->lock) -typedef struct { +typedef volatile struct { union { struct { uint32_t reserved0: 10; @@ -272,6 +272,12 @@ void timerEnd(hw_timer_t *timer){ } void timerAttachInterrupt(hw_timer_t *timer, void (*fn)(void), bool edge){ +#if CONFIG_IDF_TARGET_ESP32 + if(edge){ + log_w("EDGE timer interrupt does not work properly on ESP32! Setting to LEVEL..."); + edge = false; + } +#endif static bool initialized = false; static intr_handle_t intr_handle = NULL; if(intr_handle){