Skip to content

Commit 52a78e6

Browse files
committed
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 <[email protected]>
1 parent 6f19b9c commit 52a78e6

File tree

1 file changed

+10
-13
lines changed

1 file changed

+10
-13
lines changed

drivers/cyw43/cyw43_ctrl.c

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -102,28 +102,25 @@ void cyw43_init(cyw43_t *self) {
102102
}
103103

104104
void cyw43_deinit(cyw43_t *self) {
105+
if (cyw43_poll == NULL) {
106+
return;
107+
}
108+
105109
CYW_ENTER
106110

107-
cyw43_ll_bus_sleep(&self->cyw43_ll, true);
108-
cyw43_delay_ms(2);
111+
// Stop the TCP/IP network interfaces.
109112
cyw43_tcpip_deinit(self, 0);
110113
cyw43_tcpip_deinit(self, 1);
111114

112-
self->itf_state = 0;
113-
114-
// Disable async polling
115+
// Turn off the SDIO bus.
116+
#if USE_SDIOIT
115117
sdio_enable_irq(false);
116-
cyw43_poll = NULL;
117-
118-
#ifdef pyb_pin_WL_RFSW_VDD
119-
// Turn the RF-switch off
120-
mp_hal_pin_low(pyb_pin_WL_RFSW_VDD);
121118
#endif
122-
123-
// Power down the WL chip and the SDIO bus
124-
mp_hal_pin_low(pyb_pin_WL_REG_ON);
125119
sdio_deinit();
126120

121+
// Power off the WLAN chip and make sure all state is reset.
122+
cyw43_init(self);
123+
127124
CYW_EXIT
128125
}
129126

0 commit comments

Comments
 (0)