diff options
| author | hathach <[email protected]> | 2023-10-31 11:53:40 +0700 |
|---|---|---|
| committer | hathach <[email protected]> | 2023-10-31 11:53:40 +0700 |
| commit | 214a4afa6aafe9daac6c1c304eb305b44e8cf86d (patch) | |
| tree | bcb71e524354c43fa055bb27fb70ed1108badafd /src | |
| parent | 6ab7875aab3e677fb3bafa8595b7eb90598c2d58 (diff) | |
dwc2 flush tx,rx fifo in dcd_init()
Diffstat (limited to 'src')
| -rw-r--r-- | src/portable/synopsys/dwc2/dcd_dwc2.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/portable/synopsys/dwc2/dcd_dwc2.c b/src/portable/synopsys/dwc2/dcd_dwc2.c index 5c5450ac2..ac93632be 100644 --- a/src/portable/synopsys/dwc2/dcd_dwc2.c +++ b/src/portable/synopsys/dwc2/dcd_dwc2.c @@ -447,6 +447,14 @@ void dcd_init(uint8_t rhport) { // (non zero-length packet), send STALL back and discard. dwc2->dcfg |= DCFG_NZLSOHSK; + // flush all TX fifo and wait for it cleared + dwc2->grstctl = GRSTCTL_TXFFLSH | (0x10u << GRSTCTL_TXFNUM_Pos); + while (dwc2->grstctl & GRSTCTL_TXFFLSH_Msk) {} + + // flush RX fifo and wait for it cleared + dwc2->grstctl = GRSTCTL_RXFFLSH; + while (dwc2->grstctl & GRSTCTL_RXFFLSH_Msk) {} + // Clear all interrupts uint32_t int_mask = dwc2->gintsts; dwc2->gintsts |= int_mask; |
