mirror of
https://github.com/apache/nuttx.git
synced 2026-06-04 23:03:27 +08:00
First round of changes from debug of USB composite device (still has problems)
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@4342 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
@@ -2397,3 +2397,9 @@
|
|||||||
* drivers/usbdev/: Lots of name changes: cdc_serial->cdcacm, usbstrg->usbmsc,
|
* drivers/usbdev/: Lots of name changes: cdc_serial->cdcacm, usbstrg->usbmsc,
|
||||||
usbser->pl2303
|
usbser->pl2303
|
||||||
* drivers/usbdev/composite*: Fleshed out support for a composite USB device.
|
* drivers/usbdev/composite*: Fleshed out support for a composite USB device.
|
||||||
|
* drivers/stm3210e-eval/composite and drivers/stm3210e-eval/src/up_composite.c:
|
||||||
|
Add a configuration test the USB composite device.
|
||||||
|
* include/nuttx/usb/usb.h, drivers/usbdev/composite_descriptors.c, and
|
||||||
|
drivers/usbdev/cdcacm_descriptors.c: Add support for the USB Interface
|
||||||
|
Association Descriptor (IAD)
|
||||||
|
|
||||||
|
|||||||
@@ -5054,10 +5054,17 @@ build
|
|||||||
(only if CONFIG_USBDEV_COMPOSITE is also defined)
|
(only if CONFIG_USBDEV_COMPOSITE is also defined)
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<code>CONFIG_COMPOSITE_COMPOSITE</code>:
|
<code>CONFIG_UBMSC_COMPOSITE</code>:
|
||||||
Configure the mass storage driver as part of a composite driver
|
Configure the mass storage driver as part of a composite driver
|
||||||
(only if CONFIG_USBDEV_COMPOSITE is also defined)
|
(only if CONFIG_USBDEV_COMPOSITE is also defined)
|
||||||
</li>
|
</li>
|
||||||
|
<li>
|
||||||
|
<code>CONFIG_COMPOSITE_IAD</code>:
|
||||||
|
If one of the members of the composite has multiple interfaces
|
||||||
|
(such as CDC/ACM), then an Interface Association Descriptor (IAD)
|
||||||
|
will be necessary. Default: IAD will be used automatically if
|
||||||
|
needed. It should not be necessary to set this.
|
||||||
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<code>CONFIG_COMPOSITE_EP0MAXPACKET</code>:
|
<code>CONFIG_COMPOSITE_EP0MAXPACKET</code>:
|
||||||
Max packet size for endpoint 0
|
Max packet size for endpoint 0
|
||||||
|
|||||||
+6
-1
@@ -1093,9 +1093,14 @@ defconfig -- This is a configuration file similar to the Linux
|
|||||||
CONFIG_CDCACM_COMPOSITE
|
CONFIG_CDCACM_COMPOSITE
|
||||||
Configure the CDC serial driver as part of a composite driver
|
Configure the CDC serial driver as part of a composite driver
|
||||||
(only if CONFIG_USBDEV_COMPOSITE is also defined)
|
(only if CONFIG_USBDEV_COMPOSITE is also defined)
|
||||||
CONFIG_COMPOSITE_COMPOSITE
|
CONFIG_USBMSC_COMPOSITE
|
||||||
Configure the mass storage driver as part of a composite driver
|
Configure the mass storage driver as part of a composite driver
|
||||||
(only if CONFIG_USBDEV_COMPOSITE is also defined)
|
(only if CONFIG_USBDEV_COMPOSITE is also defined)
|
||||||
|
CONFIG_COMPOSITE_IAD
|
||||||
|
If one of the members of the composite has multiple interfaces
|
||||||
|
(such as CDC/ACM), then an Interface Association Descriptor (IAD)
|
||||||
|
will be necessary. Default: IAD will be used automatically if
|
||||||
|
needed. It should not be necessary to set this.
|
||||||
CONFIG_COMPOSITE_EP0MAXPACKET
|
CONFIG_COMPOSITE_EP0MAXPACKET
|
||||||
Max packet size for endpoint 0
|
Max packet size for endpoint 0
|
||||||
CONFIG_COMPOSITE_VENDORID and CONFIG_COMPOSITE_VENDORSTR
|
CONFIG_COMPOSITE_VENDORID and CONFIG_COMPOSITE_VENDORSTR
|
||||||
|
|||||||
@@ -271,11 +271,11 @@ LEDs
|
|||||||
The STM3210E-EVAL board has four LEDs labeled LD1, LD2, LD3 and LD4 on the
|
The STM3210E-EVAL board has four LEDs labeled LD1, LD2, LD3 and LD4 on the
|
||||||
board.. These LEDs are not used by the board port unless CONFIG_ARCH_LEDS is
|
board.. These LEDs are not used by the board port unless CONFIG_ARCH_LEDS is
|
||||||
defined. In that case, the usage by the board port is defined in
|
defined. In that case, the usage by the board port is defined in
|
||||||
include/board.h and src/up_leds.c. The LEDs are used to encode OS-related\
|
include/board.h and src/up_leds.c. The LEDs are used to encode OS-related
|
||||||
events as follows:
|
events as follows:
|
||||||
|
|
||||||
SYMBOL Meaning LED1* LED2 LED3 LED4
|
SYMBOL Meaning LED1* LED2 LED3 LED4
|
||||||
------------------- ----------------------- ------- ------- ------- ------
|
---------------- ----------------------- ----- ----- ----- -----
|
||||||
LED_STARTED NuttX has been started ON OFF OFF OFF
|
LED_STARTED NuttX has been started ON OFF OFF OFF
|
||||||
LED_HEAPALLOCATE Heap has been allocated OFF ON OFF OFF
|
LED_HEAPALLOCATE Heap has been allocated OFF ON OFF OFF
|
||||||
LED_IRQSENABLED Interrupts enabled ON ON OFF OFF
|
LED_IRQSENABLED Interrupts enabled ON ON OFF OFF
|
||||||
@@ -630,6 +630,13 @@ Where <subdir> is one of the following:
|
|||||||
|
|
||||||
CONFIG_STM32_CODESOURCERYW=y : CodeSourcery under Windows
|
CONFIG_STM32_CODESOURCERYW=y : CodeSourcery under Windows
|
||||||
|
|
||||||
|
composite
|
||||||
|
---------
|
||||||
|
|
||||||
|
This configuration exercises a composite USB interface consisting
|
||||||
|
of a CDC/ACM device and a USB mass storage device. This configuration
|
||||||
|
uses apps/examples/composite.
|
||||||
|
|
||||||
nsh and nsh2:
|
nsh and nsh2:
|
||||||
------------
|
------------
|
||||||
Configure the NuttShell (nsh) located at examples/nsh.
|
Configure the NuttShell (nsh) located at examples/nsh.
|
||||||
|
|||||||
@@ -646,8 +646,6 @@ CONFIG_NET_RESOLV_ENTRIES=4
|
|||||||
#
|
#
|
||||||
# CONFIG_USBDEV
|
# CONFIG_USBDEV
|
||||||
# Enables USB device support
|
# Enables USB device support
|
||||||
# CONFIG_USBDEV_COMPOSITE
|
|
||||||
# Enables USB composite device support
|
|
||||||
# CONFIG_USBDEV_ISOCHRONOUS
|
# CONFIG_USBDEV_ISOCHRONOUS
|
||||||
# Build in extra support for isochronous endpoints
|
# Build in extra support for isochronous endpoints
|
||||||
# CONFIG_USBDEV_DUALSPEED
|
# CONFIG_USBDEV_DUALSPEED
|
||||||
@@ -663,7 +661,6 @@ CONFIG_NET_RESOLV_ENTRIES=4
|
|||||||
# Number of trace entries to remember
|
# Number of trace entries to remember
|
||||||
#
|
#
|
||||||
CONFIG_USBDEV=y
|
CONFIG_USBDEV=y
|
||||||
CONFIG_USBDEV_COMPOSITE=y
|
|
||||||
CONFIG_USBDEV_ISOCHRONOUS=n
|
CONFIG_USBDEV_ISOCHRONOUS=n
|
||||||
CONFIG_USBDEV_DUALSPEED=n
|
CONFIG_USBDEV_DUALSPEED=n
|
||||||
CONFIG_USBDEV_SELFPOWERED=y
|
CONFIG_USBDEV_SELFPOWERED=y
|
||||||
@@ -744,7 +741,7 @@ CONFIG_USBMSC=y
|
|||||||
CONFIG_USBMSC_COMPOSITE=y
|
CONFIG_USBMSC_COMPOSITE=y
|
||||||
CONFIG_USBMSC_IFNOBASE=2
|
CONFIG_USBMSC_IFNOBASE=2
|
||||||
CONFIG_USBMSC_EP0MAXPACKET=64
|
CONFIG_USBMSC_EP0MAXPACKET=64
|
||||||
CONFIG_USBMSC_EPBULKOUT=2
|
CONFIG_USBMSC_EPBULKOUT=4
|
||||||
CONFIG_USBMSC_EPBULKIN=5
|
CONFIG_USBMSC_EPBULKIN=5
|
||||||
CONFIG_USBMSC_NRDREQS=2
|
CONFIG_USBMSC_NRDREQS=2
|
||||||
CONFIG_USBMSC_NWRREQS=2
|
CONFIG_USBMSC_NWRREQS=2
|
||||||
@@ -818,13 +815,13 @@ CONFIG_CDCACM=y
|
|||||||
CONFIG_CDCACM_COMPOSITE=y
|
CONFIG_CDCACM_COMPOSITE=y
|
||||||
CONFIG_CDCACM_IFNOBASE=0
|
CONFIG_CDCACM_IFNOBASE=0
|
||||||
#CONFIG_CDCACM_EP0MAXPACKET
|
#CONFIG_CDCACM_EP0MAXPACKET
|
||||||
#CONFIG_CDCACM_EPINTIN
|
CONFIG_CDCACM_EPINTIN=1
|
||||||
#CONFIG_CDCACM_EPINTIN_FSSIZE
|
#CONFIG_CDCACM_EPINTIN_FSSIZE
|
||||||
#CONFIG_CDCACM_EPINTIN_HSSIZE
|
#CONFIG_CDCACM_EPINTIN_HSSIZE
|
||||||
#CONFIG_CDCACM_EPBULKOUT
|
CONFIG_CDCACM_EPBULKOUT=3
|
||||||
#CONFIG_CDCACM_EPBULKOUT_FSSIZE
|
#CONFIG_CDCACM_EPBULKOUT_FSSIZE
|
||||||
#CONFIG_CDCACM_EPBULKOUT_HSSIZE
|
#CONFIG_CDCACM_EPBULKOUT_HSSIZE
|
||||||
#CONFIG_CDCACM_EPBULKIN
|
CONFIG_CDCACM_EPBULKIN=2
|
||||||
#CONFIG_CDCACM_EPBULKIN_FSSIZE
|
#CONFIG_CDCACM_EPBULKIN_FSSIZE
|
||||||
#CONFIG_CDCACM_EPBULKIN_HSSIZE
|
#CONFIG_CDCACM_EPBULKIN_HSSIZE
|
||||||
#CONFIG_CDCACM_NWRREQS
|
#CONFIG_CDCACM_NWRREQS
|
||||||
@@ -836,6 +833,40 @@ CONFIG_CDCACM_IFNOBASE=0
|
|||||||
#CONFIG_CDCACM_RXBUFSIZE
|
#CONFIG_CDCACM_RXBUFSIZE
|
||||||
#CONFIG_CDCACM_TXBUFSIZE
|
#CONFIG_CDCACM_TXBUFSIZE
|
||||||
|
|
||||||
|
#
|
||||||
|
# USB Composite Device Configuration
|
||||||
|
#
|
||||||
|
# CONFIG_USBDEV_COMPOSITE
|
||||||
|
# Enables USB composite device support
|
||||||
|
# CONFIG_COMPOSITE_IAD
|
||||||
|
# If one of the members of the composite has multiple interfaces
|
||||||
|
# (such as CDC/ACM), then an Interface Association Descriptor (IAD)
|
||||||
|
# will be necessary. Default: IAD will be used automatically if
|
||||||
|
# needed. It should not be necessary to set this.
|
||||||
|
# CONFIG_COMPOSITE_EP0MAXPACKET
|
||||||
|
# Max packet size for endpoint 0
|
||||||
|
# CONFIG_COMPOSITE_VENDORID and CONFIG_COMPOSITE_VENDORSTR
|
||||||
|
# The vendor ID code/string
|
||||||
|
# CONFIG_COMPOSITE_PRODUCTID and CONFIG_COMPOSITE_PRODUCTSTR
|
||||||
|
# The product ID code/string
|
||||||
|
# CONFIG_COMPOSITE_SERIALSTR
|
||||||
|
# Device serial number string
|
||||||
|
# CONFIG_COMPOSITE_CONFIGSTR
|
||||||
|
# Configuration string
|
||||||
|
# CONFIG_COMPOSITE_VERSIONNO
|
||||||
|
# The device version number
|
||||||
|
#
|
||||||
|
CONFIG_USBDEV_COMPOSITE=y
|
||||||
|
CONFIG_COMPOSITE_IAD=y
|
||||||
|
#CONFIG_COMPOSITE_EP0MAXPACKET
|
||||||
|
CONFIG_COMPOSITE_VENDORID=0x03eb
|
||||||
|
CONFIG_COMPOSITE_PRODUCTID=0x2022
|
||||||
|
CONFIG_COMPOSITE_VENDORSTR="NuttX"
|
||||||
|
CONFIG_COMPOSITE_PRODUCTSTR="Composite Device"
|
||||||
|
CONFIG_COMPOSITE_SERIALSTR="12345"
|
||||||
|
CONFIG_COMPOSITE_CONFIGSTR="examples/composite"
|
||||||
|
CONFIG_COMPOSITE_VERSIONNO=0x0101
|
||||||
|
|
||||||
#
|
#
|
||||||
# Settings for examples/uip
|
# Settings for examples/uip
|
||||||
#
|
#
|
||||||
@@ -1015,12 +1046,6 @@ CONFIG_EXAMPLES_USBMSC_TRACEINTERRUPTS=n
|
|||||||
#
|
#
|
||||||
# CONFIG_EXAMPLES_COMPOSITE_DEBUGMM
|
# CONFIG_EXAMPLES_COMPOSITE_DEBUGMM
|
||||||
# Enables some debug tests to check for memory usage and memory leaks.
|
# Enables some debug tests to check for memory usage and memory leaks.
|
||||||
# CONFIG_COMPOSITE_VENDORID and CONFIG_COMPOSITE_PRODUCTID
|
|
||||||
# The vendor ID code/string
|
|
||||||
# CONFIG_USBMSC_PRODUCTID and CONFIG_USBMSC_PRODUCTSTR
|
|
||||||
# The product ID code/string
|
|
||||||
# CONFIG_COMPOSITE_VERSIONNO
|
|
||||||
# The device version number
|
|
||||||
#
|
#
|
||||||
# CONFIG_EXAMPLES_COMPOSITE_NLUNS
|
# CONFIG_EXAMPLES_COMPOSITE_NLUNS
|
||||||
# Defines the number of logical units (LUNs) exported by the USB storage
|
# Defines the number of logical units (LUNs) exported by the USB storage
|
||||||
@@ -1062,16 +1087,11 @@ CONFIG_EXAMPLES_USBMSC_TRACEINTERRUPTS=n
|
|||||||
# Show interrupt-related events.
|
# Show interrupt-related events.
|
||||||
#
|
#
|
||||||
CONFIG_EXAMPLES_COMPOSITE_DEBUGMM=n
|
CONFIG_EXAMPLES_COMPOSITE_DEBUGMM=n
|
||||||
CONFIG_COMPOSITE_VENDORID=0x03eb
|
|
||||||
CONFIG_COMPOSITE_PRODUCTID=0x2022
|
|
||||||
CONFIG_COMPOSITE_VENDORSTR="NuttX"
|
|
||||||
CONFIG_COMPOSITE_PRODUCTSTR="Composite Device"
|
|
||||||
CONFIG_COMPOSITE_VERSIONNO
|
|
||||||
CONFIG_EXAMPLES_COMPOSITE_NLUNS=1
|
CONFIG_EXAMPLES_COMPOSITE_NLUNS=1
|
||||||
CONFIG_EXAMPLES_COMPOSITE_DEVMINOR1=0
|
CONFIG_EXAMPLES_COMPOSITE_DEVMINOR1=0
|
||||||
CONFIG_EXAMPLES_COMPOSITE_DEVPATH1="/dev/mmcsd0"
|
CONFIG_EXAMPLES_COMPOSITE_DEVPATH1="/dev/mmcsd0"
|
||||||
CONFIG_EXAMPLES_COMPOSITE_TTYUSB=0
|
CONFIG_EXAMPLES_COMPOSITE_TTYUSB=0
|
||||||
CCONFIG_EXAMPLES_COMPOSITE_SERDEV="/dev/ttyUSB0"
|
CONFIG_EXAMPLES_COMPOSITE_SERDEV="/dev/ttyUSB0"
|
||||||
CONFIG_EXAMPLES_COMPOSITE_BUFSIZE=256
|
CONFIG_EXAMPLES_COMPOSITE_BUFSIZE=256
|
||||||
CONFIG_EXAMPLES_COMPOSITE_TRACEINIT=n
|
CONFIG_EXAMPLES_COMPOSITE_TRACEINIT=n
|
||||||
CONFIG_EXAMPLES_COMPOSITE_TRACECLASS=n
|
CONFIG_EXAMPLES_COMPOSITE_TRACECLASS=n
|
||||||
|
|||||||
+21
-1
@@ -64,6 +64,10 @@
|
|||||||
# define CONFIG_CDCACM_STRBASE (4)
|
# define CONFIG_CDCACM_STRBASE (4)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(CONFIG_CDCACM_COMPOSITE) && !defined(CONFIG_COMPOSITE_IAD)
|
||||||
|
# warning "CONFIG_COMPOSITE_IAD may be needed"
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Packet and request buffer sizes */
|
/* Packet and request buffer sizes */
|
||||||
|
|
||||||
#ifndef CONFIG_CDCACM_COMPOSITE
|
#ifndef CONFIG_CDCACM_COMPOSITE
|
||||||
@@ -158,7 +162,7 @@
|
|||||||
|
|
||||||
/* Configuration descriptor size */
|
/* Configuration descriptor size */
|
||||||
|
|
||||||
#ifndef CONFIG_CDCACM_COMPOSITE
|
#if !defined(CONFIG_CDCACM_COMPOSITE)
|
||||||
|
|
||||||
/* Number of individual descriptors in the configuration descriptor:
|
/* Number of individual descriptors in the configuration descriptor:
|
||||||
* Configuration descriptor + (2) interface descriptors + (3) endpoint
|
* Configuration descriptor + (2) interface descriptors + (3) endpoint
|
||||||
@@ -172,6 +176,22 @@
|
|||||||
# define SIZEOF_CDCACM_CFGDESC \
|
# define SIZEOF_CDCACM_CFGDESC \
|
||||||
(USB_SIZEOF_CFGDESC + 2*USB_SIZEOF_IFDESC + 3*USB_SIZEOF_EPDESC + \
|
(USB_SIZEOF_CFGDESC + 2*USB_SIZEOF_IFDESC + 3*USB_SIZEOF_EPDESC + \
|
||||||
SIZEOF_ACM_FUNCDESC + SIZEOF_HDR_FUNCDESC + SIZEOF_UNION_FUNCDESC(1))
|
SIZEOF_ACM_FUNCDESC + SIZEOF_HDR_FUNCDESC + SIZEOF_UNION_FUNCDESC(1))
|
||||||
|
|
||||||
|
#elif defined(CONFIG_COMPOSITE_IAD)
|
||||||
|
|
||||||
|
/* Number of individual descriptors in the configuration descriptor:
|
||||||
|
* (1) interface association descriptor + (2) interface descriptors +
|
||||||
|
* (3) endpoint descriptors + (3) ACM descriptors.
|
||||||
|
*/
|
||||||
|
|
||||||
|
# define CDCACM_CFGGROUP_SIZE (9)
|
||||||
|
|
||||||
|
/* The size of the config descriptor: (8 + 2*9 + 3*7 + 4 + 5 + 5) = 61 */
|
||||||
|
|
||||||
|
# define SIZEOF_CDCACM_CFGDESC \
|
||||||
|
(USB_SIZEOF_IADDESC +2*USB_SIZEOF_IFDESC + 3*USB_SIZEOF_EPDESC + \
|
||||||
|
SIZEOF_ACM_FUNCDESC + SIZEOF_HDR_FUNCDESC + SIZEOF_UNION_FUNCDESC(1))
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
/* Number of individual descriptors in the configuration descriptor:
|
/* Number of individual descriptors in the configuration descriptor:
|
||||||
|
|||||||
@@ -139,6 +139,22 @@ static const struct usb_cfgdesc_s g_cfgdesc =
|
|||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* Interface association descriptor */
|
||||||
|
|
||||||
|
#if defined(CONFIG_CDCACM_COMPOSITE) && defined(CONFIG_COMPOSITE_IAD)
|
||||||
|
static const struct usb_iaddesc_s g_iaddesc =
|
||||||
|
{
|
||||||
|
USB_SIZEOF_IADDESC, /* len */
|
||||||
|
USB_DESC_TYPE_INTERFACEASSOCIATION, /* type */
|
||||||
|
CONFIG_CDCACM_IFNOBASE, /* firstif */
|
||||||
|
CDCACM_NINTERFACES, /* nifs */
|
||||||
|
USB_CLASS_CDC, /* class */
|
||||||
|
CDC_SUBCLASS_ACM, /* subclass */
|
||||||
|
CDC_PROTO_NONE, /* protocol */
|
||||||
|
0 /* ifunction */
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Notification interface */
|
/* Notification interface */
|
||||||
|
|
||||||
static const struct usb_ifdesc_s g_notifdesc =
|
static const struct usb_ifdesc_s g_notifdesc =
|
||||||
@@ -273,12 +289,25 @@ static const struct cfgdecsc_group_s g_cfggroup[CDCACM_CFGGROUP_SIZE] =
|
|||||||
* provided by the composite device logic.
|
* provided by the composite device logic.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef CONFIG_CDCACM_COMPOSITE
|
#if !defined(CONFIG_CDCACM_COMPOSITE)
|
||||||
{
|
{
|
||||||
USB_SIZEOF_CFGDESC, /* 1. Configuration descriptor */
|
USB_SIZEOF_CFGDESC, /* 1. Configuration descriptor */
|
||||||
0,
|
0,
|
||||||
(FAR void *)&g_cfgdesc
|
(FAR void *)&g_cfgdesc
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/* If the serial device is part of a composite device, then it should
|
||||||
|
* begin with an interface association descriptor (IAD) because the
|
||||||
|
* CDC/ACM device consists of more than one interface. The IAD associates
|
||||||
|
* the two CDC/ACM interfaces with the same CDC/ACM device.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#elif defined(CONFIG_COMPOSITE_IAD)
|
||||||
|
{
|
||||||
|
USB_SIZEOF_IADDESC, /* 1. Interface association descriptor */
|
||||||
|
0,
|
||||||
|
(FAR void *)&g_iaddesc
|
||||||
|
},
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
USB_SIZEOF_IFDESC, /* 2. Notification interface */
|
USB_SIZEOF_IFDESC, /* 2. Notification interface */
|
||||||
|
|||||||
@@ -185,6 +185,18 @@
|
|||||||
# warning "Interface numbers are not contiguous"
|
# warning "Interface numbers are not contiguous"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* Check if an IAD is needed */
|
||||||
|
|
||||||
|
#ifdef CONFIG_COMPOSITE_IAD
|
||||||
|
# if DEV1_NINTERFACES == 1 && DEV2_NINTERFACES == 1
|
||||||
|
# warning "CONFIG_COMPOSITE_IAD not needed"
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if !defined(CONFIG_COMPOSITE_IAD) && DEV1_NINTERFACES > 1 && DEV2_NINTERFACES > 1
|
||||||
|
# warning "CONFIG_COMPOSITE_IAD may be needed"
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Total size of the configuration descriptor: */
|
/* Total size of the configuration descriptor: */
|
||||||
|
|
||||||
#define COMPOSITE_CFGDESCSIZE (USB_SIZEOF_CFGDESC + DEV1_CFGDESCSIZE + DEV2_CFGDESCSIZE)
|
#define COMPOSITE_CFGDESCSIZE (USB_SIZEOF_CFGDESC + DEV1_CFGDESCSIZE + DEV2_CFGDESCSIZE)
|
||||||
|
|||||||
@@ -84,9 +84,15 @@ static const struct usb_devdesc_s g_devdesc =
|
|||||||
LSBYTE(0x0200),
|
LSBYTE(0x0200),
|
||||||
MSBYTE(0x0200)
|
MSBYTE(0x0200)
|
||||||
},
|
},
|
||||||
|
#ifdef CONFIG_COMPOSITE_IAD
|
||||||
|
USB_CLASS_MISC, /* class */
|
||||||
|
2, /* subclass */
|
||||||
|
1, /* protocol */
|
||||||
|
#else
|
||||||
USB_CLASS_PER_INTERFACE, /* class */
|
USB_CLASS_PER_INTERFACE, /* class */
|
||||||
0, /* subclass */
|
0, /* subclass */
|
||||||
0, /* protocol */
|
0, /* protocol */
|
||||||
|
#endif
|
||||||
CONFIG_COMPOSITE_EP0MAXPACKET, /* maxpacketsize */
|
CONFIG_COMPOSITE_EP0MAXPACKET, /* maxpacketsize */
|
||||||
{
|
{
|
||||||
LSBYTE(CONFIG_COMPOSITE_VENDORID), /* vendor */
|
LSBYTE(CONFIG_COMPOSITE_VENDORID), /* vendor */
|
||||||
@@ -240,31 +246,31 @@ int16_t composite_mkcfgdesc(uint8_t *buf, uint8_t speed, uint8_t type)
|
|||||||
int16_t composite_mkcfgdesc(uint8_t *buf)
|
int16_t composite_mkcfgdesc(uint8_t *buf)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
FAR struct usb_cfgdesc_s *cfgdesc = (struct usb_cfgdesc_s*)buf;
|
|
||||||
int16_t len;
|
int16_t len;
|
||||||
|
int16_t total;
|
||||||
|
|
||||||
/* Configuration descriptor -- Copy the canned configuration descriptor. */
|
/* Configuration descriptor -- Copy the canned configuration descriptor. */
|
||||||
|
|
||||||
memcpy(cfgdesc, &g_cfgdesc, USB_SIZEOF_CFGDESC);
|
memcpy(buf, &g_cfgdesc, USB_SIZEOF_CFGDESC);
|
||||||
len = USB_SIZEOF_CFGDESC;
|
total = USB_SIZEOF_CFGDESC;
|
||||||
buf += USB_SIZEOF_CFGDESC;
|
buf += USB_SIZEOF_CFGDESC;
|
||||||
|
|
||||||
/* Copy DEV1/DEV2 configuration descriptors */
|
/* Copy DEV1/DEV2 interface descriptors */
|
||||||
|
|
||||||
#ifdef CONFIG_USBDEV_DUALSPEED
|
#ifdef CONFIG_USBDEV_DUALSPEED
|
||||||
len = DEV1_MKCFGDESC(buf, speed, type);
|
len = DEV1_MKCFGDESC(buf, speed, type);
|
||||||
|
total += len;
|
||||||
buf += len;
|
buf += len;
|
||||||
len = DEV2_MKCFGDESC(buf, speed, type);
|
total += DEV2_MKCFGDESC(buf, speed, type);
|
||||||
buf += len;
|
|
||||||
#else
|
#else
|
||||||
len = DEV1_MKCFGDESC(buf);
|
len = DEV1_MKCFGDESC(buf);
|
||||||
|
total += len;
|
||||||
buf += len;
|
buf += len;
|
||||||
len = DEV2_MKCFGDESC(buf);
|
total += DEV2_MKCFGDESC(buf);
|
||||||
buf += len;
|
|
||||||
#endif
|
#endif
|
||||||
DEBUGASSERT(len == COMPOSITE_CFGDESCSIZE);
|
|
||||||
|
|
||||||
return COMPOSITE_CFGDESCSIZE;
|
DEBUGASSERT(total == COMPOSITE_CFGDESCSIZE);
|
||||||
|
return total;
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
|
|||||||
@@ -1660,6 +1660,7 @@ errout_with_mutex:
|
|||||||
int usbmsc_classobject(FAR void *handle,
|
int usbmsc_classobject(FAR void *handle,
|
||||||
FAR struct usbdevclass_driver_s **classdev)
|
FAR struct usbdevclass_driver_s **classdev)
|
||||||
{
|
{
|
||||||
|
FAR struct usbmsc_alloc_s *alloc = (FAR struct usbmsc_alloc_s *)handle;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
DEBUGASSERT(handle && classdev);
|
DEBUGASSERT(handle && classdev);
|
||||||
@@ -1673,8 +1674,7 @@ int usbmsc_classobject(FAR void *handle,
|
|||||||
{
|
{
|
||||||
/* On sucess, return an (typed) instance of the class instance */
|
/* On sucess, return an (typed) instance of the class instance */
|
||||||
|
|
||||||
*classdev = (FAR struct usbdevclass_driver_s *)
|
*classdev = &alloc->drvr.drvr;
|
||||||
&((FAR struct usbmsc_alloc_s *)handle)->dev;
|
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -369,7 +369,8 @@
|
|||||||
/* The size of the config descriptor: (9 + 9 + 2*7) = 32 */
|
/* The size of the config descriptor: (9 + 9 + 2*7) = 32 */
|
||||||
|
|
||||||
# define SIZEOF_USBMSC_CFGDESC \
|
# define SIZEOF_USBMSC_CFGDESC \
|
||||||
(USB_SIZEOF_CFGDESC + USB_SIZEOF_IFDESC + 2*USB_SIZEOF_EPDESC)
|
(USB_SIZEOF_CFGDESC + USB_SIZEOF_IFDESC + USBMSC_NENDPOINTS * USB_SIZEOF_EPDESC)
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
/* Number of individual descriptors in the configuration descriptor:
|
/* Number of individual descriptors in the configuration descriptor:
|
||||||
@@ -380,7 +381,9 @@
|
|||||||
|
|
||||||
/* The size of the config descriptor: (9 + 2*7) = 23 */
|
/* The size of the config descriptor: (9 + 2*7) = 23 */
|
||||||
|
|
||||||
# define SIZEOF_USBMSC_CFGDESC (USB_SIZEOF_IFDESC + 2*USB_SIZEOF_EPDESC)
|
# define SIZEOF_USBMSC_CFGDESC \
|
||||||
|
(USB_SIZEOF_IFDESC + USBMSC_NENDPOINTS * USB_SIZEOF_EPDESC)
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Block driver helpers *****************************************************/
|
/* Block driver helpers *****************************************************/
|
||||||
|
|||||||
@@ -109,7 +109,10 @@ static const struct usb_cfgdesc_s g_cfgdesc =
|
|||||||
{
|
{
|
||||||
USB_SIZEOF_CFGDESC, /* len */
|
USB_SIZEOF_CFGDESC, /* len */
|
||||||
USB_DESC_TYPE_CONFIG, /* type */
|
USB_DESC_TYPE_CONFIG, /* type */
|
||||||
{0, 0}, /* totallen -- to be provided */
|
{ /* totallen */
|
||||||
|
LSBYTE(SIZEOF_USBMSC_CFGDESC),
|
||||||
|
MSBYTE(SIZEOF_USBMSC_CFGDESC)
|
||||||
|
},
|
||||||
USBMSC_NINTERFACES, /* ninterfaces */
|
USBMSC_NINTERFACES, /* ninterfaces */
|
||||||
USBMSC_CONFIGID, /* cfgvalue */
|
USBMSC_CONFIGID, /* cfgvalue */
|
||||||
USBMSC_CONFIGSTRID, /* icfg */
|
USBMSC_CONFIGSTRID, /* icfg */
|
||||||
@@ -353,30 +356,19 @@ int16_t usbmsc_mkcfgdesc(uint8_t *buf, uint8_t speed, uint8_t type)
|
|||||||
int16_t usbmsc_mkcfgdesc(uint8_t *buf)
|
int16_t usbmsc_mkcfgdesc(uint8_t *buf)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
#ifndef CONFIG_USBMSC_COMPOSITE
|
|
||||||
FAR struct usb_cfgdesc_s *cfgdesc = (struct usb_cfgdesc_s*)buf;
|
|
||||||
#endif
|
|
||||||
#ifdef CONFIG_USBDEV_DUALSPEED
|
#ifdef CONFIG_USBDEV_DUALSPEED
|
||||||
FAR const struct usb_epdesc_s *epdesc;
|
FAR const struct usb_epdesc_s *epdesc;
|
||||||
bool hispeed = (speed == USB_SPEED_HIGH);
|
bool hispeed = (speed == USB_SPEED_HIGH);
|
||||||
uint16_t bulkmxpacket;
|
uint16_t bulkmxpacket;
|
||||||
#endif
|
#endif
|
||||||
uint16_t totallen;
|
|
||||||
|
|
||||||
/* This is the total length of the configuration (not necessarily the
|
/* Configuration descriptor. If the USB mass storage device is
|
||||||
* size that we will be sending now.
|
* configured as part of a composite device, then the configuration
|
||||||
*/
|
|
||||||
|
|
||||||
totallen = USB_SIZEOF_CFGDESC + USB_SIZEOF_IFDESC + USBMSC_NENDPOINTS * USB_SIZEOF_EPDESC;
|
|
||||||
|
|
||||||
/* Configuration descriptor -- Copy the canned descriptor and fill in the
|
|
||||||
* type (we'll also need to update the size below). If the USB mass storage
|
|
||||||
* device is configured as part of a composite device, then the configuration
|
|
||||||
* descriptor will be provided by the composite device logic.
|
* descriptor will be provided by the composite device logic.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef CONFIG_USBMSC_COMPOSITE
|
#ifndef CONFIG_USBMSC_COMPOSITE
|
||||||
memcpy(cfgdesc, &g_cfgdesc, USB_SIZEOF_CFGDESC);
|
memcpy(buf, &g_cfgdesc, USB_SIZEOF_CFGDESC);
|
||||||
buf += USB_SIZEOF_CFGDESC;
|
buf += USB_SIZEOF_CFGDESC;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -409,13 +401,7 @@ int16_t usbmsc_mkcfgdesc(uint8_t *buf)
|
|||||||
memcpy(buf, &g_fsepbulkindesc, USB_SIZEOF_EPDESC);
|
memcpy(buf, &g_fsepbulkindesc, USB_SIZEOF_EPDESC);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Finally, fill in the total size of the configuration descriptor */
|
return SIZEOF_USBMSC_CFGDESC;
|
||||||
|
|
||||||
#ifndef CONFIG_USBMSC_COMPOSITE
|
|
||||||
cfgdesc->totallen[0] = LSBYTE(totallen);
|
|
||||||
cfgdesc->totallen[1] = MSBYTE(totallen);
|
|
||||||
#endif
|
|
||||||
return totallen;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
|
|||||||
@@ -198,6 +198,7 @@
|
|||||||
#define USB_CLASS_CONTENT_SEC (0x0d)
|
#define USB_CLASS_CONTENT_SEC (0x0d)
|
||||||
#define USB_CLASS_VIDEO (0x0e)
|
#define USB_CLASS_VIDEO (0x0e)
|
||||||
#define USB_CLASS_WIRELESS_CONTROLLER (0xe0)
|
#define USB_CLASS_WIRELESS_CONTROLLER (0xe0)
|
||||||
|
#define USB_CLASS_MISC (0xef)
|
||||||
#define USB_CLASS_APP_SPEC (0xfe)
|
#define USB_CLASS_APP_SPEC (0xfe)
|
||||||
#define USB_CLASS_VENDOR_SPEC (0xff)
|
#define USB_CLASS_VENDOR_SPEC (0xff)
|
||||||
|
|
||||||
@@ -377,6 +378,29 @@ struct usb_qualdesc_s
|
|||||||
};
|
};
|
||||||
#define USB_SIZEOF_QUALDESC 10
|
#define USB_SIZEOF_QUALDESC 10
|
||||||
|
|
||||||
|
/* Interface association descriptor
|
||||||
|
*
|
||||||
|
* The Universal Serial Bus Specification, revision 2.0, does not support grouping
|
||||||
|
* more than one interface of a composite device within a single function. However,
|
||||||
|
* the USB Device Working Group (DWG) created USB device classes that allow for
|
||||||
|
* functions with multiple interfaces, and the USB Implementor's Forum issued an
|
||||||
|
* Engineering Change Notification (ECN) that defines a mechanism for grouping
|
||||||
|
* interfaces.
|
||||||
|
*/
|
||||||
|
|
||||||
|
struct usb_iaddesc_s
|
||||||
|
{
|
||||||
|
uint8_t len; /* Descriptor length */
|
||||||
|
uint8_t type; /* Descriptor type */
|
||||||
|
uint8_t firstif; /* Number of first interface of the function */
|
||||||
|
uint8_t nifs; /* Number of interfaces associated with the function */
|
||||||
|
uint8_t class; /* Class code*/
|
||||||
|
uint8_t subclass; /* Sub-class code */
|
||||||
|
uint8_t protocol; /* Protocol code */
|
||||||
|
uint8_t ifunction; /* Index to string identifying the function */
|
||||||
|
};
|
||||||
|
#define USB_SIZEOF_IADDESC 8
|
||||||
|
|
||||||
/************************************************************************************
|
/************************************************************************************
|
||||||
* Public Data
|
* Public Data
|
||||||
************************************************************************************/
|
************************************************************************************/
|
||||||
|
|||||||
Reference in New Issue
Block a user