Skip to content

Commit 724ef1a

Browse files
committed
set txfifo empty level to complete and change back fifo tx to normal size
1 parent 9986bd8 commit 724ef1a

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/portable/synopsys/dwc2/dcd_dwc2.c

+7-5
Original file line numberDiff line numberDiff line change
@@ -154,9 +154,11 @@ static bool fifo_alloc(uint8_t rhport, uint8_t ep_addr, uint16_t packet_size) {
154154
dwc2->grxfsiz = sz;
155155
}
156156
} else {
157-
// The fifo-empty interrupt fires when the interrupt is half empty. In order
157+
// Note if The TXFELVL is configured as half empty. In order
158158
// to be able to write a packet at that point, the fifo must be twice the max_size.
159-
fifo_size = fifo_size * 2;
159+
if ((dwc2->gahbcfg & GAHBCFG_TXFELVL) == 0) {
160+
fifo_size *= 2;
161+
}
160162

161163
// Check if free space is available
162164
TU_ASSERT(_allocated_fifo_words_tx + fifo_size + dwc2->grxfsiz <= _dwc2_controller[rhport].ep_fifo_size / 4);
@@ -596,13 +598,13 @@ void dcd_init(uint8_t rhport) {
596598
int_mask = dwc2->gotgint;
597599
dwc2->gotgint |= int_mask;
598600

599-
// Configure TX FIFO to set the TX FIFO empty interrupt when half-empty
600-
dwc2->gahbcfg &= ~GAHBCFG_TXFELVL;
601-
602601
// Required as part of core initialization.
603602
dwc2->gintmsk = GINTMSK_OTGINT | GINTMSK_RXFLVLM |
604603
GINTMSK_USBSUSPM | GINTMSK_USBRST | GINTMSK_ENUMDNEM | GINTMSK_WUIM;
605604

605+
// Configure TX FIFO empty level for interrupt. Default is complete empty
606+
dwc2->gahbcfg |= GAHBCFG_TXFELVL;
607+
606608
// Enable global interrupt
607609
dwc2->gahbcfg |= GAHBCFG_GINT;
608610

0 commit comments

Comments
 (0)