Skip to content

Commit

Permalink
fix(core/usbd_core): reset endpoint only for altsetting 0
Browse files Browse the repository at this point in the history
  • Loading branch information
sakumisu committed Sep 26, 2024
1 parent 76bbd09 commit 98101ee
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions core/usbd_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -489,10 +489,13 @@ static bool usbd_set_interface(uint8_t busid, uint8_t iface, uint8_t alt_setting
if (cur_iface == iface) {
ep_desc = (struct usb_endpoint_descriptor *)p;

if (cur_alt_setting != alt_setting) {
if (alt_setting == 0) {
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);
goto find_end;
} else {
}
}

Expand All @@ -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);

return ret;
Expand Down

0 comments on commit 98101ee

Please sign in to comment.