diff options
| author | Maxime Vincent <[email protected]> | 2025-04-07 11:36:02 +0200 |
|---|---|---|
| committer | Maxime Vincent <[email protected]> | 2025-04-07 11:36:06 +0200 |
| commit | 7d8433abab25734981f1b5eab3c5724a945df711 (patch) | |
| tree | ca88386e3c086153b0a20a95a95cc6086ec5d3dc /src | |
| parent | 865e3488f99209c57b73953428dccf2bc666f0be (diff) | |
dwc2/host: enable disconnect interrupt + handle it
Signed-off-by: Maxime Vincent <[email protected]>
Diffstat (limited to 'src')
| -rw-r--r-- | src/portable/synopsys/dwc2/hcd_dwc2.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/portable/synopsys/dwc2/hcd_dwc2.c b/src/portable/synopsys/dwc2/hcd_dwc2.c index 7cbef05b7..4c3d23b65 100644 --- a/src/portable/synopsys/dwc2/hcd_dwc2.c +++ b/src/portable/synopsys/dwc2/hcd_dwc2.c @@ -381,7 +381,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; @@ -1330,6 +1330,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) { |
