Skip to content

Commit 50b060a

Browse files
committed
really fix attachInterrupt to work on either core
1 parent 6125a40 commit 50b060a

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

cores/esp32/esp32-hal-gpio.c

+9-2
Original file line numberDiff line numberDiff line change
@@ -187,16 +187,23 @@ static void IRAM_ATTR __onPinInterrupt(void *arg)
187187
extern void __attachInterrupt(uint8_t pin, voidFuncPtr userFunc, int intr_type)
188188
{
189189
static bool interrupt_initialized = false;
190+
static int core_id = 0;
191+
190192
if(!interrupt_initialized) {
191193
interrupt_initialized = true;
194+
core_id = xPortGetCoreID();
192195
ESP_INTR_DISABLE(ETS_GPIO_INUM);
193-
intr_matrix_set(xPortGetCoreID(), ETS_GPIO_INTR_SOURCE, ETS_GPIO_INUM);
196+
intr_matrix_set(core_id, ETS_GPIO_INTR_SOURCE, ETS_GPIO_INUM);
194197
xt_set_interrupt_handler(ETS_GPIO_INUM, &__onPinInterrupt, NULL);
195198
ESP_INTR_ENABLE(ETS_GPIO_INUM);
196199
}
197200
__pinInterruptHandlers[pin] = userFunc;
198201
ESP_INTR_DISABLE(ETS_GPIO_INUM);
199-
GPIO.pin[pin].int_ena = 1;
202+
if(core_id) { //APP_CPU
203+
GPIO.pin[pin].int_ena = 1;
204+
} else { //PRO_CPU
205+
GPIO.pin[pin].int_ena = 4;
206+
}
200207
GPIO.pin[pin].int_type = intr_type;
201208
ESP_INTR_ENABLE(ETS_GPIO_INUM);
202209
}

0 commit comments

Comments
 (0)