diff options
| author | HiFiPhile <[email protected]> | 2025-04-18 11:24:23 +0200 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-04-18 11:24:23 +0200 |
| commit | 91163c92170740ab5d6e0b5b768e6f0c8856f86b (patch) | |
| tree | 6692769b8826051a2ae4be8de59240173c698fba /src | |
| parent | 3fd7854a91f82b683af7a6442f8447f02ab5a29c (diff) | |
| parent | cea2c972488896316d1b980bed317c7226b99306 (diff) | |
Merge pull request #3067 from maximevince/dwc2-host-fix-disconnect
dwc2/host: enable disconnect interrupt + handle it
Diffstat (limited to 'src')
| -rw-r--r-- | src/portable/synopsys/dwc2/hcd_dwc2.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/portable/synopsys/dwc2/hcd_dwc2.c b/src/portable/synopsys/dwc2/hcd_dwc2.c index 33c0edba1..518a5efdf 100644 --- a/src/portable/synopsys/dwc2/hcd_dwc2.c +++ b/src/portable/synopsys/dwc2/hcd_dwc2.c @@ -390,7 +390,7 @@ bool hcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) { dwc2->hprt = HPRT_POWER; // turn on VBUS // Enable required interrupts - dwc2->gintmsk |= GINTSTS_OTGINT | GINTSTS_CONIDSTSCHNG | GINTSTS_HPRTINT | GINTSTS_HCINT; + dwc2->gintmsk |= GINTSTS_OTGINT | GINTSTS_CONIDSTSCHNG | GINTSTS_HPRTINT | GINTSTS_HCINT | GINTSTS_DISCINT; // NPTX can hold at least 2 packet, change interrupt level to half-empty uint32_t gahbcfg = dwc2->gahbcfg & ~GAHBCFG_TX_FIFO_EPMTY_LVL; @@ -1308,8 +1308,6 @@ static void handle_hprt_irq(uint8_t rhport, bool in_isr) { if (hprt_bm.conn_status) { hcd_event_device_attach(rhport, in_isr); - } else { - hcd_event_device_remove(rhport, in_isr); } } @@ -1372,6 +1370,14 @@ void hcd_int_handler(uint8_t rhport, bool in_isr) { handle_channel_irq(rhport, in_isr); } + if (gintsts & GINTSTS_DISCINT) { + // Device disconnected + dwc2->gintsts = GINTSTS_DISCINT; + if (!(dwc2->hprt & HPRT_CONN_STATUS)) { + hcd_event_device_remove(rhport, in_isr); + } + } + #if CFG_TUH_DWC2_SLAVE_ENABLE // RxFIFO non-empty interrupt handling if (gintsts & GINTSTS_RXFLVL) { |
