summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDamien George <damien@micropython.org>2021-08-27 18:06:26 +1000
committerDamien George <damien@micropython.org>2021-08-31 13:00:11 +1000
commit52a78e69658eca65bcb8d6577df2de2db7932c9e (patch)
tree033314e15afd6fa7276ff6be2c2727362b9871ec
parent6f19b9c08d7d8c03981a999d4eddeb3c500125ab (diff)
drivers/cyw43: Fix cyw43_deinit so it can be called many times in a row.
This makes sure deinit() can be called on the interface many times without error, and that the state of the driver is fully reset. Fixes issue #7493. Signed-off-by: Damien George <damien@micropython.org>
-rw-r--r--drivers/cyw43/cyw43_ctrl.c23
1 files changed, 10 insertions, 13 deletions
diff --git a/drivers/cyw43/cyw43_ctrl.c b/drivers/cyw43/cyw43_ctrl.c
index aaa266b0d..9bd7602de 100644
--- a/drivers/cyw43/cyw43_ctrl.c
+++ b/drivers/cyw43/cyw43_ctrl.c
@@ -102,28 +102,25 @@ void cyw43_init(cyw43_t *self) {
}
void cyw43_deinit(cyw43_t *self) {
+ if (cyw43_poll == NULL) {
+ return;
+ }
+
CYW_ENTER
- cyw43_ll_bus_sleep(&self->cyw43_ll, true);
- cyw43_delay_ms(2);
+ // Stop the TCP/IP network interfaces.
cyw43_tcpip_deinit(self, 0);
cyw43_tcpip_deinit(self, 1);
- self->itf_state = 0;
-
- // Disable async polling
+ // Turn off the SDIO bus.
+ #if USE_SDIOIT
sdio_enable_irq(false);
- cyw43_poll = NULL;
-
- #ifdef pyb_pin_WL_RFSW_VDD
- // Turn the RF-switch off
- mp_hal_pin_low(pyb_pin_WL_RFSW_VDD);
#endif
-
- // Power down the WL chip and the SDIO bus
- mp_hal_pin_low(pyb_pin_WL_REG_ON);
sdio_deinit();
+ // Power off the WLAN chip and make sure all state is reset.
+ cyw43_init(self);
+
CYW_EXIT
}