From cde81a296d30d0b927b30393bf98c3fe4cbbb258 Mon Sep 17 00:00:00 2001 From: guozhanxin Date: Thu, 19 Sep 2019 20:58:58 +0800 Subject: [PATCH] =?UTF-8?q?[usbd]=20Fixed=20an=20error=20where=20change=20?= =?UTF-8?q?the=20interface=20did=20not=20call=20handler.|=E4=BF=AE?= =?UTF-8?q?=E6=AD=A3=E4=BA=86=E6=94=B9=E5=8F=98=E6=8E=A5=E5=8F=A3=E4=B8=8D?= =?UTF-8?q?=E8=B0=83=E7=94=A8=E5=9B=9E=E8=B0=83=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/drivers/usb/usbdevice/core/core.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/components/drivers/usb/usbdevice/core/core.c b/components/drivers/usb/usbdevice/core/core.c index d57295effc..584556303f 100644 --- a/components/drivers/usb/usbdevice/core/core.c +++ b/components/drivers/usb/usbdevice/core/core.c @@ -237,7 +237,8 @@ static rt_err_t _get_interface(struct udevice* device, ureq_t setup) { rt_uint8_t value; uintf_t intf; - + ufunction_t func; + /* parameter check */ RT_ASSERT(device != RT_NULL); RT_ASSERT(setup != RT_NULL); @@ -251,12 +252,17 @@ static rt_err_t _get_interface(struct udevice* device, ureq_t setup) } /* find the specified interface and its alternate setting */ - intf = rt_usbd_find_interface(device, setup->wIndex & 0xFF, RT_NULL); + intf = rt_usbd_find_interface(device, setup->wIndex & 0xFF, &func); value = intf->curr_setting->intf_desc->bAlternateSetting; /* send the interface alternate setting to endpoint 0*/ rt_usbd_ep0_write(device, &value, 1); + if (intf->handler) + { + intf->handler(func, setup); + } + return RT_EOK; } @@ -270,6 +276,7 @@ static rt_err_t _get_interface(struct udevice* device, ureq_t setup) */ static rt_err_t _set_interface(struct udevice* device, ureq_t setup) { + ufunction_t func; uintf_t intf; uep_t ep; struct rt_list_node* i; @@ -288,7 +295,7 @@ static rt_err_t _set_interface(struct udevice* device, ureq_t setup) } /* find the specified interface */ - intf = rt_usbd_find_interface(device, setup->wIndex & 0xFF, RT_NULL); + intf = rt_usbd_find_interface(device, setup->wIndex & 0xFF, &func); /* set alternate setting to the interface */ rt_usbd_set_altsetting(intf, setup->wValue & 0xFF); @@ -303,6 +310,11 @@ static rt_err_t _set_interface(struct udevice* device, ureq_t setup) } dcd_ep0_send_status(device->dcd); + if (intf->handler) + { + intf->handler(func, setup); + } + return RT_EOK; }