summaryrefslogtreecommitdiff
path: root/shared-module/network
diff options
context:
space:
mode:
authorNick Moore <nick@zoic.org>2019-05-10 13:55:45 +1000
committerNick Moore <nick@zoic.org>2019-05-10 13:55:45 +1000
commitaf0bba062275cd06577018e276ebe6c5ee0428ce (patch)
treea354dd55a4869248ebfa4ca8282bb20fda62cd35 /shared-module/network
parente00a702ce9df8109e15e5268ee3fb41df2902681 (diff)
reset wiznet at network deinitialize adafruit/circuitpython#1800
Diffstat (limited to 'shared-module/network')
-rw-r--r--shared-module/network/__init__.c5
-rw-r--r--shared-module/network/__init__.h1
2 files changed, 6 insertions, 0 deletions
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 {