mirror of
https://github.com/RT-Thread/rt-thread.git
synced 2025-01-18 20:43:54 +08:00
handle standard request to interface that defined in class
This commit is contained in:
parent
9721603b72
commit
a3bde3c4a3
@ -355,6 +355,38 @@ static rt_err_t _set_address(struct udevice* device, ureq_t setup)
|
|||||||
return RT_EOK;
|
return RT_EOK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This function will handle standard request to
|
||||||
|
* interface that defined in class-specifics
|
||||||
|
*
|
||||||
|
* @param device the usb device object.
|
||||||
|
* @param setup the setup request.
|
||||||
|
*
|
||||||
|
* @return RT_EOK on successful.
|
||||||
|
*/
|
||||||
|
static rt_err_t _request_interface(struct udevice* device, ureq_t setup)
|
||||||
|
{
|
||||||
|
uintf_t intf;
|
||||||
|
uclass_t cls;
|
||||||
|
rt_err_t ret;
|
||||||
|
|
||||||
|
/* parameter check */
|
||||||
|
RT_ASSERT(device != RT_NULL);
|
||||||
|
RT_ASSERT(setup != RT_NULL);
|
||||||
|
|
||||||
|
RT_DEBUG_LOG(RT_DEBUG_USB, ("_request_interface\n"));
|
||||||
|
|
||||||
|
intf = rt_usbd_find_interface(device, setup->index & 0xFF, &cls);
|
||||||
|
if (intf != RT_NULL)
|
||||||
|
{
|
||||||
|
ret = intf->handler(device, cls, setup);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
ret = -RT_ERROR;
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This function will handle standard request.
|
* This function will handle standard request.
|
||||||
*
|
*
|
||||||
@ -419,9 +451,14 @@ static rt_err_t _standard_request(struct udevice* device, ureq_t setup)
|
|||||||
_set_interface(device, setup);
|
_set_interface(device, setup);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
rt_kprintf("unknown interface request\n");
|
if (_request_interface(device, setup) != RT_EOK)
|
||||||
dcd_ep_stall(device->dcd, 0);
|
{
|
||||||
break;
|
rt_kprintf("unknown interface request\n");
|
||||||
|
dcd_ep_stall(device->dcd, 0);
|
||||||
|
return - RT_ERROR;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case USB_REQ_TYPE_ENDPOINT:
|
case USB_REQ_TYPE_ENDPOINT:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user