Most USB Composite device debug

git-svn-id: https://nuttx.svn.sourceforge.net/svnroot/nuttx/trunk@4344 7fd9a85b-ad96-42d3-883c-3090e2eb8679
This commit is contained in:
patacongo
2012-01-27 21:03:20 +00:00
parent f0d2b3cca3
commit 41d243ce3e
9 changed files with 107 additions and 20 deletions
+7 -3
View File
@@ -140,16 +140,19 @@
# define CDCACM_SERIALSTRID (3)
# define CDCACM_CONFIGSTRID (4)
# define CDCACM_LASTBASESTRID (4)
# undef CONFIG_CDCACM_STRBASE
# define CONFIG_CDCACM_STRBASE (4)
# define CONFIG_CDCACM_STRBASE (0)
#else
# define CDCACM_LASTBASESTRID CONFIG_CDCACM_STRBASE
#endif
/* These string IDs only exist if a user-defined string is provided */
#ifdef CONFIG_CDCACM_NOTIFSTR
# define CDCACM_NOTIFSTRID (CONFIG_CDCACM_STRBASE+1)
# define CDCACM_NOTIFSTRID (CDCACM_LASTBASESTRID+1)
#else
# define CDCACM_NOTIFSTRID CONFIG_CDCACM_STRBASE
# define CDCACM_NOTIFSTRID CDCACM_LASTBASESTRID
#endif
#ifdef CONFIG_CDCACM_DATAIFSTR
@@ -159,6 +162,7 @@
#endif
#define CDCACM_LASTSTRID CDCACM_DATAIFSTRID
#define CDCACM_NSTRIDS (CDCACM_LASTSTRID - CONFIG_CDCACM_STRBASE)
/* Configuration descriptor size */
+25 -6
View File
@@ -470,7 +470,8 @@ static int composite_setup(FAR struct usbdevclass_driver_s *driver,
case USB_DESC_TYPE_CONFIG:
{
#ifdef CONFIG_USBDEV_DUALSPEED
ret = composite_mkcfgdesc(ctrlreq->buf, dev->speed, ctrl->value[1]);
ret = composite_mkcfgdesc(ctrlreq->buf, dev->speed,
ctrl->value[1]);
#else
ret = composite_mkcfgdesc(ctrlreq->buf);
#endif
@@ -479,9 +480,23 @@ static int composite_setup(FAR struct usbdevclass_driver_s *driver,
case USB_DESC_TYPE_STRING:
{
/* index == language code. */
/* value == string index. Zero is the language ID. */
ret = composite_mkstrdesc(ctrl->value[0], (struct usb_strdesc_s *)ctrlreq->buf);
uint8_t strid = ctrl->value[0];
FAR struct usb_strdesc_s *buf = (FAR struct usb_strdesc_s *)ctrlreq->buf;
if (strid <= COMPOSITE_NSTRIDS)
{
ret = composite_mkstrdesc(strid, buf);
}
else if (strid < DEV1_STRIDBASE + DEV1_NSTRIDS)
{
ret = DEV1_MKSTRDESC(strid, buf);
}
else if (strid < DEV2_STRIDBASE + DEV2_NSTRIDS)
{
ret = DEV2_MKSTRDESC(strid, buf);
}
}
break;
@@ -530,7 +545,8 @@ static int composite_setup(FAR struct usbdevclass_driver_s *driver,
if (ctrl->type == USB_REQ_RECIPIENT_INTERFACE &&
priv->config == COMPOSITE_CONFIGID)
{
dispatched = (composite_classsetup(priv, dev, ctrl) >= 0);
ret = composite_classsetup(priv, dev, ctrl);
dispatched = true;
}
}
break;
@@ -540,7 +556,8 @@ static int composite_setup(FAR struct usbdevclass_driver_s *driver,
if (ctrl->type == (USB_DIR_IN|USB_REQ_RECIPIENT_INTERFACE) &&
priv->config == COMPOSITE_CONFIGIDNONE)
{
dispatched = (composite_classsetup(priv, dev, ctrl) >= 0);
ret = composite_classsetup(priv, dev, ctrl);
dispatched = true;
}
}
break;
@@ -565,7 +582,8 @@ static int composite_setup(FAR struct usbdevclass_driver_s *driver,
recipient = ctrl->type & USB_REQ_RECIPIENT_MASK;
if (recipient == USB_REQ_RECIPIENT_INTERFACE || recipient == USB_REQ_RECIPIENT_ENDPOINT)
{
dispatched = (composite_classsetup(priv, dev, ctrl) >= 0);
ret = composite_classsetup(priv, dev, ctrl);
dispatched = true;
}
}
@@ -592,6 +610,7 @@ static int composite_setup(FAR struct usbdevclass_driver_s *driver,
composite_ep0incomplete(dev->ep0, ctrlreq);
}
}
return ret;
}
+23 -8
View File
@@ -118,26 +118,28 @@
#if defined(CONFIG_CDCACM_COMPOSITE)
# define DEV1_IS_CDCACM 1
# define DEV1_MKCFGDESC cdcacm_mkcfgdesc
# define DEV1_MKSTRDESC cdcacm_mkstrdesc
# define DEV1_CLASSOBJECT board_cdcclassobject
# define DEV1_UNINITIALIZE board_cdcuninitialize
# define DEV1_NCONFIGS CDCACM_NCONFIGS
# define DEV1_CONFIGID CDCACM_CONFIGID
# define DEV1_FIRSTINTERFACE CONFIG_CDCACM_IFNOBASE
# define DEV1_NINTERFACES CDCACM_NINTERFACES
# define DEV1_FIRSTSTRID CONFIG_CDCACM_STRBASE
# define DEV1_NSTRIDS (CDCACM_LASTSTRID-CONFIG_CDCACM_STRBASE)
# define DEV1_STRIDBASE CONFIG_CDCACM_STRBASE
# define DEV1_NSTRIDS CDCACM_NSTRIDS
# define DEV1_CFGDESCSIZE SIZEOF_CDCACM_CFGDESC
#elif defined(CONFIG_CDCACM_COMPOSITE)
# define DEV1_IS_USBMSC 1
# define DEV1_MKCFGDESC usbmsc_mkcfgdesc
# define DEV1_MKSTRDESC usbmsc_mkstrdesc
# define DEV1_CLASSOBJECT board_mscclassobject
# define DEV1_UNINITIALIZE board_mscuninitialize
# define DEV1_NCONFIGS USBMSC_NCONFIGS
# define DEV1_CONFIGID USBMSC_CONFIGID
# define DEV1_FIRSTINTERFACE CONFIG_USBMSC_IFNOBASE
# define DEV1_NINTERFACES USBMSC_NINTERFACES
# define DEV1_FIRSTSTRID CONFIG_USBMSC_IFNOBASE
# define DEV1_NSTRIDS (USBMSC_LASTSTRID-CONFIG_USBMSC_STRBASE)
# define DEV1_STRIDBASE CONFIG_USBMSC_IFNOBASE
# define DEV1_NSTRIDS USBMSC_NSTRIDS
# define DEV1_CFGDESCSIZE SIZEOF_USBMSC_CFGDESC
#else
# error "No members of the composite defined"
@@ -150,26 +152,28 @@
#if defined(CONFIG_CDCACM_COMPOSITE) && !defined(DEV1_IS_CDCACM)
# define DEV2_IS_CDCACM 1
# define DEV2_MKCFGDESC cdcacm_mkcfgdesc
# define DEV2_MKSTRDESC cdcacm_mkstrdesc
# define DEV2_CLASSOBJECT board_cdcclassobject
# define DEV2_UNINITIALIZE board_cdcuninitialize
# define DEV2_NCONFIGS CDCACM_NCONFIGS
# define DEV2_CONFIGID CDCACM_CONFIGID
# define DEV2_FIRSTINTERFACE CONFIG_CDCACM_IFNOBASE
# define DEV2_NINTERFACES CDCACM_NINTERFACES
# define DEV2_FIRSTSTRID CONFIG_CDCACM_STRBASE
# define DEV2_NSTRIDS (CDCACM_LASTSTRID-CONFIG_CDCACM_STRBASE)
# define DEV2_STRIDBASE CONFIG_CDCACM_STRBASE
# define DEV2_NSTRIDS CDCACM_NSTRIDS
# define DEV2_CFGDESCSIZE SIZEOF_CDCACM_CFGDESC
#elif defined(CONFIG_CDCACM_COMPOSITE) && !defined(DEV1_IS_USBMSC)
# define DEV2_IS_USBMSC 1
# define DEV2_MKCFGDESC usbmsc_mkcfgdesc
# define DEV2_MKSTRDESC usbmsc_mkstrdesc
# define DEV2_UNINITIALIZE board_mscuninitialize
# define DEV2_CLASSOBJECT board_mscclassobject
# define DEV2_NCONFIGS USBMSC_NCONFIGS
# define DEV2_CONFIGID USBMSC_CONFIGID
# define DEV2_FIRSTINTERFACE CONFIG_USBMSC_IFNOBASE
# define DEV2_NINTERFACES USBMSC_NINTERFACES
# define DEV2_FIRSTSTRID CONFIG_CDCACM_STRBASE
# define DEV2_NSTRIDS (USBMSC_LASTSTRID-CONFIG_USBMSC_STRBASE)
# define DEV2_STRIDBASE CONFIG_USBMSC_STRBASE
# define DEV2_NSTRIDS USBMSC_NSTRIDS
# define DEV2_CFGDESCSIZE SIZEOF_USBMSC_CFGDESC
#else
# error "Insufficient members of the composite defined"
@@ -232,6 +236,17 @@
#define COMPOSITE_PRODUCTSTRID (2)
#define COMPOSITE_SERIALSTRID (3)
#define COMPOSITE_CONFIGSTRID (4)
#define COMPOSITE_NSTRIDS (4)
/* Verify string configuration */
#if COMPOSITE_NSTRIDS != DEV1_STRIDBASE
# warning "The DEV1 string base should be COMPOSITE_NSTRIDS"
#endif
#if (DEV1_STRIDBASE + DEV1_NSTRIDS) != DEV2_STRIDBASE
# warning "String IDs are not contiguous"
#endif
/* Everpresent MIN/MAX macros ***********************************************/
+1 -1
View File
@@ -183,7 +183,7 @@ int composite_mkstrdesc(uint8_t id, struct usb_strdesc_s *strdesc)
return 4;
}
case COMPOSITE_MANUFACTURERSTRID:
case COMPOSITE_MANUFACTURERSTRID:
str = g_compvendorstr;
break;
+3 -1
View File
@@ -298,11 +298,13 @@
# define USBMSC_INTERFACESTRID USBMSC_CONFIGSTRID
# undef CONFIG_USBMSC_STRBASE
# define CONFIG_USBMSC_STRBASE (4)
# define CONFIG_USBMSC_STRBASE (0)
#else
# define USBMSC_INTERFACESTRID (CONFIG_USBMSC_STRBASE+1)
#endif
#define USBMSC_LASTSTRID USBMSC_INTERFACESTRID
#define USBMSC_NSTRIDS (USBMSC_LASTSTRID - CONFIG_USBMSC_STRBASE)
#define USBMSC_NCONFIGS (1) /* Number of configurations supported */