Skip to content

ESP32: Return correct deep sleep wakeup pin #10513

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 29, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion ports/espressif/common-hal/alarm/pin/PinAlarm.c
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,17 @@ mp_obj_t alarm_pin_pinalarm_record_wake_alarm(void) {

#ifdef SOC_PM_SUPPORT_EXT0_WAKEUP
if (cause == ESP_SLEEP_WAKEUP_EXT0) {
pin_number = REG_GET_FIELD(RTC_IO_EXT_WAKEUP0_REG, RTC_IO_EXT_WAKEUP0_SEL);
int rtc_io_pin_number = REG_GET_FIELD(RTC_IO_EXT_WAKEUP0_REG, RTC_IO_EXT_WAKEUP0_SEL);
// Look up the GPIO equivalent pin for this RTC GPIO pin. On ESP32, the numbering
// is different for RTC_GPIO and regular GPIO, and there's no mapping table.
// The RTC and GPIO pin numbers match for all other current chips, so we could skip this
// for those chips, but it's not expensive, and maybe there will be another mismatch in the future.
for (gpio_num_t gpio_num = 0; gpio_num < SOC_GPIO_PIN_COUNT; gpio_num++) {
if (rtc_io_number_get(gpio_num) == rtc_io_pin_number) {
pin_number = gpio_num;
break;
}
}
} else {
#endif
#ifdef SOC_PM_SUPPORT_EXT1_WAKEUP
Expand Down