mirror of
https://github.com/RT-Thread/rt-thread.git
synced 2025-01-18 18:53:31 +08:00
[Components][USB Device]各个class对HS进行了适配
部分class还不支持HS,RNDIS存在暂时无法解决的已知bug
This commit is contained in:
parent
b553543b4b
commit
5035662cd9
@ -114,15 +114,17 @@ static struct udevice_descriptor dev_desc =
|
||||
USB_DYNAMIC, //bNumConfigurations;
|
||||
};
|
||||
|
||||
//FS and HS needed
|
||||
static struct usb_qualifier_descriptor dev_qualifier =
|
||||
{
|
||||
sizeof(dev_qualifier),
|
||||
USB_DESC_TYPE_DEVICEQUALIFIER,
|
||||
0x0200,
|
||||
USB_CLASS_CDC,
|
||||
0x00,
|
||||
64,
|
||||
0x01,
|
||||
sizeof(dev_qualifier), //bLength
|
||||
USB_DESC_TYPE_DEVICEQUALIFIER, //bDescriptorType
|
||||
0x0200, //bcdUSB
|
||||
USB_CLASS_CDC, //bDeviceClass
|
||||
0x00, //bDeviceSubClass
|
||||
0x00, //bDeviceProtocol
|
||||
64, //bMaxPacketSize0
|
||||
0x01, //bNumConfigurations
|
||||
0,
|
||||
};
|
||||
|
||||
@ -566,7 +568,8 @@ ufunction_t rt_usbd_function_cdc_create(udevice_t device)
|
||||
|
||||
/* create a cdc function */
|
||||
func = rt_usbd_function_new(device, &dev_desc, &ops);
|
||||
rt_usbd_device_set_qualifier(device, &dev_qualifier);
|
||||
//not support HS
|
||||
//rt_usbd_device_set_qualifier(device, &dev_qualifier);
|
||||
|
||||
/* allocate memory for cdc vcom data */
|
||||
data = (struct vcom*)rt_malloc(sizeof(struct vcom));
|
||||
|
@ -41,7 +41,7 @@ struct rt_ecm_eth
|
||||
rt_uint8_t dev_addr[MAX_ADDR_LEN];
|
||||
|
||||
ALIGN(4)
|
||||
rt_uint8_t rx_pool[64];
|
||||
rt_uint8_t rx_pool[512];
|
||||
ALIGN(4)
|
||||
rt_size_t rx_size;
|
||||
ALIGN(4)
|
||||
@ -147,14 +147,14 @@ const static struct ucdc_data_descriptor _data_desc =
|
||||
USB_DESC_TYPE_ENDPOINT,
|
||||
USB_DIR_OUT | USB_DYNAMIC,
|
||||
USB_EP_ATTR_BULK,
|
||||
USB_CDC_BUFSIZE,
|
||||
USB_DYNAMIC,
|
||||
0x00,
|
||||
/* endpoint, bulk in */
|
||||
USB_DESC_LENGTH_ENDPOINT,
|
||||
USB_DESC_TYPE_ENDPOINT,
|
||||
USB_DYNAMIC | USB_DIR_IN,
|
||||
USB_EP_ATTR_BULK,
|
||||
USB_CDC_BUFSIZE,
|
||||
USB_DYNAMIC,
|
||||
0x00,
|
||||
};
|
||||
|
||||
@ -170,17 +170,20 @@ const static char* _ustring[] =
|
||||
};
|
||||
|
||||
ALIGN(4)
|
||||
//FS and HS needed
|
||||
static struct usb_qualifier_descriptor dev_qualifier =
|
||||
{
|
||||
sizeof(dev_qualifier),
|
||||
USB_DESC_TYPE_DEVICEQUALIFIER,
|
||||
0x0200,
|
||||
USB_CLASS_CDC,
|
||||
0x00,
|
||||
64,
|
||||
0x01,
|
||||
sizeof(dev_qualifier), //bLength
|
||||
USB_DESC_TYPE_DEVICEQUALIFIER, //bDescriptorType
|
||||
0x0200, //bcdUSB
|
||||
USB_CLASS_CDC, //bDeviceClass
|
||||
USB_CDC_SUBCLASS_ETH, //bDeviceSubClass
|
||||
USB_CDC_PROTOCOL_NONE, //bDeviceProtocol
|
||||
64, //bMaxPacketSize0
|
||||
0x01, //bNumConfigurations
|
||||
0,
|
||||
};
|
||||
|
||||
static rt_err_t _cdc_send_notifi(ufunction_t func,ucdc_notification_code_t notifi,rt_uint16_t wValue,rt_uint16_t wLength)
|
||||
{
|
||||
static struct ucdc_management_element_notifications _notifi;
|
||||
@ -472,7 +475,7 @@ static struct ufunction_ops ops =
|
||||
*
|
||||
* @return RT_EOK on successful.
|
||||
*/
|
||||
static rt_err_t _cdc_descriptor_config(ucdc_comm_desc_t comm, rt_uint8_t cintf_nr, ucdc_data_desc_t data, rt_uint8_t dintf_nr)
|
||||
static rt_err_t _cdc_descriptor_config(ucdc_comm_desc_t comm, rt_uint8_t cintf_nr, ucdc_data_desc_t data, rt_uint8_t dintf_nr, rt_uint8_t device_is_hs)
|
||||
{
|
||||
comm->call_mgmt_desc.data_interface = dintf_nr;
|
||||
comm->union_desc.master_interface = cintf_nr;
|
||||
@ -480,7 +483,8 @@ static rt_err_t _cdc_descriptor_config(ucdc_comm_desc_t comm, rt_uint8_t cintf_n
|
||||
#ifdef RT_USB_DEVICE_COMPOSITE
|
||||
comm->iad_desc.bFirstInterface = cintf_nr;
|
||||
#endif
|
||||
|
||||
data->ep_out_desc.wMaxPacketSize = device_is_hs ? 512 : 64;
|
||||
data->ep_in_desc.wMaxPacketSize = device_is_hs ? 512 : 64;
|
||||
return RT_EOK;
|
||||
}
|
||||
|
||||
@ -532,7 +536,7 @@ ufunction_t rt_usbd_function_ecm_create(udevice_t device)
|
||||
(rt_off_t)&((ucdc_eth_desc_t)0)->intf_desc);
|
||||
rt_usbd_altsetting_config_descriptor(data_setting, &_data_desc, 0);
|
||||
/* configure the cdc interface descriptor */
|
||||
_cdc_descriptor_config(comm_setting->desc, intf_comm->intf_num, data_setting->desc, intf_data->intf_num);
|
||||
_cdc_descriptor_config(comm_setting->desc, intf_comm->intf_num, data_setting->desc, intf_data->intf_num, device->dcd->device_is_hs);
|
||||
|
||||
/* create a command endpoint */
|
||||
comm_desc = (ucdc_eth_desc_t)comm_setting->desc;
|
||||
|
@ -227,18 +227,21 @@ static struct udevice_descriptor _dev_desc =
|
||||
USB_DYNAMIC, //bNumConfigurations;
|
||||
};
|
||||
|
||||
static struct usb_qualifier_descriptor _dev_qualifier =
|
||||
//FS and HS needed
|
||||
static struct usb_qualifier_descriptor dev_qualifier =
|
||||
{
|
||||
sizeof(_dev_qualifier),
|
||||
USB_DESC_TYPE_DEVICEQUALIFIER,
|
||||
0x0200,
|
||||
USB_CLASS_HID,
|
||||
0x00,
|
||||
64,
|
||||
0x01,
|
||||
sizeof(dev_qualifier), //bLength
|
||||
USB_DESC_TYPE_DEVICEQUALIFIER, //bDescriptorType
|
||||
0x0200, //bcdUSB
|
||||
USB_CLASS_MASS_STORAGE, //bDeviceClass
|
||||
0x06, //bDeviceSubClass
|
||||
0x50, //bDeviceProtocol
|
||||
64, //bMaxPacketSize0
|
||||
0x01, //bNumConfigurations
|
||||
0,
|
||||
};
|
||||
|
||||
|
||||
/* hid interface descriptor */
|
||||
const static struct uhid_comm_descriptor _hid_comm_desc =
|
||||
{
|
||||
@ -631,7 +634,8 @@ ufunction_t rt_usbd_function_hid_create(udevice_t device)
|
||||
|
||||
/* create a cdc function */
|
||||
func = rt_usbd_function_new(device, &_dev_desc, &ops);
|
||||
rt_usbd_device_set_qualifier(device, &_dev_qualifier);
|
||||
//not support hs
|
||||
//rt_usbd_device_set_qualifier(device, &_dev_qualifier);
|
||||
|
||||
/* allocate memory for cdc vcom data */
|
||||
data = (struct hid_s*)rt_malloc(sizeof(struct hid_s));
|
||||
|
@ -88,8 +88,8 @@ static struct udevice_descriptor dev_desc =
|
||||
USB_DESC_TYPE_DEVICE, //type;
|
||||
USB_BCD_VERSION, //bcdUSB;
|
||||
USB_CLASS_MASS_STORAGE, //bDeviceClass;
|
||||
0x00, //bDeviceSubClass;
|
||||
0x00, //bDeviceProtocol;
|
||||
0x06, //bDeviceSubClass;
|
||||
0x50, //bDeviceProtocol;
|
||||
0x40, //bMaxPacketSize0;
|
||||
_VENDOR_ID, //idVendor;
|
||||
_PRODUCT_ID, //idProduct;
|
||||
@ -100,15 +100,17 @@ static struct udevice_descriptor dev_desc =
|
||||
USB_DYNAMIC, //bNumConfigurations;
|
||||
};
|
||||
|
||||
//FS and HS needed
|
||||
static struct usb_qualifier_descriptor dev_qualifier =
|
||||
{
|
||||
sizeof(dev_qualifier),
|
||||
USB_DESC_TYPE_DEVICEQUALIFIER,
|
||||
0x0200,
|
||||
USB_CLASS_MASS_STORAGE,
|
||||
0x00,
|
||||
64,
|
||||
0x01,
|
||||
sizeof(dev_qualifier), //bLength
|
||||
USB_DESC_TYPE_DEVICEQUALIFIER, //bDescriptorType
|
||||
0x0200, //bcdUSB
|
||||
USB_CLASS_MASS_STORAGE, //bDeviceClass
|
||||
0x06, //bDeviceSubClass
|
||||
0x50, //bDeviceProtocol
|
||||
64, //bMaxPacketSize0
|
||||
0x01, //bNumConfigurations
|
||||
0,
|
||||
};
|
||||
|
||||
@ -141,14 +143,14 @@ const static struct umass_descriptor _mass_desc =
|
||||
USB_DESC_TYPE_ENDPOINT, //type;
|
||||
USB_DYNAMIC | USB_DIR_OUT, //bEndpointAddress;
|
||||
USB_EP_ATTR_BULK, //bmAttributes;
|
||||
0x40, //wMaxPacketSize;
|
||||
USB_DYNAMIC, //wMaxPacketSize;
|
||||
0x00, //bInterval;
|
||||
|
||||
USB_DESC_LENGTH_ENDPOINT, //bLength;
|
||||
USB_DESC_TYPE_ENDPOINT, //type;
|
||||
USB_DYNAMIC | USB_DIR_IN, //bEndpointAddress;
|
||||
USB_EP_ATTR_BULK, //bmAttributes;
|
||||
0x40, //wMaxPacketSize;
|
||||
USB_DYNAMIC, //wMaxPacketSize;
|
||||
0x00, //bInterval;
|
||||
};
|
||||
|
||||
@ -1043,11 +1045,13 @@ static struct ufunction_ops ops =
|
||||
_function_disable,
|
||||
RT_NULL,
|
||||
};
|
||||
static rt_err_t _mstorage_descriptor_config(umass_desc_t desc, rt_uint8_t cintf_nr)
|
||||
static rt_err_t _mstorage_descriptor_config(umass_desc_t desc, rt_uint8_t cintf_nr, rt_uint8_t device_is_hs)
|
||||
{
|
||||
#ifdef RT_USB_DEVICE_COMPOSITE
|
||||
desc->iad_desc.bFirstInterface = cintf_nr;
|
||||
#endif
|
||||
desc->ep_out_desc.wMaxPacketSize = device_is_hs ? 512 : 64;
|
||||
desc->ep_in_desc.wMaxPacketSize = device_is_hs ? 512 : 64;
|
||||
return RT_EOK;
|
||||
}
|
||||
/**
|
||||
@ -1090,7 +1094,7 @@ ufunction_t rt_usbd_function_mstorage_create(udevice_t device)
|
||||
rt_usbd_altsetting_config_descriptor(setting, &_mass_desc, (rt_off_t)&((umass_desc_t)0)->intf_desc);
|
||||
|
||||
/* configure the msc interface descriptor */
|
||||
_mstorage_descriptor_config(setting->desc, intf->intf_num);
|
||||
_mstorage_descriptor_config(setting->desc, intf->intf_num, device->dcd->device_is_hs);
|
||||
|
||||
/* create a bulk out and a bulk in endpoint */
|
||||
mass_desc = (umass_desc_t)setting->desc;
|
||||
|
@ -58,9 +58,9 @@ struct rt_rndis_eth
|
||||
#endif /* RNDIS_DELAY_LINK_UP */
|
||||
|
||||
ALIGN(4)
|
||||
rt_uint8_t rx_pool[64];
|
||||
rt_uint8_t rx_pool[512];
|
||||
ALIGN(4)
|
||||
rt_uint8_t tx_pool[64];
|
||||
rt_uint8_t tx_pool[512];
|
||||
|
||||
rt_uint32_t cmd_pool[2];
|
||||
ALIGN(4)
|
||||
@ -175,14 +175,14 @@ const static struct ucdc_data_descriptor _data_desc =
|
||||
USB_DESC_TYPE_ENDPOINT,
|
||||
USB_DIR_OUT | USB_DYNAMIC,
|
||||
USB_EP_ATTR_BULK,
|
||||
USB_CDC_BUFSIZE,
|
||||
USB_DYNAMIC,
|
||||
0x00,
|
||||
/* endpoint, bulk in */
|
||||
USB_DESC_LENGTH_ENDPOINT,
|
||||
USB_DESC_TYPE_ENDPOINT,
|
||||
USB_DYNAMIC | USB_DIR_IN,
|
||||
USB_EP_ATTR_BULK,
|
||||
USB_CDC_BUFSIZE,
|
||||
USB_DYNAMIC,
|
||||
0x00,
|
||||
};
|
||||
|
||||
@ -206,16 +206,17 @@ struct usb_os_function_comp_id_descriptor rndis_func_comp_id_desc =
|
||||
.subCompatibleID = {'5', '1', '6', '2', '0', '0', '1', 0x00},
|
||||
.reserved2 = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
|
||||
};
|
||||
ALIGN(4)
|
||||
//FS and HS needed
|
||||
static struct usb_qualifier_descriptor dev_qualifier =
|
||||
{
|
||||
sizeof(dev_qualifier),
|
||||
USB_DESC_TYPE_DEVICEQUALIFIER,
|
||||
0x0200,
|
||||
USB_CLASS_CDC,
|
||||
0x00,
|
||||
64,
|
||||
0x01,
|
||||
sizeof(dev_qualifier), //bLength
|
||||
USB_DESC_TYPE_DEVICEQUALIFIER, //bDescriptorType
|
||||
0x0200, //bcdUSB
|
||||
USB_CLASS_CDC, //bDeviceClass
|
||||
USB_CDC_SUBCLASS_ACM, //bDeviceSubClass
|
||||
USB_CDC_PROTOCOL_VENDOR, //bDeviceProtocol
|
||||
64, //bMaxPacketSize0
|
||||
0x01, //bNumConfigurations
|
||||
0,
|
||||
};
|
||||
|
||||
@ -401,7 +402,7 @@ static rt_err_t _rndis_query_response(ufunction_t func,rndis_query_msg_t msg)
|
||||
case OID_GEN_LINK_SPEED:
|
||||
resp = _create_resp(4);
|
||||
if(resp == RT_NULL) break;
|
||||
_set_resp(resp, (10UL * 1000 * 1000) / 100);
|
||||
_set_resp(resp, func->device->dcd->device_is_hs ? (480UL * 1000 *1000) : (12UL * 1000 * 1000) / 100);
|
||||
break;
|
||||
|
||||
case OID_GEN_MEDIA_CONNECT_STATUS:
|
||||
@ -1008,7 +1009,7 @@ static struct ufunction_ops ops =
|
||||
*
|
||||
* @return RT_EOK on successful.
|
||||
*/
|
||||
static rt_err_t _cdc_descriptor_config(ucdc_comm_desc_t comm, rt_uint8_t cintf_nr, ucdc_data_desc_t data, rt_uint8_t dintf_nr)
|
||||
static rt_err_t _cdc_descriptor_config(ucdc_comm_desc_t comm, rt_uint8_t cintf_nr, ucdc_data_desc_t data, rt_uint8_t dintf_nr, rt_uint8_t device_is_hs)
|
||||
{
|
||||
comm->call_mgmt_desc.data_interface = dintf_nr;
|
||||
comm->union_desc.master_interface = cintf_nr;
|
||||
@ -1016,7 +1017,8 @@ static rt_err_t _cdc_descriptor_config(ucdc_comm_desc_t comm, rt_uint8_t cintf_n
|
||||
#ifdef RT_USB_DEVICE_COMPOSITE
|
||||
comm->iad_desc.bFirstInterface = cintf_nr;
|
||||
#endif
|
||||
|
||||
data->ep_out_desc.wMaxPacketSize = device_is_hs ? 512 : 64;
|
||||
data->ep_in_desc.wMaxPacketSize = device_is_hs ? 512 : 64;
|
||||
return RT_EOK;
|
||||
}
|
||||
|
||||
@ -1237,7 +1239,7 @@ ufunction_t rt_usbd_function_rndis_create(udevice_t device)
|
||||
(rt_off_t)&((ucdc_comm_desc_t)0)->intf_desc);
|
||||
rt_usbd_altsetting_config_descriptor(data_setting, &_data_desc, 0);
|
||||
/* configure the cdc interface descriptor */
|
||||
_cdc_descriptor_config(comm_setting->desc, intf_comm->intf_num, data_setting->desc, intf_data->intf_num);
|
||||
_cdc_descriptor_config(comm_setting->desc, intf_comm->intf_num, data_setting->desc, intf_data->intf_num, device->dcd->device_is_hs);
|
||||
|
||||
/* create a command endpoint */
|
||||
comm_desc = (ucdc_comm_desc_t)comm_setting->desc;
|
||||
|
Loading…
x
Reference in New Issue
Block a user