From 75cf8e21a7e525eb24b7fd34fe5859cba331fcc2 Mon Sep 17 00:00:00 2001 From: Michiel van Leeuwen Date: Thu, 4 May 2023 10:02:42 +0200 Subject: [PATCH] Use double-sized fifo only for IN endpoints --- src/portable/synopsys/dwc2/dcd_dwc2.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/portable/synopsys/dwc2/dcd_dwc2.c b/src/portable/synopsys/dwc2/dcd_dwc2.c index d84014789..c3d3ae085 100644 --- a/src/portable/synopsys/dwc2/dcd_dwc2.c +++ b/src/portable/synopsys/dwc2/dcd_dwc2.c @@ -648,10 +648,7 @@ bool dcd_edpt_open (uint8_t rhport, tusb_desc_endpoint_t const * desc_edpt) xfer->max_size = tu_edpt_packet_size(desc_edpt); xfer->interval = desc_edpt->bInterval; - // The fifo-empty interrupt fires when the interrupt is half empty. In order - // to be able to write a packet at that point, the fifo must be twice the - // max_size. - uint16_t const fifo_size = tu_div_ceil(xfer->max_size * 2, 4); + uint16_t fifo_size = tu_div_ceil(xfer->max_size, 4); if(dir == TUSB_DIR_OUT) { @@ -697,6 +694,11 @@ bool dcd_edpt_open (uint8_t rhport, tusb_desc_endpoint_t const * desc_edpt) // In FIFO is allocated by following rules: // - IN EP 1 gets FIFO 1, IN EP "n" gets FIFO "n". + // The fifo-empty interrupt fires when the interrupt is half empty. In order + // to be able to write a packet at that point, the fifo must be twice the + // max_size. + fifo_size = fifo_size * 2; + // Check if free space is available TU_ASSERT(_allocated_fifo_words_tx + fifo_size + dwc2->grxfsiz <= _dwc2_controller[rhport].ep_fifo_size/4);