|
|
@@ -412,10 +412,28 @@ tusb_speed_t hcd_port_speed_get(uint8_t rhport)
|
|
|
// Close all opened endpoint belong to this device
|
|
|
void hcd_device_close(uint8_t rhport, uint8_t dev_addr)
|
|
|
{
|
|
|
- (void) rhport;
|
|
|
- (void) dev_addr;
|
|
|
+ pico_trace("hcd_device_close %d\n", dev_addr);
|
|
|
+ (void) rhport;
|
|
|
+
|
|
|
+ if (dev_addr == 0) return;
|
|
|
+
|
|
|
+ for (size_t i = 1; i < TU_ARRAY_SIZE(ep_pool); i++)
|
|
|
+ {
|
|
|
+ hw_endpoint_t* ep = &ep_pool[i];
|
|
|
|
|
|
- pico_trace("hcd_device_close %d\n", dev_addr);
|
|
|
+ if (ep->dev_addr == dev_addr && ep->configured)
|
|
|
+ {
|
|
|
+ // in case it is an interrupt endpoint, disable it
|
|
|
+ usb_hw_clear->int_ep_ctrl = (1 << (ep->interrupt_num + 1));
|
|
|
+ usb_hw->int_ep_addr_ctrl[ep->interrupt_num] = 0;
|
|
|
+
|
|
|
+ // unconfigure the endpoint
|
|
|
+ ep->configured = false;
|
|
|
+ *ep->endpoint_control = 0;
|
|
|
+ *ep->buffer_control = 0;
|
|
|
+ hw_endpoint_reset_transfer(ep);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
uint32_t hcd_frame_number(uint8_t rhport)
|