From af0bba062275cd06577018e276ebe6c5ee0428ce Mon Sep 17 00:00:00 2001 From: Nick Moore Date: Fri, 10 May 2019 13:55:45 +1000 Subject: reset wiznet at network deinitialize adafruit/circuitpython#1800 --- shared-module/network/__init__.c | 5 +++++ shared-module/network/__init__.h | 1 + 2 files changed, 6 insertions(+) (limited to 'shared-module/network') diff --git a/shared-module/network/__init__.c b/shared-module/network/__init__.c index c5783758d..bf33fef7a 100644 --- a/shared-module/network/__init__.c +++ b/shared-module/network/__init__.c @@ -43,6 +43,11 @@ void network_module_init(void) { } void network_module_deinit(void) { + for (mp_uint_t i = 0; i < MP_STATE_PORT(mod_network_nic_list).len; i++) { + mp_obj_t nic = MP_STATE_PORT(mod_network_nic_list).items[i]; + mod_network_nic_type_t *nic_type = (mod_network_nic_type_t*)mp_obj_get_type(nic); + if (nic_type->deinit != NULL) nic_type->deinit(nic); + } mp_obj_list_set_len(&MP_STATE_PORT(mod_network_nic_list), 0); } diff --git a/shared-module/network/__init__.h b/shared-module/network/__init__.h index 00a3c3957..504065979 100644 --- a/shared-module/network/__init__.h +++ b/shared-module/network/__init__.h @@ -62,6 +62,7 @@ typedef struct _mod_network_nic_type_t { int (*settimeout)(struct _mod_network_socket_obj_t *socket, mp_uint_t timeout_ms, int *_errno); int (*ioctl)(struct _mod_network_socket_obj_t *socket, mp_uint_t request, mp_uint_t arg, int *_errno); void (*timer_tick)(struct _mod_network_socket_obj_t *socket); + void (*deinit)(struct _mod_network_socket_obj_t *socket); } mod_network_nic_type_t; typedef struct _mod_network_socket_obj_t { -- cgit v1.2.3