Fix hardware timers

Fixes: https://github.com/espressif/arduino-esp32/issues/5337
Fixes: https://github.com/espressif/arduino-esp32/issues/4743

Thanks to @maxgerhardt
This commit is contained in:
me-no-dev 2021-06-28 15:44:30 +03:00
parent 21947ebe76
commit 8f46bade7a

View File

@ -47,7 +47,7 @@
#define HWTIMER_LOCK() portENTER_CRITICAL(timer->lock) #define HWTIMER_LOCK() portENTER_CRITICAL(timer->lock)
#define HWTIMER_UNLOCK() portEXIT_CRITICAL(timer->lock) #define HWTIMER_UNLOCK() portEXIT_CRITICAL(timer->lock)
typedef struct { typedef volatile struct {
union { union {
struct { struct {
uint32_t reserved0: 10; 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){ 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 bool initialized = false;
static intr_handle_t intr_handle = NULL; static intr_handle_t intr_handle = NULL;
if(intr_handle){ if(intr_handle){