mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-17 19:23:34 +08:00
Massive name change USB STRG -> USB MSC
git-svn-id: https://nuttx.svn.sourceforge.net/svnroot/nuttx/trunk@4334 7fd9a85b-ad96-42d3-883c-3090e2eb8679
This commit is contained in:
@@ -45,7 +45,7 @@ ifeq ($(CONFIG_CDCSER),y)
|
||||
CSRCS += cdcacm.c cdcacm_descriptors.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_USBSTRG),y)
|
||||
ifeq ($(CONFIG_USBMSC),y)
|
||||
CSRCS += msc.c msc_descriptors.c msc_scsi.c
|
||||
endif
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@
|
||||
# include "cdcacm.h"
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_USBSTRG_COMPOSITE
|
||||
#ifdef CONFIG_USBMSC_COMPOSITE
|
||||
# include "msc.h"
|
||||
#endif
|
||||
|
||||
@@ -114,18 +114,18 @@
|
||||
|
||||
/* Constituent devices ******************************************************/
|
||||
|
||||
#undef DEV1_IS_CDCSERIAL
|
||||
#undef DEV1_IS_USBSTRG
|
||||
#undef DEV1_IS_CDCACM
|
||||
#undef DEV1_IS_USBMSC
|
||||
|
||||
#undef DEV2_IS_CDCSERIAL
|
||||
#undef DEV2_IS_USBSTRG
|
||||
#undef DEV2_IS_CDCACM
|
||||
#undef DEV2_IS_USBMSC
|
||||
|
||||
/* Pick the first device in the composite. At present, this may only be
|
||||
* the CDC serial device or the mass storage device.
|
||||
*/
|
||||
|
||||
#if defined(CONFIG_CDCSER_COMPOSITE)
|
||||
# define DEV1_IS_CDCSERIAL 1
|
||||
# define DEV1_IS_CDCACM 1
|
||||
# define DEV1_MKCFGDESC cdcser_mkcfgdesc
|
||||
# define DEV1_CLASSOBJECT board_cdcclassobject
|
||||
# define DEV1_NCONFIGS CDCSER_NCONFIGS
|
||||
@@ -136,16 +136,16 @@
|
||||
# define DEV1_NSTRIDS (CDCSER_LASTSTRID-CONFIG_CDCSER_STRBASE)
|
||||
# define DEV1_CFGDESCSIZE SIZEOF_CDCSER_CFGDESC
|
||||
#elif defined(CONFIG_CDCSER_COMPOSITE)
|
||||
# define DEV1_IS_USBSTRG 1
|
||||
# define DEV1_MKCFGDESC usbstrg_mkcfgdesc
|
||||
# define DEV1_IS_USBMSC 1
|
||||
# define DEV1_MKCFGDESC usbmsc_mkcfgdesc
|
||||
# define DEV1_CLASSOBJECT board_mscclassobject
|
||||
# define DEV1_NCONFIGS USBSTRG_NCONFIGS
|
||||
# define DEV1_CONFIGID USBSTRG_CONFIGID
|
||||
# define DEV1_FIRSTINTERFACE CONFIG_USBSTRG_IFNOBASE
|
||||
# define DEV1_NINTERFACES USBSTRG_NINTERFACES
|
||||
# define DEV1_FIRSTSTRID CONFIG_USBSTRG_IFNOBASE
|
||||
# define DEV1_NSTRIDS (USBSTRG_LASTSTRID-CONFIG_USBSTRG_STRBASE)
|
||||
# define DEV1_CFGDESCSIZE SIZEOF_USBSTRG_CFGDESC
|
||||
# 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_CFGDESCSIZE SIZEOF_USBMSC_CFGDESC
|
||||
#else
|
||||
# error "No members of the composite defined"
|
||||
#endif
|
||||
@@ -154,8 +154,8 @@
|
||||
* the CDC serial device or the mass storage device.
|
||||
*/
|
||||
|
||||
#if defined(CONFIG_CDCSER_COMPOSITE) && !defined(DEV1_IS_CDCSERIAL)
|
||||
# define DEV2_IS_CDCSERIAL 1
|
||||
#if defined(CONFIG_CDCSER_COMPOSITE) && !defined(DEV1_IS_CDCACM)
|
||||
# define DEV2_IS_CDCACM 1
|
||||
# define DEV2_MKCFGDESC cdcser_mkcfgdesc
|
||||
# define DEV2_CLASSOBJECT board_cdcclassobject
|
||||
# define DEV2_NCONFIGS CDCSER_NCONFIGS
|
||||
@@ -165,17 +165,17 @@
|
||||
# define DEV2_FIRSTSTRID CONFIG_CDCSER_STRBASE
|
||||
# define DEV2_NSTRIDS (CDCSER_LASTSTRID-CONFIG_CDCSER_STRBASE)
|
||||
# define DEV2_CFGDESCSIZE SIZEOF_CDCSER_CFGDESC
|
||||
#elif defined(CONFIG_CDCSER_COMPOSITE) && !defined(DEV1_IS_USBSTRG)
|
||||
# define DEV2_IS_USBSTRG 1
|
||||
# define DEV2_MKCFGDESC usbstrg_mkcfgdesc
|
||||
#elif defined(CONFIG_CDCSER_COMPOSITE) && !defined(DEV1_IS_USBMSC)
|
||||
# define DEV2_IS_USBMSC 1
|
||||
# define DEV2_MKCFGDESC usbmsc_mkcfgdesc
|
||||
# define DEV2_CLASSOBJECT board_mscclassobject
|
||||
# define DEV2_NCONFIGS USBSTRG_NCONFIGS
|
||||
# define DEV2_CONFIGID USBSTRG_CONFIGID
|
||||
# define DEV2_FIRSTINTERFACE CONFIG_USBSTRG_IFNOBASE
|
||||
# define DEV2_NINTERFACES USBSTRG_NINTERFACES
|
||||
# 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_CDCSER_STRBASE
|
||||
# define DEV2_NSTRIDS (USBSTRG_LASTSTRID-CONFIG_USBSTRG_STRBASE)
|
||||
# define DEV2_CFGDESCSIZE SIZEOF_USBSTRG_CFGDESC
|
||||
# define DEV2_NSTRIDS (USBMSC_LASTSTRID-CONFIG_USBMSC_STRBASE)
|
||||
# define DEV2_CFGDESCSIZE SIZEOF_USBMSC_CFGDESC
|
||||
#else
|
||||
# error "Insufficient members of the composite defined"
|
||||
#endif
|
||||
@@ -253,7 +253,7 @@ extern const char g_compserialstr[];
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: usbstrg_mkstrdesc
|
||||
* Name: usbmsc_mkstrdesc
|
||||
*
|
||||
* Description:
|
||||
* Construct a string descriptor
|
||||
|
||||
@@ -150,7 +150,7 @@ static const struct usb_qualdesc_s g_qualdesc =
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: usbstrg_mkstrdesc
|
||||
* Name: composite_mkstrdesc
|
||||
*
|
||||
* Description:
|
||||
* Construct a string descriptor
|
||||
|
||||
+242
-242
File diff suppressed because it is too large
Load Diff
+180
-180
@@ -59,140 +59,140 @@
|
||||
****************************************************************************/
|
||||
/* Configuration ************************************************************/
|
||||
/* If the USB mass storage device is configured as part of a composite device
|
||||
* then both CONFIG_USBDEV_COMPOSITE and CONFIG_USBSTRG_COMPOSITE must be
|
||||
* then both CONFIG_USBDEV_COMPOSITE and CONFIG_USBMSC_COMPOSITE must be
|
||||
* defined.
|
||||
*/
|
||||
|
||||
#ifndef CONFIG_USBDEV_COMPOSITE
|
||||
# undef CONFIG_USBSTRG_COMPOSITE
|
||||
# undef CONFIG_USBMSC_COMPOSITE
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_USBSTRG_COMPOSITE) && !defined(CONFIG_USBSTRG_STRBASE)
|
||||
# define CONFIG_USBSTRG_STRBASE (4)
|
||||
#if defined(CONFIG_USBMSC_COMPOSITE) && !defined(CONFIG_USBMSC_STRBASE)
|
||||
# define CONFIG_USBMSC_STRBASE (4)
|
||||
#endif
|
||||
|
||||
/* Interface IDs. If the mass storage driver is built as a component of a
|
||||
* composite device, then the interface IDs may need to be offset.
|
||||
*/
|
||||
|
||||
#ifndef CONFIG_USBSTRG_COMPOSITE
|
||||
# undef CONFIG_USBSTRG_IFNOBASE
|
||||
# define CONFIG_USBSTRG_IFNOBASE 0
|
||||
#ifndef CONFIG_USBMSC_COMPOSITE
|
||||
# undef CONFIG_USBMSC_IFNOBASE
|
||||
# define CONFIG_USBMSC_IFNOBASE 0
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_USBSTRG_IFNOBASE
|
||||
# define CONFIG_USBSTRG_IFNOBASE 0
|
||||
#ifndef CONFIG_USBMSC_IFNOBASE
|
||||
# define CONFIG_USBMSC_IFNOBASE 0
|
||||
#endif
|
||||
|
||||
/* Number of requests in the write queue */
|
||||
|
||||
#ifndef CONFIG_USBSTRG_NWRREQS
|
||||
# define CONFIG_USBSTRG_NWRREQS 4
|
||||
#ifndef CONFIG_USBMSC_NWRREQS
|
||||
# define CONFIG_USBMSC_NWRREQS 4
|
||||
#endif
|
||||
|
||||
/* Number of requests in the read queue */
|
||||
|
||||
#ifndef CONFIG_USBSTRG_NRDREQS
|
||||
# define CONFIG_USBSTRG_NRDREQS 4
|
||||
#ifndef CONFIG_USBMSC_NRDREQS
|
||||
# define CONFIG_USBMSC_NRDREQS 4
|
||||
#endif
|
||||
|
||||
/* Logical endpoint numbers / max packet sizes */
|
||||
|
||||
#ifndef CONFIG_USBSTRG_EPBULKOUT
|
||||
#ifndef CONFIG_USBMSC_EPBULKOUT
|
||||
# warning "EPBULKOUT not defined in the configuration"
|
||||
# define CONFIG_USBSTRG_EPBULKOUT 2
|
||||
# define CONFIG_USBMSC_EPBULKOUT 2
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_USBSTRG_EPBULKIN
|
||||
#ifndef CONFIG_USBMSC_EPBULKIN
|
||||
# warning "EPBULKIN not defined in the configuration"
|
||||
# define CONFIG_USBSTRG_EPBULKIN 3
|
||||
# define CONFIG_USBMSC_EPBULKIN 3
|
||||
#endif
|
||||
|
||||
/* Packet and request buffer sizes */
|
||||
|
||||
#ifndef CONFIG_CDCSER_COMPOSITE
|
||||
# ifndef CONFIG_USBSTRG_EP0MAXPACKET
|
||||
# define CONFIG_USBSTRG_EP0MAXPACKET 64
|
||||
# ifndef CONFIG_USBMSC_EP0MAXPACKET
|
||||
# define CONFIG_USBMSC_EP0MAXPACKET 64
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_USBSTRG_BULKINREQLEN
|
||||
#ifndef CONFIG_USBMSC_BULKINREQLEN
|
||||
# ifdef CONFIG_USBDEV_DUALSPEED
|
||||
# define CONFIG_USBSTRG_BULKINREQLEN 512
|
||||
# define CONFIG_USBMSC_BULKINREQLEN 512
|
||||
# else
|
||||
# define CONFIG_USBSTRG_BULKINREQLEN 64
|
||||
# define CONFIG_USBMSC_BULKINREQLEN 64
|
||||
# endif
|
||||
#else
|
||||
# ifdef CONFIG_USBDEV_DUALSPEED
|
||||
# if CONFIG_USBSTRG_BULKINREQLEN < 512
|
||||
# if CONFIG_USBMSC_BULKINREQLEN < 512
|
||||
# warning "Bulk in buffer size smaller than max packet"
|
||||
# undef CONFIG_USBSTRG_BULKINREQLEN
|
||||
# define CONFIG_USBSTRG_BULKINREQLEN 512
|
||||
# undef CONFIG_USBMSC_BULKINREQLEN
|
||||
# define CONFIG_USBMSC_BULKINREQLEN 512
|
||||
# endif
|
||||
# else
|
||||
# if CONFIG_USBSTRG_BULKINREQLEN < 64
|
||||
# if CONFIG_USBMSC_BULKINREQLEN < 64
|
||||
# warning "Bulk in buffer size smaller than max packet"
|
||||
# undef CONFIG_USBSTRG_BULKINREQLEN
|
||||
# define CONFIG_USBSTRG_BULKINREQLEN 64
|
||||
# undef CONFIG_USBMSC_BULKINREQLEN
|
||||
# define CONFIG_USBMSC_BULKINREQLEN 64
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_USBSTRG_BULKOUTREQLEN
|
||||
#ifndef CONFIG_USBMSC_BULKOUTREQLEN
|
||||
# ifdef CONFIG_USBDEV_DUALSPEED
|
||||
# define CONFIG_USBSTRG_BULKOUTREQLEN 512
|
||||
# define CONFIG_USBMSC_BULKOUTREQLEN 512
|
||||
# else
|
||||
# define CONFIG_USBSTRG_BULKOUTREQLEN 64
|
||||
# define CONFIG_USBMSC_BULKOUTREQLEN 64
|
||||
# endif
|
||||
#else
|
||||
# ifdef CONFIG_USBDEV_DUALSPEED
|
||||
# if CONFIG_USBSTRG_BULKOUTREQLEN < 512
|
||||
# if CONFIG_USBMSC_BULKOUTREQLEN < 512
|
||||
# warning "Bulk in buffer size smaller than max packet"
|
||||
# undef CONFIG_USBSTRG_BULKOUTREQLEN
|
||||
# define CONFIG_USBSTRG_BULKOUTREQLEN 512
|
||||
# undef CONFIG_USBMSC_BULKOUTREQLEN
|
||||
# define CONFIG_USBMSC_BULKOUTREQLEN 512
|
||||
# endif
|
||||
# else
|
||||
# if CONFIG_USBSTRG_BULKOUTREQLEN < 64
|
||||
# if CONFIG_USBMSC_BULKOUTREQLEN < 64
|
||||
# warning "Bulk in buffer size smaller than max packet"
|
||||
# undef CONFIG_USBSTRG_BULKOUTREQLEN
|
||||
# define CONFIG_USBSTRG_BULKOUTREQLEN 64
|
||||
# undef CONFIG_USBMSC_BULKOUTREQLEN
|
||||
# define CONFIG_USBMSC_BULKOUTREQLEN 64
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* Vendor and product IDs and strings */
|
||||
|
||||
#ifndef CONFIG_USBSTRG_COMPOSITE
|
||||
# ifndef CONFIG_USBSTRG_VENDORID
|
||||
# warning "CONFIG_USBSTRG_VENDORID not defined"
|
||||
# define CONFIG_USBSTRG_VENDORID 0x584e
|
||||
#ifndef CONFIG_USBMSC_COMPOSITE
|
||||
# ifndef CONFIG_USBMSC_VENDORID
|
||||
# warning "CONFIG_USBMSC_VENDORID not defined"
|
||||
# define CONFIG_USBMSC_VENDORID 0x584e
|
||||
# endif
|
||||
|
||||
# ifndef CONFIG_USBSTRG_PRODUCTID
|
||||
# warning "CONFIG_USBSTRG_PRODUCTID not defined"
|
||||
# define CONFIG_USBSTRG_PRODUCTID 0x5342
|
||||
# ifndef CONFIG_USBMSC_PRODUCTID
|
||||
# warning "CONFIG_USBMSC_PRODUCTID not defined"
|
||||
# define CONFIG_USBMSC_PRODUCTID 0x5342
|
||||
# endif
|
||||
|
||||
# ifndef CONFIG_USBSTRG_VERSIONNO
|
||||
# define CONFIG_USBSTRG_VERSIONNO (0x0399)
|
||||
# ifndef CONFIG_USBMSC_VERSIONNO
|
||||
# define CONFIG_USBMSC_VERSIONNO (0x0399)
|
||||
# endif
|
||||
|
||||
# ifndef CONFIG_USBSTRG_VENDORSTR
|
||||
# ifndef CONFIG_USBMSC_VENDORSTR
|
||||
# warning "No Vendor string specified"
|
||||
# define CONFIG_USBSTRG_VENDORSTR "NuttX"
|
||||
# define CONFIG_USBMSC_VENDORSTR "NuttX"
|
||||
# endif
|
||||
|
||||
# ifndef CONFIG_USBSTRG_PRODUCTSTR
|
||||
# ifndef CONFIG_USBMSC_PRODUCTSTR
|
||||
# warning "No Product string specified"
|
||||
# define CONFIG_USBSTRG_PRODUCTSTR "USBdev Storage"
|
||||
# define CONFIG_USBMSC_PRODUCTSTR "USBdev Storage"
|
||||
# endif
|
||||
|
||||
# undef CONFIG_USBSTRG_SERIALSTR
|
||||
# define CONFIG_USBSTRG_SERIALSTR "0101"
|
||||
# undef CONFIG_USBMSC_SERIALSTR
|
||||
# define CONFIG_USBMSC_SERIALSTR "0101"
|
||||
#endif
|
||||
|
||||
#undef CONFIG_USBSTRG_CONFIGSTR
|
||||
#define CONFIG_USBSTRG_CONFIGSTR "Bulk"
|
||||
#undef CONFIG_USBMSC_CONFIGSTR
|
||||
#define CONFIG_USBMSC_CONFIGSTR "Bulk"
|
||||
|
||||
/* Debug -- must be consistent with include/debug.h */
|
||||
|
||||
@@ -220,8 +220,8 @@
|
||||
|
||||
/* Packet and request buffer sizes */
|
||||
|
||||
#ifndef CONFIG_USBSTRG_EP0MAXPACKET
|
||||
# define CONFIG_USBSTRG_EP0MAXPACKET 64
|
||||
#ifndef CONFIG_USBMSC_EP0MAXPACKET
|
||||
# define CONFIG_USBMSC_EP0MAXPACKET 64
|
||||
#endif
|
||||
|
||||
/* USB Controller */
|
||||
@@ -244,131 +244,131 @@
|
||||
|
||||
/* Current state of the worker thread */
|
||||
|
||||
#define USBSTRG_STATE_NOTSTARTED (0) /* Thread has not yet been started */
|
||||
#define USBSTRG_STATE_STARTED (1) /* Started, but is not yet initialized */
|
||||
#define USBSTRG_STATE_IDLE (2) /* Started and waiting for commands */
|
||||
#define USBSTRG_STATE_CMDPARSE (3) /* Processing a received command */
|
||||
#define USBSTRG_STATE_CMDREAD (4) /* Processing a SCSI read command */
|
||||
#define USBSTRG_STATE_CMDWRITE (5) /* Processing a SCSI write command */
|
||||
#define USBSTRG_STATE_CMDFINISH (6) /* Finish command processing */
|
||||
#define USBSTRG_STATE_CMDSTATUS (7) /* Processing the final status of the command */
|
||||
#define USBSTRG_STATE_TERMINATED (8) /* Thread has exitted */
|
||||
#define USBMSC_STATE_NOTSTARTED (0) /* Thread has not yet been started */
|
||||
#define USBMSC_STATE_STARTED (1) /* Started, but is not yet initialized */
|
||||
#define USBMSC_STATE_IDLE (2) /* Started and waiting for commands */
|
||||
#define USBMSC_STATE_CMDPARSE (3) /* Processing a received command */
|
||||
#define USBMSC_STATE_CMDREAD (4) /* Processing a SCSI read command */
|
||||
#define USBMSC_STATE_CMDWRITE (5) /* Processing a SCSI write command */
|
||||
#define USBMSC_STATE_CMDFINISH (6) /* Finish command processing */
|
||||
#define USBMSC_STATE_CMDSTATUS (7) /* Processing the final status of the command */
|
||||
#define USBMSC_STATE_TERMINATED (8) /* Thread has exitted */
|
||||
|
||||
/* Event communicated to worker thread */
|
||||
|
||||
#define USBSTRG_EVENT_NOEVENTS (0) /* There are no outstanding events */
|
||||
#define USBSTRG_EVENT_READY (1 << 0) /* Initialization is complete */
|
||||
#define USBSTRG_EVENT_RDCOMPLETE (1 << 1) /* A read has completed there is data to be processed */
|
||||
#define USBSTRG_EVENT_WRCOMPLETE (1 << 2) /* A write has completed and a request is available */
|
||||
#define USBSTRG_EVENT_TERMINATEREQUEST (1 << 3) /* Shutdown requested */
|
||||
#define USBSTRG_EVENT_DISCONNECT (1 << 4) /* USB disconnect received */
|
||||
#define USBSTRG_EVENT_RESET (1 << 5) /* USB storage setup reset received */
|
||||
#define USBSTRG_EVENT_CFGCHANGE (1 << 6) /* USB setup configuration change received */
|
||||
#define USBSTRG_EVENT_IFCHANGE (1 << 7) /* USB setup interface change received */
|
||||
#define USBSTRG_EVENT_ABORTBULKOUT (1 << 8) /* SCSI receive failure */
|
||||
#define USBMSC_EVENT_NOEVENTS (0) /* There are no outstanding events */
|
||||
#define USBMSC_EVENT_READY (1 << 0) /* Initialization is complete */
|
||||
#define USBMSC_EVENT_RDCOMPLETE (1 << 1) /* A read has completed there is data to be processed */
|
||||
#define USBMSC_EVENT_WRCOMPLETE (1 << 2) /* A write has completed and a request is available */
|
||||
#define USBMSC_EVENT_TERMINATEREQUEST (1 << 3) /* Shutdown requested */
|
||||
#define USBMSC_EVENT_DISCONNECT (1 << 4) /* USB disconnect received */
|
||||
#define USBMSC_EVENT_RESET (1 << 5) /* USB storage setup reset received */
|
||||
#define USBMSC_EVENT_CFGCHANGE (1 << 6) /* USB setup configuration change received */
|
||||
#define USBMSC_EVENT_IFCHANGE (1 << 7) /* USB setup interface change received */
|
||||
#define USBMSC_EVENT_ABORTBULKOUT (1 << 8) /* SCSI receive failure */
|
||||
|
||||
/* SCSI command flags (passed to usbstrg_setupcmd()) */
|
||||
/* SCSI command flags (passed to usbmsc_setupcmd()) */
|
||||
|
||||
#define USBSTRG_FLAGS_DIRMASK (0x03) /* Bits 0-1: Data direction */
|
||||
#define USBSTRG_FLAGS_DIRNONE (0x00) /* No data to send */
|
||||
#define USBSTRG_FLAGS_DIRHOST2DEVICE (0x01) /* Host-to-device */
|
||||
#define USBSTRG_FLAGS_DIRDEVICE2HOST (0x02) /* Device-to-host */
|
||||
#define USBSTRG_FLAGS_BLOCKXFR (0x04) /* Bit 2: Command is a block transfer request */
|
||||
#define USBSTRG_FLAGS_LUNNOTNEEDED (0x08) /* Bit 3: Command does not require a valid LUN */
|
||||
#define USBSTRG_FLAGS_UACOKAY (0x10) /* Bit 4: Command OK if unit attention condition */
|
||||
#define USBSTRG_FLAGS_RETAINSENSEDATA (0x20) /* Bit 5: Do not clear sense data */
|
||||
#define USBMSC_FLAGS_DIRMASK (0x03) /* Bits 0-1: Data direction */
|
||||
#define USBMSC_FLAGS_DIRNONE (0x00) /* No data to send */
|
||||
#define USBMSC_FLAGS_DIRHOST2DEVICE (0x01) /* Host-to-device */
|
||||
#define USBMSC_FLAGS_DIRDEVICE2HOST (0x02) /* Device-to-host */
|
||||
#define USBMSC_FLAGS_BLOCKXFR (0x04) /* Bit 2: Command is a block transfer request */
|
||||
#define USBMSC_FLAGS_LUNNOTNEEDED (0x08) /* Bit 3: Command does not require a valid LUN */
|
||||
#define USBMSC_FLAGS_UACOKAY (0x10) /* Bit 4: Command OK if unit attention condition */
|
||||
#define USBMSC_FLAGS_RETAINSENSEDATA (0x20) /* Bit 5: Do not clear sense data */
|
||||
|
||||
/* Descriptors **************************************************************/
|
||||
|
||||
/* Big enough to hold our biggest descriptor */
|
||||
|
||||
#define USBSTRG_MXDESCLEN (64)
|
||||
#define USBMSC_MXDESCLEN (64)
|
||||
|
||||
/* String language */
|
||||
|
||||
#define USBSTRG_STR_LANGUAGE (0x0409) /* en-us */
|
||||
#define USBMSC_STR_LANGUAGE (0x0409) /* en-us */
|
||||
|
||||
/* Descriptor strings */
|
||||
|
||||
#ifndef CONFIG_USBSTRG_COMPOSITE
|
||||
# define USBSTRG_MANUFACTURERSTRID (1)
|
||||
# define USBSTRG_PRODUCTSTRID (2)
|
||||
# define USBSTRG_SERIALSTRID (3)
|
||||
# define USBSTRG_CONFIGSTRID (4)
|
||||
# define USBSTRG_INTERFACESTRID USBSTRG_CONFIGSTRID
|
||||
#ifndef CONFIG_USBMSC_COMPOSITE
|
||||
# define USBMSC_MANUFACTURERSTRID (1)
|
||||
# define USBMSC_PRODUCTSTRID (2)
|
||||
# define USBMSC_SERIALSTRID (3)
|
||||
# define USBMSC_CONFIGSTRID (4)
|
||||
# define USBMSC_INTERFACESTRID USBMSC_CONFIGSTRID
|
||||
|
||||
# undef CONFIG_USBSTRG_STRBASE
|
||||
# define CONFIG_USBSTRG_STRBASE (4)
|
||||
# undef CONFIG_USBMSC_STRBASE
|
||||
# define CONFIG_USBMSC_STRBASE (4)
|
||||
#else
|
||||
# define USBSTRG_INTERFACESTRID (CONFIG_USBSTRG_STRBASE+1)
|
||||
# define USBMSC_INTERFACESTRID (CONFIG_USBMSC_STRBASE+1)
|
||||
#endif
|
||||
#define USBSTRG_LASTSTRID USBSTRG_INTERFACESTRID
|
||||
#define USBMSC_LASTSTRID USBMSC_INTERFACESTRID
|
||||
|
||||
#define USBSTRG_NCONFIGS (1) /* Number of configurations supported */
|
||||
#define USBMSC_NCONFIGS (1) /* Number of configurations supported */
|
||||
|
||||
/* Configuration Descriptor */
|
||||
|
||||
#define USBSTRG_NINTERFACES (1) /* Number of interfaces in the configuration */
|
||||
#define USBSTRG_INTERFACEID (CONFIG_USBSTRG_IFNOBASE+0)
|
||||
#define USBSTRG_ALTINTERFACEID USBSTRG_INTERFACEID
|
||||
#define USBMSC_NINTERFACES (1) /* Number of interfaces in the configuration */
|
||||
#define USBMSC_INTERFACEID (CONFIG_USBMSC_IFNOBASE+0)
|
||||
#define USBMSC_ALTINTERFACEID USBMSC_INTERFACEID
|
||||
|
||||
#define USBSTRG_CONFIGIDNONE (0) /* Config ID means to return to address mode */
|
||||
#define USBSTRG_CONFIGID (1) /* The only supported configuration ID */
|
||||
#define USBMSC_CONFIGIDNONE (0) /* Config ID means to return to address mode */
|
||||
#define USBMSC_CONFIGID (1) /* The only supported configuration ID */
|
||||
|
||||
/* Interface description */
|
||||
|
||||
#define USBSTRG_NENDPOINTS (2) /* Number of endpoints in the interface */
|
||||
#define USBMSC_NENDPOINTS (2) /* Number of endpoints in the interface */
|
||||
|
||||
/* Endpoint configuration */
|
||||
|
||||
#define USBSTRG_EPOUTBULK_ADDR (CONFIG_USBSTRG_EPBULKOUT)
|
||||
#define USBSTRG_EPOUTBULK_ATTR (USB_EP_ATTR_XFER_BULK)
|
||||
#define USBMSC_EPOUTBULK_ADDR (CONFIG_USBMSC_EPBULKOUT)
|
||||
#define USBMSC_EPOUTBULK_ATTR (USB_EP_ATTR_XFER_BULK)
|
||||
|
||||
#define USBSTRG_EPINBULK_ADDR (USB_DIR_IN|CONFIG_USBSTRG_EPBULKIN)
|
||||
#define USBSTRG_EPINBULK_ATTR (USB_EP_ATTR_XFER_BULK)
|
||||
#define USBMSC_EPINBULK_ADDR (USB_DIR_IN|CONFIG_USBMSC_EPBULKIN)
|
||||
#define USBMSC_EPINBULK_ATTR (USB_EP_ATTR_XFER_BULK)
|
||||
|
||||
#define USBSTRG_HSBULKMAXPACKET (512)
|
||||
#define USBSTRG_HSBULKMXPKTSHIFT (9)
|
||||
#define USBSTRG_HSBULKMXPKTMASK (0x000001ff)
|
||||
#define USBSTRG_FSBULKMAXPACKET (64)
|
||||
#define USBSTRG_FSBULKMXPKTSHIFT (6)
|
||||
#define USBSTRG_FSBULKMXPKTMASK (0x0000003f)
|
||||
#define USBMSC_HSBULKMAXPACKET (512)
|
||||
#define USBMSC_HSBULKMXPKTSHIFT (9)
|
||||
#define USBMSC_HSBULKMXPKTMASK (0x000001ff)
|
||||
#define USBMSC_FSBULKMAXPACKET (64)
|
||||
#define USBMSC_FSBULKMXPKTSHIFT (6)
|
||||
#define USBMSC_FSBULKMXPKTMASK (0x0000003f)
|
||||
|
||||
/* Macros for dual speed vs. full speed only operation */
|
||||
|
||||
#ifdef CONFIG_USBDEV_DUALSPEED
|
||||
# define USBSTRG_EPBULKINDESC(hs) \
|
||||
usbstrg_getepdesc((hs) ? USBSTRG_EPHSBULKIN : USBSTRG_EPFSBULKIN)
|
||||
# define USBSTRG_EPBULKOUTDESC(hs) \
|
||||
usbstrg_getepdesc((hs) ? USBSTRG_EPHSBULKOUT : USBSTRG_EPFSBULKOUT)
|
||||
# define USBSTRG_BULKMAXPACKET(hs) \
|
||||
((hs) ? USBSTRG_HSBULKMAXPACKET : USBSTRG_FSBULKMAXPACKET)
|
||||
# define USBSTRG_BULKMXPKTSHIFT(d) \
|
||||
(((d)->speed==USB_SPEED_HIGH) ? USBSTRG_HSBULKMXPKTSHIFT : USBSTRG_FSBULKMXPKTSHIFT)
|
||||
# define USBSTRG_BULKMXPKTMASK(d) \
|
||||
(((d)->speed==USB_SPEED_HIGH) ? USBSTRG_HSBULKMXPKTMASK : USBSTRG_FSBULKMXPKTMASK)
|
||||
# define USBMSC_EPBULKINDESC(hs) \
|
||||
usbmsc_getepdesc((hs) ? USBMSC_EPHSBULKIN : USBMSC_EPFSBULKIN)
|
||||
# define USBMSC_EPBULKOUTDESC(hs) \
|
||||
usbmsc_getepdesc((hs) ? USBMSC_EPHSBULKOUT : USBMSC_EPFSBULKOUT)
|
||||
# define USBMSC_BULKMAXPACKET(hs) \
|
||||
((hs) ? USBMSC_HSBULKMAXPACKET : USBMSC_FSBULKMAXPACKET)
|
||||
# define USBMSC_BULKMXPKTSHIFT(d) \
|
||||
(((d)->speed==USB_SPEED_HIGH) ? USBMSC_HSBULKMXPKTSHIFT : USBMSC_FSBULKMXPKTSHIFT)
|
||||
# define USBMSC_BULKMXPKTMASK(d) \
|
||||
(((d)->speed==USB_SPEED_HIGH) ? USBMSC_HSBULKMXPKTMASK : USBMSC_FSBULKMXPKTMASK)
|
||||
#else
|
||||
# define USBSTRG_EPBULKINDESC(d) usbstrg_getepdesc(USBSTRG_EPFSBULKIN)
|
||||
# define USBSTRG_EPBULKOUTDESC(d) usbstrg_getepdesc(USBSTRG_EPFSBULKOUT)
|
||||
# define USBSTRG_BULKMAXPACKET(hs) USBSTRG_FSBULKMAXPACKET
|
||||
# define USBSTRG_BULKMXPKTSHIFT(d) USBSTRG_FSBULKMXPKTSHIFT
|
||||
# define USBSTRG_BULKMXPKTMASK(d) USBSTRG_FSBULKMXPKTMASK
|
||||
# define USBMSC_EPBULKINDESC(d) usbmsc_getepdesc(USBMSC_EPFSBULKIN)
|
||||
# define USBMSC_EPBULKOUTDESC(d) usbmsc_getepdesc(USBMSC_EPFSBULKOUT)
|
||||
# define USBMSC_BULKMAXPACKET(hs) USBMSC_FSBULKMAXPACKET
|
||||
# define USBMSC_BULKMXPKTSHIFT(d) USBMSC_FSBULKMXPKTSHIFT
|
||||
# define USBMSC_BULKMXPKTMASK(d) USBMSC_FSBULKMXPKTMASK
|
||||
#endif
|
||||
|
||||
/* Configuration descriptor size */
|
||||
|
||||
#ifndef CONFIG_USBSTRG_COMPOSITE
|
||||
#ifndef CONFIG_USBMSC_COMPOSITE
|
||||
|
||||
/* Number of individual descriptors in the configuration descriptor:
|
||||
* (1) Configuration descriptor + (1) interface descriptor + (2) interface
|
||||
* descriptors.
|
||||
*/
|
||||
|
||||
# define USBSTRG_CFGGROUP_SIZE (4)
|
||||
# define USBMSC_CFGGROUP_SIZE (4)
|
||||
|
||||
/* The size of the config descriptor: (9 + 9 + 2*7) = 32 */
|
||||
|
||||
# define SIZEOF_USBSTRG_CFGDESC \
|
||||
# define SIZEOF_USBMSC_CFGDESC \
|
||||
(USB_SIZEOF_CFGDESC + USB_SIZEOF_IFDESC + 2*USB_SIZEOF_EPDESC)
|
||||
#else
|
||||
|
||||
@@ -376,18 +376,18 @@
|
||||
* (1) interface descriptor + (2) interface descriptors.
|
||||
*/
|
||||
|
||||
# define USBSTRG_CFGGROUP_SIZE (3)
|
||||
# define USBMSC_CFGGROUP_SIZE (3)
|
||||
|
||||
/* The size of the config descriptor: (9 + 2*7) = 23 */
|
||||
|
||||
# define SIZEOF_USBSTRG_CFGDESC (USB_SIZEOF_IFDESC + 2*USB_SIZEOF_EPDESC)
|
||||
# define SIZEOF_USBMSC_CFGDESC (USB_SIZEOF_IFDESC + 2*USB_SIZEOF_EPDESC)
|
||||
#endif
|
||||
|
||||
/* Block driver helpers *****************************************************/
|
||||
|
||||
#define USBSTRG_DRVR_READ(l,b,s,n) ((l)->inode->u.i_bops->read((l)->inode,b,s,n))
|
||||
#define USBSTRG_DRVR_WRITE(l,b,s,n) ((l)->inode->u.i_bops->write((l)->inode,b,s,n))
|
||||
#define USBSTRG_DRVR_GEOMETRY(l,g) ((l)->inode->u.i_bops->geometry((l)->inode,g))
|
||||
#define USBMSC_DRVR_READ(l,b,s,n) ((l)->inode->u.i_bops->read((l)->inode,b,s,n))
|
||||
#define USBMSC_DRVR_WRITE(l,b,s,n) ((l)->inode->u.i_bops->write((l)->inode,b,s,n))
|
||||
#define USBMSC_DRVR_GEOMETRY(l,g) ((l)->inode->u.i_bops->geometry((l)->inode,g))
|
||||
|
||||
/* Everpresent MIN/MAX macros ***********************************************/
|
||||
|
||||
@@ -404,28 +404,28 @@
|
||||
****************************************************************************/
|
||||
/* Endpoint descriptors */
|
||||
|
||||
enum usbstrg_epdesc_e
|
||||
enum usbmsc_epdesc_e
|
||||
{
|
||||
USBSTRG_EPFSBULKOUT = 0, /* Full speed bulk OUT endpoint descriptor */
|
||||
USBSTRG_EPFSBULKIN /* Full speed bulk IN endpoint descriptor */
|
||||
USBMSC_EPFSBULKOUT = 0, /* Full speed bulk OUT endpoint descriptor */
|
||||
USBMSC_EPFSBULKIN /* Full speed bulk IN endpoint descriptor */
|
||||
#ifdef CONFIG_USBDEV_DUALSPEED
|
||||
,
|
||||
USBSTRG_EPHSBULKOUT, /* High speed bulk OUT endpoint descriptor */
|
||||
USBSTRG_EPHSBULKIN /* High speed bulk IN endpoint descriptor */
|
||||
USBMSC_EPHSBULKOUT, /* High speed bulk OUT endpoint descriptor */
|
||||
USBMSC_EPHSBULKIN /* High speed bulk IN endpoint descriptor */
|
||||
#endif
|
||||
};
|
||||
|
||||
/* Container to support a list of requests */
|
||||
|
||||
struct usbstrg_req_s
|
||||
struct usbmsc_req_s
|
||||
{
|
||||
FAR struct usbstrg_req_s *flink; /* Implements a singly linked list */
|
||||
FAR struct usbmsc_req_s *flink; /* Implements a singly linked list */
|
||||
FAR struct usbdev_req_s *req; /* The contained request */
|
||||
};
|
||||
|
||||
/* This structure describes one LUN: */
|
||||
|
||||
struct usbstrg_lun_s
|
||||
struct usbmsc_lun_s
|
||||
{
|
||||
struct inode *inode; /* Inode structure of open'ed block driver */
|
||||
uint8_t readonly:1; /* Media is read-only */
|
||||
@@ -440,7 +440,7 @@ struct usbstrg_lun_s
|
||||
|
||||
/* Describes the overall state of the driver */
|
||||
|
||||
struct usbstrg_dev_s
|
||||
struct usbmsc_dev_s
|
||||
{
|
||||
FAR struct usbdev_s *usbdev; /* usbdev driver pointer (Non-null if registered) */
|
||||
|
||||
@@ -466,12 +466,12 @@ struct usbstrg_dev_s
|
||||
|
||||
/* SCSI command processing */
|
||||
|
||||
struct usbstrg_lun_s *lun; /* Currently selected LUN */
|
||||
struct usbstrg_lun_s *luntab; /* Allocated table of all LUNs */
|
||||
uint8_t cdb[USBSTRG_MAXCDBLEN]; /* Command data (cdb[]) from CBW */
|
||||
struct usbmsc_lun_s *lun; /* Currently selected LUN */
|
||||
struct usbmsc_lun_s *luntab; /* Allocated table of all LUNs */
|
||||
uint8_t cdb[USBMSC_MAXCDBLEN]; /* Command data (cdb[]) from CBW */
|
||||
uint8_t phaseerror:1; /* Need to send phase sensing status */
|
||||
uint8_t shortpacket:1; /* Host transmission stopped unexpectedly */
|
||||
uint8_t cbwdir:2; /* Direction from CBW. See USBSTRG_FLAGS_DIR* definitions */
|
||||
uint8_t cbwdir:2; /* Direction from CBW. See USBMSC_FLAGS_DIR* definitions */
|
||||
uint8_t cdblen; /* Length of cdb[] from CBW */
|
||||
uint8_t cbwlun; /* LUN from the CBW */
|
||||
uint16_t nsectbytes; /* Bytes buffered in iobuffer[] */
|
||||
@@ -498,8 +498,8 @@ struct usbstrg_dev_s
|
||||
* EPBULKIN; Read requests will be queued in the EBULKOUT.
|
||||
*/
|
||||
|
||||
struct usbstrg_req_s wrreqs[CONFIG_USBSTRG_NWRREQS];
|
||||
struct usbstrg_req_s rdreqs[CONFIG_USBSTRG_NRDREQS];
|
||||
struct usbmsc_req_s wrreqs[CONFIG_USBMSC_NWRREQS];
|
||||
struct usbmsc_req_s rdreqs[CONFIG_USBMSC_NRDREQS];
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
@@ -519,7 +519,7 @@ extern "C"
|
||||
|
||||
/* Mass storage class vendor/product/serial number strings */
|
||||
|
||||
#ifndef CONFIG_USBSTRG_COMPOSITE
|
||||
#ifndef CONFIG_USBMSC_COMPOSITE
|
||||
EXTERN const char g_mscvendorstr[];
|
||||
EXTERN const char g_mscproductstr[];
|
||||
EXTERN const char g_mscserialstr[];
|
||||
@@ -542,7 +542,7 @@ EXTERN const char g_compserialstr[];
|
||||
************************************************************************************/
|
||||
|
||||
/************************************************************************************
|
||||
* Name: usbstrg_mkstrdesc
|
||||
* Name: usbmsc_mkstrdesc
|
||||
*
|
||||
* Description:
|
||||
* Construct a string descriptor
|
||||
@@ -550,22 +550,22 @@ EXTERN const char g_compserialstr[];
|
||||
************************************************************************************/
|
||||
|
||||
struct usb_strdesc_s;
|
||||
int usbstrg_mkstrdesc(uint8_t id, struct usb_strdesc_s *strdesc);
|
||||
int usbmsc_mkstrdesc(uint8_t id, struct usb_strdesc_s *strdesc);
|
||||
|
||||
/************************************************************************************
|
||||
* Name: usbstrg_getepdesc
|
||||
* Name: usbmsc_getepdesc
|
||||
*
|
||||
* Description:
|
||||
* Return a pointer to the raw device descriptor
|
||||
*
|
||||
************************************************************************************/
|
||||
|
||||
#ifndef CONFIG_USBSTRG_COMPOSITE
|
||||
FAR const struct usb_devdesc_s *usbstrg_getdevdesc(void);
|
||||
#ifndef CONFIG_USBMSC_COMPOSITE
|
||||
FAR const struct usb_devdesc_s *usbmsc_getdevdesc(void);
|
||||
#endif
|
||||
|
||||
/************************************************************************************
|
||||
* Name: usbstrg_getepdesc
|
||||
* Name: usbmsc_getepdesc
|
||||
*
|
||||
* Description:
|
||||
* Return a pointer to the raw endpoint descriptor (used for configuring endpoints)
|
||||
@@ -573,10 +573,10 @@ FAR const struct usb_devdesc_s *usbstrg_getdevdesc(void);
|
||||
************************************************************************************/
|
||||
|
||||
struct usb_epdesc_s;
|
||||
FAR const struct usb_epdesc_s *usbstrg_getepdesc(enum usbstrg_epdesc_e epid);
|
||||
FAR const struct usb_epdesc_s *usbmsc_getepdesc(enum usbmsc_epdesc_e epid);
|
||||
|
||||
/************************************************************************************
|
||||
* Name: usbstrg_mkcfgdesc
|
||||
* Name: usbmsc_mkcfgdesc
|
||||
*
|
||||
* Description:
|
||||
* Construct the configuration descriptor
|
||||
@@ -584,25 +584,25 @@ FAR const struct usb_epdesc_s *usbstrg_getepdesc(enum usbstrg_epdesc_e epid);
|
||||
************************************************************************************/
|
||||
|
||||
#ifdef CONFIG_USBDEV_DUALSPEED
|
||||
int16_t usbstrg_mkcfgdesc(FAR uint8_t *buf, uint8_t speed, uint8_t type);
|
||||
int16_t usbmsc_mkcfgdesc(FAR uint8_t *buf, uint8_t speed, uint8_t type);
|
||||
#else
|
||||
int16_t usbstrg_mkcfgdesc(FAR uint8_t *buf);
|
||||
int16_t usbmsc_mkcfgdesc(FAR uint8_t *buf);
|
||||
#endif
|
||||
|
||||
/************************************************************************************
|
||||
* Name: usbstrg_getqualdesc
|
||||
* Name: usbmsc_getqualdesc
|
||||
*
|
||||
* Description:
|
||||
* Return a pointer to the raw qual descriptor
|
||||
*
|
||||
************************************************************************************/
|
||||
|
||||
#if !defined(CONFIG_USBSTRG_COMPOSITE) && defined(CONFIG_USBDEV_DUALSPEED)
|
||||
FAR const struct usb_qualdesc_s *usbstrg_getqualdesc(void);
|
||||
#if !defined(CONFIG_USBMSC_COMPOSITE) && defined(CONFIG_USBDEV_DUALSPEED)
|
||||
FAR const struct usb_qualdesc_s *usbmsc_getqualdesc(void);
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: usbstrg_workerthread
|
||||
* Name: usbmsc_workerthread
|
||||
*
|
||||
* Description:
|
||||
* This is the main function of the USB storage worker thread. It loops
|
||||
@@ -610,10 +610,10 @@ FAR const struct usb_qualdesc_s *usbstrg_getqualdesc(void);
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
EXTERN void *usbstrg_workerthread(void *arg);
|
||||
EXTERN void *usbmsc_workerthread(void *arg);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: usbstrg_setconfig
|
||||
* Name: usbmsc_setconfig
|
||||
*
|
||||
* Description:
|
||||
* Set the device configuration by allocating and configuring endpoints and
|
||||
@@ -621,20 +621,20 @@ EXTERN void *usbstrg_workerthread(void *arg);
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
EXTERN int usbstrg_setconfig(FAR struct usbstrg_dev_s *priv, uint8_t config);
|
||||
EXTERN int usbmsc_setconfig(FAR struct usbmsc_dev_s *priv, uint8_t config);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: usbstrg_resetconfig
|
||||
* Name: usbmsc_resetconfig
|
||||
*
|
||||
* Description:
|
||||
* Mark the device as not configured and disable all endpoints.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
EXTERN void usbstrg_resetconfig(FAR struct usbstrg_dev_s *priv);
|
||||
EXTERN void usbmsc_resetconfig(FAR struct usbmsc_dev_s *priv);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: usbstrg_wrcomplete
|
||||
* Name: usbmsc_wrcomplete
|
||||
*
|
||||
* Description:
|
||||
* Handle completion of write request. This function probably executes
|
||||
@@ -642,11 +642,11 @@ EXTERN void usbstrg_resetconfig(FAR struct usbstrg_dev_s *priv);
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
EXTERN void usbstrg_wrcomplete(FAR struct usbdev_ep_s *ep,
|
||||
FAR struct usbdev_req_s *req);
|
||||
EXTERN void usbmsc_wrcomplete(FAR struct usbdev_ep_s *ep,
|
||||
FAR struct usbdev_req_s *req);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: usbstrg_rdcomplete
|
||||
* Name: usbmsc_rdcomplete
|
||||
*
|
||||
* Description:
|
||||
* Handle completion of read request on the bulk OUT endpoint. This
|
||||
@@ -654,11 +654,11 @@ EXTERN void usbstrg_wrcomplete(FAR struct usbdev_ep_s *ep,
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
EXTERN void usbstrg_rdcomplete(FAR struct usbdev_ep_s *ep,
|
||||
FAR struct usbdev_req_s *req);
|
||||
EXTERN void usbmsc_rdcomplete(FAR struct usbdev_ep_s *ep,
|
||||
FAR struct usbdev_req_s *req);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: usbstrg_deferredresponse
|
||||
* Name: usbmsc_deferredresponse
|
||||
*
|
||||
* Description:
|
||||
* Some EP0 setup request cannot be responded to immediately becuase they
|
||||
@@ -668,7 +668,7 @@ EXTERN void usbstrg_rdcomplete(FAR struct usbdev_ep_s *ep,
|
||||
*
|
||||
* 1. USB_REQ_SETCONFIGURATION,
|
||||
* 2. USB_REQ_SETINTERFACE, or
|
||||
* 3. USBSTRG_REQ_MSRESET
|
||||
* 3. USBMSC_REQ_MSRESET
|
||||
*
|
||||
* In all cases, the success reponse is a zero-length packet; the failure
|
||||
* response is an EP0 stall.
|
||||
@@ -679,7 +679,7 @@ EXTERN void usbstrg_rdcomplete(FAR struct usbdev_ep_s *ep,
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
EXTERN void usbstrg_deferredresponse(FAR struct usbstrg_dev_s *priv, bool failed);
|
||||
EXTERN void usbmsc_deferredresponse(FAR struct usbmsc_dev_s *priv, bool failed);
|
||||
|
||||
#undef EXTERN
|
||||
#if defined(__cplusplus)
|
||||
|
||||
@@ -71,7 +71,7 @@
|
||||
* composite device logic.
|
||||
*/
|
||||
|
||||
#ifndef CONFIG_USBSTRG_COMPOSITE
|
||||
#ifndef CONFIG_USBMSC_COMPOSITE
|
||||
static const struct usb_devdesc_s g_devdesc =
|
||||
{
|
||||
USB_SIZEOF_DEVDESC, /* len */
|
||||
@@ -80,22 +80,22 @@ static const struct usb_devdesc_s g_devdesc =
|
||||
USB_CLASS_PER_INTERFACE, /* class */
|
||||
0, /* subclass */
|
||||
0, /* protocol */
|
||||
CONFIG_USBSTRG_EP0MAXPACKET, /* maxpacketsize */
|
||||
CONFIG_USBMSC_EP0MAXPACKET, /* maxpacketsize */
|
||||
{ /* vendor */
|
||||
LSBYTE(CONFIG_USBSTRG_VENDORID),
|
||||
MSBYTE(CONFIG_USBSTRG_VENDORID)
|
||||
LSBYTE(CONFIG_USBMSC_VENDORID),
|
||||
MSBYTE(CONFIG_USBMSC_VENDORID)
|
||||
},
|
||||
{ /* product */
|
||||
LSBYTE(CONFIG_USBSTRG_PRODUCTID),
|
||||
MSBYTE(CONFIG_USBSTRG_PRODUCTID) },
|
||||
LSBYTE(CONFIG_USBMSC_PRODUCTID),
|
||||
MSBYTE(CONFIG_USBMSC_PRODUCTID) },
|
||||
{ /* device */
|
||||
LSBYTE(CONFIG_USBSTRG_VERSIONNO),
|
||||
MSBYTE(CONFIG_USBSTRG_VERSIONNO)
|
||||
LSBYTE(CONFIG_USBMSC_VERSIONNO),
|
||||
MSBYTE(CONFIG_USBMSC_VERSIONNO)
|
||||
},
|
||||
USBSTRG_MANUFACTURERSTRID, /* imfgr */
|
||||
USBSTRG_PRODUCTSTRID, /* iproduct */
|
||||
USBSTRG_SERIALSTRID, /* serno */
|
||||
USBSTRG_NCONFIGS /* nconfigs */
|
||||
USBMSC_MANUFACTURERSTRID, /* imfgr */
|
||||
USBMSC_PRODUCTSTRID, /* iproduct */
|
||||
USBMSC_SERIALSTRID, /* serno */
|
||||
USBMSC_NCONFIGS /* nconfigs */
|
||||
};
|
||||
#endif
|
||||
|
||||
@@ -104,15 +104,15 @@ static const struct usb_devdesc_s g_devdesc =
|
||||
* composite device logic.
|
||||
*/
|
||||
|
||||
#ifndef CONFIG_USBSTRG_COMPOSITE
|
||||
#ifndef CONFIG_USBMSC_COMPOSITE
|
||||
static const struct usb_cfgdesc_s g_cfgdesc =
|
||||
{
|
||||
USB_SIZEOF_CFGDESC, /* len */
|
||||
USB_DESC_TYPE_CONFIG, /* type */
|
||||
{0, 0}, /* totallen -- to be provided */
|
||||
USBSTRG_NINTERFACES, /* ninterfaces */
|
||||
USBSTRG_CONFIGID, /* cfgvalue */
|
||||
USBSTRG_CONFIGSTRID, /* icfg */
|
||||
USBMSC_NINTERFACES, /* ninterfaces */
|
||||
USBMSC_CONFIGID, /* cfgvalue */
|
||||
USBMSC_CONFIGSTRID, /* icfg */
|
||||
USB_CONFIG_ATTR_ONE|SELFPOWERED|REMOTEWAKEUP, /* attr */
|
||||
(CONFIG_USBDEV_MAXPOWER + 1) / 2 /* mxpower */
|
||||
};
|
||||
@@ -124,13 +124,13 @@ static const struct usb_ifdesc_s g_ifdesc =
|
||||
{
|
||||
USB_SIZEOF_IFDESC, /* len */
|
||||
USB_DESC_TYPE_INTERFACE, /* type */
|
||||
USBSTRG_INTERFACEID, /* ifno */
|
||||
USBSTRG_ALTINTERFACEID, /* alt */
|
||||
USBSTRG_NENDPOINTS, /* neps */
|
||||
USBMSC_INTERFACEID, /* ifno */
|
||||
USBMSC_ALTINTERFACEID, /* alt */
|
||||
USBMSC_NENDPOINTS, /* neps */
|
||||
USB_CLASS_MASS_STORAGE, /* class */
|
||||
USBSTRG_SUBCLASS_SCSI, /* subclass */
|
||||
USBSTRG_PROTO_BULKONLY, /* protocol */
|
||||
USBSTRG_INTERFACESTRID /* iif */
|
||||
USBMSC_SUBCLASS_SCSI, /* subclass */
|
||||
USBMSC_PROTO_BULKONLY, /* protocol */
|
||||
USBMSC_INTERFACESTRID /* iif */
|
||||
};
|
||||
|
||||
/* Endpoint descriptors */
|
||||
@@ -139,11 +139,11 @@ static const struct usb_epdesc_s g_fsepbulkoutdesc =
|
||||
{
|
||||
USB_SIZEOF_EPDESC, /* len */
|
||||
USB_DESC_TYPE_ENDPOINT, /* type */
|
||||
USBSTRG_EPOUTBULK_ADDR, /* addr */
|
||||
USBSTRG_EPOUTBULK_ATTR, /* attr */
|
||||
USBMSC_EPOUTBULK_ADDR, /* addr */
|
||||
USBMSC_EPOUTBULK_ATTR, /* attr */
|
||||
{ /* maxpacket */
|
||||
LSBYTE(USBSTRG_FSBULKMAXPACKET),
|
||||
MSBYTE(USBSTRG_FSBULKMAXPACKET)
|
||||
LSBYTE(USBMSC_FSBULKMAXPACKET),
|
||||
MSBYTE(USBMSC_FSBULKMAXPACKET)
|
||||
},
|
||||
0 /* interval */
|
||||
};
|
||||
@@ -152,17 +152,17 @@ static const struct usb_epdesc_s g_fsepbulkindesc =
|
||||
{
|
||||
USB_SIZEOF_EPDESC, /* len */
|
||||
USB_DESC_TYPE_ENDPOINT, /* type */
|
||||
USBSTRG_EPINBULK_ADDR, /* addr */
|
||||
USBSTRG_EPINBULK_ATTR, /* attr */
|
||||
USBMSC_EPINBULK_ADDR, /* addr */
|
||||
USBMSC_EPINBULK_ATTR, /* attr */
|
||||
{ /* maxpacket */
|
||||
LSBYTE(USBSTRG_FSBULKMAXPACKET),
|
||||
MSBYTE(USBSTRG_FSBULKMAXPACKET)
|
||||
LSBYTE(USBMSC_FSBULKMAXPACKET),
|
||||
MSBYTE(USBMSC_FSBULKMAXPACKET)
|
||||
},
|
||||
0 /* interval */
|
||||
};
|
||||
|
||||
#ifdef CONFIG_USBDEV_DUALSPEED
|
||||
#ifndef CONFIG_USBSTRG_COMPOSITE
|
||||
#ifndef CONFIG_USBMSC_COMPOSITE
|
||||
static const struct usb_qualdesc_s g_qualdesc =
|
||||
{
|
||||
USB_SIZEOF_QUALDESC, /* len */
|
||||
@@ -174,8 +174,8 @@ static const struct usb_qualdesc_s g_qualdesc =
|
||||
USB_CLASS_PER_INTERFACE, /* class */
|
||||
0, /* subclass */
|
||||
0, /* protocol */
|
||||
CONFIG_USBSTRG_EP0MAXPACKET, /* mxpacketsize */
|
||||
USBSTRG_NCONFIGS, /* nconfigs */
|
||||
CONFIG_USBMSC_EP0MAXPACKET, /* mxpacketsize */
|
||||
USBMSC_NCONFIGS, /* nconfigs */
|
||||
0, /* reserved */
|
||||
};
|
||||
#endif
|
||||
@@ -184,11 +184,11 @@ static const struct usb_epdesc_s g_hsepbulkoutdesc =
|
||||
{
|
||||
USB_SIZEOF_EPDESC, /* len */
|
||||
USB_DESC_TYPE_ENDPOINT, /* type */
|
||||
USBSTRG_EPOUTBULK_ADDR, /* addr */
|
||||
USBSTRG_EPOUTBULK_ATTR, /* attr */
|
||||
USBMSC_EPOUTBULK_ADDR, /* addr */
|
||||
USBMSC_EPOUTBULK_ATTR, /* attr */
|
||||
{ /* maxpacket */
|
||||
LSBYTE(USBSTRG_HSBULKMAXPACKET),
|
||||
MSBYTE(USBSTRG_HSBULKMAXPACKET)
|
||||
LSBYTE(USBMSC_HSBULKMAXPACKET),
|
||||
MSBYTE(USBMSC_HSBULKMAXPACKET)
|
||||
},
|
||||
0 /* interval */
|
||||
};
|
||||
@@ -197,11 +197,11 @@ static const struct usb_epdesc_s g_hsepbulkindesc =
|
||||
{
|
||||
USB_SIZEOF_EPDESC, /* len */
|
||||
USB_DESC_TYPE_ENDPOINT, /* type */
|
||||
USBSTRG_EPINBULK_ADDR, /* addr */
|
||||
USBSTRG_EPINBULK_ATTR, /* attr */
|
||||
USBMSC_EPINBULK_ADDR, /* addr */
|
||||
USBMSC_EPINBULK_ATTR, /* attr */
|
||||
{ /* maxpacket */
|
||||
LSBYTE(USBSTRG_HSBULKMAXPACKET),
|
||||
MSBYTE(USBSTRG_HSBULKMAXPACKET)
|
||||
LSBYTE(USBMSC_HSBULKMAXPACKET),
|
||||
MSBYTE(USBMSC_HSBULKMAXPACKET)
|
||||
},
|
||||
0 /* interval */
|
||||
};
|
||||
@@ -212,10 +212,10 @@ static const struct usb_epdesc_s g_hsepbulkindesc =
|
||||
****************************************************************************/
|
||||
/* Strings ******************************************************************/
|
||||
|
||||
#ifndef CONFIG_USBSTRG_COMPOSITE
|
||||
const char g_msccendorstr[] = CONFIG_USBSTRG_VENDORSTR;
|
||||
const char g_mscproductstr[] = CONFIG_USBSTRG_PRODUCTSTR;
|
||||
const char g_mscserialstr[] = CONFIG_USBSTRG_SERIALSTR;
|
||||
#ifndef CONFIG_USBMSC_COMPOSITE
|
||||
const char g_msccendorstr[] = CONFIG_USBMSC_VENDORSTR;
|
||||
const char g_mscproductstr[] = CONFIG_USBMSC_PRODUCTSTR;
|
||||
const char g_mscserialstr[] = CONFIG_USBMSC_SERIALSTR;
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
@@ -227,14 +227,14 @@ const char g_mscserialstr[] = CONFIG_USBSTRG_SERIALSTR;
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: usbstrg_mkstrdesc
|
||||
* Name: usbmsc_mkstrdesc
|
||||
*
|
||||
* Description:
|
||||
* Construct a string descriptor
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int usbstrg_mkstrdesc(uint8_t id, struct usb_strdesc_s *strdesc)
|
||||
int usbmsc_mkstrdesc(uint8_t id, struct usb_strdesc_s *strdesc)
|
||||
{
|
||||
const char *str;
|
||||
int len;
|
||||
@@ -243,34 +243,34 @@ int usbstrg_mkstrdesc(uint8_t id, struct usb_strdesc_s *strdesc)
|
||||
|
||||
switch (id)
|
||||
{
|
||||
#ifndef CONFIG_USBSTRG_COMPOSITE
|
||||
#ifndef CONFIG_USBMSC_COMPOSITE
|
||||
case 0:
|
||||
{
|
||||
/* Descriptor 0 is the language id */
|
||||
|
||||
strdesc->len = 4;
|
||||
strdesc->type = USB_DESC_TYPE_STRING;
|
||||
strdesc->data[0] = LSBYTE(USBSTRG_STR_LANGUAGE);
|
||||
strdesc->data[1] = MSBYTE(USBSTRG_STR_LANGUAGE);
|
||||
strdesc->data[0] = LSBYTE(USBMSC_STR_LANGUAGE);
|
||||
strdesc->data[1] = MSBYTE(USBMSC_STR_LANGUAGE);
|
||||
return 4;
|
||||
}
|
||||
|
||||
case USBSTRG_MANUFACTURERSTRID:
|
||||
case USBMSC_MANUFACTURERSTRID:
|
||||
str = g_vendorstr;
|
||||
break;
|
||||
|
||||
case USBSTRG_PRODUCTSTRID:
|
||||
case USBMSC_PRODUCTSTRID:
|
||||
str = g_productstr;
|
||||
break;
|
||||
|
||||
case USBSTRG_SERIALSTRID:
|
||||
case USBMSC_SERIALSTRID:
|
||||
str = g_serialstr;
|
||||
break;
|
||||
#endif
|
||||
|
||||
/* case USBSTRG_CONFIGSTRID: */
|
||||
case USBSTRG_INTERFACESTRID:
|
||||
str = CONFIG_USBSTRG_CONFIGSTR;
|
||||
/* case USBMSC_CONFIGSTRID: */
|
||||
case USBMSC_INTERFACESTRID:
|
||||
str = CONFIG_USBMSC_CONFIGSTR;
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -294,22 +294,22 @@ int usbstrg_mkstrdesc(uint8_t id, struct usb_strdesc_s *strdesc)
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: usbstrg_getepdesc
|
||||
* Name: usbmsc_getepdesc
|
||||
*
|
||||
* Description:
|
||||
* Return a pointer to the raw device descriptor
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef CONFIG_USBSTRG_COMPOSITE
|
||||
FAR const struct usb_devdesc_s *usbstrg_getdevdesc(void)
|
||||
#ifndef CONFIG_USBMSC_COMPOSITE
|
||||
FAR const struct usb_devdesc_s *usbmsc_getdevdesc(void)
|
||||
{
|
||||
return &g_devdesc;
|
||||
}
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: usbstrg_getepdesc
|
||||
* Name: usbmsc_getepdesc
|
||||
*
|
||||
* Description:
|
||||
* Return a pointer to the raw endpoint descriptor (used for configuring
|
||||
@@ -317,21 +317,21 @@ FAR const struct usb_devdesc_s *usbstrg_getdevdesc(void)
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
FAR const struct usb_epdesc_s *usbstrg_getepdesc(enum usbstrg_epdesc_e epid)
|
||||
FAR const struct usb_epdesc_s *usbmsc_getepdesc(enum usbmsc_epdesc_e epid)
|
||||
{
|
||||
switch (epid)
|
||||
{
|
||||
case USBSTRG_EPFSBULKOUT: /* Full speed bulk OUT endpoint descriptor */
|
||||
case USBMSC_EPFSBULKOUT: /* Full speed bulk OUT endpoint descriptor */
|
||||
return &g_fsepbulkoutdesc;
|
||||
|
||||
case USBSTRG_EPFSBULKIN: /* Full speed bulk IN endpoint descriptor */
|
||||
case USBMSC_EPFSBULKIN: /* Full speed bulk IN endpoint descriptor */
|
||||
return &g_fsepbulkindesc;
|
||||
|
||||
#ifdef CONFIG_USBDEV_DUALSPEED
|
||||
case USBSTRG_EPHSBULKOUT: /* High speed bulk OUT endpoint descriptor */
|
||||
case USBMSC_EPHSBULKOUT: /* High speed bulk OUT endpoint descriptor */
|
||||
return &g_hsepbulkoutdesc;
|
||||
|
||||
case USBSTRG_EPHSBULKIN: /* High speed bulk IN endpoint descriptor */
|
||||
case USBMSC_EPHSBULKIN: /* High speed bulk IN endpoint descriptor */
|
||||
return &g_hsepbulkindesc;
|
||||
#endif
|
||||
default:
|
||||
@@ -340,7 +340,7 @@ FAR const struct usb_epdesc_s *usbstrg_getepdesc(enum usbstrg_epdesc_e epid)
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
* Name: usbstrg_mkcfgdesc
|
||||
* Name: usbmsc_mkcfgdesc
|
||||
*
|
||||
* Description:
|
||||
* Construct the configuration descriptor
|
||||
@@ -348,12 +348,12 @@ FAR const struct usb_epdesc_s *usbstrg_getepdesc(enum usbstrg_epdesc_e epid)
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_USBDEV_DUALSPEED
|
||||
int16_t usbstrg_mkcfgdesc(uint8_t *buf, uint8_t speed, uint8_t type)
|
||||
int16_t usbmsc_mkcfgdesc(uint8_t *buf, uint8_t speed, uint8_t type)
|
||||
#else
|
||||
int16_t usbstrg_mkcfgdesc(uint8_t *buf)
|
||||
int16_t usbmsc_mkcfgdesc(uint8_t *buf)
|
||||
#endif
|
||||
{
|
||||
#ifndef CONFIG_USBSTRG_COMPOSITE
|
||||
#ifndef CONFIG_USBMSC_COMPOSITE
|
||||
FAR struct usb_cfgdesc_s *cfgdesc = (struct usb_cfgdesc_s*)buf;
|
||||
#endif
|
||||
#ifdef CONFIG_USBDEV_DUALSPEED
|
||||
@@ -367,7 +367,7 @@ int16_t usbstrg_mkcfgdesc(uint8_t *buf)
|
||||
* size that we will be sending now.
|
||||
*/
|
||||
|
||||
totallen = USB_SIZEOF_CFGDESC + USB_SIZEOF_IFDESC + USBSTRG_NENDPOINTS * USB_SIZEOF_EPDESC;
|
||||
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
|
||||
@@ -375,7 +375,7 @@ int16_t usbstrg_mkcfgdesc(uint8_t *buf)
|
||||
* descriptor will be provided by the composite device logic.
|
||||
*/
|
||||
|
||||
#ifndef CONFIG_USBSTRG_COMPOSITE
|
||||
#ifndef CONFIG_USBMSC_COMPOSITE
|
||||
memcpy(cfgdesc, &g_cfgdesc, USB_SIZEOF_CFGDESC);
|
||||
buf += USB_SIZEOF_CFGDESC;
|
||||
#endif
|
||||
@@ -396,12 +396,12 @@ int16_t usbstrg_mkcfgdesc(uint8_t *buf)
|
||||
hispeed = !hispeed;
|
||||
}
|
||||
|
||||
bulkmxpacket = USBSTRG_BULKMAXPACKET(hispeed);
|
||||
epdesc = USBSTRG_EPBULKINDESC(hispeed);
|
||||
bulkmxpacket = USBMSC_BULKMAXPACKET(hispeed);
|
||||
epdesc = USBMSC_EPBULKINDESC(hispeed);
|
||||
memcpy(buf, epdesc, USB_SIZEOF_EPDESC);
|
||||
buf += USB_SIZEOF_EPDESC;
|
||||
|
||||
epdesc = USBSTRG_EPBULKOUTDESC(hispeed);
|
||||
epdesc = USBMSC_EPBULKOUTDESC(hispeed);
|
||||
memcpy(buf, epdesc, USB_SIZEOF_EPDESC);
|
||||
#else
|
||||
memcpy(buf, &g_fsepbulkoutdesc, USB_SIZEOF_EPDESC);
|
||||
@@ -411,7 +411,7 @@ int16_t usbstrg_mkcfgdesc(uint8_t *buf)
|
||||
|
||||
/* Finally, fill in the total size of the configuration descriptor */
|
||||
|
||||
#ifndef CONFIG_USBSTRG_COMPOSITE
|
||||
#ifndef CONFIG_USBMSC_COMPOSITE
|
||||
cfgdesc->totallen[0] = LSBYTE(totallen);
|
||||
cfgdesc->totallen[1] = MSBYTE(totallen);
|
||||
#endif
|
||||
@@ -419,15 +419,15 @@ int16_t usbstrg_mkcfgdesc(uint8_t *buf)
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: usbstrg_getqualdesc
|
||||
* Name: usbmsc_getqualdesc
|
||||
*
|
||||
* Description:
|
||||
* Return a pointer to the raw qual descriptor
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#if !defined(CONFIG_USBSTRG_COMPOSITE) && defined(CONFIG_USBDEV_DUALSPEED)
|
||||
FAR const struct usb_qualdesc_s *usbstrg_getqualdesc(void)
|
||||
#if !defined(CONFIG_USBMSC_COMPOSITE) && defined(CONFIG_USBDEV_DUALSPEED)
|
||||
FAR const struct usb_qualdesc_s *usbmsc_getqualdesc(void)
|
||||
{
|
||||
return &g_qualdesc;
|
||||
}
|
||||
|
||||
+432
-432
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user