summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichiel van Leeuwen <[email protected]>2023-05-04 10:02:42 +0200
committerMichiel van Leeuwen <[email protected]>2023-05-04 10:02:42 +0200
commit75cf8e21a7e525eb24b7fd34fe5859cba331fcc2 (patch)
tree93d32b9663bf4ec9308125d83a73293d49c84700
parent678edbe20320fe4d17437a9175ec8ff88f752ecb (diff)
Use double-sized fifo only for IN endpoints
-rw-r--r--src/portable/synopsys/dwc2/dcd_dwc2.c10
1 files 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);