summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrobert-hh <robert@hammelrath.com>2022-07-29 08:22:42 +0200
committerDamien George <damien@micropython.org>2022-08-09 16:42:03 +1000
commit999b66d53108a014194e7a30f20d4a269fdda6b4 (patch)
tree3cc12c0f8b074708f568385867c30d7531dae87a
parent73699a846c031ecde70cf6bd629ef9a8232291e3 (diff)
extmod/network_wiznet5k: Schedule clearing of interrupt flags.
Avoiding conflicts between the IRQ and an active transfers. Before this change the device could lock up in heavy traffic situations. Fix found and code supplied by @omogenot.
-rw-r--r--extmod/network_wiznet5k.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/extmod/network_wiznet5k.c b/extmod/network_wiznet5k.c
index 5a26c0895..bdf94993d 100644
--- a/extmod/network_wiznet5k.c
+++ b/extmod/network_wiznet5k.c
@@ -177,11 +177,10 @@ STATIC void wiznet5k_lwip_init(wiznet5k_obj_t *self);
STATIC mp_obj_t mpy_wiznet_read_int(mp_obj_t none_in) {
(void)none_in;
- wizchip_clrinterrupt(IK_SOCK_0);
- setSn_IR(0, Sn_IR_RECV);
-
- // Handle incoming data
- wiznet5k_try_poll();
+ // Handle incoming data, unless the SPI bus is busy
+ if (mp_hal_pin_read(wiznet5k_obj.cs)) {
+ wiznet5k_try_poll();
+ }
return mp_const_none;
}
STATIC MP_DEFINE_CONST_FUN_OBJ_1(mpy_wiznet_read_int_obj, mpy_wiznet_read_int);
@@ -343,6 +342,10 @@ void wiznet5k_poll(void) {
}
}
}
+ wizchip_clrinterrupt(IK_SOCK_0);
+ #if _WIZCHIP_ == W5100S
+ setSn_IR(0, Sn_IR_RECV); // W5100S driver bug: must write to the Sn_IR register to reset the IRQ signal
+ #endif
}
#endif // MICROPY_PY_LWIP