From 55bd1d5ee27706c46edeae4944ef534bb3a73a29 Mon Sep 17 00:00:00 2001 From: Luca Burelli Date: Wed, 25 Sep 2024 22:47:08 +0200 Subject: [PATCH] digitalPinToInterrupt: fix double pin remapping (#10373) The digitalPinToInterrupt() macro currently remaps the pin number to the GPIO number. This is not necessary, as most users will then use the returned value in attachInterrupt() or other similar API functions, which already perform the same remapping. The first half of the macro (the condition) does indeed require the remapping to ensure the check operates on GPIO numbers. Fixes espressif/arduino-esp32#10367. --- cores/esp32/Arduino.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cores/esp32/Arduino.h b/cores/esp32/Arduino.h index 4a92f29d0..2b115505c 100644 --- a/cores/esp32/Arduino.h +++ b/cores/esp32/Arduino.h @@ -142,7 +142,7 @@ #endif #define EXTERNAL_NUM_INTERRUPTS NUM_DIGITAL_PINS // All GPIOs #define analogInputToDigitalPin(p) (((p) < NUM_ANALOG_INPUTS) ? (analogChannelToDigitalPin(p)) : -1) -#define digitalPinToInterrupt(p) ((((uint8_t)digitalPinToGPIONumber(p)) < NUM_DIGITAL_PINS) ? digitalPinToGPIONumber(p) : NOT_AN_INTERRUPT) +#define digitalPinToInterrupt(p) ((((uint8_t)digitalPinToGPIONumber(p)) < NUM_DIGITAL_PINS) ? (p) : NOT_AN_INTERRUPT) #define digitalPinHasPWM(p) (((uint8_t)digitalPinToGPIONumber(p)) < NUM_DIGITAL_PINS) typedef bool boolean;