mirror of
https://github.com/hathach/tinyusb.git
synced 2025-03-31 07:20:23 +00:00
dwc2 flush tx,rx fifo in dcd_init()
This commit is contained in:
parent
6ab7875aab
commit
214a4afa6a
@ -447,6 +447,14 @@ void dcd_init(uint8_t rhport) {
|
|||||||
// (non zero-length packet), send STALL back and discard.
|
// (non zero-length packet), send STALL back and discard.
|
||||||
dwc2->dcfg |= DCFG_NZLSOHSK;
|
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
|
// Clear all interrupts
|
||||||
uint32_t int_mask = dwc2->gintsts;
|
uint32_t int_mask = dwc2->gintsts;
|
||||||
dwc2->gintsts |= int_mask;
|
dwc2->gintsts |= int_mask;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user