Skip to content

WIP: rp2: Make GPIO wakeup from lightsleep consistent. #16442

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

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
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
8 changes: 6 additions & 2 deletions ports/rp2/machine_pin.c
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ void machine_pin_deinit(void) {
continue;
}
gpio_set_irq_enabled(i, GPIO_IRQ_ALL, false);
gpio_set_dormant_irq_enabled(i, GPIO_IRQ_ALL, false);
}
irq_remove_handler(IO_IRQ_BANK0, gpio_irq);
}
Expand Down Expand Up @@ -445,16 +446,19 @@ void mp_hal_pin_interrupt(mp_hal_pin_obj_t pin, mp_obj_t handler, mp_uint_t trig

// Disable all IRQs while data is updated.
gpio_set_irq_enabled(pin, GPIO_IRQ_ALL, false);
gpio_set_dormant_irq_enabled(pin, GPIO_IRQ_ALL, false);

// Update IRQ data.
irq->base.handler = handler;
irq->base.ishard = hard;
irq->flags = 0;
irq->trigger = trigger;

// Enable IRQ if a handler is given.
if (handler != mp_const_none && trigger != MP_HAL_PIN_TRIGGER_NONE) {
if (trigger != MP_HAL_PIN_TRIGGER_NONE) {
// Enable IRQ even if no handler is set, so pin can wake CPU from WFI/WFE
gpio_set_irq_enabled(pin, trigger, true);
// Also have the IRQ wake us from indefinite lightsleep
gpio_set_dormant_irq_enabled(pin, trigger, true);
}
}

Expand Down
Loading