Merge pull request #1055 from uestczyh222/master

[Components][Drivers][USB]Add IAD support for MSC class
This commit is contained in:
Bernard Xiong 2017-11-29 19:03:36 +08:00 committed by GitHub
commit e279772da2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 30 additions and 3 deletions

View File

@ -166,7 +166,11 @@ menu "Using USB"
bool "Enable to use device as winusb device"
default n
endif
if RT_USB_DEVICE_MSTORAGE
config RT_USB_MSTORAGE_DISK_NAME
string "msc class disk name"
default "flash0"
endif
if RT_USB_DEVICE_HID
config RT_USB_DEVICE_HID_KEYBOARD
bool "Use to HID device as Keyboard"

View File

@ -116,6 +116,17 @@ static struct usb_qualifier_descriptor dev_qualifier =
const static struct umass_descriptor _mass_desc =
{
#ifdef RT_USB_DEVICE_COMPOSITE
/* Interface Association Descriptor */
USB_DESC_LENGTH_IAD,
USB_DESC_TYPE_IAD,
USB_DYNAMIC,
0x01,
USB_CLASS_MASS_STORAGE,
0x06,
0x50,
0x00,
#endif
USB_DESC_LENGTH_INTERFACE, //bLength;
USB_DESC_TYPE_INTERFACE, //type;
USB_DYNAMIC, //bInterfaceNumber;
@ -1028,7 +1039,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)
{
#ifdef RT_USB_DEVICE_COMPOSITE
desc->iad_desc.bFirstInterface = cintf_nr;
#endif
return RT_EOK;
}
/**
* This function will create a mass storage function instance.
*
@ -1066,7 +1083,10 @@ ufunction_t rt_usbd_function_mstorage_create(udevice_t device)
setting = rt_usbd_altsetting_new(sizeof(struct umass_descriptor));
/* config desc in alternate setting */
rt_usbd_altsetting_config_descriptor(setting, &_mass_desc, 0);
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);
/* create a bulk out and a bulk in endpoint */
mass_desc = (umass_desc_t)setting->desc;

View File

@ -32,6 +32,9 @@
struct umass_descriptor
{
#ifdef RT_USB_DEVICE_COMPOSITE
struct uiad_descriptor iad_desc;
#endif
struct uinterface_descriptor intf_desc;
struct uendpoint_descriptor ep_out_desc;
struct uendpoint_descriptor ep_in_desc;