summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFelix Dörre <felix@dogcraft.de>2023-02-21 07:11:14 +0000
committerDamien George <damien@micropython.org>2023-09-29 15:15:42 +1000
commit3c2b2f7a4d790c66dbe723c5ed59ec18472baa6f (patch)
treec78719a9587f4f780f4e23d5318e84de32eaf5ab
parent584c495d3201bbf01190cff673533bc405cee53f (diff)
rp2/modmachine: Fix lightsleep while wifi is powered off.
While cyw43 is deinitialized, an interrupt occurs. That is handled with these lines: ports/rp2/mpnetworkport.c#L59-L61 and as pendsv is disabled while in network code, the poll function then just waits there. When deinit has finished, the poll func is executed, but skipped: src/cyw43_ctrl.c#L222-L225 this skips the `CYW43_POST_POLL_HOOK` which would re-enable interrupts, but also reset `cyw43_has_pending`. And in that state, the lightsleep code, will skip sleeping as it thinks there is a network packet pending to be handled. With this change applied, lightsleep works as expected when the wifi chip is enabled, and when it's powered off.
-rw-r--r--ports/rp2/modmachine.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/ports/rp2/modmachine.c b/ports/rp2/modmachine.c
index 1efbb0931..35c938b54 100644
--- a/ports/rp2/modmachine.c
+++ b/ports/rp2/modmachine.c
@@ -146,7 +146,7 @@ STATIC mp_obj_t machine_lightsleep(size_t n_args, const mp_obj_t *args) {
uint32_t my_interrupts = save_and_disable_interrupts();
#if MICROPY_PY_NETWORK_CYW43
- if (cyw43_has_pending) {
+ if (cyw43_has_pending && cyw43_poll != NULL) {
restore_interrupts(my_interrupts);
return mp_const_none;
}