From d493724a7bd0f4dca718f478aec301d299bd5416 Mon Sep 17 00:00:00 2001 From: me-no-dev Date: Thu, 2 Jul 2020 13:05:17 +0300 Subject: [PATCH] ESP32-S2: Detect EP IN Xfer Timeout In some rare ocasions (bad cable, noise, etc.) data transfer might timeout and hang the endpoint, unless the interrupt flag is cleared. This pull request targets to solve that case. --- src/portable/espressif/esp32s2/dcd_esp32s2.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/portable/espressif/esp32s2/dcd_esp32s2.c b/src/portable/espressif/esp32s2/dcd_esp32s2.c index d49b69a10..3d30b6016 100644 --- a/src/portable/espressif/esp32s2/dcd_esp32s2.c +++ b/src/portable/espressif/esp32s2/dcd_esp32s2.c @@ -637,6 +637,13 @@ static void handle_epin_ints(void) USB0.dtknqr4_fifoemptymsk &= ~(1 << n); } } + + // XFER Timeout + if (USB0.in_ep_reg[n].diepint & USB_D_TIMEOUT0_M) { + // Clear interrupt or enpoint will hang. + USB0.in_ep_reg[n].diepint = USB_D_TIMEOUT0_M; + // Maybe retry? + } } } }