Skip to content

Commit ffb1647

Browse files
committed
retired all transferring endpoint if device is disconnected
1 parent e2c862b commit ffb1647

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/pio_usb_host.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,16 @@ static bool __no_inline_not_in_flash_func(connection_check)(root_port_t *port) {
195195
port->connected = false;
196196
port->suspended = true;
197197
port->ints |= PIO_USB_INTS_DISCONNECT_BITS;
198+
199+
// failed/retired all queuing transfer in this root
200+
uint8_t root_idx = port - PIO_USB_ROOT_PORT(0);
201+
for (int ep_idx = 0; ep_idx < PIO_USB_EP_POOL_CNT; ep_idx++) {
202+
endpoint_t *ep = PIO_USB_ENDPOINT(ep_idx);
203+
if ((ep->root_idx == root_idx) && ep->size && ep->has_transfer) {
204+
pio_usb_ll_transfer_complete(ep, PIO_USB_INTS_ENDPOINT_ERROR_BITS);
205+
}
206+
}
207+
198208
return false;
199209
}
200210
}

0 commit comments

Comments
 (0)