usb_core: rework handling of clear feature

Change-Id: Icb1e973aa5fd8520eff0796aa8164e0a988d9107
This commit is contained in:
Amaury Pouly 2013-07-24 22:29:44 +02:00 committed by Marcin Bukat
parent c4f2a46e0d
commit 21c5ffe09a

View file

@ -687,6 +687,16 @@ static void usb_core_do_set_config(uint8_t config)
#endif
}
static void usb_core_do_clear_feature(int recip, int recip_nr, int feature)
{
logf("usb_core: CLEAR FEATURE (%d,%d,%d)", recip, recip_nr, feature);
if(recip == USB_RECIP_ENDPOINT)
{
if(feature == USB_ENDPOINT_HALT)
usb_drv_stall(EP_NUM(recip_nr), false, EP_DIR(recip_nr));
}
}
static void request_handler_device(struct usb_ctrlrequest* req)
{
switch(req->bRequest) {
@ -809,9 +819,9 @@ static void request_handler_endpoint_standard(struct usb_ctrlrequest* req)
{
switch (req->bRequest) {
case USB_REQ_CLEAR_FEATURE:
if(req->wValue == USB_ENDPOINT_HALT)
usb_drv_stall(EP_NUM(req->wIndex), false, EP_DIR(req->wIndex));
usb_core_do_clear_feature(USB_RECIP_ENDPOINT,
req->wIndex,
req->wValue);
usb_drv_send(EP_CONTROL, NULL, 0);
break;
case USB_REQ_SET_FEATURE: