fix(core/usbd_core): reset endpoint only for altsetting 0, refs:#258

This commit is contained in:
sakumisu
2024-09-26 21:23:27 +08:00
parent 76bbd09fed
commit 0d65bbc6ba

View File

@@ -489,10 +489,13 @@ static bool usbd_set_interface(uint8_t busid, uint8_t iface, uint8_t alt_setting
if (cur_iface == iface) { if (cur_iface == iface) {
ep_desc = (struct usb_endpoint_descriptor *)p; ep_desc = (struct usb_endpoint_descriptor *)p;
if (cur_alt_setting != alt_setting) { if (alt_setting == 0) {
ret = usbd_reset_endpoint(busid, ep_desc); ret = usbd_reset_endpoint(busid, ep_desc);
} else { goto find_end;
} else if (cur_alt_setting == alt_setting) {
ret = usbd_set_endpoint(busid, ep_desc); ret = usbd_set_endpoint(busid, ep_desc);
goto find_end;
} else {
} }
} }
@@ -510,6 +513,7 @@ static bool usbd_set_interface(uint8_t busid, uint8_t iface, uint8_t alt_setting
} }
} }
find_end:
usbd_class_event_notify_handler(busid, USBD_EVENT_SET_INTERFACE, (void *)if_desc); usbd_class_event_notify_handler(busid, USBD_EVENT_SET_INTERFACE, (void *)if_desc);
return ret; return ret;