-
Notifications
You must be signed in to change notification settings - Fork 7.7k
Labels
Area: Peripherals APIRelates to peripheral's APIs.Relates to peripheral's APIs.Chip: ESP32-S2Issue is related to support of ESP32-S2 ChipIssue is related to support of ESP32-S2 ChipChip: ESP32-S3Issue is related to support of ESP32-S3 ChipIssue is related to support of ESP32-S3 ChipStatus: SolvedThe issue has been resolved and requires no further action.The issue has been resolved and requires no further action.Type: Bug 🐛All bugsAll bugs
Milestone
Description
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
// Not a working sketch
void IRAM_ATTR Callback() {
}
void setup() {
//This does not work:
attachInterrupt(digitalPinToInterrupt(48), Callback, FALLING);
//This works:
attachInterrupt(48, Callback, FALLING);
}
Debug Message
Crash
Other Steps to Reproduce
No response
I have checked existing issues, online documentation and the Troubleshooting Guide
- I confirm I have checked existing issues, online documentation and Troubleshooting guide.
Metadata
Metadata
Assignees
Labels
Area: Peripherals APIRelates to peripheral's APIs.Relates to peripheral's APIs.Chip: ESP32-S2Issue is related to support of ESP32-S2 ChipIssue is related to support of ESP32-S2 ChipChip: ESP32-S3Issue is related to support of ESP32-S3 ChipIssue is related to support of ESP32-S3 ChipStatus: SolvedThe issue has been resolved and requires no further action.The issue has been resolved and requires no further action.Type: Bug 🐛All bugsAll bugs
Type
Projects
Status
Done