summaryrefslogtreecommitdiff
path: root/components
diff options
context:
space:
mode:
authorguozhanxin <[email protected]>2019-09-12 18:00:18 +0800
committerguozhanxin <[email protected]>2019-09-12 18:04:44 +0800
commit59dfbb1266eda4f8c5c60ebe194b325297f8aef7 (patch)
treebf0ac2181693d83ae80e5c9189f245db43f0d625 /components
parent900cc4b13b83cd5ecf5b9508f8235459740b1ee5 (diff)
[usb device] Fix the problem of multiple altsetting of interface failing to properly enumerate.
修复多备用设备的接口不能正常枚举的问题。
Diffstat (limited to 'components')
-rw-r--r--components/drivers/usb/usbdevice/core/core.c31
1 files changed, 18 insertions, 13 deletions
diff --git a/components/drivers/usb/usbdevice/core/core.c b/components/drivers/usb/usbdevice/core/core.c
index ae0704585f..d57295effc 100644
--- a/components/drivers/usb/usbdevice/core/core.c
+++ b/components/drivers/usb/usbdevice/core/core.c
@@ -1488,9 +1488,10 @@ uep_t rt_usbd_find_endpoint(udevice_t device, ufunction_t* pfunc, rt_uint8_t ep_
*/
rt_err_t rt_usbd_device_add_config(udevice_t device, uconfig_t cfg)
{
- struct rt_list_node *i, *j, *k;
+ struct rt_list_node *i, *j, *k, *m;
ufunction_t func;
uintf_t intf;
+ ualtsetting_t altsetting;
uep_t ep;
RT_DEBUG_LOG(RT_DEBUG_USB, ("rt_usbd_device_add_config\n"));
@@ -1512,22 +1513,26 @@ rt_err_t rt_usbd_device_add_config(udevice_t device, uconfig_t cfg)
intf = (uintf_t)rt_list_entry(j, struct uinterface, list);
cfg->cfg_desc.bNumInterfaces++;
- /* allocate address for every endpoint in the interface alternate setting */
- for(k=intf->curr_setting->ep_list.next;
- k!=&intf->curr_setting->ep_list; k=k->next)
+ for(k=intf->setting_list.next; k!=&intf->setting_list;k=k->next)
{
- ep = (uep_t)rt_list_entry(k, struct uendpoint, list);
- if(rt_usbd_ep_assign(device, ep) != RT_EOK)
+ altsetting = (ualtsetting_t)rt_list_entry(k, struct ualtsetting, list);
+
+ /* allocate address for every endpoint in the interface alternate setting */
+ for(m=altsetting->ep_list.next; m!=&altsetting->ep_list; m=m->next)
{
- rt_kprintf("endpoint assign error\n");
+ ep = (uep_t)rt_list_entry(m, struct uendpoint, list);
+ if(rt_usbd_ep_assign(device, ep) != RT_EOK)
+ {
+ rt_kprintf("endpoint assign error\n");
+ }
}
- }
- /* construct complete configuration descriptor */
- rt_memcpy((void*)&cfg->cfg_desc.data[cfg->cfg_desc.wTotalLength - USB_DESC_LENGTH_CONFIG],
- (void*)intf->curr_setting->desc,
- intf->curr_setting->desc_size);
- cfg->cfg_desc.wTotalLength += intf->curr_setting->desc_size;
+ /* construct complete configuration descriptor */
+ rt_memcpy((void*)&cfg->cfg_desc.data[cfg->cfg_desc.wTotalLength - USB_DESC_LENGTH_CONFIG],
+ (void*)altsetting->desc,
+ altsetting->desc_size);
+ cfg->cfg_desc.wTotalLength += altsetting->desc_size;
+ }
}
}