Skip to content

Commit fdec056

Browse files
authored
Update esp32-hal-timer.c in attempt to fix Timers
For fixing Hardware Timers: Timer functions do not work at all in PlatformIO espressif#5337 espressif#5337 espressif@8f46bad?diff=split
1 parent e88ff4d commit fdec056

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

cores/esp32/esp32-hal-timer.c

+7-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
#define HWTIMER_LOCK() portENTER_CRITICAL(timer->lock)
3737
#define HWTIMER_UNLOCK() portEXIT_CRITICAL(timer->lock)
3838

39-
typedef struct {
39+
typedef volatile struct {
4040
union {
4141
struct {
4242
uint32_t reserved0: 10;
@@ -240,6 +240,12 @@ void timerEnd(hw_timer_t *timer){
240240
}
241241

242242
void timerAttachInterrupt(hw_timer_t *timer, void (*fn)(void), bool edge){
243+
#if CONFIG_IDF_TARGET_ESP32
244+
if(edge){
245+
log_w("EDGE timer interrupt does not work properly on ESP32! Setting to LEVEL...");
246+
edge = false;
247+
}
248+
#endif
243249
static bool initialized = false;
244250
static intr_handle_t intr_handle = NULL;
245251
if(intr_handle){

0 commit comments

Comments
 (0)