diff options
| author | heyuanjie87 <[email protected]> | 2013-01-17 12:23:06 +0800 |
|---|---|---|
| committer | heyuanjie87 <[email protected]> | 2013-01-17 12:23:06 +0800 |
| commit | a3bde3c4a364a2648f626eaab6b79f6e74535525 (patch) | |
| tree | 2479f9dff1546abbe95b791cb1b6a6d053d6ecb4 /components/drivers | |
| parent | 9721603b72121566b6c0b42c5f39ce9c2599121f (diff) | |
handle standard request to interface that defined in class
Diffstat (limited to 'components/drivers')
| -rw-r--r-- | components/drivers/usb/usbdevice/core/core.c | 43 |
1 files changed, 40 insertions, 3 deletions
diff --git a/components/drivers/usb/usbdevice/core/core.c b/components/drivers/usb/usbdevice/core/core.c index c0f21a1cd4..ea4efde2d7 100644 --- a/components/drivers/usb/usbdevice/core/core.c +++ b/components/drivers/usb/usbdevice/core/core.c @@ -356,6 +356,38 @@ static rt_err_t _set_address(struct udevice* device, ureq_t setup) } /** + * 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. * * @param device the usb device object. @@ -419,9 +451,14 @@ static rt_err_t _standard_request(struct udevice* device, ureq_t setup) _set_interface(device, setup); break; default: - rt_kprintf("unknown interface request\n"); - dcd_ep_stall(device->dcd, 0); - break; + if (_request_interface(device, setup) != RT_EOK) + { + rt_kprintf("unknown interface request\n"); + dcd_ep_stall(device->dcd, 0); + return - RT_ERROR; + } + else + break; } break; case USB_REQ_TYPE_ENDPOINT: |
