Updates from coding standard review of PRs 753 and 754

This commit is contained in:
Gregory Nutt
2018-11-09 07:44:22 -06:00
parent 2fad9b86d1
commit 071d69e082
6 changed files with 291 additions and 226 deletions
+94 -72
View File
@@ -1,7 +1,7 @@
/**************************************************************************** /****************************************************************************
* drivers/usbdev/composite.c * drivers/usbdev/composite.c
* *
* Copyright (C) 2012, 2016-2017 Gregory Nutt. All rights reserved. * Copyright (C) 2012, 2016-2018 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org> * Author: Gregory Nutt <gnutt@nuttx.org>
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@@ -79,7 +79,8 @@ struct composite_alloc_s
/**************************************************************************** /****************************************************************************
* Private Function Prototypes * Private Function Prototypes
****************************************************************************/ ****************************************************************************/
/* USB helps ****************************************************************/
/* USB helpers **************************************************************/
static void composite_ep0incomplete(FAR struct usbdev_ep_s *ep, static void composite_ep0incomplete(FAR struct usbdev_ep_s *ep,
FAR struct usbdev_req_s *req); FAR struct usbdev_req_s *req);
@@ -200,79 +201,94 @@ static int composite_classsetup(FAR struct composite_dev_s *priv,
* in each device's composite_devdesc_s. * in each device's composite_devdesc_s.
* *
****************************************************************************/ ****************************************************************************/
#ifdef CONFIG_COMPOSITE_MSFT_OS_DESCRIPTORS #ifdef CONFIG_COMPOSITE_MSFT_OS_DESCRIPTORS
static int composite_msftdescriptor(FAR struct composite_dev_s *priv, static int composite_msftdescriptor(FAR struct composite_dev_s *priv,
FAR struct usbdev_s *dev, FAR struct usbdev_s *dev,
FAR const struct usb_ctrlreq_s *ctrl, FAR struct usbdev_req_s *ctrl_rsp, FAR bool *dispatched) FAR const struct usb_ctrlreq_s *ctrl,
FAR struct usbdev_req_s *ctrl_rsp,
FAR bool *dispatched)
{ {
if (ctrl->index[0] == MSFTOSDESC_INDEX_FUNCTION) if (ctrl->index[0] == MSFTOSDESC_INDEX_FUNCTION)
{
/* Function descriptor is common to whole device */
int i;
FAR struct usb_msft_os_feature_desc_s *response = (FAR struct usb_msft_os_feature_desc_s*)ctrl_rsp->buf;
memset(response, 0, sizeof(*response));
for (i = 0; i < priv->ndevices; i++)
{
if (priv->device[i].compdesc.msft_compatible_id[0] != 0)
{
FAR struct usb_msft_os_function_desc_s *func = &response->function[response->count];
memset(func, 0, sizeof(*func));
func->firstif = priv->device[i].compdesc.devinfo.ifnobase;
func->nifs = priv->device[i].compdesc.devinfo.ninterfaces;
memcpy(func->compatible_id, priv->device[i].compdesc.msft_compatible_id, sizeof(func->compatible_id));
memcpy(func->sub_id, priv->device[i].compdesc.msft_sub_id, sizeof(func->sub_id));
response->count++;
}
}
if (response->count > 0)
{
size_t total_len = sizeof(struct usb_msft_os_feature_desc_s) + (response->count - 1) * sizeof(struct usb_msft_os_function_desc_s);
response->len[0] = (total_len >> 0) & 0xFF;
response->len[1] = (total_len >> 8) & 0xFF;
response->len[2] = (total_len >> 16) & 0xFF;
response->len[3] = (total_len >> 24) & 0xFF;
response->version[1] = 0x01;
response->index[0] = MSFTOSDESC_INDEX_FUNCTION;
return total_len;
}
else
{
return 0;
}
}
else if (ctrl->index[0] == MSFTOSDESC_INDEX_EXTPROP || ctrl->index[0] == ctrl->value[0])
{
/* Extended properties are per-interface, pass the request to subdevice.
* NOTE: The documentation in OS_Desc_Ext_Prop.docx seems a bit incorrect here,
* the interface is in ctrl->value low byte.
* Also WinUSB driver has limitation that index[0] will not be correct if
* trying to read descriptors using e.g. libusb xusb.exe.
*/
int i;
int ret = -ENOTSUP;
uint8_t interface = ctrl->value[0];
for (i = 0; i < priv->ndevices; i++)
{ {
if (interface >= priv->device[i].compdesc.devinfo.ifnobase && /* Function descriptor is common to whole device */
interface < (priv->device[i].compdesc.devinfo.ifnobase +
priv->device[i].compdesc.devinfo.ninterfaces)) FAR struct usb_msft_os_feature_desc_s *response =
(FAR struct usb_msft_os_feature_desc_s *)ctrl_rsp->buf;
int i;
memset(response, 0, sizeof(*response));
for (i = 0; i < priv->ndevices; i++)
{ {
ret = CLASS_SETUP(priv->device[i].dev, dev, ctrl, NULL, 0); if (priv->device[i].compdesc.msft_compatible_id[0] != 0)
*dispatched = true; {
break; FAR struct usb_msft_os_function_desc_s *func =
&response->function[response->count];
memset(func, 0, sizeof(*func));
func->firstif = priv->device[i].compdesc.devinfo.ifnobase;
func->nifs = priv->device[i].compdesc.devinfo.ninterfaces;
memcpy(func->compatible_id, priv->device[i].compdesc.msft_compatible_id,
sizeof(func->compatible_id));
memcpy(func->sub_id, priv->device[i].compdesc.msft_sub_id,
sizeof(func->sub_id));
response->count++;
}
}
if (response->count > 0)
{
size_t total_len = sizeof(struct usb_msft_os_feature_desc_s) +
(response->count - 1) *
sizeof(struct usb_msft_os_function_desc_s);
response->len[0] = (total_len >> 0) & 0xFF;
response->len[1] = (total_len >> 8) & 0xFF;
response->len[2] = (total_len >> 16) & 0xFF;
response->len[3] = (total_len >> 24) & 0xFF;
response->version[1] = 0x01;
response->index[0] = MSFTOSDESC_INDEX_FUNCTION;
return total_len;
}
else
{
return 0;
} }
} }
else if (ctrl->index[0] == MSFTOSDESC_INDEX_EXTPROP ||
return ret; ctrl->index[0] == ctrl->value[0])
} {
/* Extended properties are per-interface, pass the request to
* subdevice. NOTE: The documentation in OS_Desc_Ext_Prop.docx seems
* a bit incorrect here, the interface is in ctrl->value low byte.
* Also WinUSB driver has limitation that index[0] will not be correct if
* trying to read descriptors using e.g. libusb xusb.exe.
*/
uint8_t interface = ctrl->value[0];
int ret = -ENOTSUP;
int i;
for (i = 0; i < priv->ndevices; i++)
{
if (interface >= priv->device[i].compdesc.devinfo.ifnobase &&
interface < (priv->device[i].compdesc.devinfo.ifnobase +
priv->device[i].compdesc.devinfo.ninterfaces))
{
ret = CLASS_SETUP(priv->device[i].dev, dev, ctrl, NULL, 0);
*dispatched = true;
break;
}
}
return ret;
}
else else
{ {
return -ENOTSUP; return -ENOTSUP;
} }
} }
#endif #endif
@@ -577,11 +593,16 @@ static int composite_setup(FAR struct usbdevclass_driver_s *driver,
#ifdef CONFIG_COMPOSITE_MSFT_OS_DESCRIPTORS #ifdef CONFIG_COMPOSITE_MSFT_OS_DESCRIPTORS
else if (strid == USB_REQ_GETMSFTOSDESCRIPTOR) else if (strid == USB_REQ_GETMSFTOSDESCRIPTOR)
{ {
/* Note: Windows has a habit of caching this response, so if you want to enable/disable /* Note: Windows has a habit of caching this response,
* it you'll usually need to change the device serial number afterwards. */ * so if you want to enable/disable it you'll usually
static const uint8_t msft_response[16] = { * need to change the device serial number afterwards.
'M',0,'S',0,'F',0,'T',0,'1',0,'0',0,'0',0,0xEE,0 */
static const uint8_t msft_response[16] =
{
'M', 0, 'S', 0, 'F', 0, 'T', 0, '1', 0, '0', 0, '0', 0, 0xEE, 0
}; };
buf->len = 18; buf->len = 18;
buf->type = USB_DESC_TYPE_STRING; buf->type = USB_DESC_TYPE_STRING;
memcpy(buf->data, msft_response, 16); memcpy(buf->data, msft_response, 16);
@@ -598,7 +619,8 @@ static int composite_setup(FAR struct usbdevclass_driver_s *driver,
strid < priv->device[i].compdesc.devinfo.strbase + strid < priv->device[i].compdesc.devinfo.strbase +
priv->device[i].compdesc.devinfo.nstrings) priv->device[i].compdesc.devinfo.nstrings)
{ {
ret = priv->device[i].compdesc.mkstrdesc(strid - priv->device[i].compdesc.devinfo.strbase, buf); ret = priv->device[i].compdesc.mkstrdesc(strid -
priv->device[i].compdesc.devinfo.strbase, buf);
break; break;
} }
} }
+137 -122
View File
@@ -37,10 +37,10 @@
* Currently it supports the app-side ("Run-Time") part of the protocol: * Currently it supports the app-side ("Run-Time") part of the protocol:
* a sequence of DFU_DETACH and USB reset commands, which will reboot into * a sequence of DFU_DETACH and USB reset commands, which will reboot into
* a separate USB DFU bootloader. * a separate USB DFU bootloader.
* *
* The bootloader is provided by board-specific logic, or STM32's * The bootloader is provided by board-specific logic, or STM32's
* built-in ROM bootloader can be used. * built-in ROM bootloader can be used.
* *
* https://www.usb.org/sites/default/files/DFU_1.1.pdf * https://www.usb.org/sites/default/files/DFU_1.1.pdf
*/ */
@@ -71,9 +71,9 @@
#define USB_REQ_DFU_GETSTATUS 3 #define USB_REQ_DFU_GETSTATUS 3
#ifdef CONFIG_DFU_MSFT_OS_DESCRIPTORS #ifdef CONFIG_DFU_MSFT_OS_DESCRIPTORS
#define DFU_MAX_DESCRIPTOR_LEN 256 # define DFU_MAX_DESCRIPTOR_LEN 256
#else #else
#define DFU_MAX_DESCRIPTOR_LEN sizeof(struct dfu_cfgdesc_s) # define DFU_MAX_DESCRIPTOR_LEN sizeof(struct dfu_cfgdesc_s)
#endif #endif
/**************************************************************************** /****************************************************************************
@@ -81,6 +81,7 @@
****************************************************************************/ ****************************************************************************/
/* Response to DFU_GETSTATUS */ /* Response to DFU_GETSTATUS */
struct dfu_getstatus_response_s struct dfu_getstatus_response_s
{ {
uint8_t status; /* Status of latest command */ uint8_t status; /* Status of latest command */
@@ -90,6 +91,7 @@ struct dfu_getstatus_response_s
}; };
/* DFU functional descriptor */ /* DFU functional descriptor */
struct dfu_funcdesc_s struct dfu_funcdesc_s
{ {
uint8_t len; /* Descriptor length */ uint8_t len; /* Descriptor length */
@@ -101,6 +103,7 @@ struct dfu_funcdesc_s
}; };
/* USB configuration descriptor */ /* USB configuration descriptor */
struct dfu_cfgdesc_s struct dfu_cfgdesc_s
{ {
struct usb_ifdesc_s ifdesc; /* DFU interface descriptor */ struct usb_ifdesc_s ifdesc; /* DFU interface descriptor */
@@ -111,8 +114,8 @@ struct dfu_driver_s
{ {
struct usbdevclass_driver_s drvr; struct usbdevclass_driver_s drvr;
struct usbdev_devinfo_s devinfo; struct usbdev_devinfo_s devinfo;
FAR struct usbdev_req_s *ctrlreq; /* Pointer to preallocated control request */ FAR struct usbdev_req_s *ctrlreq; /* Pointer to preallocated control request */
struct work_s work_item; /* Work queue entry for activating bootloader */ struct work_s work_item; /* Work queue entry for activating bootloader */
}; };
/**************************************************************************** /****************************************************************************
@@ -151,23 +154,23 @@ const static struct usbdevclass_driverops_s g_dfu_driverops =
static const struct dfu_cfgdesc_s g_dfu_cfgdesc = static const struct dfu_cfgdesc_s g_dfu_cfgdesc =
{ {
{ {
.len = USB_SIZEOF_IFDESC, .len = USB_SIZEOF_IFDESC,
.type = USB_DESC_TYPE_INTERFACE, .type = USB_DESC_TYPE_INTERFACE,
.ifno = 0, .ifno = 0,
.alt = 0, .alt = 0,
.neps = 0, .neps = 0,
.classid = 0xFE, .classid = 0xFE,
.subclass = 0x01, .subclass = 0x01,
.protocol = 0x01, /* DFU runtime protocol */ .protocol = 0x01, /* DFU runtime protocol */
.iif = 0 .iif = 0
}, },
{ {
.len = sizeof(struct dfu_funcdesc_s), .len = sizeof(struct dfu_funcdesc_s),
.type = 0x21, .type = 0x21,
.attributes = 0x0B, .attributes = 0x0B,
.detach_timeout = { LSBYTE(DFU_MAX_TIMEOUT), MSBYTE(DFU_MAX_TIMEOUT) }, .detach_timeout = { LSBYTE(DFU_MAX_TIMEOUT), MSBYTE(DFU_MAX_TIMEOUT) },
.transfer_size = { LSBYTE(DFU_MAX_TRANSFER), MSBYTE(DFU_MAX_TRANSFER) }, .transfer_size = { LSBYTE(DFU_MAX_TRANSFER), MSBYTE(DFU_MAX_TRANSFER) },
.dfu_version = { LSBYTE(DFU_VERSION), MSBYTE(DFU_VERSION) } .dfu_version = { LSBYTE(DFU_VERSION), MSBYTE(DFU_VERSION) }
} }
}; };
@@ -234,24 +237,26 @@ static void usbclass_ep0incomplete(FAR struct usbdev_ep_s *ep,
static int16_t usbclass_mkcfgdesc(FAR uint8_t *buf, static int16_t usbclass_mkcfgdesc(FAR uint8_t *buf,
FAR struct usbdev_devinfo_s *devinfo) FAR struct usbdev_devinfo_s *devinfo)
{ {
FAR struct dfu_cfgdesc_s *dest = (FAR struct dfu_cfgdesc_s*)buf; FAR struct dfu_cfgdesc_s *dest = (FAR struct dfu_cfgdesc_s *)buf;
*dest = g_dfu_cfgdesc; *dest = g_dfu_cfgdesc;
dest->ifdesc.ifno += devinfo->ifnobase; dest->ifdesc.ifno += devinfo->ifnobase;
dest->ifdesc.iif = devinfo->strbase; dest->ifdesc.iif = devinfo->strbase;
return sizeof(g_dfu_cfgdesc); return sizeof(g_dfu_cfgdesc);
} }
static int convert_to_utf16(FAR uint8_t *dest, FAR const char *src) static int convert_to_utf16(FAR uint8_t *dest, FAR const char *src)
{ {
int bytes = 0; int bytes = 0;
while (*src) while (*src)
{ {
*dest++ = *src++; *dest++ = *src++;
*dest++ = 0x00; *dest++ = 0x00;
bytes += 2; bytes += 2;
} }
return bytes; return bytes;
} }
@@ -279,48 +284,51 @@ static int dfu_make_msft_extprop_desc(FAR uint8_t *buf)
{ {
FAR const char *propname = "DeviceInterfaceGUIDs"; FAR const char *propname = "DeviceInterfaceGUIDs";
FAR const char *propval = CONFIG_DFU_INTERFACE_GUID; FAR const char *propval = CONFIG_DFU_INTERFACE_GUID;
FAR struct usb_msft_os_extprop_hdr_s *hdr = (FAR struct usb_msft_os_extprop_hdr_s*)buf; FAR struct usb_msft_os_extprop_hdr_s *hdr =
(FAR struct usb_msft_os_extprop_hdr_s *)buf;
FAR uint8_t *payload = buf + sizeof(struct usb_msft_os_extprop_hdr_s); FAR uint8_t *payload = buf + sizeof(struct usb_msft_os_extprop_hdr_s);
int namelen, valuelen, proplen, totallen; int namelen;
int valuelen;
namelen = strlen(propname) * 2 + 2; int proplen;
int totallen;
namelen = strlen(propname) * 2 + 2;
valuelen = strlen(propval) * 2 + 4; valuelen = strlen(propval) * 2 + 4;
proplen = 14 + namelen + valuelen; proplen = 14 + namelen + valuelen;
totallen = sizeof(struct usb_msft_os_extprop_hdr_s) + proplen; totallen = sizeof(struct usb_msft_os_extprop_hdr_s) + proplen;
memset(buf, 0, totallen); memset(buf, 0, totallen);
hdr->len[0] = LSBYTE(totallen); hdr->len[0] = LSBYTE(totallen);
hdr->len[1] = MSBYTE(totallen); hdr->len[1] = MSBYTE(totallen);
hdr->version[1] = 0x01; hdr->version[1] = 0x01;
hdr->index[0] = MSFTOSDESC_INDEX_EXTPROP; hdr->index[0] = MSFTOSDESC_INDEX_EXTPROP;
hdr->count[0] = 1; hdr->count[0] = 1;
*payload++ = LSBYTE(proplen); // dwSize *payload++ = LSBYTE(proplen); /* dwSize */
*payload++ = MSBYTE(proplen); *payload++ = MSBYTE(proplen);
*payload++ = 0; *payload++ = 0;
*payload++ = 0; *payload++ = 0;
*payload++ = 7; // dwPropertyDataType = REG_MULTI_SZ *payload++ = 7; /* dwPropertyDataType = REG_MULTI_SZ */
*payload++ = 0; *payload++ = 0;
*payload++ = 0; *payload++ = 0;
*payload++ = 0; *payload++ = 0;
*payload++ = LSBYTE(namelen); // wPropertyNameLength *payload++ = LSBYTE(namelen); /* wPropertyNameLength */
*payload++ = MSBYTE(namelen); *payload++ = MSBYTE(namelen);
payload += convert_to_utf16(payload, propname); // bPropertyName payload += convert_to_utf16(payload, propname); /* bPropertyName */
*payload++ = 0; // Null terminator *payload++ = 0; /* Null terminator */
*payload++ = 0; *payload++ = 0;
*payload++= LSBYTE(valuelen); // dwPropertyDataLength *payload++ = LSBYTE(valuelen); /* dwPropertyDataLength */
*payload++= MSBYTE(valuelen); *payload++ = MSBYTE(valuelen);
*payload++ = 0; *payload++ = 0;
*payload++ = 0; *payload++ = 0;
payload += convert_to_utf16(payload, propval); payload += convert_to_utf16(payload, propval);
*payload++ = 0; // Null terminator for string *payload++ = 0; /* Null terminator for string */
*payload++ = 0; *payload++ = 0;
*payload++ = 0; // Null terminator for array *payload++ = 0; /* Null terminator for array */
*payload++ = 0; *payload++ = 0;
return totallen; return totallen;
} }
#endif #endif
static void dfu_workqueue_callback(void *arg) static void dfu_workqueue_callback(void *arg)
@@ -338,69 +346,76 @@ static int usbclass_setup(FAR struct usbdevclass_driver_s *driver,
uint16_t value; uint16_t value;
uint16_t len; uint16_t len;
int ret = -EOPNOTSUPP; int ret = -EOPNOTSUPP;
value = GETUINT16(ctrl->value); value = GETUINT16(ctrl->value);
len = GETUINT16(ctrl->len); len = GETUINT16(ctrl->len);
usbtrace(TRACE_CLASSSETUP, ctrl->req); usbtrace(TRACE_CLASSSETUP, ctrl->req);
uinfo("type=%02x req=%02x value=%04x len=%04x\n", uinfo("type=%02x req=%02x value=%04x len=%04x\n",
ctrl->type, ctrl->req, value, len); ctrl->type, ctrl->req, value, len);
if ((ctrl->type & USB_REQ_TYPE_MASK) == USB_REQ_TYPE_STANDARD) if ((ctrl->type & USB_REQ_TYPE_MASK) == USB_REQ_TYPE_STANDARD)
{
if (ctrl->req == USB_REQ_GETDESCRIPTOR)
{ {
if (ctrl->value[1] == USB_DESC_TYPE_CONFIG) if (ctrl->req == USB_REQ_GETDESCRIPTOR)
{ {
ret = usbclass_mkcfgdesc(ctrlreq->buf, &priv->devinfo); if (ctrl->value[1] == USB_DESC_TYPE_CONFIG)
} {
else if (ctrl->value[1] == USB_DESC_TYPE_STRING) ret = usbclass_mkcfgdesc(ctrlreq->buf, &priv->devinfo);
{ }
ret = usbclass_mkstrdesc(ctrl->value[0], (struct usb_strdesc_s *)ctrlreq->buf); else if (ctrl->value[1] == USB_DESC_TYPE_STRING)
} {
ret = usbclass_mkstrdesc(ctrl->value[0],
(FAR struct usb_strdesc_s *)ctrlreq->buf);
}
}
else if (ctrl->req == USB_REQ_SETCONFIGURATION)
{
return 0; /* Composite driver will send the reply */
}
else if (ctrl->req == USB_REQ_SETINTERFACE)
{
/* Only one alternate setting (0) is supported */
if (value == 0)
{
ret = 0;
}
}
else if (ctrl->req == USB_REQ_GETINTERFACE)
{
*(FAR uint8_t *) ctrlreq->buf = 0;
ret = 1;
}
} }
else if (ctrl->req == USB_REQ_SETCONFIGURATION)
{
return 0; // Composite driver will send the reply
}
else if (ctrl->req == USB_REQ_SETINTERFACE)
{
// Only one alternate setting (0) is supported
if (value == 0)
{
ret = 0;
}
}
else if (ctrl->req == USB_REQ_GETINTERFACE)
{
*(FAR uint8_t *) ctrlreq->buf = 0;
ret = 1;
}
}
else if ((ctrl->type & USB_REQ_TYPE_MASK) == USB_REQ_TYPE_CLASS) else if ((ctrl->type & USB_REQ_TYPE_MASK) == USB_REQ_TYPE_CLASS)
{
if (ctrl->req == USB_REQ_DFU_DETACH)
{ {
// Execute the bootloader activation through work queue, so that we can send if (ctrl->req == USB_REQ_DFU_DETACH)
// the USB reply packet first. {
work_queue(HPWORK, &priv->work_item, dfu_workqueue_callback, NULL, 1); /* Execute the bootloader activation through work queue, so that
ret = 0; * we can send the USB reply packet first.
*/
work_queue(HPWORK, &priv->work_item, dfu_workqueue_callback, NULL, 1);
ret = 0;
}
else if (ctrl->req == USB_REQ_DFU_GETSTATUS)
{
/* Respond with APP_IDLE status */
FAR struct dfu_getstatus_response_s *response =
(FAR struct dfu_getstatus_response_s *)ctrlreq->buf;
memset(response, 0, sizeof(struct dfu_getstatus_response_s));
ret = sizeof(struct dfu_getstatus_response_s);
}
} }
else if (ctrl->req == USB_REQ_DFU_GETSTATUS)
{
/* Respond with APP_IDLE status */
FAR struct dfu_getstatus_response_s *response = (FAR struct dfu_getstatus_response_s*)ctrlreq->buf;
memset(response, 0, sizeof(struct dfu_getstatus_response_s));
ret = sizeof(struct dfu_getstatus_response_s);
}
}
#ifdef CONFIG_DFU_MSFT_OS_DESCRIPTORS #ifdef CONFIG_DFU_MSFT_OS_DESCRIPTORS
else if (ctrl->req == USB_REQ_GETMSFTOSDESCRIPTOR) else if (ctrl->req == USB_REQ_GETMSFTOSDESCRIPTOR)
{ {
ret = dfu_make_msft_extprop_desc(ctrlreq->buf); ret = dfu_make_msft_extprop_desc(ctrlreq->buf);
} }
#endif #endif
/* Respond to the setup command if data was returned. On an error return /* Respond to the setup command if data was returned. On an error return
* value (ret < 0), the USB driver will stall. * value (ret < 0), the USB driver will stall.
*/ */
@@ -424,15 +439,16 @@ static int usbclass_bind(FAR struct usbdevclass_driver_s *driver,
FAR struct usbdev_s *dev) FAR struct usbdev_s *dev)
{ {
FAR struct dfu_driver_s *priv = (FAR struct dfu_driver_s *)driver; FAR struct dfu_driver_s *priv = (FAR struct dfu_driver_s *)driver;
priv->ctrlreq = usbclass_allocreq(dev->ep0, DFU_MAX_DESCRIPTOR_LEN); priv->ctrlreq = usbclass_allocreq(dev->ep0, DFU_MAX_DESCRIPTOR_LEN);
if (priv->ctrlreq == NULL) if (priv->ctrlreq == NULL)
{ {
usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_ALLOCCTRLREQ), 0); usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_ALLOCCTRLREQ), 0);
return -ENOMEM; return -ENOMEM;
} }
priv->ctrlreq->callback = usbclass_ep0incomplete; priv->ctrlreq->callback = usbclass_ep0incomplete;
return OK; return OK;
} }
@@ -440,18 +456,17 @@ static void usbclass_unbind(FAR struct usbdevclass_driver_s *driver,
FAR struct usbdev_s *dev) FAR struct usbdev_s *dev)
{ {
FAR struct dfu_driver_s *priv = (FAR struct dfu_driver_s *)driver; FAR struct dfu_driver_s *priv = (FAR struct dfu_driver_s *)driver;
if (priv->ctrlreq != NULL) if (priv->ctrlreq != NULL)
{ {
usbclass_freereq(dev->ep0, priv->ctrlreq); usbclass_freereq(dev->ep0, priv->ctrlreq);
priv->ctrlreq = NULL; priv->ctrlreq = NULL;
} }
} }
static void usbclass_disconnect(FAR struct usbdevclass_driver_s *driver, static void usbclass_disconnect(FAR struct usbdevclass_driver_s *driver,
FAR struct usbdev_s *dev) FAR struct usbdev_s *dev)
{ {
} }
/**************************************************************************** /****************************************************************************
@@ -464,23 +479,24 @@ static void usbclass_disconnect(FAR struct usbdevclass_driver_s *driver,
* 0 on success, negative error code on failure. * 0 on success, negative error code on failure.
* *
****************************************************************************/ ****************************************************************************/
static int usbclass_classobject(int minor, static int usbclass_classobject(int minor,
FAR struct usbdev_devinfo_s *devinfo, FAR struct usbdev_devinfo_s *devinfo,
FAR struct usbdevclass_driver_s **classdev) FAR struct usbdevclass_driver_s **classdev)
{ {
FAR struct dfu_driver_s *alloc; FAR struct dfu_driver_s *alloc;
alloc = kmm_zalloc(sizeof(struct dfu_driver_s)); alloc = kmm_zalloc(sizeof(struct dfu_driver_s));
if (!alloc) if (alloc == NULL)
{ {
return -ENOMEM; return -ENOMEM;
} }
*classdev = &alloc->drvr; *classdev = &alloc->drvr;
alloc->drvr.speed = USB_SPEED_FULL; alloc->drvr.speed = USB_SPEED_FULL;
alloc->drvr.ops = &g_dfu_driverops; alloc->drvr.ops = &g_dfu_driverops;
return OK; return OK;
} }
@@ -494,6 +510,7 @@ static int usbclass_classobject(int minor,
* 0 on success, negative error code on failure. * 0 on success, negative error code on failure.
* *
****************************************************************************/ ****************************************************************************/
static void usbclass_uninitialize(FAR struct usbdevclass_driver_s *classdev) static void usbclass_uninitialize(FAR struct usbdevclass_driver_s *classdev)
{ {
kmm_free(classdev); kmm_free(classdev);
@@ -507,13 +524,13 @@ void usbdev_dfu_get_composite_devdesc(struct composite_devdesc_s *dev)
{ {
memset(dev, 0, sizeof(struct composite_devdesc_s)); memset(dev, 0, sizeof(struct composite_devdesc_s));
dev->mkconfdesc = usbclass_mkcfgdesc; dev->mkconfdesc = usbclass_mkcfgdesc;
dev->mkstrdesc = usbclass_mkstrdesc; dev->mkstrdesc = usbclass_mkstrdesc;
dev->classobject = usbclass_classobject; dev->classobject = usbclass_classobject;
dev->uninitialize = usbclass_uninitialize; dev->uninitialize = usbclass_uninitialize;
dev->nconfigs = 1; dev->nconfigs = 1;
dev->configid = 0; dev->configid = 0;
dev->cfgdescsize = sizeof(g_dfu_cfgdesc); dev->cfgdescsize = sizeof(g_dfu_cfgdesc);
dev->devinfo.ninterfaces = 1; dev->devinfo.ninterfaces = 1;
dev->devinfo.nstrings = 1; dev->devinfo.nstrings = 1;
dev->devinfo.nendpoints = 0; dev->devinfo.nendpoints = 0;
@@ -522,5 +539,3 @@ void usbdev_dfu_get_composite_devdesc(struct composite_devdesc_s *dev)
memcpy(dev->msft_compatible_id, "WINUSB", 6); memcpy(dev->msft_compatible_id, "WINUSB", 6);
#endif #endif
} }
+42 -29
View File
@@ -1,7 +1,7 @@
/**************************************************************************** /****************************************************************************
* drivers/usbdev/rndis.c * drivers/usbdev/rndis.c
* *
* Copyright (C) 2011-2017 Gregory Nutt. All rights reserved. * Copyright (C) 2011-2018 Gregory Nutt. All rights reserved.
* Authors: Sakari Kapanen <sakari.m.kapanen@gmail.com>, * Authors: Sakari Kapanen <sakari.m.kapanen@gmail.com>,
* Petteri Aimonen <jpa@git.mail.kapsi.fi> * Petteri Aimonen <jpa@git.mail.kapsi.fi>
* *
@@ -72,7 +72,8 @@
#define CONFIG_RNDIS_NWRREQS (2) #define CONFIG_RNDIS_NWRREQS (2)
#define RNDIS_PACKET_HDR_SIZE (sizeof(struct rndis_packet_msg)) #define RNDIS_PACKET_HDR_SIZE (sizeof(struct rndis_packet_msg))
#define CONFIG_RNDIS_BULKIN_REQLEN (CONFIG_NET_ETH_PKTSIZE + CONFIG_NET_GUARDSIZE + RNDIS_PACKET_HDR_SIZE) #define CONFIG_RNDIS_BULKIN_REQLEN \
(CONFIG_NET_ETH_PKTSIZE + CONFIG_NET_GUARDSIZE + RNDIS_PACKET_HDR_SIZE)
#define CONFIG_RNDIS_BULKOUT_REQLEN CONFIG_RNDIS_BULKIN_REQLEN #define CONFIG_RNDIS_BULKOUT_REQLEN CONFIG_RNDIS_BULKIN_REQLEN
#define RNDIS_NCONFIGS (1) #define RNDIS_NCONFIGS (1)
@@ -1849,7 +1850,7 @@ static int usbclass_mkstrdesc(uint8_t id, FAR struct usb_strdesc_s *strdesc)
static int16_t usbclass_mkcfgdesc(FAR uint8_t *buf, static int16_t usbclass_mkcfgdesc(FAR uint8_t *buf,
FAR struct usbdev_devinfo_s *devinfo) FAR struct usbdev_devinfo_s *devinfo)
{ {
FAR struct rndis_cfgdesc_s *dest = (FAR struct rndis_cfgdesc_s*)buf; FAR struct rndis_cfgdesc_s *dest = (FAR struct rndis_cfgdesc_s *)buf;
uint16_t totallen; uint16_t totallen;
/* This is the total length of the configuration (not necessarily the /* This is the total length of the configuration (not necessarily the
@@ -1861,16 +1862,18 @@ static int16_t usbclass_mkcfgdesc(FAR uint8_t *buf,
#ifndef CONFIG_RNDIS_COMPOSITE #ifndef CONFIG_RNDIS_COMPOSITE
/* For a stand-alone device, just fill in the total length */ /* For a stand-alone device, just fill in the total length */
dest->cfgdesc.totallen[0] = LSBYTE(totallen); dest->cfgdesc.totallen[0] = LSBYTE(totallen);
dest->cfgdesc.totallen[1] = MSBYTE(totallen); dest->cfgdesc.totallen[1] = MSBYTE(totallen);
#else #else
/* For composite device, apply possible offset to the interface numbers */ /* For composite device, apply possible offset to the interface numbers */
dest->assoc_desc.firstif += devinfo->ifnobase; dest->assoc_desc.firstif += devinfo->ifnobase;
dest->comm_ifdesc.ifno += devinfo->ifnobase; dest->comm_ifdesc.ifno += devinfo->ifnobase;
dest->epintindesc.addr = USB_EPIN(devinfo->epno[RNDIS_EP_INTIN_IDX]); dest->epintindesc.addr = USB_EPIN(devinfo->epno[RNDIS_EP_INTIN_IDX]);
dest->data_ifdesc.ifno += devinfo->ifnobase; dest->data_ifdesc.ifno += devinfo->ifnobase;
dest->epbulkindesc.addr = USB_EPIN(devinfo->epno[RNDIS_EP_BULKIN_IDX]); dest->epbulkindesc.addr = USB_EPIN(devinfo->epno[RNDIS_EP_BULKIN_IDX]);
dest->epbulkoutdesc.addr = USB_EPOUT(devinfo->epno[RNDIS_EP_BULKOUT_IDX]); dest->epbulkoutdesc.addr = USB_EPOUT(devinfo->epno[RNDIS_EP_BULKOUT_IDX]);
#endif #endif
return totallen; return totallen;
@@ -1929,7 +1932,8 @@ static int usbclass_bind(FAR struct usbdevclass_driver_s *driver,
/* Pre-allocate the IN interrupt endpoint */ /* Pre-allocate the IN interrupt endpoint */
priv->epintin = DEV_ALLOCEP(dev, USB_EPIN(priv->devinfo.epno[RNDIS_EP_INTIN_IDX]), true, USB_EP_ATTR_XFER_INT); priv->epintin = DEV_ALLOCEP(dev, USB_EPIN(priv->devinfo.epno[RNDIS_EP_INTIN_IDX]),
true, USB_EP_ATTR_XFER_INT);
if (!priv->epintin) if (!priv->epintin)
{ {
usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_EPINTINALLOCFAIL), 0); usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_EPINTINALLOCFAIL), 0);
@@ -1951,7 +1955,8 @@ static int usbclass_bind(FAR struct usbdevclass_driver_s *driver,
/* Pre-allocate the IN bulk endpoint */ /* Pre-allocate the IN bulk endpoint */
priv->epbulkin = DEV_ALLOCEP(dev, USB_EPIN(priv->devinfo.epno[RNDIS_EP_BULKIN_IDX]), true, USB_EP_ATTR_XFER_BULK); priv->epbulkin = DEV_ALLOCEP(dev, USB_EPIN(priv->devinfo.epno[RNDIS_EP_BULKIN_IDX]),
true, USB_EP_ATTR_XFER_BULK);
if (!priv->epbulkin) if (!priv->epbulkin)
{ {
usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_EPBULKINALLOCFAIL), 0); usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_EPBULKINALLOCFAIL), 0);
@@ -1963,7 +1968,8 @@ static int usbclass_bind(FAR struct usbdevclass_driver_s *driver,
/* Pre-allocate the OUT bulk endpoint */ /* Pre-allocate the OUT bulk endpoint */
priv->epbulkout = DEV_ALLOCEP(dev, USB_EPOUT(priv->devinfo.epno[RNDIS_EP_BULKOUT_IDX]), false, USB_EP_ATTR_XFER_BULK); priv->epbulkout = DEV_ALLOCEP(dev, USB_EPOUT(priv->devinfo.epno[RNDIS_EP_BULKOUT_IDX]),
false, USB_EP_ATTR_XFER_BULK);
if (!priv->epbulkout) if (!priv->epbulkout)
{ {
usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_EPBULKOUTALLOCFAIL), 0); usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_EPBULKOUTALLOCFAIL), 0);
@@ -2028,6 +2034,7 @@ static int usbclass_bind(FAR struct usbdevclass_driver_s *driver,
} }
/* Report if we are selfpowered */ /* Report if we are selfpowered */
#ifndef CONFIG_RNDIS_COMPOSITE #ifndef CONFIG_RNDIS_COMPOSITE
#ifdef CONFIG_USBDEV_SELFPOWERED #ifdef CONFIG_USBDEV_SELFPOWERED
DEV_SETSELFPOWERED(dev); DEV_SETSELFPOWERED(dev);
@@ -2250,7 +2257,8 @@ static int usbclass_setup(FAR struct usbdevclass_driver_s *driver,
{ {
/* index == language code. */ /* index == language code. */
ret = usbclass_mkstrdesc(ctrl->value[0], (struct usb_strdesc_s *)ctrlreq->buf); ret = usbclass_mkstrdesc(ctrl->value[0],
(FAR struct usb_strdesc_s *)ctrlreq->buf);
} }
break; break;
@@ -2525,10 +2533,10 @@ static int usbclass_setconfig(FAR struct rndis_dev_s *priv, uint8_t config)
priv->rdreq->callback = rndis_rdcomplete; priv->rdreq->callback = rndis_rdcomplete;
ret = rndis_submit_rdreq(priv); ret = rndis_submit_rdreq(priv);
if (ret != OK) if (ret != OK)
{ {
usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_RDSUBMIT), (uint16_t)-ret); usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_RDSUBMIT), (uint16_t)-ret);
goto errout; goto errout;
} }
/* We are successfully configured */ /* We are successfully configured */
@@ -2555,6 +2563,7 @@ errout:
* 0 on success, negative error code on failure. * 0 on success, negative error code on failure.
* *
****************************************************************************/ ****************************************************************************/
static int usbclass_classobject(int minor, static int usbclass_classobject(int minor,
FAR struct usbdev_devinfo_s *devinfo, FAR struct usbdev_devinfo_s *devinfo,
FAR struct usbdevclass_driver_s **classdev) FAR struct usbdevclass_driver_s **classdev)
@@ -2623,7 +2632,7 @@ static int usbclass_classobject(int minor,
static void usbclass_uninitialize(FAR struct usbdevclass_driver_s *classdev) static void usbclass_uninitialize(FAR struct usbdevclass_driver_s *classdev)
{ {
FAR struct rndis_driver_s *drvr = (FAR struct rndis_driver_s*)classdev; FAR struct rndis_driver_s *drvr = (FAR struct rndis_driver_s *)classdev;
FAR struct rndis_alloc_s *alloc = (FAR struct rndis_alloc_s *)drvr->dev; FAR struct rndis_alloc_s *alloc = (FAR struct rndis_alloc_s *)drvr->dev;
if (drvr->dev->registered) if (drvr->dev->registered)
@@ -2656,6 +2665,7 @@ static void usbclass_uninitialize(FAR struct usbdevclass_driver_s *classdev)
* 0 on success, -errno on failure * 0 on success, -errno on failure
* *
****************************************************************************/ ****************************************************************************/
#ifndef CONFIG_RNDIS_COMPOSITE #ifndef CONFIG_RNDIS_COMPOSITE
int usbdev_rndis_initialize(FAR const uint8_t *mac_address) int usbdev_rndis_initialize(FAR const uint8_t *mac_address)
{ {
@@ -2670,7 +2680,7 @@ int usbdev_rndis_initialize(FAR const uint8_t *mac_address)
return ret; return ret;
} }
drvr = (FAR struct rndis_driver_s*)classdev; drvr = (FAR struct rndis_driver_s *)classdev;
if (mac_address) if (mac_address)
{ {
@@ -2709,9 +2719,11 @@ int usbdev_rndis_initialize(FAR const uint8_t *mac_address)
* 0 on success, -errno on failure * 0 on success, -errno on failure
* *
****************************************************************************/ ****************************************************************************/
int usbdev_rndis_set_host_mac_addr(FAR struct net_driver_s *netdev, FAR const uint8_t *mac_address)
int usbdev_rndis_set_host_mac_addr(FAR struct net_driver_s *netdev,
FAR const uint8_t *mac_address)
{ {
FAR struct rndis_dev_s *dev = (FAR struct rndis_dev_s*)netdev; FAR struct rndis_dev_s *dev = (FAR struct rndis_dev_s *)netdev;
if (mac_address) if (mac_address)
{ {
@@ -2721,11 +2733,10 @@ int usbdev_rndis_set_host_mac_addr(FAR struct net_driver_s *netdev, FAR const ui
{ {
memcpy(dev->host_mac_address, g_rndis_default_mac_addr, 6); memcpy(dev->host_mac_address, g_rndis_default_mac_addr, 6);
} }
return OK; return OK;
} }
/**************************************************************************** /****************************************************************************
* Name: usbdev_rndis_get_composite_devdesc * Name: usbdev_rndis_get_composite_devdesc
* *
@@ -2746,20 +2757,22 @@ void usbdev_rndis_get_composite_devdesc(struct composite_devdesc_s *dev)
{ {
memset(dev, 0, sizeof(struct composite_devdesc_s)); memset(dev, 0, sizeof(struct composite_devdesc_s));
dev->mkconfdesc = usbclass_mkcfgdesc; dev->mkconfdesc = usbclass_mkcfgdesc;
dev->mkstrdesc = usbclass_mkstrdesc; dev->mkstrdesc = usbclass_mkstrdesc;
dev->classobject = usbclass_classobject; dev->classobject = usbclass_classobject;
dev->uninitialize = usbclass_uninitialize; dev->uninitialize = usbclass_uninitialize;
dev->nconfigs = RNDIS_NCONFIGS; dev->nconfigs = RNDIS_NCONFIGS;
dev->configid = RNDIS_CONFIGID; dev->configid = RNDIS_CONFIGID;
dev->cfgdescsize = sizeof(g_rndis_cfgdesc); dev->cfgdescsize = sizeof(g_rndis_cfgdesc);
dev->devinfo.ninterfaces = RNDIS_NINTERFACES; dev->devinfo.ninterfaces = RNDIS_NINTERFACES;
dev->devinfo.nstrings = 0; dev->devinfo.nstrings = 0;
dev->devinfo.nendpoints = RNDIS_NUM_EPS; dev->devinfo.nendpoints = RNDIS_NUM_EPS;
/* Default endpoint indexes, board-specific logic can override these */ /* Default endpoint indexes, board-specific logic can override these */
dev->devinfo.epno[RNDIS_EP_INTIN_IDX] = USB_EPNO(RNDIS_EPINTIN_ADDR); dev->devinfo.epno[RNDIS_EP_INTIN_IDX] = USB_EPNO(RNDIS_EPINTIN_ADDR);
dev->devinfo.epno[RNDIS_EP_BULKIN_IDX] = USB_EPNO(RNDIS_EPBULKIN_ADDR); dev->devinfo.epno[RNDIS_EP_BULKIN_IDX] = USB_EPNO(RNDIS_EPBULKIN_ADDR);
dev->devinfo.epno[RNDIS_EP_BULKOUT_IDX] = USB_EPNO(RNDIS_EPBULKOUT_ADDR); dev->devinfo.epno[RNDIS_EP_BULKOUT_IDX] = USB_EPNO(RNDIS_EPBULKOUT_ADDR);
} }
#endif #endif
+1
View File
@@ -91,3 +91,4 @@ void usbdev_dfu_activate_bootloader();
#endif #endif
#endif /* __INCLUDE_NUTTX_USB_DFU_H */ #endif /* __INCLUDE_NUTTX_USB_DFU_H */
+4 -2
View File
@@ -1,7 +1,7 @@
/************************************************************************************ /************************************************************************************
* include/nuttx/usb/rndis.h * include/nuttx/usb/rndis.h
* *
* Copyright (C) 2011-2017 Gregory Nutt. All rights reserved. * Copyright (C) 2011-2018 Gregory Nutt. All rights reserved.
* Authors: Sakari Kapanen <sakari.m.kapanen@gmail.com>, * Authors: Sakari Kapanen <sakari.m.kapanen@gmail.com>,
Petteri Aimonen <jpa@git.mail.kapsi.fi> Petteri Aimonen <jpa@git.mail.kapsi.fi>
* *
@@ -49,6 +49,7 @@
****************************************************************************/ ****************************************************************************/
/* Indexes for devinfo.epno[] array. Used for composite device configuration. */ /* Indexes for devinfo.epno[] array. Used for composite device configuration. */
#define RNDIS_EP_INTIN_IDX (0) #define RNDIS_EP_INTIN_IDX (0)
#define RNDIS_EP_BULKIN_IDX (1) #define RNDIS_EP_BULKIN_IDX (1)
#define RNDIS_EP_BULKOUT_IDX (2) #define RNDIS_EP_BULKOUT_IDX (2)
@@ -110,7 +111,8 @@ int usbdev_rndis_initialize(FAR const uint8_t *mac_address);
* *
****************************************************************************/ ****************************************************************************/
int usbdev_rndis_set_host_mac_addr(FAR struct net_driver_s *netdev, FAR const uint8_t *mac_address); int usbdev_rndis_set_host_mac_addr(FAR struct net_driver_s *netdev,
FAR const uint8_t *mac_address);
/**************************************************************************** /****************************************************************************
* Name: usbdev_rndis_get_composite_devdesc * Name: usbdev_rndis_get_composite_devdesc
+13 -1
View File
@@ -1,7 +1,7 @@
/************************************************************************************ /************************************************************************************
* include/nuttx/usb/usb.h * include/nuttx/usb/usb.h
* *
* Copyright (C) 2008, 2009-2010, 2012 Gregory Nutt. All rights reserved. * Copyright (C) 2008, 2009-2010, 2012, 2008 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org> * Author: Gregory Nutt <gnutt@nuttx.org>
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@@ -47,6 +47,7 @@
/************************************************************************************ /************************************************************************************
* Pre-processor Definitions * Pre-processor Definitions
************************************************************************************/ ************************************************************************************/
/* A packet identifier (PID) immediately follows the SYNC field of every USB packet. /* A packet identifier (PID) immediately follows the SYNC field of every USB packet.
* A PID consists of a four-bit packet type field followed by a four-bit check field * A PID consists of a four-bit packet type field followed by a four-bit check field
* USB Tokens (See Table 8-1 in the USB specification) * USB Tokens (See Table 8-1 in the USB specification)
@@ -260,6 +261,7 @@
#define USB_MAX_DEVICES (127) #define USB_MAX_DEVICES (127)
/* Microsoft OS Descriptor specific values */ /* Microsoft OS Descriptor specific values */
#define USB_REQ_GETMSFTOSDESCRIPTOR (0xEE) #define USB_REQ_GETMSFTOSDESCRIPTOR (0xEE)
#define MSFTOSDESC_INDEX_FUNCTION 4 #define MSFTOSDESC_INDEX_FUNCTION 4
#define MSFTOSDESC_INDEX_EXTPROP 5 #define MSFTOSDESC_INDEX_EXTPROP 5
@@ -278,6 +280,7 @@ struct usb_ctrlreq_s
uint8_t index[2]; uint8_t index[2];
uint8_t len[2]; uint8_t len[2];
}; };
#define USB_SIZEOF_CTRLREQ 8 #define USB_SIZEOF_CTRLREQ 8
/* Generic descriptor */ /* Generic descriptor */
@@ -307,6 +310,7 @@ struct usb_devdesc_s
uint8_t serno; /* Serial number */ uint8_t serno; /* Serial number */
uint8_t nconfigs; /* Number of configurations */ uint8_t nconfigs; /* Number of configurations */
}; };
#define USB_SIZEOF_DEVDESC 18 #define USB_SIZEOF_DEVDESC 18
/* Configuration descriptor */ /* Configuration descriptor */
@@ -322,6 +326,7 @@ struct usb_cfgdesc_s
uint8_t attr; /* Attributes */ uint8_t attr; /* Attributes */
uint8_t mxpower; /* Max power (mA/2) */ uint8_t mxpower; /* Max power (mA/2) */
}; };
#define USB_SIZEOF_CFGDESC 9 #define USB_SIZEOF_CFGDESC 9
struct usb_otherspeedconfigdesc_s struct usb_otherspeedconfigdesc_s
@@ -335,6 +340,7 @@ struct usb_otherspeedconfigdesc_s
uint8_t attr; /* Attributes */ uint8_t attr; /* Attributes */
uint8_t mxpower; /* Max power (mA/2) */ uint8_t mxpower; /* Max power (mA/2) */
}; };
#define USB_SIZEOF_OTHERSPEEDCONFIGDESC 9 #define USB_SIZEOF_OTHERSPEEDCONFIGDESC 9
/* String descriptor */ /* String descriptor */
@@ -360,6 +366,7 @@ struct usb_ifdesc_s
uint8_t protocol; /* Interface protocol */ uint8_t protocol; /* Interface protocol */
uint8_t iif; /* iInterface */ uint8_t iif; /* iInterface */
}; };
#define USB_SIZEOF_IFDESC 9 #define USB_SIZEOF_IFDESC 9
/* Endpoint descriptor */ /* Endpoint descriptor */
@@ -373,6 +380,7 @@ struct usb_epdesc_s
uint8_t mxpacketsize[2]; /* Maximum packet size */ uint8_t mxpacketsize[2]; /* Maximum packet size */
uint8_t interval; /* Interval */ uint8_t interval; /* Interval */
}; };
#define USB_SIZEOF_EPDESC 7 #define USB_SIZEOF_EPDESC 7
struct usb_audioepdesc_s struct usb_audioepdesc_s
@@ -381,6 +389,7 @@ struct usb_audioepdesc_s
uint8_t refresh; uint8_t refresh;
uint8_t synchaddr; uint8_t synchaddr;
}; };
#define USB_SIZEOF_AUDIOEPDESC 9 #define USB_SIZEOF_AUDIOEPDESC 9
/* Device qualifier descriptor */ /* Device qualifier descriptor */
@@ -397,6 +406,7 @@ struct usb_qualdesc_s
uint8_t nconfigs; /* Number of configurations */ uint8_t nconfigs; /* Number of configurations */
uint8_t reserved; uint8_t reserved;
}; };
#define USB_SIZEOF_QUALDESC 10 #define USB_SIZEOF_QUALDESC 10
/* Interface association descriptor /* Interface association descriptor
@@ -420,6 +430,7 @@ struct usb_iaddesc_s
uint8_t protocol; /* Protocol code */ uint8_t protocol; /* Protocol code */
uint8_t ifunction; /* Index to string identifying the function */ uint8_t ifunction; /* Index to string identifying the function */
}; };
#define USB_SIZEOF_IADDESC 8 #define USB_SIZEOF_IADDESC 8
/* Microsoft OS function descriptor. /* Microsoft OS function descriptor.
@@ -460,6 +471,7 @@ struct usb_msft_os_feature_desc_s
* The interface will have one extended properties descriptor, which may contain * The interface will have one extended properties descriptor, which may contain
* multiple properties inside it. * multiple properties inside it.
*/ */
struct usb_msft_os_extprop_hdr_s struct usb_msft_os_extprop_hdr_s
{ {
uint8_t len[4]; /* Descriptor length */ uint8_t len[4]; /* Descriptor length */