Skip to content

Commit 6125a40

Browse files
committed
fix GPIO attachInterrupt
1 parent 5d61d8d commit 6125a40

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

cores/esp32/esp32-hal-gpio.c

+5-3
Original file line numberDiff line numberDiff line change
@@ -190,21 +190,23 @@ extern void __attachInterrupt(uint8_t pin, voidFuncPtr userFunc, int intr_type)
190190
if(!interrupt_initialized) {
191191
interrupt_initialized = true;
192192
ESP_INTR_DISABLE(ETS_GPIO_INUM);
193-
intr_matrix_set(PRO_CPU_NUM, ETS_GPIO_INTR_SOURCE, ETS_GPIO_INUM);
193+
intr_matrix_set(xPortGetCoreID(), ETS_GPIO_INTR_SOURCE, ETS_GPIO_INUM);
194194
xt_set_interrupt_handler(ETS_GPIO_INUM, &__onPinInterrupt, NULL);
195195
ESP_INTR_ENABLE(ETS_GPIO_INUM);
196196
}
197197
__pinInterruptHandlers[pin] = userFunc;
198198
ESP_INTR_DISABLE(ETS_GPIO_INUM);
199-
GPIO.pin[pin].val = (GPIO.pin[pin].val & ~((GPIO_PIN0_INT_ENA << GPIO_PIN0_INT_ENA_S) | (GPIO_PIN0_INT_TYPE << GPIO_PIN0_INT_TYPE_S))) | (((uint32_t)0x4 << GPIO_PIN0_INT_ENA_S) | ((uint32_t)intr_type << GPIO_PIN0_INT_TYPE_S));
199+
GPIO.pin[pin].int_ena = 1;
200+
GPIO.pin[pin].int_type = intr_type;
200201
ESP_INTR_ENABLE(ETS_GPIO_INUM);
201202
}
202203

203204
extern void __detachInterrupt(uint8_t pin)
204205
{
205206
__pinInterruptHandlers[pin] = NULL;
206207
ESP_INTR_DISABLE(ETS_GPIO_INUM);
207-
GPIO.pin[pin].val = (GPIO.pin[pin].val & ~((GPIO_PIN0_INT_ENA << GPIO_PIN0_INT_ENA_S) | (GPIO_PIN0_INT_TYPE << GPIO_PIN0_INT_TYPE_S)));
208+
GPIO.pin[pin].int_ena = 0;
209+
GPIO.pin[pin].int_type = 0;
208210
ESP_INTR_ENABLE(ETS_GPIO_INUM);
209211
}
210212

0 commit comments

Comments
 (0)