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.
This commit is contained in:
Felix Dörre 2023-02-21 07:11:14 +00:00 committed by Damien George
parent 584c495d32
commit 3c2b2f7a4d

View File

@ -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(); uint32_t my_interrupts = save_and_disable_interrupts();
#if MICROPY_PY_NETWORK_CYW43 #if MICROPY_PY_NETWORK_CYW43
if (cyw43_has_pending) { if (cyw43_has_pending && cyw43_poll != NULL) {
restore_interrupts(my_interrupts); restore_interrupts(my_interrupts);
return mp_const_none; return mp_const_none;
} }