Reset endpoint specified in request, not the one it arrived on.

This commit is contained in:
Martin Ling
2022-03-29 23:40:08 +01:00
parent 84898a0bcb
commit 2fba08cf42
3 changed files with 9 additions and 2 deletions

View File

@ -44,7 +44,7 @@ usb_queue_head_t* usb_queue_head(
return &usb_qh[USB_QH_INDEX(endpoint_address)]; return &usb_qh[USB_QH_INDEX(endpoint_address)];
} }
static usb_endpoint_t* usb_endpoint_from_address( usb_endpoint_t* usb_endpoint_from_address(
const uint_fast8_t endpoint_address const uint_fast8_t endpoint_address
) { ) {
return (usb_endpoint_t*)usb_queue_head(endpoint_address)->_reserved_0; return (usb_endpoint_t*)usb_queue_head(endpoint_address)->_reserved_0;

View File

@ -58,6 +58,10 @@ void usb_set_address_deferred(
const uint_fast8_t address const uint_fast8_t address
); );
usb_endpoint_t* usb_endpoint_from_address(
const uint_fast8_t endpoint_address
);
void usb_endpoint_init( void usb_endpoint_init(
const usb_endpoint_t* const endpoint const usb_endpoint_t* const endpoint
); );

View File

@ -369,9 +369,12 @@ static usb_request_status_t usb_standard_request_get_status(
static usb_request_status_t usb_standard_request_clear_feature_setup( static usb_request_status_t usb_standard_request_clear_feature_setup(
usb_endpoint_t* const endpoint) usb_endpoint_t* const endpoint)
{ {
switch (endpoint->setup.value) { switch (endpoint->setup.value) {
case USB_FEATURE_SELECTOR_ENDPOINT_HALT: case USB_FEATURE_SELECTOR_ENDPOINT_HALT:
usb_endpoint_reset_data_toggle(endpoint); usb_endpoint_reset_data_toggle(
usb_endpoint_from_address(endpoint->setup.index)
);
return USB_REQUEST_STATUS_OK; return USB_REQUEST_STATUS_OK;
default: default:
return USB_REQUEST_STATUS_STALL; return USB_REQUEST_STATUS_STALL;