From 49aa0b72a8301f21281fa6498af47ac26bcb1bea Mon Sep 17 00:00:00 2001 From: Jerzy Kasenberg Date: Fri, 15 Oct 2021 11:34:26 +0200 Subject: [PATCH] dcd_da146xx: Fix EPIN stall notification handling Normal TX handler for IN non-0 endpoints is called during outgoing transfer or just after it was finished. It may need to fill TX fifo with same data if TX_DONE is present but ACK_STAT is not. It may need to fill more data when called during transfer. But it may also be called when STALL was sent. In this case TX_DONE is set ACK_STAT is not, just like for packets that were sent but no ACK was received. Code was trying to send something again. There was nothing to send so empty ZLP was scheduled for stalled endpoint. This ZLP was later send to host where valid response was required. This change checks if notification was for STALL endpoint and does not try to fill TX FIFO in that case. --- src/portable/dialog/da146xx/dcd_da146xx.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/portable/dialog/da146xx/dcd_da146xx.c b/src/portable/dialog/da146xx/dcd_da146xx.c index a36165343..c4b46ac08 100644 --- a/src/portable/dialog/da146xx/dcd_da146xx.c +++ b/src/portable/dialog/da146xx/dcd_da146xx.c @@ -632,6 +632,13 @@ static void handle_epx_tx_ev(xfer_ctl_t *xfer) return; } } + else if (regs->epc_in & USB_USB_EPC1_REG_USB_STALL_Msk) + { + // TX_DONE also indicates that STALL packet was just sent, there is + // no point to put anything into transmit FIFO. It could result in + // empty packet being scheduled. + return; + } } if (txs & USB_USB_TXS1_REG_USB_TX_URUN_Msk) {