Skip to content

Commit ccc07d9

Browse files
committed
digitalPinToInterrupt: fix double pin remapping
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 #10367.
1 parent ae052f4 commit ccc07d9

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

cores/esp32/Arduino.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@
142142
#endif
143143
#define EXTERNAL_NUM_INTERRUPTS NUM_DIGITAL_PINS // All GPIOs
144144
#define analogInputToDigitalPin(p) (((p) < NUM_ANALOG_INPUTS) ? (analogChannelToDigitalPin(p)) : -1)
145-
#define digitalPinToInterrupt(p) ((((uint8_t)digitalPinToGPIONumber(p)) < NUM_DIGITAL_PINS) ? digitalPinToGPIONumber(p) : NOT_AN_INTERRUPT)
145+
#define digitalPinToInterrupt(p) ((((uint8_t)digitalPinToGPIONumber(p)) < NUM_DIGITAL_PINS) ? (p) : NOT_AN_INTERRUPT)
146146
#define digitalPinHasPWM(p) (((uint8_t)digitalPinToGPIONumber(p)) < NUM_DIGITAL_PINS)
147147

148148
typedef bool boolean;

0 commit comments

Comments
 (0)