Skip to content

Commit 9ced459

Browse files
committed
Fix build compilation due to changes in the HW_TIMER's structs
1 parent dc0ff8c commit 9ced459

File tree

1 file changed

+20
-19
lines changed

1 file changed

+20
-19
lines changed

cores/esp32/esp32-hal-timer.c

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -90,17 +90,10 @@ typedef void (*voidFuncPtr)(void);
9090
static voidFuncPtr __timerInterruptHandlers[4] = {0,0,0,0};
9191

9292
void ARDUINO_ISR_ATTR __timerISR(void * arg){
93-
#if CONFIG_IDF_TARGET_ESP32
9493
uint32_t s0 = TIMERG0.int_st_timers.val;
9594
uint32_t s1 = TIMERG1.int_st_timers.val;
9695
TIMERG0.int_clr_timers.val = s0;
9796
TIMERG1.int_clr_timers.val = s1;
98-
#else
99-
uint32_t s0 = TIMERG0.int_st.val;
100-
uint32_t s1 = TIMERG1.int_st.val;
101-
TIMERG0.int_clr.val = s0;
102-
TIMERG1.int_clr.val = s1;
103-
#endif
10497
uint8_t status = (s1 & 3) << 2 | (s0 & 3);
10598
uint8_t i = 4;
10699
//restart the timers that should autoreload
@@ -238,19 +231,19 @@ hw_timer_t * timerBegin(uint8_t num, uint16_t divider, bool countUp){
238231
}
239232
timer->dev->config.enable = 0;
240233
if(timer->group) {
241-
TIMERG1.int_ena.val &= ~BIT(timer->timer);
242234
#if CONFIG_IDF_TARGET_ESP32
243-
TIMERG1.int_clr_timers.val |= BIT(timer->timer);
235+
TIMERG1.int_ena.val &= ~BIT(timer->timer);
244236
#else
245-
TIMERG1.int_clr.val = BIT(timer->timer);
237+
TIMERG1.int_ena_timers.val &= ~BIT(timer->timer);
246238
#endif
239+
TIMERG1.int_clr_timers.val |= BIT(timer->timer);
247240
} else {
248-
TIMERG0.int_ena.val &= ~BIT(timer->timer);
249241
#if CONFIG_IDF_TARGET_ESP32
250-
TIMERG0.int_clr_timers.val |= BIT(timer->timer);
242+
TIMERG0.int_ena.val &= ~BIT(timer->timer);
251243
#else
252-
TIMERG0.int_clr.val = BIT(timer->timer);
244+
TIMERG0.int_ena_timers.val &= ~BIT(timer->timer);
253245
#endif
246+
TIMERG0.int_clr_timers.val |= BIT(timer->timer);
254247
}
255248
#ifdef TIMER_GROUP_SUPPORTS_XTAL_CLOCK
256249
timer->dev->config.use_xtal = 0;
@@ -288,19 +281,19 @@ void timerAttachInterrupt(hw_timer_t *timer, void (*fn)(void), bool edge){
288281
timer->dev->config.edge_int_en = 0;
289282
timer->dev->config.alarm_en = 0;
290283
if(timer->num & 2){
291-
TIMERG1.int_ena.val &= ~BIT(timer->timer);
292284
#if CONFIG_IDF_TARGET_ESP32
293-
TIMERG1.int_clr_timers.val |= BIT(timer->timer);
285+
TIMERG1.int_ena.val &= ~BIT(timer->timer);
294286
#else
295-
TIMERG1.int_clr.val = BIT(timer->timer);
287+
TIMERG1.int_ena_timers.val &= ~BIT(timer->timer);
296288
#endif
289+
TIMERG1.int_clr_timers.val |= BIT(timer->timer);
297290
} else {
298-
TIMERG0.int_ena.val &= ~BIT(timer->timer);
299291
#if CONFIG_IDF_TARGET_ESP32
300-
TIMERG0.int_clr_timers.val |= BIT(timer->timer);
292+
TIMERG0.int_ena.val &= ~BIT(timer->timer);
301293
#else
302-
TIMERG0.int_clr.val = BIT(timer->timer);
294+
TIMERG0.int_ena_timers.val &= ~BIT(timer->timer);
303295
#endif
296+
TIMERG0.int_clr_timers.val |= BIT(timer->timer);
304297
}
305298
__timerInterruptHandlers[timer->num] = NULL;
306299
} else {
@@ -332,9 +325,17 @@ void timerAttachInterrupt(hw_timer_t *timer, void (*fn)(void), bool edge){
332325
intr_matrix_set(esp_intr_get_cpu(intr_handle), intr_source, esp_intr_get_intno(intr_handle));
333326
}
334327
if(timer->group){
328+
#if CONFIG_IDF_TARGET_ESP32
335329
TIMERG1.int_ena.val |= BIT(timer->timer);
330+
#else
331+
TIMERG1.int_ena_timers.val |= BIT(timer->timer);
332+
#endif
336333
} else {
334+
#if CONFIG_IDF_TARGET_ESP32
337335
TIMERG0.int_ena.val |= BIT(timer->timer);
336+
#else
337+
TIMERG0.int_ena_timers.val |= BIT(timer->timer);
338+
#endif
338339
}
339340
}
340341
if(intr_handle){

0 commit comments

Comments
 (0)