digitalPinToInterrupt doesn't accept pin 48 #8560
Labels
Area: Peripherals API
Relates to peripheral's APIs.
Chip: ESP32-S2
Issue is related to support of ESP32-S2 Chip
Chip: ESP32-S3
Issue is related to support of ESP32-S3 Chip
Status: Solved
Type: Bug 🐛
All bugs
Milestone
Board
bpi_leaf_s3, and other ESP32-S2 and ESP-S3 variants
Device Description
Not relevant
Hardware Configuration
A pushbutton on IO48.
Version
latest master (checkout manually)
IDE Name
PlatformIO
Operating System
Any
Flash frequency
40MHz
PSRAM enabled
no
Upload speed
5000000
Description
In many variants for ESP32S2 and ESP32S3, digitalPinToInterrupt is defined as:
#define digitalPinToInterrupt(p) (((p)<48)?(p):-1)
But pin 48 is also valid as interrupt source.
Without a fix, this crashes:
attachInterrupt(digitalPinToInterrupt(48), Callback, FALLING);
The line should read:
#define digitalPinToInterrupt(p) (((p)<=48)?(p):-1)
Furthermore, returning -1 doesn't play nice with attachInterrupt() that accepts an uint8_t. attachInterrupt lacks a bounds check for array access so this gives undefined behavior (for me, a crash).
Sketch
Debug Message
Other Steps to Reproduce
No response
I have checked existing issues, online documentation and the Troubleshooting Guide
The text was updated successfully, but these errors were encountered: