extmod/network_wiznet5k: Deinit the NIC before (re-)initialisation.

If nic.active(True) is called several times in a row, the device may lock
up.  Even if that is bad coding practice, calling wiznet5k_deinit() in
wiznet5k_init() prevents the lock.
pull/9032/head
robert-hh 2022-07-27 21:01:29 +02:00 zatwierdzone przez Damien George
rodzic be2beab71a
commit 73699a846c
1 zmienionych plików z 13 dodań i 10 usunięć

Wyświetl plik

@ -198,6 +198,16 @@ STATIC void wiznet5k_config_interrupt(bool enabled) {
);
}
void wiznet5k_deinit(void) {
for (struct netif *netif = netif_list; netif != NULL; netif = netif->next) {
if (netif == &wiznet5k_obj.netif) {
netif_remove(netif);
netif->flags = 0;
break;
}
}
}
STATIC void wiznet5k_init(void) {
// Configure wiznet for raw ethernet frame usage.
@ -219,6 +229,9 @@ STATIC void wiznet5k_init(void) {
wiznet5k_config_interrupt(true);
}
// Deinit before a new init to clear the state from a previous activation
wiznet5k_deinit();
// Hook the Wiznet into lwIP
wiznet5k_lwip_init(&wiznet5k_obj);
@ -229,16 +242,6 @@ STATIC void wiznet5k_init(void) {
mod_network_register_nic(&wiznet5k_obj);
}
void wiznet5k_deinit(void) {
for (struct netif *netif = netif_list; netif != NULL; netif = netif->next) {
if (netif == &wiznet5k_obj.netif) {
netif_remove(netif);
netif->flags = 0;
break;
}
}
}
STATIC void wiznet5k_send_ethernet(wiznet5k_obj_t *self, size_t len, const uint8_t *buf) {
uint8_t ip[4] = {1, 1, 1, 1}; // dummy
int ret = WIZCHIP_EXPORT(sendto)(0, (byte *)buf, len, ip, 11); // dummy port