Skip to content

Commit

Permalink
digitalPinToInterrupt: fix double pin remapping (#10372)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
pillo79 authored Sep 25, 2024
1 parent bcb92a1 commit f23914e
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion cores/esp32/Arduino.h
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,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;
Expand Down

0 comments on commit f23914e

Please sign in to comment.