Skip to content

Commit c8b1c15

Browse files
committed
Test GPIO number in attachInterrupt()
1 parent 8e2af4b commit c8b1c15

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

cores/esp32/esp32-hal-gpio.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,9 @@ extern void __attachInterruptFunctionalArg(uint8_t pin, voidFuncPtrArg userFunc,
167167
{
168168
static bool interrupt_initialized = false;
169169

170+
// makes sure that pin -1 (255) will never work -- this follows Arduino standard
171+
if (pin >= NUM_DIGITAL_PINS) return;
172+
170173
if(!interrupt_initialized) {
171174
esp_err_t err = gpio_install_isr_service((int)ARDUINO_ISR_FLAG);
172175
interrupt_initialized = (err == ESP_OK) || (err == ESP_ERR_INVALID_STATE);

0 commit comments

Comments
 (0)