diff options
-rw-r--r-- | nuttx/ChangeLog | 6 | ||||
-rw-r--r-- | nuttx/Documentation/NuttxPortingGuide.html | 55 | ||||
-rw-r--r-- | nuttx/TODO | 22 | ||||
-rw-r--r-- | nuttx/configs/README.txt | 45 | ||||
-rwxr-xr-x | nuttx/configs/stm3210e-eval/usbserial/defconfig | 65 | ||||
-rw-r--r-- | nuttx/drivers/usbdev/Make.defs | 4 | ||||
-rw-r--r-- | nuttx/drivers/usbdev/cdc_serial.c | 554 | ||||
-rw-r--r-- | nuttx/drivers/usbdev/usbdev_serial.c | 10 | ||||
-rwxr-xr-x | nuttx/include/nuttx/usb/cdc.h | 1737 | ||||
-rw-r--r-- | nuttx/include/nuttx/usb/cdc_serial.h | 40 | ||||
-rw-r--r-- | nuttx/include/nuttx/usb/usb.h | 28 | ||||
-rw-r--r-- | nuttx/include/nuttx/usb/usbdev_trace.h | 2 | ||||
-rw-r--r-- | nuttx/lib/stdio/lib_fopen.c | 4 |
13 files changed, 1431 insertions, 1141 deletions
diff --git a/nuttx/ChangeLog b/nuttx/ChangeLog index 1c3666876..c916d8cf9 100644 --- a/nuttx/ChangeLog +++ b/nuttx/ChangeLog @@ -2080,3 +2080,9 @@ 6.10 2011-xx-xx Gregory Nutt <spudmonkey@racsa.co.cr> + * lib/stdio/lib_fopen.c: Fix an error in fopen(); the file pointer was not + being positioned at the end of the file when the "a" and "a+" modes are + used. There are other issues with the "a+" modes (see the top-level TODO + list). + * drivers/usbdev/cdc_serial.c and include/nuttx/usb/cdc.h and cdc_serial.h: + Add support for the CDC ACM serial device class.
\ No newline at end of file diff --git a/nuttx/Documentation/NuttxPortingGuide.html b/nuttx/Documentation/NuttxPortingGuide.html index e02e85cc5..de02f2519 100644 --- a/nuttx/Documentation/NuttxPortingGuide.html +++ b/nuttx/Documentation/NuttxPortingGuide.html @@ -12,7 +12,7 @@ <h1><big><font color="#3c34ec"> <i>NuttX RTOS Porting Guide</i> </font></big></h1> - <p>Last Updated: September 4, 2011</p> + <p>Last Updated: September 13, 2011</p> </td> </tr> </table> @@ -4744,7 +4744,7 @@ build </li> </ul> -<h3>USB Serial Device Class Driver</h3> +<h3>USB Serial Device Class Driver (Prolific PL2303 Emulation)</h3> <ul> <li> <code>CONFIG_USBSER</code>: Enable compilation of the USB serial driver @@ -4772,6 +4772,57 @@ build </li> </ul> +<h3>USB serial device class driver (Standard CDC ACM class)</h3> +<ul> + <li> + <code>CONFIG_CDCSER</code>: Enable compilation of the USB serial driver + </li> + <li> + <code>CONFIG_CDCSER_EP0MAXPACKET</code>: Endpoint 0 max packet size. Default 8. + </li> + <li> + <code>CONFIG_CDCSER_EPINTIN</code>: The logical 7-bit address of a hardware endpoint that supports + interrupt IN operation. Default 2. + </li> + <li> + <code>CONFIG_CDCSER_EPINTIN_FSSIZE</code>: Max package size for the interrupt IN endpoint if full speed mode. Default 64. + </li> + <li> + <code>CONFIG_CDCSER_EPINTIN_HSSIZE</code>: Max package size for the interrupt IN endpoint if high speed mode. Default 512. + </li> + <li> + <code>CONFIG_CDCSER_EPBULKOUT</code>: The logical 7-bit address of a hardware endpoint that supports + bulk OUT operation. + </li> + <li> + <code>CONFIG_CDCSER_EPBULKOUT_FSSIZE</code>: Max package size for the bulk OUT endpoint if full speed mode. Default 64. + </li> + <li> + <code>CONFIG_CDCSER_EPBULKOUT_HSSIZE</code>: Max package size for the bulk OUT endpoint if high speed mode. Default 512. + </li> + <li> + <code>CONFIG_CDCSER_EPBULKIN</code>: The logical 7-bit address of a hardware endpoint that supports + bulk IN operation + </li> + <li> + <code>CONFIG_CDCSER_EPBULKIN_FSSIZE</code>: Max package size for the bulk IN endpoint if full speed mode. Default 64. + </li> + <li> + <code>CONFIG_CDCSER_EPBULKIN_HSSIZE</code>: Max package size for the bulk IN endpoint if high speed mode. Default 512. + </li> + <li> + <code>CONFIG_CDCSER_NWRREQS</code> and <code>CONFIG_CDCSER_NRDREQS</code>: The number of write/read requests that can be in flight. Default 4. + </li> + <li> + <code>CONFIG_CDCSER_VENDORID</code> and <code>CONFIG_CDCSER_VENDORSTR</code>: The vendor ID code/string. Default 0x03eb and "NuttX" + </li> + <li> + <code>CONFIG_CDCSER_PRODUCTID</code> and <code>CONFIG_CDCSER_PRODUCTSTR</code>: The product ID code/string. Default 0x204b and "CDC/ACM Serial" + </li> + <li> + <code>CONFIG_CDCSER_RXBUFSIZE</code> and <code>CONFIG_CDCSER_TXBUFSIZE</code>: Size of the serial receive/transmit buffers. Default 256. +</ul> + <h3>USB Storage Device Configuration</h3> <ul> <li> diff --git a/nuttx/TODO b/nuttx/TODO index 5eba13ace..71cba9523 100644 --- a/nuttx/TODO +++ b/nuttx/TODO @@ -1,5 +1,5 @@ -NuttX TODO List (Last updated September 9, 2011) -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +NuttX TODO List (Last updated September 12, 2011) +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ This file summarizes known NuttX bugs, limitations, inconsistencies with standards, things that could be improved, and ideas for enhancements. @@ -15,7 +15,7 @@ nuttx/ (5) Binary loaders (binfmt/) (16) Network (net/, drivers/net) (2) USB (drivers/usbdev, drivers/usbhost) - (6) Libraries (lib/) + (7) Libraries (lib/) (9) File system/Generic drivers (fs/, drivers/) (2) Graphics subystem (graphics/) (1) Pascal add-on (pcode/) @@ -415,6 +415,22 @@ o Libraries (lib/) Status: Open Priority: Low + Description: NuttX only supports a single file pointer so reads and writes + must be from the same position. This prohibits implementation + of behavior like that required for fopen() with the "a+" mode. + According to the fopen man page: + + "a+ Open for reading and appending (writing at end of file). + The file is created if it does not exist. The initial file + position for reading is at the beginning of the file, but + output is always appended to the end of the file." + + At present, the single NuttX file pointer is positioned to the + end of the file for both reading and writing. + Status: Open + Priority: Medium. This kind of operation is probably not very common in + deeply embedded systems but is required by standards. + o File system / Generic drivers (fs/, drivers/) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/nuttx/configs/README.txt b/nuttx/configs/README.txt index f958e3085..32767c1c2 100644 --- a/nuttx/configs/README.txt +++ b/nuttx/configs/README.txt @@ -922,7 +922,7 @@ defconfig -- This is a configuration file similar to the Linux CONFIG_USBHOST_BULK_DISABLE=n, CONFIG_NFILE_DESCRIPTORS > 0, and CONFIG_SCHED_WORKQUEUE=y - USB serial device class driver + USB serial device class driver (Prolific PL2303 Emulation) CONFIG_USBSER Enable compilation of the USB serial driver @@ -944,6 +944,49 @@ defconfig -- This is a configuration file similar to the Linux CONFIG_USBSER_RXBUFSIZE and CONFIG_USBSER_TXBUFSIZE Size of the serial receive/transmit buffers + USB serial device class driver (Standard CDC ACM class) + + CONFIG_CDCSER + Enable compilation of the USB serial driver + CONFIG_CDCSER_EP0MAXPACKET + Endpoint 0 max packet size. Default 8. + CONFIG_CDCSER_EPINTIN + The logical 7-bit address of a hardware endpoint that supports + interrupt IN operation. Default 2. + CONFIG_CDCSER_EPINTIN_FSSIZE + Max package size for the interrupt IN endpoint if full speed mode. + Default 64. + CONFIG_CDCSER_EPINTIN_HSSIZE + Max package size for the interrupt IN endpoint if high speed mode. + Default 512. + CONFIG_CDCSER_EPBULKOUT + The logical 7-bit address of a hardware endpoint that supports + bulk OUT operation + CONFIG_CDCSER_EPBULKOUT_FSSIZE + Max package size for the bulk OUT endpoint if full speed mode. + Default 64. + CONFIG_CDCSER_EPBULKOUT_HSSIZE + Max package size for the bulk OUT endpoint if high speed mode. + Default 512. + CONFIG_CDCSER_EPBULKIN + The logical 7-bit address of a hardware endpoint that supports + bulk IN operation + CONFIG_CDCSER_EPBULKIN_FSSIZE + Max package size for the bulk IN endpoint if full speed mode. + Default 64. + CONFIG_CDCSER_EPBULKIN_HSSIZE + Max package size for the bulk IN endpoint if high speed mode. + Default 512. + CONFIG_CDCSER_NWRREQS and CONFIG_CDCSER_NRDREQS + The number of write/read requests that can be in flight. + Default 256. + CONFIG_CDCSER_VENDORID and CONFIG_CDCSER_VENDORSTR + The vendor ID code/string. Default 0x03eb and "NuttX" + CONFIG_CDCSER_PRODUCTID and CONFIG_CDCSER_PRODUCTSTR + The product ID code/string. Default 0x204b and "CDC/ACM Serial" + CONFIG_CDCSER_RXBUFSIZE and CONFIG_CDCSER_TXBUFSIZE + Size of the serial receive/transmit buffers. Default 256. + USB Storage Device Configuration CONFIG_USBSTRG diff --git a/nuttx/configs/stm3210e-eval/usbserial/defconfig b/nuttx/configs/stm3210e-eval/usbserial/defconfig index 362951cd3..cb4d9fb4c 100755 --- a/nuttx/configs/stm3210e-eval/usbserial/defconfig +++ b/nuttx/configs/stm3210e-eval/usbserial/defconfig @@ -633,7 +633,7 @@ CONFIG_USBDEV_TRACE=n CONFIG_USBDEV_TRACE_NRECORDS=128 # -# USB Serial Device Configuration +# USB Serial Device Configuration (Prolific PL2303 Emulation) # # CONFIG_USBSER # Enable compilation of the USB serial driver @@ -669,6 +669,69 @@ CONFIG_USBSER_RXBUFSIZE=512 CONFIG_USBSER_TXBUFSIZE=512 # +# USB serial device class driver (Standard CDC ACM class) +# +# CONFIG_CDCSER +# Enable compilation of the USB serial driver +# CONFIG_CDCSER_EP0MAXPACKET +# Endpoint 0 max packet size. Default 8. +# CONFIG_CDCSER_EPINTIN +# The logical 7-bit address of a hardware endpoint that supports +# interrupt IN operation. Default 2. +# CONFIG_CDCSER_EPINTIN_FSSIZE +# Max package size for the interrupt IN endpoint if full speed mode. +# Default 64. +# CONFIG_CDCSER_EPINTIN_HSSIZE +# Max package size for the interrupt IN endpoint if high speed mode. +# Default 512. +# CONFIG_CDCSER_EPBULKOUT +# The logical 7-bit address of a hardware endpoint that supports +# bulk OUT operation +# CONFIG_CDCSER_EPBULKOUT_FSSIZE +# Max package size for the bulk OUT endpoint if full speed mode. +# Default 64. +# CONFIG_CDCSER_EPBULKOUT_HSSIZE +# Max package size for the bulk OUT endpoint if high speed mode. +# Default 512. +# CONFIG_CDCSER_EPBULKIN +# The logical 7-bit address of a hardware endpoint that supports +# bulk IN operation +# CONFIG_CDCSER_EPBULKIN_FSSIZE +# Max package size for the bulk IN endpoint if full speed mode. +# Default 64. +# CONFIG_CDCSER_EPBULKIN_HSSIZE +# Max package size for the bulk IN endpoint if high speed mode. +# Default 512. +# CONFIG_CDCSER_NWRREQS and CONFIG_CDCSER_NRDREQS +# The number of write/read requests that can be in flight. +# Default 256. +# CONFIG_CDCSER_VENDORID and CONFIG_CDCSER_VENDORSTR +# The vendor ID code/string. Default 0x03eb and "NuttX" +# CONFIG_CDCSER_PRODUCTID and CONFIG_CDCSER_PRODUCTSTR +# The product ID code/string. Default 0x204b and "CDC/ACM Serial" +# CONFIG_CDCSER_RXBUFSIZE and CONFIG_CDCSER_TXBUFSIZE +# Size of the serial receive/transmit buffers. Default 256. +# +CONFIG_CDCSER=n +#CONFIG_CDCSER_EP0MAXPACKET +#CONFIG_CDCSER_EPINTIN +#CONFIG_CDCSER_EPINTIN_FSSIZE +#CONFIG_CDCSER_EPINTIN_HSSIZE +#CONFIG_CDCSER_EPBULKOUT +#CONFIG_CDCSER_EPBULKOUT_FSSIZE +#CONFIG_CDCSER_EPBULKOUT_HSSIZE +#CONFIG_CDCSER_EPBULKIN +#CONFIG_CDCSER_EPBULKIN_FSSIZE +#CONFIG_CDCSER_EPBULKIN_HSSIZE +#CONFIG_CDCSER_NWRREQS +#CONFIG_CDCSER_NRDREQS +#CONFIG_CDCSER_VENDORID +#CONFIG_CDCSER_VENDORSTR +#CONFIG_CDCSER_PRODUCTID +#CONFIG_CDCSER_PRODUCTSTR +#CONFIG_CDCSER_RXBUFSIZE +#CONFIG_CDCSER_TXBUFSIZE + # USB Storage Device Configuration # # CONFIG_USBSTRG diff --git a/nuttx/drivers/usbdev/Make.defs b/nuttx/drivers/usbdev/Make.defs index 2a1c51625..1a0a8d412 100644 --- a/nuttx/drivers/usbdev/Make.defs +++ b/nuttx/drivers/usbdev/Make.defs @@ -41,6 +41,10 @@ ifeq ($(CONFIG_USBSER),y) CSRCS += usbdev_serial.c endif +ifeq ($(CONFIG_CDCSER),y) + CSRCS += cdc_serial.c +endif + ifeq ($(CONFIG_USBSTRG),y) CSRCS += usbdev_storage.c usbdev_scsi.c endif diff --git a/nuttx/drivers/usbdev/cdc_serial.c b/nuttx/drivers/usbdev/cdc_serial.c index 21f3680db..6e14ca6e8 100644 --- a/nuttx/drivers/usbdev/cdc_serial.c +++ b/nuttx/drivers/usbdev/cdc_serial.c @@ -56,6 +56,7 @@ #include <nuttx/serial.h> #include <nuttx/usb/usb.h> +#include <nuttx/usb/cdc.h> #include <nuttx/usb/usbdev.h> #include <nuttx/usb/cdc_serial.h> #include <nuttx/usb/usbdev_trace.h> @@ -102,6 +103,8 @@ #define CDCSER_PRODUCTSTRID (2) #define CDCSER_SERIALSTRID (3) #define CDCSER_CONFIGSTRID (4) +#define CDCSER_NOTIFSTRID (5) +#define CDCSER_DATAIFSTRID (6) /* Number of individual descriptors in the configuration descriptor */ @@ -131,18 +134,18 @@ /* Trace values *************************************************************/ -#define CDCSER_CLASSAPI_SETUP TRACE_EVENT(TRACE_CLASSAPI_ID, CDCSER_TRACECLASSAPI_SETUP) -#define CDCSER_CLASSAPI_SHUTDOWN TRACE_EVENT(TRACE_CLASSAPI_ID, CDCSER_TRACECLASSAPI_SHUTDOWN) -#define CDCSER_CLASSAPI_ATTACH TRACE_EVENT(TRACE_CLASSAPI_ID, CDCSER_TRACECLASSAPI_ATTACH) -#define CDCSER_CLASSAPI_DETACH TRACE_EVENT(TRACE_CLASSAPI_ID, CDCSER_TRACECLASSAPI_DETACH) -#define CDCSER_CLASSAPI_IOCTL TRACE_EVENT(TRACE_CLASSAPI_ID, CDCSER_TRACECLASSAPI_IOCTL) -#define CDCSER_CLASSAPI_RECEIVE TRACE_EVENT(TRACE_CLASSAPI_ID, CDCSER_TRACECLASSAPI_RECEIVE) -#define CDCSER_CLASSAPI_RXINT TRACE_EVENT(TRACE_CLASSAPI_ID, CDCSER_TRACECLASSAPI_RXINT) -#define CDCSER_CLASSAPI_RXAVAILABLE TRACE_EVENT(TRACE_CLASSAPI_ID, CDCSER_TRACECLASSAPI_RXAVAILABLE) -#define CDCSER_CLASSAPI_SEND TRACE_EVENT(TRACE_CLASSAPI_ID, CDCSER_TRACECLASSAPI_SEND) -#define CDCSER_CLASSAPI_TXINT TRACE_EVENT(TRACE_CLASSAPI_ID, CDCSER_TRACECLASSAPI_TXINT) -#define CDCSER_CLASSAPI_TXREADY TRACE_EVENT(TRACE_CLASSAPI_ID, CDCSER_TRACECLASSAPI_TXREADY) -#define CDCSER_CLASSAPI_TXEMPTY TRACE_EVENT(TRACE_CLASSAPI_ID, CDCSER_TRACECLASSAPI_TXEMPTY) +#define CDCSER_CLASSAPI_SETUP TRACE_EVENT(TRACE_CLASSAPI_ID, USBSER_TRACECLASSAPI_SETUP) +#define CDCSER_CLASSAPI_SHUTDOWN TRACE_EVENT(TRACE_CLASSAPI_ID, USBSER_TRACECLASSAPI_SHUTDOWN) +#define CDCSER_CLASSAPI_ATTACH TRACE_EVENT(TRACE_CLASSAPI_ID, USBSER_TRACECLASSAPI_ATTACH) +#define CDCSER_CLASSAPI_DETACH TRACE_EVENT(TRACE_CLASSAPI_ID, USBSER_TRACECLASSAPI_DETACH) +#define CDCSER_CLASSAPI_IOCTL TRACE_EVENT(TRACE_CLASSAPI_ID, USBSER_TRACECLASSAPI_IOCTL) +#define CDCSER_CLASSAPI_RECEIVE TRACE_EVENT(TRACE_CLASSAPI_ID, USBSER_TRACECLASSAPI_RECEIVE) +#define CDCSER_CLASSAPI_RXINT TRACE_EVENT(TRACE_CLASSAPI_ID, USBSER_TRACECLASSAPI_RXINT) +#define CDCSER_CLASSAPI_RXAVAILABLE TRACE_EVENT(TRACE_CLASSAPI_ID, USBSER_TRACECLASSAPI_RXAVAILABLE) +#define CDCSER_CLASSAPI_SEND TRACE_EVENT(TRACE_CLASSAPI_ID, USBSER_TRACECLASSAPI_SEND) +#define CDCSER_CLASSAPI_TXINT TRACE_EVENT(TRACE_CLASSAPI_ID, USBSER_TRACECLASSAPI_TXINT) +#define CDCSER_CLASSAPI_TXREADY TRACE_EVENT(TRACE_CLASSAPI_ID, USBSER_TRACECLASSAPI_TXREADY) +#define CDCSER_CLASSAPI_TXEMPTY TRACE_EVENT(TRACE_CLASSAPI_ID, USBSER_TRACECLASSAPI_TXEMPTY) /**************************************************************************** * Private Types @@ -152,29 +155,31 @@ struct usbser_req_s { - FAR struct usbser_req_s *flink; /* Implements a singly linked list */ - FAR struct usbdev_req_s *req; /* The contained request */ + FAR struct usbser_req_s *flink; /* Implements a singly linked list */ + FAR struct usbdev_req_s *req; /* The contained request */ }; /* This structure describes the internal state of the driver */ struct usbser_dev_s { - FAR struct uart_dev_s serdev; /* Serial device structure */ - FAR struct usbdev_s *usbdev; /* usbdev driver pointer */ - - uint8_t config; /* Configuration number */ - uint8_t nwrq; /* Number of queue write requests (in reqlist)*/ - uint8_t nrdq; /* Number of queue read requests (in epbulkout) */ - bool rxenabled; /* true: UART RX "interrupts" enabled */ - uint8_t linest[7]; /* Fake line status */ - int16_t rxhead; /* Working head; used when rx int disabled */ - - FAR struct usbdev_ep_s *epintin; /* Interrupt IN endpoint structure */ - FAR struct usbdev_ep_s *epbulkin; /* Bulk IN endpoint structure */ - FAR struct usbdev_ep_s *epbulkout; /* Bulk OUT endpoint structure */ - FAR struct usbdev_req_s *ctrlreq; /* Control request */ - struct sq_queue_s reqlist; /* List of write request containers */ + FAR struct uart_dev_s serdev; /* Serial device structure */ + FAR struct usbdev_s *usbdev; /* usbdev driver pointer */ + + uint8_t config; /* Configuration number */ + uint8_t nwrq; /* Number of queue write requests (in reqlist)*/ + uint8_t nrdq; /* Number of queue read requests (in epbulkout) */ + bool rxenabled; /* true: UART RX "interrupts" enabled */ + int16_t rxhead; /* Working head; used when rx int disabled */ + + uint8_t ctrlline; /* Buffered control line state */ + struct cdc_linecoding_s linecoding; /* Buffered line status */ + + FAR struct usbdev_ep_s *epintin; /* Interrupt IN endpoint structure */ + FAR struct usbdev_ep_s *epbulkin; /* Bulk IN endpoint structure */ + FAR struct usbdev_ep_s *epbulkout; /* Bulk OUT endpoint structure */ + FAR struct usbdev_req_s *ctrlreq; /* Control request */ + struct sq_queue_s reqlist; /* List of write request containers */ /* Pre-allocated write request containers. The write requests will * be linked in a free list (reqlist), and used to send requests to @@ -212,8 +217,9 @@ struct usbser_alloc_s struct cfgdecsc_group_s { - FAR void *desc; - unsigned int size; + uint16_t descsize; /* Size of the descriptor in bytes */ + uint16_t hsepsize; /* High speed max packet size */ + FAR void *desc; /* A pointer to the descriptor */ }; /**************************************************************************** @@ -239,13 +245,18 @@ static void usbclass_freereq(FAR struct usbdev_ep_s *ep, static int usbclass_mkstrdesc(uint8_t id, struct usb_strdesc_s *strdesc); #ifdef CONFIG_USBDEV_DUALSPEED -static void usbclass_mkepbulkdesc(const struct usb_epdesc_s *indesc, - uint16_t mxpacket, struct usb_epdesc_s *outdesc); -static int16_t usbclass_mkcfgdesc(uint8_t *buf, uint8_t speed, uint8_t type); +static void usbclass_mkepdesc(FAR const struct usb_epdesc_s *indesc, + uint16_t mxpacket, FAR struct usb_epdesc_s *outdesc); +static int16_t usbclass_mkcfgdesc(FAR uint8_t *buf, uint8_t speed, uint8_t type); #else -static int16_t usbclass_mkcfgdesc(uint8_t *buf); +static int16_t usbclass_mkcfgdesc(FAR uint8_t *buf); #endif static void usbclass_resetconfig(FAR struct usbser_dev_s *priv); +#ifdef CONFIG_USBDEV_DUALSPEED +static int usbclass_epconfigure(FAR struct usbdev_ep_s *ep, + FAR const struct usb_epdesc_s *indesc, uint16_t mxpacket, + bool last); +#endif static int usbclass_setconfig(FAR struct usbser_dev_s *priv, uint8_t config); @@ -336,7 +347,7 @@ static const struct usb_devdesc_s g_devdesc = /* Configuration descriptor */ -static const struct usb_cfgdesc_s g_cfgdesc; +static const struct usb_cfgdesc_s g_cfgdesc = { USB_SIZEOF_CFGDESC, /* len */ USB_DESC_TYPE_CONFIG, /* type */ @@ -363,7 +374,11 @@ static const struct usb_ifdesc_s g_notifdesc = USB_CLASS_CDC, /* class */ CDC_SUBCLASS_ACM, /* subclass */ CDC_PROTO_ATM, /* proto */ +#ifdef CONFIG_CDCSER_NOTIFSTR CDCSER_NOTIFSTRID /* iif */ +#else + 0 /* iif */ +#endif }; /* Header functional descriptor */ @@ -397,7 +412,7 @@ static const struct cdc_union_funcdesc_s g_unionfunc = USB_DESC_TYPE_CSINTERFACE, /* type */ CDC_DSUBTYPE_UNION, /* subtype */ 0, /* master */ - 1 /* slave[0] */ + {1} /* slave[0] */ }; /* Interrupt IN endpoint descriptor */ @@ -408,8 +423,9 @@ static const struct usb_epdesc_s g_epintindesc = USB_DESC_TYPE_ENDPOINT, /* type */ CDCSER_EPINTIN_ADDR, /* addr */ CDCSER_EPINTIN_ATTR, /* attr */ - { LSBYTE(CONFIG_CDCSER_EPINTIN_SIZE), /* maxpacket */ - MSBYTE(CONFIG_CDCSER_EPINTIN_SIZE) + { + LSBYTE(CONFIG_CDCSER_EPINTIN_FSSIZE), /* maxpacket (full speed) */ + MSBYTE(CONFIG_CDCSER_EPINTIN_FSSIZE) }, 0xff /* interval */ }; @@ -426,7 +442,11 @@ static const struct usb_ifdesc_s g_dataifdesc = USB_CLASS_CDC_DATA, /* class */ CDC_DATA_SUBCLASS_NONE, /* subclass */ CDC_DATA_PROTO_NONE, /* proto */ +#ifdef CONFIG_CDCSER_DATAIFSTR CDCSER_DATAIFSTRID /* iif */ +#else + 0 /* iif */ +#endif }; /* Bulk OUT endpoint descriptor */ @@ -437,8 +457,9 @@ static const struct usb_epdesc_s g_epbulkoutdesc = USB_DESC_TYPE_ENDPOINT, /* type */ CDCSER_EPOUTBULK_ADDR, /* addr */ CDCSER_EPINTIN_ATTR, /* attr */ - { LSBYTE(CONFIG_CDCSER_BULKOUT_EPSIZE), /* maxpacket */ - MSBYTE(CONFIG_CDCSER_BULKOUT_EPSIZE) + { + LSBYTE(CONFIG_CDCSER_EPBULKOUT_FSSIZE), /* maxpacket (full speed) */ + MSBYTE(CONFIG_CDCSER_EPBULKOUT_FSSIZE) }, 1 /* interval */ }; @@ -451,8 +472,9 @@ static const struct usb_epdesc_s g_epbulkindesc = USB_DESC_TYPE_ENDPOINT, /* type */ CDCSER_EPINBULK_ADDR, /* addr */ CDCSER_EPINBULK_ATTR, /* attr */ - { LSBYTE(CONFIG_CDCSER_BULKIN_EPSIZE), /* maxpacket */ - MSBYTE(CONFIG_CDCSER_BULKIN_EPSIZE) + { + LSBYTE(CONFIG_CDCSER_EPBULKIN_FSSIZE), /* maxpacket (full speed) */ + MSBYTE(CONFIG_CDCSER_EPBULKIN_FSSIZE) }, 1 /* interval */ }; @@ -469,40 +491,49 @@ static const struct usb_epdesc_s g_epbulkindesc = static const struct cfgdecsc_group_s g_cfggroup[CDCSER_CFGGROUP_SIZE] = { { - (FAR void *)&g_cfgdesc, /* 1. Configuration descriptor */ - USB_SIZEOF_CFGDESC + USB_SIZEOF_CFGDESC, /* 1. Configuration descriptor */ + 0, + (FAR void *)&g_cfgdesc }, { - (FAR void *)&g_notifdesc, /* 2. Notification interface */ - USB_SIZEOF_IFDESC + USB_SIZEOF_IFDESC, /* 2. Notification interface */ + 0, + (FAR void *)&g_notifdesc }, { - (FAR void *)&g_funchdr, /* 3. Header functional descriptor */ - SIZEOF_HDR_FUNCDESC + SIZEOF_HDR_FUNCDESC, /* 3. Header functional descriptor */ + 0, + (FAR void *)&g_funchdr }, { - (FAR void *)&g_acmfunc, /* 4. ACM functional descriptor */ - SIZEOF_ACM_FUNCDESC + SIZEOF_ACM_FUNCDESC, /* 4. ACM functional descriptor */ + 0, + (FAR void *)&g_acmfunc }, { - (FAR void *)&g_unionfunc, /* 5. Union functional descriptor */ - SIZEOF_UNION_FUNCDESC(1) + SIZEOF_UNION_FUNCDESC(1), /* 5. Union functional descriptor */ + 0, + (FAR void *)&g_unionfunc }, { - (FAR void *)&g_epintindesc, /* 6. Interrupt IN endpoint descriptor */ - USB_SIZEOF_EPDESC + USB_SIZEOF_EPDESC, /* 6. Interrupt IN endpoint descriptor */ + CONFIG_CDCSER_EPINTIN_HSSIZE, + (FAR void *)&g_epintindesc }, { - (FAR void *)&g_dataifdesc, /* 7. Data interface descriptor */ - USB_SIZEOF_IFDESC + USB_SIZEOF_IFDESC, /* 7. Data interface descriptor */ + 0, + (FAR void *)&g_dataifdesc }, { - (FAR void *)&g_epbulkoutdesc, /* 8. Bulk OUT endpoint descriptor */ - USB_SIZEOF_EPDESC + USB_SIZEOF_EPDESC, /* 8. Bulk OUT endpoint descriptor */ + CONFIG_CDCSER_EPBULKOUT_HSSIZE, + (FAR void *)&g_epbulkoutdesc }, { - (FAR void *)&g_epbulkindesc, /* 9. Bulk OUT endpoint descriptor */ - USB_SIZEOF_EPDESC + USB_SIZEOF_EPDESC, /* 9. Bulk OUT endpoint descriptor */ + CONFIG_CDCSER_EPBULKIN_HSSIZE, + (FAR void *)&g_epbulkindesc } }; @@ -613,7 +644,7 @@ static int usbclass_sndpacket(FAR struct usbser_dev_s *priv) #ifdef CONFIG_DEBUG if (priv == NULL) { - usbtrace(TRACE_CLSERROR(CDCSER_TRACEERR_INVALIDARG), 0); + usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_INVALIDARG), 0); return -ENODEV; } #endif @@ -658,7 +689,7 @@ static int usbclass_sndpacket(FAR struct usbser_dev_s *priv) ret = EP_SUBMIT(ep, req); if (ret != OK) { - usbtrace(TRACE_CLSERROR(CDCSER_TRACEERR_SUBMITFAIL), (uint16_t)-ret); + usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_SUBMITFAIL), (uint16_t)-ret); break; } } @@ -774,7 +805,7 @@ static inline int usbclass_recvpacket(FAR struct usbser_dev_s *priv, if (nbytes < reqlen) { - usbtrace(TRACE_CLSERROR(CDCSER_TRACEERR_RXOVERRUN), 0); + usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_RXOVERRUN), 0); return -ENOSPC; } return OK; @@ -872,6 +903,18 @@ static int usbclass_mkstrdesc(uint8_t id, struct usb_strdesc_s *strdesc) str = CONFIG_CDCSER_CONFIGSTR; break; +#ifdef CONFIG_CDCSER_NOTIFSTR + case CDCSER_NOTIFSTRID: + str = CONFIG_CDCSER_NOTIFSTR; + break; +#endif + +#ifdef CONFIG_CDCSER_DATAIFSTR + case CDCSER_DATAIFSTRID: + str = CONFIG_CDCSER_DATAIFSTR; + break; +#endif + default: return -EINVAL; } @@ -893,19 +936,19 @@ static int usbclass_mkstrdesc(uint8_t id, struct usb_strdesc_s *strdesc) } /**************************************************************************** - * Name: usbclass_mkepbulkdesc + * Name: usbclass_mkepdesc * * Description: - * Construct the endpoint descriptor + * Construct the endpoint descriptor using the correct max packet size. * ****************************************************************************/ #ifdef CONFIG_USBDEV_DUALSPEED -static inline void usbclass_mkepbulkdesc(const FAR struct usb_epdesc_s *indesc, - uint16_t mxpacket, - FAR struct usb_epdesc_s *outdesc) +static inline void usbclass_mkepdesc(FAR const FAR struct usb_epdesc_s *indesc, + uint16_t mxpacket, + FAR struct usb_epdesc_s *outdesc) { - /* Copy the canned descriptor */ + /* Copy the "canned" descriptor */ memcpy(outdesc, indesc, USB_SIZEOF_EPDESC); @@ -925,74 +968,63 @@ static inline void usbclass_mkepbulkdesc(const FAR struct usb_epdesc_s *indesc, ****************************************************************************/ #ifdef CONFIG_USBDEV_DUALSPEED -static int16_t usbclass_mkcfgdesc(uint8_t *buf, uint8_t speed, uint8_t type) +static int16_t usbclass_mkcfgdesc(FAR uint8_t *buf, uint8_t speed, uint8_t type) #else -static int16_t usbclass_mkcfgdesc(uint8_t *buf) +static int16_t usbclass_mkcfgdesc(FAR uint8_t *buf) #endif { - FAR struct usb_cfgdesc_s *cfgdesc = (struct usb_cfgdesc_s*)buf; + FAR const struct cfgdecsc_group_s *group; + FAR uint8_t *dest = buf; + int i; + #ifdef CONFIG_USBDEV_DUALSPEED bool hispeed = (speed == USB_SPEED_HIGH); - uint16_t bulkmxpacket; -#endif - uint16_t totallen; - - /* This is the total length of the configuration (not necessarily the - * size that we will be sending now. - */ - totallen = USB_SIZEOF_CFGDESC + USB_SIZEOF_IFDESC + CDCSER_NENDPOINTS * USB_SIZEOF_EPDESC; + /* Check for switches between high and full speed */ - /* Configuration descriptor -- Copy the canned descriptor and fill in the - * type (we'll also need to update the size below - */ - - memcpy(cfgdesc, &g_cfgdesc, USB_SIZEOF_CFGDESC); - buf += USB_SIZEOF_CFGDESC; - - /* Copy the canned interface descriptor */ - - memcpy(buf, &g_ifdesc, USB_SIZEOF_IFDESC); - buf += USB_SIZEOF_IFDESC; - - /* Make the three endpoint configurations. First, check for switches - * between high and full speed - */ - -#ifdef CONFIG_USBDEV_DUALSPEED if (type == USB_DESC_TYPE_OTHERSPEEDCONFIG) { hispeed = !hispeed; } #endif - memcpy(buf, &g_epintindesc, USB_SIZEOF_EPDESC); - buf += USB_SIZEOF_EPDESC; + /* Copy all of the descriptors in the group */ -#ifdef CONFIG_USBDEV_DUALSPEED - if (hispeed) - { - bulkmxpacket = 512; - } - else + for (i = 0, dest = buf; i < CDCSER_CFGGROUP_SIZE; i++) { - bulkmxpacket = 64; - } + group = &g_cfggroup[i]; - usbclass_mkepbulkdesc(&g_epbulkoutdesc, bulkmxpacket, (struct usb_epdesc_s*)buf); - buf += USB_SIZEOF_EPDESC; - usbclass_mkepbulkdesc(&g_epbulkindesc, bulkmxpacket, (struct usb_epdesc_s*)buf); -#else - memcpy(buf, &g_epbulkoutdesc, USB_SIZEOF_EPDESC); - buf += USB_SIZEOF_EPDESC; - memcpy(buf, &g_epbulkindesc, USB_SIZEOF_EPDESC); + /* The "canned" descriptors all have full speed endpoint maxpacket + * sizes. If high speed is selected, we will have to change the + * endpoint maxpacket size. + * + * Is there a alternative high speed maxpacket size in the table? + * If so, that is sufficient proof that the descriptor that we + * just copied is an endpoint descriptor and needs the fixup + */ + +#ifdef CONFIG_USBDEV_DUALSPEED + if (highspeed && group->hsepsize != 0) + { + usbclass_mkepdesc(group->desc, group->hsepsize, + (FAR struct usb_epdesc_s*)dest); + } + else #endif + /* Copy the "canned" descriptor with the full speed max packet + * size + */ + + { + memcpy(dest, group->desc, group->descsize); + } + + /* Advance to the destination location for the next descriptor */ - /* Finally, fill in the total size of the configuration descriptor */ + dest += group->descsize; + } - cfgdesc->totallen[0] = LSBYTE(totallen); - cfgdesc->totallen[1] = MSBYTE(totallen); - return totallen; + return SIZEOF_CDCSER_CFGDESC; } /**************************************************************************** @@ -1024,6 +1056,25 @@ static void usbclass_resetconfig(FAR struct usbser_dev_s *priv) } /**************************************************************************** + * Name: usbclass_epconfigure + * + * Description: + * Configure one endpoint. + * + ****************************************************************************/ + +#ifdef CONFIG_USBDEV_DUALSPEED +static int usbclass_epconfigure(FAR struct usbdev_ep_s *ep, + FAR const struct usb_epdesc_s *indesc, + uint16_t mxpacket, bool last) +{ + struct usb_epdesc_s epdesc; + usbclass_mkepdesc(indesc, mxpacket, &epdesc); + return EP_CONFIGURE(ep, &epdesc, last); +} +#endif + +/**************************************************************************** * Name: usbclass_setconfig * * Description: @@ -1035,17 +1086,13 @@ static void usbclass_resetconfig(FAR struct usbser_dev_s *priv) static int usbclass_setconfig(FAR struct usbser_dev_s *priv, uint8_t config) { FAR struct usbdev_req_s *req; -#ifdef CONFIG_USBDEV_DUALSPEED - struct usb_epdesc_s epdesc; - uint16_t bulkmxpacket; -#endif int i; int ret = 0; #if CONFIG_DEBUG if (priv == NULL) { - usbtrace(TRACE_CLSERROR(CDCSER_TRACEERR_INVALIDARG), 0); + usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_INVALIDARG), 0); return -EIO; } #endif @@ -1054,7 +1101,7 @@ static int usbclass_setconfig(FAR struct usbser_dev_s *priv, uint8_t config) { /* Already configured -- Do nothing */ - usbtrace(TRACE_CLSERROR(CDCSER_TRACEERR_ALREADYCONFIGURED), 0); + usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_ALREADYCONFIGURED), 0); return 0; } @@ -1066,7 +1113,7 @@ static int usbclass_setconfig(FAR struct usbser_dev_s *priv, uint8_t config) if (config == CDCSER_CONFIGIDNONE) { - usbtrace(TRACE_CLSERROR(CDCSER_TRACEERR_CONFIGNONE), 0); + usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_CONFIGNONE), 0); return 0; } @@ -1074,16 +1121,27 @@ static int usbclass_setconfig(FAR struct usbser_dev_s *priv, uint8_t config) if (config != CDCSER_CONFIGID) { - usbtrace(TRACE_CLSERROR(CDCSER_TRACEERR_CONFIGIDBAD), 0); + usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_CONFIGIDBAD), 0); return -EINVAL; } /* Configure the IN interrupt endpoint */ - ret = EP_CONFIGURE(priv->epintin, &g_epintindesc, false); +#ifdef CONFIG_USBDEV_DUALSPEED + if (priv->usbdev->speed == USB_SPEED_HIGH) + { + ret = usbclass_epconfigure(priv->epintin, &g_epintindesc, + CONFIG_CDCSER_EPINTIN_HSSIZE, false); + } + else +#endif + { + ret = EP_CONFIGURE(priv->epintin, &g_epintindesc, false); + } + if (ret < 0) { - usbtrace(TRACE_CLSERROR(CDCSER_TRACEERR_EPINTINCONFIGFAIL), 0); + usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_EPINTINCONFIGFAIL), 0); goto errout; } priv->epintin->priv = priv; @@ -1093,21 +1151,18 @@ static int usbclass_setconfig(FAR struct usbser_dev_s *priv, uint8_t config) #ifdef CONFIG_USBDEV_DUALSPEED if (priv->usbdev->speed == USB_SPEED_HIGH) { - bulkmxpacket = 512; + ret = usbclass_epconfigure(priv->epbulkin, &g_epbulkindesc, + CONFIG_CDCSER_EPBULKIN_HSSIZE, false); } else +#endif { - bulkmxpacket = 64; + ret = EP_CONFIGURE(priv->epbulkin, &g_epbulkindesc, false); } - usbclass_mkepbulkdesc(&g_epbulkindesc, bulkmxpacket, &epdesc); - ret = EP_CONFIGURE(priv->epbulkin, &epdesc, false); -#else - ret = EP_CONFIGURE(priv->epbulkin, &g_epbulkindesc, false); -#endif if (ret < 0) { - usbtrace(TRACE_CLSERROR(CDCSER_TRACEERR_EPBULKINCONFIGFAIL), 0); + usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_EPBULKINCONFIGFAIL), 0); goto errout; } @@ -1116,14 +1171,20 @@ static int usbclass_setconfig(FAR struct usbser_dev_s *priv, uint8_t config) /* Configure the OUT bulk endpoint */ #ifdef CONFIG_USBDEV_DUALSPEED - usbclass_mkepbulkdesc(&g_epbulkoutdesc, bulkmxpacket, &epdesc); - ret = EP_CONFIGURE(priv->epbulkout, &epdesc, true); -#else - ret = EP_CONFIGURE(priv->epbulkout, &g_epbulkoutdesc, true); + if (priv->usbdev->speed == USB_SPEED_HIGH) + { + ret = usbclass_epconfigure(priv->epbulkout, &g_epbulkoutdesc, + CONFIG_CDCSER_EPBULKOUT_HSSIZE, true); + } + else #endif + { + ret = EP_CONFIGURE(priv->epbulkout, &g_epbulkoutdesc, true); + } + if (ret < 0) { - usbtrace(TRACE_CLSERROR(CDCSER_TRACEERR_EPBULKOUTCONFIGFAIL), 0); + usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_EPBULKOUTCONFIGFAIL), 0); goto errout; } @@ -1139,7 +1200,7 @@ static int usbclass_setconfig(FAR struct usbser_dev_s *priv, uint8_t config) ret = EP_SUBMIT(priv->epbulkout, req); if (ret != OK) { - usbtrace(TRACE_CLSERROR(CDCSER_TRACEERR_RDSUBMIT), (uint16_t)-ret); + usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_RDSUBMIT), (uint16_t)-ret); goto errout; } priv->nrdq++; @@ -1166,7 +1227,7 @@ static void usbclass_ep0incomplete(FAR struct usbdev_ep_s *ep, { if (req->result || req->xfrd != req->len) { - usbtrace(TRACE_CLSERROR(CDCSER_TRACEERR_REQRESULT), (uint16_t)-req->result); + usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_REQRESULT), (uint16_t)-req->result); } } @@ -1191,7 +1252,7 @@ static void usbclass_rdcomplete(FAR struct usbdev_ep_s *ep, #ifdef CONFIG_DEBUG if (!ep || !ep->priv || !req) { - usbtrace(TRACE_CLSERROR(CDCSER_TRACEERR_INVALIDARG), 0); + usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_INVALIDARG), 0); return; } #endif @@ -1211,13 +1272,13 @@ static void usbclass_rdcomplete(FAR struct usbdev_ep_s *ep, break; case -ESHUTDOWN: /* Disconnection */ - usbtrace(TRACE_CLSERROR(CDCSER_TRACEERR_RDSHUTDOWN), 0); + usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_RDSHUTDOWN), 0); priv->nrdq--; irqrestore(flags); return; default: /* Some other error occurred */ - usbtrace(TRACE_CLSERROR(CDCSER_TRACEERR_RDUNEXPECTED), (uint16_t)-req->result); + usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_RDUNEXPECTED), (uint16_t)-req->result); break; }; @@ -1232,7 +1293,7 @@ static void usbclass_rdcomplete(FAR struct usbdev_ep_s *ep, ret = EP_SUBMIT(ep, req); if (ret != OK) { - usbtrace(TRACE_CLSERROR(CDCSER_TRACEERR_RDSUBMIT), (uint16_t)-req->result); + usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_RDSUBMIT), (uint16_t)-req->result); } irqrestore(flags); } @@ -1258,7 +1319,7 @@ static void usbclass_wrcomplete(FAR struct usbdev_ep_s *ep, #ifdef CONFIG_DEBUG if (!ep || !ep->priv || !req || !req->priv) { - usbtrace(TRACE_CLSERROR(CDCSER_TRACEERR_INVALIDARG), 0); + usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_INVALIDARG), 0); return; } #endif @@ -1287,11 +1348,11 @@ static void usbclass_wrcomplete(FAR struct usbdev_ep_s *ep, break; case -ESHUTDOWN: /* Disconnection */ - usbtrace(TRACE_CLSERROR(CDCSER_TRACEERR_WRSHUTDOWN), priv->nwrq); + usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_WRSHUTDOWN), priv->nwrq); break; default: /* Some other error occurred */ - usbtrace(TRACE_CLSERROR(CDCSER_TRACEERR_WRUNEXPECTED), (uint16_t)-req->result); + usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_WRUNEXPECTED), (uint16_t)-req->result); break; } } @@ -1329,7 +1390,7 @@ static int usbclass_bind(FAR struct usbdev_s *dev, FAR struct usbdevclass_driver priv->ctrlreq = usbclass_allocreq(dev->ep0, CDCSER_MXDESCLEN); if (priv->ctrlreq == NULL) { - usbtrace(TRACE_CLSERROR(CDCSER_TRACEERR_ALLOCCTRLREQ), 0); + usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_ALLOCCTRLREQ), 0); ret = -ENOMEM; goto errout; } @@ -1347,7 +1408,7 @@ static int usbclass_bind(FAR struct usbdev_s *dev, FAR struct usbdevclass_driver priv->epintin = DEV_ALLOCEP(dev, CDCSER_EPINTIN_ADDR, true, USB_EP_ATTR_XFER_INT); if (!priv->epintin) { - usbtrace(TRACE_CLSERROR(CDCSER_TRACEERR_EPINTINALLOCFAIL), 0); + usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_EPINTINALLOCFAIL), 0); ret = -ENODEV; goto errout; } @@ -1358,7 +1419,7 @@ static int usbclass_bind(FAR struct usbdev_s *dev, FAR struct usbdevclass_driver priv->epbulkin = DEV_ALLOCEP(dev, CDCSER_EPINBULK_ADDR, true, USB_EP_ATTR_XFER_BULK); if (!priv->epbulkin) { - usbtrace(TRACE_CLSERROR(CDCSER_TRACEERR_EPBULKINALLOCFAIL), 0); + usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_EPBULKINALLOCFAIL), 0); ret = -ENODEV; goto errout; } @@ -1369,7 +1430,7 @@ static int usbclass_bind(FAR struct usbdev_s *dev, FAR struct usbdevclass_driver priv->epbulkout = DEV_ALLOCEP(dev, CDCSER_EPOUTBULK_ADDR, false, USB_EP_ATTR_XFER_BULK); if (!priv->epbulkout) { - usbtrace(TRACE_CLSERROR(CDCSER_TRACEERR_EPBULKOUTALLOCFAIL), 0); + usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_EPBULKOUTALLOCFAIL), 0); ret = -ENODEV; goto errout; } @@ -1389,7 +1450,7 @@ static int usbclass_bind(FAR struct usbdev_s *dev, FAR struct usbdevclass_driver reqcontainer->req = usbclass_allocreq(priv->epbulkout, reqlen); if (reqcontainer->req == NULL) { - usbtrace(TRACE_CLSERROR(CDCSER_TRACEERR_RDALLOCREQ), -ENOMEM); + usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_RDALLOCREQ), -ENOMEM); ret = -ENOMEM; goto errout; } @@ -1411,7 +1472,7 @@ static int usbclass_bind(FAR struct usbdev_s *dev, FAR struct usbdevclass_driver reqcontainer->req = usbclass_allocreq(priv->epbulkin, reqlen); if (reqcontainer->req == NULL) { - usbtrace(TRACE_CLSERROR(CDCSER_TRACEERR_WRALLOCREQ), -ENOMEM); + usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_WRALLOCREQ), -ENOMEM); ret = -ENOMEM; goto errout; } @@ -1460,7 +1521,7 @@ static void usbclass_unbind(FAR struct usbdev_s *dev) #ifdef CONFIG_DEBUG if (!dev || !dev->ep0) { - usbtrace(TRACE_CLSERROR(CDCSER_TRACEERR_INVALIDARG), 0); + usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_INVALIDARG), 0); return; } #endif @@ -1472,7 +1533,7 @@ static void usbclass_unbind(FAR struct usbdev_s *dev) #ifdef CONFIG_DEBUG if (!priv) { - usbtrace(TRACE_CLSERROR(CDCSER_TRACEERR_EP0NOTBOUND), 0); + usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_EP0NOTBOUND), 0); return; } #endif @@ -1584,7 +1645,7 @@ static int usbclass_setup(FAR struct usbdev_s *dev, const struct usb_ctrlreq_s * #ifdef CONFIG_DEBUG if (!dev || !dev->ep0 || !ctrl) { - usbtrace(TRACE_CLSERROR(CDCSER_TRACEERR_INVALIDARG), 0); + usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_INVALIDARG), 0); return -EIO; } #endif @@ -1597,7 +1658,7 @@ static int usbclass_setup(FAR struct usbdev_s *dev, const struct usb_ctrlreq_s * #ifdef CONFIG_DEBUG if (!priv || !priv->ctrlreq) { - usbtrace(TRACE_CLSERROR(CDCSER_TRACEERR_EP0NOTBOUND), 0); + usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_EP0NOTBOUND), 0); return -ENODEV; } #endif @@ -1668,7 +1729,7 @@ static int usbclass_setup(FAR struct usbdev_s *dev, const struct usb_ctrlreq_s * default: { - usbtrace(TRACE_CLSERROR(CDCSER_TRACEERR_GETUNKNOWNDESC), value); + usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_GETUNKNOWNDESC), value); } break; } @@ -1729,78 +1790,109 @@ static int usbclass_setup(FAR struct usbdev_s *dev, const struct usb_ctrlreq_s * break; default: - usbtrace(TRACE_CLSERROR(CDCSER_TRACEERR_UNSUPPORTEDSTDREQ), ctrl->req); + usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_UNSUPPORTEDSTDREQ), ctrl->req); break; } } break; - /*********************************************************************** - * PL2303 Vendor-Specific Requests - ***********************************************************************/ + /************************************************************************ + * CDC ACM-Specific Requests + ************************************************************************/ - case CDC_CONTROL_TYPE: + /* ACM_GET_LINE_CODING requests current DTE rate, stop-bits, parity, and + * number-of-character bits. (Optional) + */ + + case ACM_GET_LINE_CODING: { - if ((ctrl->type & USB_REQ_RECIPIENT_MASK) == USB_REQ_RECIPIENT_INTERFACE) + if (ctrl->type == (USB_DIR_IN|USB_REQ_TYPE_CLASS|USB_REQ_RECIPIENT_INTERFACE)) { - switch (ctrl->req) - { - case CDC_SETLINEREQUEST: - { - memcpy(priv->linest, ctrlreq->buf, min(len, 7)); - ret = 0; - } - break; + /* Return the current line status from the private data structure */ + + memcpy(ctrlreq->buf, &priv->linecoding, SIZEOF_CDC_LINECODING); + ret = SIZEOF_CDC_LINECODING; + } + else + { + usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_UNSUPPORTEDCLASSREQ), ctrl->type); + } + } + break; + /* ACM_SET_LINE_CODING configures DTE rate, stop-bits, parity, and + * number-of-character bits. (Optional) + */ - case CDC_GETLINEREQUEST: - { - memcpy(ctrlreq->buf, priv->linest, 7); - ret = 7; - } - break; + case ACM_SET_LINE_CODING: + { + if (ctrl->type == (USB_DIR_OUT|USB_REQ_TYPE_CLASS|USB_REQ_RECIPIENT_INTERFACE)) + { + /* Save the new line status in the private data structure */ - case CDC_SETCONTROLREQUEST: - case CDC_BREAKREQUEST: - { - ret = 0; - } - break; + memcpy(&priv->linecoding, ctrlreq->buf, min(len, 7)); + ret = 0; - default: - usbtrace(TRACE_CLSERROR(CDCSER_TRACEERR_UNSUPPORTEDCTRLREQ), ctrl->type); - break; - } + /* If there is a registered callback to receive line status info, then + * callout now. + */ +#warning "Missing logic" + } + else + { + usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_UNSUPPORTEDCLASSREQ), ctrl->type); } } break; - case CDC_RWREQUEST_TYPE: + /* ACM_SET_CTRL_LINE_STATE: RS-232 signal used to tell the DCE device the + * DTE device is now present. (Optional) + */ + + case ACM_SET_CTRL_LINE_STATE: { - if ((ctrl->type & USB_REQ_RECIPIENT_MASK) == USB_REQ_RECIPIENT_DEVICE) + if (ctrl->type == (USB_DIR_OUT|USB_REQ_TYPE_CLASS|USB_REQ_RECIPIENT_INTERFACE)) { - if (ctrl->req == CDC_RWREQUEST) - { - if ((ctrl->type & USB_DIR_IN) != 0) - { - *(uint32_t*)ctrlreq->buf = 0xdeadbeef; - ret = 4; - } - else - { - ret = 0; - } - } - else - { - usbtrace(TRACE_CLSERROR(CDCSER_TRACEERR_UNSUPPORTEDRWREQ), ctrl->type); - } + /* Save the control line state in the private data structure. Only bits + * 0 and 1 have meaning. + */ + + priv->ctrlline = value & 3; + ret = 0; + + /* If there is a registered callback to receive control line status info, + * then callout now. + */ +#warning "Missing logic" + } + else + { + usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_UNSUPPORTEDCLASSREQ), ctrl->type); + } + } + break; + + /* Sends special carrier*/ + + case ACM_SEND_BREAK: + { + if (ctrl->type == (USB_DIR_OUT|USB_REQ_TYPE_CLASS|USB_REQ_RECIPIENT_INTERFACE)) + { + /* If there is a registered callback to handle the SendBreak request, + * then callout now. + */ +#warning "Missing logic" + ret = 0; + } + else + { + usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_UNSUPPORTEDCLASSREQ), ctrl->type); } } break; default: - usbtrace(TRACE_CLSERROR(CDCSER_TRACEERR_UNSUPPORTEDTYPE), ctrl->type); + usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_UNSUPPORTEDTYPE), ctrl->type); break; } @@ -1815,7 +1907,7 @@ static int usbclass_setup(FAR struct usbdev_s *dev, const struct usb_ctrlreq_s * ret = EP_SUBMIT(dev->ep0, ctrlreq); if (ret < 0) { - usbtrace(TRACE_CLSERROR(CDCSER_TRACEERR_EPRESPQ), (uint16_t)-ret); + usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_EPRESPQ), (uint16_t)-ret); ctrlreq->result = OK; usbclass_ep0incomplete(dev->ep0, ctrlreq); } @@ -1844,7 +1936,7 @@ static void usbclass_disconnect(FAR struct usbdev_s *dev) #ifdef CONFIG_DEBUG if (!dev || !dev->ep0) { - usbtrace(TRACE_CLSERROR(CDCSER_TRACEERR_INVALIDARG), 0); + usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_INVALIDARG), 0); return; } #endif @@ -1856,7 +1948,7 @@ static void usbclass_disconnect(FAR struct usbdev_s *dev) #ifdef CONFIG_DEBUG if (!priv) { - usbtrace(TRACE_CLSERROR(CDCSER_TRACEERR_EP0NOTBOUND), 0); + usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_EP0NOTBOUND), 0); return; } #endif @@ -1902,7 +1994,7 @@ static int usbser_setup(FAR struct uart_dev_s *dev) #if CONFIG_DEBUG if (!dev || !dev->priv) { - usbtrace(TRACE_CLSERROR(CDCSER_TRACEERR_INVALIDARG), 0); + usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_INVALIDARG), 0); return -EIO; } #endif @@ -1915,7 +2007,7 @@ static int usbser_setup(FAR struct uart_dev_s *dev) if (priv->config == CDCSER_CONFIGIDNONE) { - usbtrace(TRACE_CLSERROR(CDCSER_TRACEERR_SETUPNOTCONNECTED), 0); + usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_SETUPNOTCONNECTED), 0); return -ENOTCONN; } @@ -1943,7 +2035,7 @@ static void usbser_shutdown(FAR struct uart_dev_s *dev) #if CONFIG_DEBUG if (!dev || !dev->priv) { - usbtrace(TRACE_CLSERROR(CDCSER_TRACEERR_INVALIDARG), 0); + usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_INVALIDARG), 0); } #endif } @@ -2005,7 +2097,7 @@ static void usbser_rxint(FAR struct uart_dev_s *dev, bool enable) #if CONFIG_DEBUG if (!dev || !dev->priv) { - usbtrace(TRACE_CLSERROR(CDCSER_TRACEERR_INVALIDARG), 0); + usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_INVALIDARG), 0); return; } #endif @@ -2096,7 +2188,7 @@ static void usbser_txint(FAR struct uart_dev_s *dev, bool enable) #if CONFIG_DEBUG if (!dev || !dev->priv) { - usbtrace(TRACE_CLSERROR(CDCSER_TRACEERR_INVALIDARG), 0); + usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_INVALIDARG), 0); return; } #endif @@ -2139,7 +2231,7 @@ static bool usbser_txempty(FAR struct uart_dev_s *dev) #if CONFIG_DEBUG if (!priv) { - usbtrace(TRACE_CLSERROR(CDCSER_TRACEERR_INVALIDARG), 0); + usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_INVALIDARG), 0); return true; } #endif @@ -2176,7 +2268,7 @@ int usbdev_serialinitialize(int minor) alloc = (FAR struct usbser_alloc_s*)kmalloc(sizeof(struct usbser_alloc_s)); if (!alloc) { - usbtrace(TRACE_CLSERROR(CDCSER_TRACEERR_ALLOCDEVSTRUCT), 0); + usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_ALLOCDEVSTRUCT), 0); return -ENOMEM; } @@ -2192,13 +2284,13 @@ int usbdev_serialinitialize(int minor) /* Fake line status */ - priv->linest[0] = (115200) & 0xff; /* Baud=115200 */ - priv->linest[1] = (115200 >> 8) & 0xff; - priv->linest[2] = (115200 >> 16) & 0xff; - priv->linest[3] = (115200 >> 24) & 0xff; - priv->linest[4] = 0; /* One stop bit */ - priv->linest[5] = 0; /* No parity */ - priv->linest[6] = 8; /*8 data bits */ + priv->linecoding.baud[0] = (115200) & 0xff; /* Baud=115200 */ + priv->linecoding.baud[1] = (115200 >> 8) & 0xff; + priv->linecoding.baud[2] = (115200 >> 16) & 0xff; + priv->linecoding.baud[3] = (115200 >> 24) & 0xff; + priv->linecoding.stop = CDC_CHFMT_STOP1; /* One stop bit */ + priv->linecoding.parity = CDC_PARITY_NONE; /* No parity */ + priv->linecoding.nbits = 8; /* 8 data bits */ /* Initialize the serial driver sub-structure */ @@ -2224,7 +2316,7 @@ int usbdev_serialinitialize(int minor) ret = usbdev_register(&drvr->drvr); if (ret) { - usbtrace(TRACE_CLSERROR(CDCSER_TRACEERR_DEVREGISTER), (uint16_t)-ret); + usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_DEVREGISTER), (uint16_t)-ret); goto errout_with_alloc; } @@ -2235,7 +2327,7 @@ int usbdev_serialinitialize(int minor) ret = uart_register("/dev/console", &pri->serdev); if (ret < 0) { - usbtrace(TRACE_CLSERROR(CDCSER_TRACEERR_CONSOLEREGISTER), (uint16_t)-ret); + usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_CONSOLEREGISTER), (uint16_t)-ret); goto errout_with_class; } #endif @@ -2246,7 +2338,7 @@ int usbdev_serialinitialize(int minor) ret = uart_register(devname, &priv->serdev); if (ret) { - usbtrace(TRACE_CLSERROR(CDCSER_TRACEERR_UARTREGISTER), (uint16_t)-ret); + usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_UARTREGISTER), (uint16_t)-ret); goto errout_with_class; } return OK; diff --git a/nuttx/drivers/usbdev/usbdev_serial.c b/nuttx/drivers/usbdev/usbdev_serial.c index 68c39200f..bef02ed73 100644 --- a/nuttx/drivers/usbdev/usbdev_serial.c +++ b/nuttx/drivers/usbdev/usbdev_serial.c @@ -78,12 +78,6 @@ # define CONFIG_USBSER_NRDREQS 4 #endif -/* Write buffer size */ - -#ifndef CONFIG_USBSER_WRBUFFERSIZE -# define CONFIG_USBSER_WRBUFFERSIZE 1024 -#endif - /* Logical endpoint numbers / max packet sizes */ #ifndef CONFIG_USBSER_EPINTIN @@ -1731,7 +1725,7 @@ static int usbclass_setup(FAR struct usbdev_s *dev, const struct usb_ctrlreq_s * break; default: - usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_UNSUPPORTEDCTRLREQ), ctrl->type); + usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_UNSUPPORTEDCLASSREQ), ctrl->type); break; } } @@ -1756,7 +1750,7 @@ static int usbclass_setup(FAR struct usbdev_s *dev, const struct usb_ctrlreq_s * } else { - usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_UNSUPPORTEDRWREQ), ctrl->type); + usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_UNSUPPORTEDCLASSREQ), ctrl->type); } } } diff --git a/nuttx/include/nuttx/usb/cdc.h b/nuttx/include/nuttx/usb/cdc.h index a6fee1817..4d75356db 100755 --- a/nuttx/include/nuttx/usb/cdc.h +++ b/nuttx/include/nuttx/usb/cdc.h @@ -1,868 +1,869 @@ -/********************************************************************************************
- * include/nuttx/usb/cdc.h
- *
- * Copyright (C) 2011 Gregory Nutt. All rights reserved.
- * Author: Gregory Nutt <spudmonkey@racsa.co.cr>
- *
- * References: "Universal Serial Bus Class Definitions for Communication
- * Devices," Version 1.1, January 19, 1999
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * 3. Neither the name NuttX nor the names of its contributors may be
- * used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
- * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- ********************************************************************************************/
-
-#ifndef __INCLUDE_NUTTX_USB_CDC_H
-#define __INCLUDE_NUTTX_USB_CDC_H
-
-/********************************************************************************************
- * Included Files
- ********************************************************************************************/
-
-#include <nuttx/config.h>
-
-/********************************************************************************************
- * Pre-processor Definitions
- ********************************************************************************************/
-/* Device Class Codes ***********************************************************************/
-/* Table 14: Communication Device Class Code (see definition USB_CLASS_CDC in usb.h) */
-/* Table 18: Data Interface Class Code (see definition USB_CLASS_CDC_DATA in usb.h) */
-
-/* Communication Inteface Class Codes *******************************************************/
-/* Table 15: Communication Interface Class Code */
-
-#define CDC_CLASS_COMM 0x02 /* Communication Interface Class */
-
-/* Communication Interface Sub-Class Codes **************************************************/
-
-#define CDC_SUBCLASS_NONE 0x00 /* Reserved */
-#define CDC_SUBCLASS_DLC 0x01 /* Direct Line Control Model */
-#define CDC_SUBCLASS_ACM 0x02 /* Abstract Control Model */
-#define CDC_SUBCLASS_TCM 0x03 /* Telephone Control Model */
-#define CDC_SUBCLASS_MCM 0x04 /* Multi-Channel Control Model */
-#define CDC_SUBCLASS_CAPI 0x05 /* CAPI Control Model */
-#define CDC_SUBCLASS_ECM 0x06 /* Ethernet Networking Control Model */
-#define CDC_SUBCLASS_ATM 0x07 /* ATM Networking Control Model */
- /* 0x08-0x7f Reserved (future use) */
- /* 0x80-0xfe Reserved (vendor specific) */
-/* Communication Interface Class Protocol Codes ********************************************/
-/* Table 17: Communication Interface Class Control Protocol Codes */
-
-#define CDC_PROTO_NONE 0x00 /* No class specific protocol required */
-#define CDC_PROTO_ATM 0x01 /* Common AT commands (also known as Hayes compatible”) */
- /* 0x02-0xfe Reserved (future use) */
-#define CDC_PROTO_VENDOR 0xff /* Vendor-specific */
-
-/* Data Interface Sub-Class Codes ***********************************************************/
-/* None defined, should be zero */
-
-#define CDC_DATA_SUBCLASS_NONE 0x00
-
-/* Date Interface Class Protocol Codes ******************************************************/
-/* Table 19: Data Interface Class Protocol Codes */
-
-#define CDC_DATA_PROTO_NONE 0x00 /* No class specific protocol required */
- /* 0x01-0x2f Reserved (future use) */
-#define CDC_DATA_PROTO_ISDN 0x30 /* Physical interface protocol for ISDN BRI */
-#define CDC_DATA_PROTO_HDLC 0x31 /* HDLC */
-#define CDC_DATA_PROTO_TRANSP 0x32 /* Transparent */
- /* 0x33-0x4f Reserved (future use) */
-#define CDC_DATA_PROTO_Q921M 0x50 /* Management protocol for Q.921 data link protocol */
-#define CDC_DATA_PROTO_Q921 0x51 /* Data link protocol for Q.931 */
-#define CDC_DATA_PROTO_Q921TM 0x52 /* TEI-multiplexor for Q.921 data link protocol */
- /* 0x53-0x8f Reserved (future use) */
-#define CDC_DATA_PROTO_V42BIS 0x90 /* Data compression procedures */
-#define CDC_DATA_PROTO_EUROISDN 0x91 /* Euro-ISDN protocol control */
-#define CDC_DATA_PROTO_V120 0x92 /* V.24 rate adaptation to ISDN */
-#define CDC_DATA_PROTO_CAPI 0x93 /* CAPI Commands */
- /* 0x94-0xfc Reserved (future use) */
-#define CDC_DATA_PROTO_HBD 0xfd /* Host based driver. */
-#define CDC_DATA_PROTO_PUFD 0xfe /* The protocol(s) are described using a Protocol Unit
- * Functional Descriptors on Communication Class
- * Interface.
- */
-#define CDC_DATA_PROTO_VENDOR 0xff /* Vendor-specific */
-
-/* Requests and Notifications ***************************************************************/
-/* Table 2: Requests, Direct Line Control Model */
-
-#define DLC_SET_AUX_LINE_STATE 0x10 /* Request to connect or disconnect secondary jack from
- * POTS circuit or CODEC, depending on hook state.
- * (Optional).
- */
-#define DLC_SET_HOOK_STATE 0x11 /* Select relay setting for on-hook, off-hook, and caller
- * ID. (Required)
- */
-#define DLC_PULSE_SETUP 0x12 /* Initiate pulse dialing preparation. (Optional).
- */
-#define DLC_SEND_PULSE 0x13 /* Request number of make/break cycles to generate.
- * (Optional)
- */
-#define DLC_SET_PULSE_TIME 0x14 /* Setup value for time of make and break periods when
- * pulse dialing. (Optional)
- */
-#define DLC_RING_AUX_JACK 0x15 /* Request for a ring signal to be generated on secondary
- * phone jack. (Optional)
- */
-/* Table 3: Notifications, Direct Line Control Model */
-
-#define DLC_AUX_JACK_HOOK_STATE 0x08 /* Indicates hook state of secondary device plugged
- * into the auxiliary phone jack. (Optional)
- */
-#define DLC_RING_DETECT 0x09 /* Message to notify host that ring voltage was
- * detected on POTS interface. (Required)
- */
-/* Table 4: Requests, Abstract Control Model */
-
-#define ACS_SEND_COMMAND 0x00 /* Issues a command in the format of the supported
- * control protocol. (Required)
- */
-#define ACS_GET_RESPONSE 0x01 /* Requests a response in the format of the
- * supported control protocol. (Required)
- */
-#define ACS_SET_COMM_FEATURE 0x02 /* Controls the settings for a particular
- * communication feature. (Optional)
- */
-#define ACS_GET_COMM_FEATURE 0x03 /* Returns the current settings for the
- * communication feature. (Optional)
- */
-#define ACS_CLEAR_COMM_FEATURE 0x04 /* Clears the settings for a particular
- * communication feature. (Optional)
- */
-#define ACS_SET_LINE_CODING 0x20 /* Configures DTE rate, stop-bits, parity, and
- * number-of-character bits. (Optional)
- */
-#define ACS_GET_LINE_CODING 0x21 /* Requests current DTE rate, stop-bits, parity, and
- * number-of-character bits. (Optional)
- */
-#define ACS_SET_CTRL_LINE_STATE 0x22 /* RS-232 signal used to tell the DCE device the
- * DTE device is now present. (Optional)
- */
-#define ACS_SEND_BREAK 0x23 /* Sends special carrier
- */
-/* Table 5: Notifications, Abstract Control Model */
-
-#define ACS_NETWORK_CONNECTION 0x00 /* Notification to host of network connection status.
- * (Optional)
- */
-#define ACS_RESPONSE_AVAILABLE 0x01 /* Notification to host to issue a GET_ENCAPSULATED_RESPONSE
- * request. (Required)
- */
-#define ACS_SERIAL_STATE 0x20 /* Returns the current state of the carrier detect, DSR,
- * break, and ring signal. (Optional)
- */
-/* Table 6: Requests, Telephone Control Model */
-
-#define TCM_SET_COMM_FEATURE 0x02 /* Used to set a unique communication feature, which is
- * normally specific to a particular device.
- * (Optional)
- */
-#define TCM_GET_COMM_FEATURE 0x03 /* Returns the current settings for the communication
- * feature. (Optional)
- */
-#define TCM_CLEAR_COMM_FEATURE 0x04 /* Clears the settings for a particular communication
- * feature. (Optional)
- */
-#define TCM_SET_RINGER_PARMS 0x30 /* Configures the ringer for a telephone device.
- * (Optional)
- */
-#define TCM_GET_RINGER_PARMS 0x31 /* Gets the current ringer configuration for a telephone
- * device. (Required)
- */
-#define TCM_SET_OPERATION_PARMS 0x32 /* Configures the operational mode of the telephone.
- * (Optional)
- */
-#define TCM_GET_OPERATION_PARMS 0x33 /* Gets the current operational mode of the telephone.
- * (Optional)
- */
-#define TCM_SET_LINE_PARMS 0x34 /* Allows changing the current state of the line
- * associated with the interface, providing basic call
- * capabilities, such as dialing and answering calls.
- * (Required)
- */
-#define TCM_GET_LINE_PARMS 0x35 /* Gets current status of the line. (Required)
- */
-#define TCM_DIAL_DIGITS 0x36 /* Dials digits on the network connection. (Required)
- */
-/* Table 7: Notifications, Telephone Control Model */
-
-#define TCM_CALL_STATE_CHANGE 0x28 /* DReports a state change on a call. (Required)
- */
-#define TCM_LINE_STATE_CHANGE 0x29 /* DReports a state change on a line. (Optional)
- */
-/* Table 8: Requests, Multi-Channel Model */
-
-#define MCM_SET_UNIT_PARAM 0x37 /* Used to set a Unit specific parameter (Optional)
- */
-#define MCM_GET_UNIT_PARAM 0x38 /* Used to retrieve a Unit specific parameter (Required)
- */
-#define MCM_CLEAR_UNIT_PARAM 0x39 /* Used to set a Unit specific parameter to its default
- * state. (Optional)
- */
-/* Table 9: Request, CAPI Control Model */
-
-#define CAPI_GET_PROFILE 0x3a /* Returns the implemented capabilities of the device
- * (Required)
- */
-/* Table 10: Requests, Ethernet Networking Control Model */
-
-#define ECM_SEND_COMMAND 0x00 /* Issues a command in the format of the supported
- * control protocol. The intent of this mechanism is
- * to support networking devices (e.g., host-based
- * cable modems) that require an additional vendor-
- * defined interface for media specific hardware
- * configuration and management. (Optional)
- */
-#define ECM_GET_RESPONSE 0x01 /* equests a response in the format of the supported
- * control protocol.
- * (Optional)
- */
-#define ECM_SET_MCAST_FILTERS 0x40 /* As applications are loaded and unloaded on the host,
- * the networking transport will instruct the device’s MAC
- * driver to change settings of the Networking device’s
- * multicast filters. (Optional)
- */
-#define ECM_SET_PM_PAT_FILTER 0x41 /* Some hosts are able to conserve energy and stay quiet
- * in a “sleeping” state while not being used. USB
- * Networking devices may provide special pattern filtering
- * hardware that enables it to wake up the attached host
- * on demand when something is attempting to contact the
- * host (e.g., an incoming web browser connection).
- * Primitives are needed in management plane to negotiate
- * the setting of these special filters
- * (Optional)
- */
-#define ECM_GET_PM_PAT_FILTER 0x42 /* Retrieves the status of the above power management
- * pattern filter setting
- * (Optional)
- */
-#define ECM_SET_PACKET_FILTER 0x43 /* Sets device filter for running a network analyzer
- * application on the host machine (Required)
- */
-#define ECM_GET_STATISTIC 0x44 /* Retrieves Ethernet device statistics such as frames
- * transmitted, frames received, and bad frames received.
- * (Optional)
- */
-/* Table 11: Notifications, Ethernet Networking Control Model */
-
-#define ECM_NETWORK_CONNECTION 0x00 /* Reports whether or not the physical layer (modem,
- * Ethernet PHY, etc.) link is up. (Required)
- */
-#define ECM_RESPONSE_AVAILABLE 0x01 /* Notification to host to issue a
- * GET_ENCAPSULATED_RESPONSE request. (Optional)
- */
-#define ECM_SPEED_CHANGE 0x2a /* Reports a change in upstream or downstream (Required)
- */
-/* Table 12: Requests, ATM Networking Control Model */
-
-#define ATM_SEND_COMMAND 0x00 /* Issues a command in the format of the supported control
- * protocol. The intent of this mechanism is to support
- * networking devices (e.g., host-based cable modems)
- * that require an additional vendor-defined interface for
- * media specific hardware configuration and
- * management. (Optional)
- */
-#define ATM_GET_RESPONSE 0x01 /* Requests a response in the format of the supported
- * control protocol. (Optional)
- */
-#define ATM_SET_DATA_FORMAT 0x50 /* Chooses which ATM data format will be exchanged
- * between the host and the ATM Networking device.
- * (Required)
- */
-#define ATM_GET_DEV_STATISTICS 0x51 /* Retrieves global statistics from the ATM Networking
- * device. (Required)
- */
-#define ATM_SET_DEFAULT_VC 0x52 /* Pre-selects the VPI/VCI value for subsequent
- * GetATMVCStatistics requests (Optional)
- */
-#define ATM_GET_VC_STATISTICS 0x53 /* Retrieves statistics from the ATM Networking device for
- * a particular VPI/VCI. (Optional)
- */
-/* Table 13: Requests, Ethernet and ATM Networking Control Model */
-
-#define ATM_NETWORK_CONNECTION 0x00 /* Reports whether or not the physical layer (modem,
- * Ethernet PHY, etc.) link is up. (Required)
- */
-#define ECM_NETWORK_CONNECTION ATM_NETWORK_CONNECTION
-#define ATM_RESPONSE_AVAILABLE 0x01 /* Notification to host to issue a
- * GET_ENCAPSULATED_RESPONSE request. (Optional)
- */
-#define ECM_RESPONSE_AVAILABLE ATM_RESPONSE_AVAILABLE
-#define ATM_SPEED_CHANGE 0x2a /* Reports a change in upstream or downstream speed of the
- * networking device connection. (Required)
- */
-#define ECM_SPEED_CHANGE ATM_SPEED_CHANGE
-
-/* Descriptors ******************************************************************************/
-/* Table 25: bDescriptor SubType in Functional Descriptors */
-
-#define CDC_DSUBTYPE_HDR 0x00 /* Header Functional Descriptor, which marks the
- * beginning of the concatenated set of functional
- * descriptors for the interface. */
-#define CDC_DSUBTYPE_CALLMGMT 0x01 /* Call Management Functional Descriptor */
-#define CDC_DSUBTYPE_ACM 0x02 /* Abstract Control Management Functional Descriptor */
-#define CDC_DSUBTYPE_DLC 0x03 /* Direct Line Management Functional Descriptor */
-#define CDC_DSUBTYPE_TCMRINGER 0x04 /* Telephone Ringer Functional Descriptor */
-#define CDC_DSUBTYPE_TCMCALL 0x05 /* Telephone Call and Line State Reporting Capabilities
- * Functional Descriptor. */
-#define CDC_DSUBTYPE_UNION 0x06 /* Union Functional descriptor */
-#define CDC_DSUBTYPE_COUNTRY 0x07 /* Country Selection Functional Descriptor */
-#define CDC_DSUBTYPE_TCMOPS 0x08 /* Telephone Operational Modes Functional Descriptor */
-#define CDC_DSUBTYPE_USBTERM 0x09 /* USB Terminal Functional Descriptor */
-#define CDC_DSUBTYPE_NETCHAN 0x0a /* Network Channel Terminal Descriptor */
-#define CDC_DSUBTYPE_PROTOUNIT 0x0b /* Protocol Unit Functional Descriptor */
-#define CDC_DSUBTYPE_EXTUNIT 0x0c /* Extension Unit Functional Descriptor */
-#define CDC_DSUBTYPE_MCM 0x0d /* Multi-Channel Management Functional Descriptor */
-#define CDC_DSUBTYPE_CAPI 0x0e /* CAPI Control Management Functional Descriptor */
-#define CDC_DSUBTYPE_ECM 0x0f /* Ethernet Networking Functional Descriptor */
-#define CDC_DSUBTYPE_ATM 0x10 /* ATM Networking Functional Descriptor */
- /* 0x11-0xff Reserved (future use) */
-
-/* Table 42: Ethernet Statistics Capabilities */
-
-#define ECMCAP_XMIT_OK (1 << 0) /* Frames transmitted without errors */
-#define ECMCAP_RVC_OK (1 << 1) /* Frames received without errors */
-#define ECMCAP_XMIT_ERROR (1 << 2) /* Frames not transmitted, or transmitted with errors */
-#define ECMCAP_RCV_ERROR (1 << 3) /* Frames received with errors that are not delivered
- * to the USB host
- */
-#define ECMCAP_RCV_NO_BUFFER (1 << 4) /* Frame missed, no buffers */
-#define ECMCAP_DIR_BYTES_XMIT (1 << 5) /* Directed bytes transmitted without errors */
-#define ECMCAP_DIR_FRAMES_XMIT (1 << 6) /* Directed frames transmitted without errors */
-#define ECMCAP_MCAST_BYTES_XMIT (1 << 7) /* Multicast bytes transmitted without errors */
-#define ECMCAP_MCAST_FRAMES_XMIT (1 << 8) /* Multicast frames transmitted without errors */
-#define ECMCAP_BCAST_BYTES_XMIT (1 << 9) /* Broadcast bytes transmitted without errors */
-#define ECMCAP_BCAST_FRAMES_XMIT (1 << 10) /* Broadcast frames transmitted without errors */
-#define ECMCAP_DIR_BYTES_RCV (1 << 11) /* Directed bytes received without errors */
-#define ECMCAP_DIR_FRAMES_RCV (1 << 12) /* Directed frames received without errors */
-#define ECMCAP_MCAST_BYTES_RCV (1 << 13) /* Multicast bytes received without errors */
-#define ECMCAP_MCAST_FRAMES_RCV (1 << 14) /* Multicast frames received without errors */
-#define ECMCAP_BCAST_BYTES_RCV (1 << 15) /* Broadcast bytes received without errors */
-#define ECMCAP_BCAST_FRAMES_RCV (1 << 16) /* Broadcast frames received without errors */
-#define ECMCAP_RCV_CRC_ERROR (1 << 17) /* Frames received with circular redundancy check
- * (CRC) or frame check sequence (FCS) error
- */
-#define ECMCAP_TRANSMIT_QUEUE_LENG (1 << 18) /* Length of transmit queue */
-#define ECMCAP_RCV_ERROR_ALIGNMENT (1 << 19) /* Frames received with alignment error */
-#define ECMCAP_XMIT_ONE_COLL (1 << 20) /* Frames transmitted with one collision */
-#define ECMCAP_XMIT_MORE_COLLS (1 << 21) /* Frames transmitted with more than one collision */
-#define ECMCAP_XMIT_DEFERRED (1 << 22) /* Frames transmitted after deferral */
-#define ECMCAP_XMIT_MAX_COLLS (1 << 23) /* Frames not transmitted due to collisions */
-#define ECMCAP_RCV_OVERRUN (1 << 24) /* Frames not received due to overrun */
-#define ECMCAP_XMIT_UNDERRUN (1 << 25) /* Frames not transmitted due to underrun */
-#define ECMCAP_XMIT_HB_FAILURE (1 << 26) /* Frames transmitted with heartbeat failure */
-#define ECMCAP_XMIT_TIMES_CRS_LOST (1 << 27) /* Times carrier sense signal lost during
- * transmission
- */
-#define ECMCAP_XMIT_LATE_COLLS (1 << 28) /* Late collisions detected */
- /* Bits 29-31 Resrved, Must be set to zero */
-
-/* Table 47: Communication Feature Selector Codes */
-
-#define FEATURE_ABSTRACT_STATE 0x01 /* Two bytes of data describing multiplexed state
- * and idle state for this Abstract Model
- * communications device
- */
-#define FEATURE_COUNTRY_SETTING 0x02 /* Country code in hexadecimal format as defined in
- * ISO 3166
- */
-/* Table 49: POTS Relay Configuration Values */
-
-#define POTS_ON_HOOK 0x0000
-#define POTS_OFF_HOOK 0x0001
-#define POTS_SNOOPING 0x0002
-
-/* Table 50: Line Coding Structure */
-
-#define CDC_CHFMT_STOP1 0 /* One stop bit */
-#define CDC_CHFMT_STOP1p5 1 /* 1.5 stop bits */
-#define CDC_CHFMT_STOP2 2 /* 2 stop bits */
-
-#define CDC_PARITY_None 0 /* No parity */
-#define CDC_PARITY_Odd 1 /* Odd parity */
-#define CDC_PARITY_Even 2 /* Even parity */
-#define CDC_PARITY_Mark 3 /* Mark parity */
-#define CDC_PARITY_Space 4 /* Space parity */
-
-/* Table 58: Call State Value Definitions */
-
-#define CDC_CALLST_IDLE 0x00 /* Call is idle */
-#define CDC_CALLST_DIAL 0x01 /* Typical dial tone */
-#define CDC_CALLST_INTDIAL 0x02 /* Interrupted dial tone */
-#define CDC_CALLST_DIALING 0x03 /* Dialing is in progress */
-#define CDC_CALLST_RINGBACK 0x04 /* Ringback */
-#define CDC_CALLST_CONNECTED 0x05 /* Connected */
-#define CDC_CALLSTINCOMING 0x06 /* Incoming call */
-
-/* Table 62: Ethernet Packet Filter Bitmap */
-
-#define PACKET_TYPE_PROMISCUOUS (1 << 0)
-#define PACKET_TYPE_ALL_MULTICAST (1 << 1)
-#define PACKET_TYPE_DIRECTED (1 << 2)
-#define PACKET_TYPE_BROADCAST (1 << 3)
-#define PACKET_TYPE_MULTICAST (1 << 4)
-
-/* Table 63: Ethernet Statistics Feature Selector Codes */
-
-#define ECM_XMIT_OK 0x01 /* Frames transmitted without errors */
-#define ECM_RVC_OK 0x02 /* Frames received without errors */
-#define ECM_XMIT_ERROR 0x03 /* Frames not transmitted, or transmitted with errors */
-#define ECM_RCV_ERROR 0x04 /* Frames received with errors that are not delivered
- * to the USB host
- */
-#define ECM_RCV_NO_BUFFER 0x05 /* Frame missed, no buffers */
-#define ECM_DIR_BYTES_XMIT 0x06 /* Directed bytes transmitted without errors */
-#define ECM_DIR_FRAMES_XMIT 0x07 /* Directed frames transmitted without errors */
-#define ECM_MCAST_BYTES_XMIT 0x08 /* Multicast bytes transmitted without errors */
-#define ECM_MCAST_FRAMES_XMIT 0x09 /* Multicast frames transmitted without errors */
-#define ECM_BCAST_BYTES_XMIT 0x0a /* Broadcast bytes transmitted without errors */
-#define ECM_BCAST_FRAMES_XMIT 0x0b /* Broadcast frames transmitted without errors */
-#define ECM_DIR_BYTES_RCV 0x0c /* Directed bytes received without errors */
-#define ECM_DIR_FRAMES_RCV 0x0d /* Directed frames received without errors */
-#define ECM_MCAST_BYTES_RCV 0x0e /* Multicast bytes received without errors */
-#define ECM_MCAST_FRAMES_RCV 0x0f /* Multicast frames received without errors */
-#define ECM_BCAST_BYTES_RCV 0x10 /* Broadcast bytes received without errors */
-#define ECM_BCAST_FRAMES_RCV 0x11 /* Broadcast frames received without errors */
-#define ECM_RCV_CRC_ERROR 0x12 /* Frames received with circular redundancy check
- * (CRC) or frame check sequence (FCS) error
- */
-#define ECM_TRANSMIT_QUEUE_LENG 0x13 /* Length of transmit queue */
-#define ECM_RCV_ERROR_ALIGNMENT 0x14 /* Frames received with alignment error */
-#define ECM_XMIT_ONE_COLL 0x15 /* Frames transmitted with one collision */
-#define ECM_XMIT_MORE_COLLS 0x16 /* Frames transmitted with more than one collision */
-#define ECM_XMIT_DEFERRED 0x17 /* Frames transmitted after deferral */
-#define ECM_XMIT_MAX_COLLS 0x18 /* Frames not transmitted due to collisions */
-#define ECM_RCV_OVERRUN 0x19 /* Frames not received due to overrun */
-#define ECM_XMIT_UNDERRUN 0x1a /* Frames not transmitted due to underrun */
-#define ECM_XMIT_HB_FAILURE 0x1b /* Frames transmitted with heartbeat failure */
-#define ECM_XMIT_TIMES_CRS_LOST 0x1c /* Times carrier sense signal lost during
- * transmission
- */
-#define ECM_XMIT_LATE_COLLS 0x1d /* Late collisions detected */
-
-/* Table 64: ATM Data Format */
-
-#define ATM_FMT_TYPE1 1 /* Type 1 format: concatenated ATM cells */
-#define ATM_FMT_TYPE1 2 /* Type 2 format: ATM header template + concatenated ATM
- * cell payloads
- */
-#define ATM_FMT_TYPE1 3 /* Type 3 format: AAL 5 SDU */
-
-/* Table 65: ATM Device Statistics Feature Selector Codes */
-
-#define US_CELLS_SENT 0x01h /* The number of cells that have been sent
- * upstream to the WAN link by the ATM layer.
- */
-#define DS_CELLS_RECEIVED 0x02h /* The number of cells that have been received
- * downstream from the WAN link by the ATM
- * layer.
- */
-#defined DS_CELLS_USB_CONGESTION 0x03h /* The number of cells that have been received
- * downstream from the WAN link by the ATM
- * layer and discarded due to congestion on the
- * USB link.
- */
-#define DS_CELLS_AAL5_CRC_ERROR 0x04h /* The number of cells that have been received
- * downstream from the WAN link by the ATM
- * layer and discarded due to AAL5 CRC errors.
- */
-#define DS_CELLS_HEC_ERROR 0x05h /* The number of cells that have been received
- * downstream from the WAN link and discarded
- * due to HEC errors in the cell header.
- */
-#define DS_CELLS_HEC_ERROR_CORRECTED 0x06h /* The number of cells that have been received
- * downstream from the WAN link and have
- * been detected with HEC errors in the cell
- * header and successfully corrected.
- */
-/* Table 66: ATM VC Selector Codes */
-
-#define VC_US_CELLS_SENT 0x01 /* The number of cells that have been sent upstream to
- * the WAN link for the specified VPI/VCI since the
- * device has been powered on or reset
- */
-#define VC_DS_CELLS_RECEIVED 0x02 /* The number of cells that have been received
- * downstream from the WAN link for the specified
- * VPI/VCI since the device has been
- * powered on or reset
- */
-/* Notifications ****************************************************************************/
-/* Table 69: UART State Bitmap Values */
-
-
-#define CDC_UART_RXCARRIER (1 << 0) /* bRxCarrier State of receiver carrier detection
- * mechanism of device. This signal corresponds to
- * V.24 signal 109 and RS-232 signal DCD.
- */
-#define CDC_UART_TXCARRIER (1 << 1) /* bTxCarrier State of transmission carrier. This
- * signal corresponds to V.24 signal 106 and RS-232
- * signal DSR.
- */
-#define CDC_UART_BREAK (1 << 2) /* bBreak State of break detection mechanism of the
- * device.
- */
-#define CDC_UART_RING (1 << 3) /* bRingSignal State of ring signal detection of the
- * device.
- */
-#define CDC_UART_FRAMING (1 << 4) /* bFraming A framing error has occurred */
-#define CDC_UART_PARITY (1 << 5) /* bParity A parity error has occurred */
-#define CDC_UART_OVERRUN (1 << 6) /* bOverRun Received data has been discarded due to
- * overrun in the device.
- */
-/* Table 70: Call State Change Value Definitions */
-
-#define CDC_CALLST_IDLE 0x01 /* Call has become idle */
-#define CDC_CALLST_DIALING 0x02 /* Dialing */
-#define CDC_CALLST_RINGBACK 0x03 /* Ringback, with an extra byte of data provided to
- * describe the type of ringback signaling
- */
-#define CDC_CALLST_CONNECTED 0x04 /* Connected, with an extra byte of data provided to
- * describe the type of connection
- */
-#define CDC_CALLST_INCOMING 0x05 /* Incoming Call, with the extra bytes of data */
-
-/* Table 71: Line State Change Values */
-
-#define CDC_LINEST_IDLE 0x0000 /* Line has become idle */
-#define CDC_LINEST_HOLD 0x0001 /* Line connected to hold position */
-#define CDC_LINEST_OFFHOOK 0x0002 /* Hook-switch has gone off hook */
-#define CDC_LINEST_ONHOOK 0x0003 /* Hook-switch has gone on hook */
-
-/********************************************************************************************
- * Public Types
- ********************************************************************************************/
-
-/* Table 1: Data Class Protocol Wrapper */
-
-struct cdc_protowrapper_s
-{
- uint8_t size[2]; /* Size of wrapper in bytes */
- uint8_t dstproto; /* bDstProtocol, Destination protocol ID */
- uint8_t srcproto; /* bSrcProtocol, Source protocol ID */
- uint8_t data[1]; /* Data payload, actual size depends of size of the wrapper */
-};
-
-/* Functional Descriptors *******************************************************************/
-/* Table 23: Functional Descriptor General Format */
-
-struct cdc_funcdesc_s
-{
- uint8_t size; /* bFunctionLength, Size of this descriptor */
- uint8_t type; /* bDescriptorType, USB_DESC_TYPE_CSINTERFACE */
- uint8_t data[1]; /* Function-specific data follows */
-};
-
-/* Table 26: Class-Specific Descriptor Header Format */
-
-struct cdc_hdr_funcdesc_s
-{
- uint8_t size; /* bFunctionLength, Size of this descriptor */
- uint8_t type; /* bDescriptorType, USB_DESC_TYPE_CSINTERFACE */
- uint8_t subtype; /* bDescriptorSubType, CDC_DSUBTYPE_HDR as defined in Table 25 */
- uint8_t cdc[2]; /* bcdCDC, USB Class Definitions for Communication Devices Specification release
- * number in binary-coded decimal.
- */
-};
-#define SIZEOF_HDR_FUNCDESC 5
-
-/* Table 27: Call Management Functional Descriptor */
-
-struct cdc_callmgmt_funcdesc_s
-{
- uint8_t size; /* bFunctionLength, Size of this descriptor */
- uint8_t type; /* bDescriptorType, USB_DESC_TYPE_CSINTERFACE */
- uint8_t subtype; /* bDescriptorSubType, CDC_DSUBTYPE_CALLMGMT as defined in Table 25 */
- uint8_t caps; /* bmCapabilities: Bit encoded */
- uint8_t ifno; /* bDataInterface, Interface number of Data Class interface
- * optionally used for call management
- */
-};
-#define SIZEOF_CALLMGMT_FUNCDESC 5
-
-/* Table 28: Abstract Control Management Functional Descriptor */
-
-struct cdc_acm_funcdesc_s
-{
- uint8_t size; /* bFunctionLength, Size of this descriptor */
- uint8_t type; /* bDescriptorType, USB_DESC_TYPE_CSINTERFACE */
- uint8_t subtype; /* bDescriptorSubType, CDC_DSUBTYPE_ACM as defined in Table 25 */
- uint8_t caps; /* bmCapabilities: Bit encoded */
-};
-#define SIZEOF_ACM_FUNCDESC 4
-
-/* Table 29: Direct Line Management Functional Descriptor */
-
-struct cdc_dlc_funcdesc_s
-{
- uint8_t size; /* bFunctionLength, Size of this descriptor */
- uint8_t type; /* bDescriptorType, USB_DESC_TYPE_CSINTERFACE */
- uint8_t subtype; /* bDescriptorSubType, CDC_DSUBTYPE_DLC as defined in Table 25 */
- uint8_t caps; /* bmCapabilities: Bit encoded */
-};
-#define SIZEOF_DLC_FUNCDESC 4
-
-/* Table 30: Telephone Ringer Functional Descriptor */
-
-struct cdc_tcmr_funcdesc_s
-{
- uint8_t size; /* bFunctionLength, Size of this descriptor */
- uint8_t type; /* bDescriptorType, USB_DESC_TYPE_CSINTERFACE */
- uint8_t subtype; /* bDescriptorSubType, CDC_DSUBTYPE_TCMRINGER as defined in Table 25 */
- uint8_t volsteps; /* bRingerVolSteps, Number of discrete steps in volume supported
- * by the ringer.
- */
- uint8_t npats; /* bNumRingerPatterns: Number of ringer patterns supported. */
-};
-#define SIZEOF_TCMR_FUNCDESC 5
-
-/* Table 31: Telephone Operational Modes Functional Descriptor */
-
-struct cdc_tcmops_funcdesc_s
-{
- uint8_t size; /* bFunctionLength, Size of this descriptor */
- uint8_t type; /* bDescriptorType, USB_DESC_TYPE_CSINTERFACE */
- uint8_t subtype; /* bDescriptorSubType, CDC_DSUBTYPE_TCMOPS as defined in Table 25 */
- uint8_t caps; /* bmCapabilities: Bit encoded */
-};
-#define SIZEOF_TCMOPS_FUNCDESC 4
-
-/* Table 32: Telephone Call State Reporting Capabilities Descriptor */
-
-struct cdc_tcmc_funcdesc_s
-{
- uint8_t size; /* bFunctionLength, Size of this descriptor */
- uint8_t type; /* bDescriptorType, USB_DESC_TYPE_CSINTERFACE */
- uint8_t subtype; /* bDescriptorSubType, CDC_DSUBTYPE_TCMCALL as defined in Table 25 */
- uint8_t caps; /* bmCapabilities: Bit encoded */
-};
-#define SIZEOF_TCMC_FUNCDESC 4
-
-/* Table 33: Union Interface Functional Descriptor */
-
-struct cdc_union_funcdesc_s
-{
- uint8_t size; /* bFunctionLength, Size of this descriptor */
- uint8_t type; /* bDescriptorType, USB_DESC_TYPE_CSINTERFACE */
- uint8_t subtype; /* bDescriptorSubType, CDC_DSUBTYPE_UNION as defined in Table 25 */
- uint8_t master; /* bMasterInterface: The interface number of the Communication or Data
- * Class interface, designated as the master or controlling interface
- * for the union
- */
- uint8_t slave[1]; /* bSlaveInterfaceN: Interface number of N slave or associated
- * interface in the union
- */
-};
-#define SIZEOF_UNION_FUNCDESC(n) ((n)+4)
-
-/* Table 34: Country Selection Functional Descriptor */
-
-struct cdc_country_funcdesc_s
-{
- uint8_t size; /* bFunctionLength, Size of this descriptor */
- uint8_t type; /* bDescriptorType, USB_DESC_TYPE_CSINTERFACE */
- uint8_t subtype; /* bDescriptorSubType, CDC_DSUBTYPE_COUNTRY as defined in Table 25 */
- uint8_t reldate; /* iCountryCodeRelDate: Index of a string giving the release date for the
- * implemented ISO 3166 Country Codes
- */
- uint16_t code[1]; /* wCountryCodeN: Country code in hexadecimal format as defined in ISO 3166,
- * release date as specified in offset 3 for Nth country supported
- */
-};
-#define SIZEOF_COUNTRY_FUNCDESC(n) (sizeof(uint16_t)*(n) + 4)
-
-/* Table 35: USB Terminal Functional Descriptor */
-
-struct cdc_usbterm_funcdesc_s
-{
- uint8_t size; /* bFunctionLength, Size of this descriptor */
- uint8_t type; /* bDescriptorType, USB_DESC_TYPE_CSINTERFACE */
- uint8_t subtype; /* bDescriptorSubType, CDC_DSUBTYPE_USBTERM as defined in Table 25 */
- uint8_t id; /* bEntityId, Constant uniquely identifying the Terminal */
- uint8_t ifno; /* bInInterfaceNo, The input interface number of the associated
- * USB interface
- */
- uint8_t outif; /* bOutInterfaceNo, The output interface number of the associated
- * USB interface
- */
- uint8_t options; /* bmOptions, bit-encoded options */
- uint8_t child[1]; /* Nth ID of lower Terminal or Unit to which this Terminal is connected. */
-};
-#define SIZEOF_USBTERM_FUNCDESC(n) ((n)+7)
-
-/* Table 36: Network Channel Terminal Functional Descriptor */
-
-struct cdc_netchan_funcdesc_s
-{
- uint8_t size; /* bFunctionLength, Size of this descriptor */
- uint8_t type; /* bDescriptorType, USB_DESC_TYPE_CSINTERFACE */
- uint8_t subtype; /* bDescriptorSubType, CDC_DSUBTYPE_NETCHAN as defined in Table 25 */
- uint8_t id; /* bEntityId, Constant uniquely identifying the Terminal */
- uint8_t name; /* iName, Index of string descriptor, describing the name of the Network
- * Channel Terminal
- */
- uint8_t index; /* bChannelIndex, The channel index of the associated network channel */
- uint8_t phyif; /* bPhysicalInterface, Type of physical interface */
-};
-#define SIZEOF_NETCHAN_FUNCDESC 7
-
-/* Table 37: Protocol Unit Functional Descriptor */
-
-struct cdc_protounit_funcdesc_s
-{
- uint8_t size; /* bFunctionLength, Size of this descriptor */
- uint8_t type; /* bDescriptorType, USB_DESC_TYPE_CSINTERFACE */
- uint8_t subtype; /* bDescriptorSubType, CDC_DSUBTYPE_PROTOUNIT as defined in Table 25 */
- uint8_t id; /* bEntityId, Constant uniquely identifying the Unit */
- uint8_t proto; /* bProtocol, Protocol code as defined in Table 19 */
- uint8_t child[1]; /* Nth ID of lower Terminal or Unit to which this Terminal is connected */
-};
-#define SIZEOF_PROTOUNIT_FUNCDESC(n) ((n)+5)
-
-/* Table 38: Extension Unit Functional Descriptor */
-
-struct cdc_extunit_funcdesc_s
-{
- uint8_t size; /* bFunctionLength, Size of this descriptor */
- uint8_t type; /* bDescriptorType, USB_DESC_TYPE_CSINTERFACE */
- uint8_t subtype; /* bDescriptorSubType, CDC_DSUBTYPE_EXTUNIT as defined in Table 25 */
- uint8_t id; /* bEntityId, Constant uniquely identifying the Extension Unit */
- uint8_t code; /* bExtensionCode, Vendor specific code identifying the Extension Unit */
- uint8_t name; /* iName, Index of string descriptor, describing the name of the Extension Unit */
- uint8_t child[1]; /* Nth ID of lower Terminal or Unit to which this Terminal is connected */
-};
-#define SIZEOF_EXTUNIT_FUNCDESC(n) ((n)+6)
-
-/* Table 39: Multi-Channel Management Functional Descriptor */
-
-struct cdc_mcm_funcdesc_s
-{
- uint8_t size; /* bFunctionLength, Size of this descriptor */
- uint8_t type; /* bDescriptorType, USB_DESC_TYPE_CSINTERFACE */
- uint8_t subtype; /* bDescriptorSubType, CDC_DSUBTYPE_MCM as defined in Table 25 */
- uint8_t caps; /* bmCapabilities: Bit encoded */
-};
-#define SIZEOF_MCM_FUNCDESC 4
-
-/* Table 40: CAPI Control Management Functional Descriptor */
-
-struct cdc_capi_funcdesc_s
-{
- uint8_t size; /* bFunctionLength, Size of this descriptor */
- uint8_t type; /* bDescriptorType, USB_DESC_TYPE_CSINTERFACE */
- uint8_t subtype; /* bDescriptorSubType, CDC_DSUBTYPE_CAPI as defined in Table 25 */
- uint8_t caps; /* bmCapabilities: Bit encoded */
-};
-#define SIZEOF_CAPI_FUNCDESC 4
-
-/* Table 41: Ethernet Networking Functional Descriptor*/
-
-struct cdc_ecm_funcdesc_s
-{
- uint8_t size; /* bFunctionLength, Size of this descriptor */
- uint8_t type; /* bDescriptorType, USB_DESC_TYPE_CSINTERFACE */
- uint8_t subtype; /* bDescriptorSubType, CDC_DSUBTYPE_ECM as defined in Table 25 */
- uint8_t mac; /* iMACAddress, Index of teh 48bit Ethernet MAC address string descriptor */
- uint8_t stats[4]; /* bmEthernetStatistics, Indicates which Ethernet statistics functions
- * the device collects. See Table 42.
- */
- uint8_t maxseg[2]; /* wMaxSegmentSize, The maximum segment size that the Ethernet device is
- * capable of supporting.
- */
- uint8_t nmcflts[2]; /* wNumberMCFilters, Contains the number of multicast filters that can be
- * configured by the host.
- */
- uint8_t npwrflts; /* bNumberPowerFilters, Contains the number of pattern filters that are
- * available for causing wake-up of the host.
- */
-};
-#define SIZEOF_ECM_FUNCDESC 13
-
-/* Table 43: ATM Networking Functional Descriptor */
-
-struct cdc_atm_funcdesc_s
-{
- uint8_t size; /* bFunctionLength, Size of this descriptor */
- uint8_t type; /* bDescriptorType, USB_DESC_TYPE_CSINTERFACE */
- uint8_t subtype; /* bDescriptorSubType, CDC_DSUBTYPE_ATM as defined in Table 25 */
- uint8_t endid; /* iEndSystemIdentifier, Index of End System Identifier string descriptor */
- uint8_t datacaps; /* bmDataCapabilities, The ATM data types the device supports */
- uint8_t devstats; /* bmATMDeviceStatistics, Indicates which optional statistics functions the
- * device collects.
- */
- uint8_t mxseg2[2]; /* wType2MaxSegmentSize, The maximum segment size that the Type 2 device is
- * capable of supporting.
- */
- uint8_t mxseg3[2]; /* wType3MaxSegmentSize, The maximum segment size that the Type 3 device is
- * capable of supporting
- */
- uint8_t mxvc[2]; /* wMaxVC, The maximum number of simultaneous virtual circuits the device is
- * capable of supporting
- */
-};
-#define SIZEOF_CALLMGMT_FUNCDESC 12
-
-/* Descriptor Data Structures ***************************************************************/
-/* Table 50: Line Coding Structure */
-
-struct cdc_linecoding_s
-{
- uint8_t baud[4]; /* dwDTERate, Data terminal rate, in bits per second */
- uint8_t stop; /* bCharFormat 0=1, 1=1.5, 2=2 stop bits */
- uint8_t parity /* bParityType, 0=None, 1=Odd, 2=Even, 3=Mark, 4=Space */
- uint8_t nbits /* bDataBits, Data bits (5,6,7,8, or 16) */
-};
-
-/* Table 55: Line Status Information Structure */
-
-struct cdc_linestatus_s
-{
- uint8_t size[2]; /* wLength, Size of this structure, in bytes */
- uint8_t ringer[4]; /* dwRingerBitmap, Ringer Configuration bitmap for this line */
- uint8_t line[4]; /* dwLineState, Defines current state of the line */
- uint32_t call[1]; /* dwCallStateN, Defines current state of call N on the line */
-};
-
-/* Table 60: Unit Parameter Structure */
-
-struct cdc_unitparm_s
-{
- uint8_t id; /* bEntityId, Unit ID */
- uint8_t index; /* bParameterIndex, A zero based value indicating Unit parameter index */
-};
-
-/* Table 61: Power Management Pattern Filter Structure */
-
-/* Notification Data Structures *************************************************************/
-/* Table 72: ConnectionSpeedChange Data Structure */
-
-struct cdc_speedchange_s
-{
- uint8_t us[4]; /* Contains the upstream bit rate, in bits per second */
- uint8_t ds[4]; /* Contains the downstream bit rate, in bits per second */
-};
-
-#endif /* __INCLUDE_NUTTX_USB_CDC_H */
+/******************************************************************************************** + * include/nuttx/usb/cdc.h + * + * Copyright (C) 2011 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * + * References: "Universal Serial Bus Class Definitions for Communication + * Devices," Version 1.1, January 19, 1999 + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ********************************************************************************************/ + +#ifndef __INCLUDE_NUTTX_USB_CDC_H +#define __INCLUDE_NUTTX_USB_CDC_H + +/******************************************************************************************** + * Included Files + ********************************************************************************************/ + +#include <nuttx/config.h> + +/******************************************************************************************** + * Pre-processor Definitions + ********************************************************************************************/ +/* Device Class Codes ***********************************************************************/ +/* Table 14: Communication Device Class Code (see definition USB_CLASS_CDC in usb.h) */ +/* Table 18: Data Interface Class Code (see definition USB_CLASS_CDC_DATA in usb.h) */ + +/* Communication Inteface Class Codes *******************************************************/ +/* Table 15: Communication Interface Class Code */ + +#define CDC_CLASS_COMM 0x02 /* Communication Interface Class */ + +/* Communication Interface Sub-Class Codes **************************************************/ + +#define CDC_SUBCLASS_NONE 0x00 /* Reserved */ +#define CDC_SUBCLASS_DLC 0x01 /* Direct Line Control Model */ +#define CDC_SUBCLASS_ACM 0x02 /* Abstract Control Model */ +#define CDC_SUBCLASS_TCM 0x03 /* Telephone Control Model */ +#define CDC_SUBCLASS_MCM 0x04 /* Multi-Channel Control Model */ +#define CDC_SUBCLASS_CAPI 0x05 /* CAPI Control Model */ +#define CDC_SUBCLASS_ECM 0x06 /* Ethernet Networking Control Model */ +#define CDC_SUBCLASS_ATM 0x07 /* ATM Networking Control Model */ + /* 0x08-0x7f Reserved (future use) */ + /* 0x80-0xfe Reserved (vendor specific) */ +/* Communication Interface Class Protocol Codes ********************************************/ +/* Table 17: Communication Interface Class Control Protocol Codes */ + +#define CDC_PROTO_NONE 0x00 /* No class specific protocol required */ +#define CDC_PROTO_ATM 0x01 /* Common AT commands (also known as Hayes compatible”) */ + /* 0x02-0xfe Reserved (future use) */ +#define CDC_PROTO_VENDOR 0xff /* Vendor-specific */ + +/* Data Interface Sub-Class Codes ***********************************************************/ +/* None defined, should be zero */ + +#define CDC_DATA_SUBCLASS_NONE 0x00 + +/* Date Interface Class Protocol Codes ******************************************************/ +/* Table 19: Data Interface Class Protocol Codes */ + +#define CDC_DATA_PROTO_NONE 0x00 /* No class specific protocol required */ + /* 0x01-0x2f Reserved (future use) */ +#define CDC_DATA_PROTO_ISDN 0x30 /* Physical interface protocol for ISDN BRI */ +#define CDC_DATA_PROTO_HDLC 0x31 /* HDLC */ +#define CDC_DATA_PROTO_TRANSP 0x32 /* Transparent */ + /* 0x33-0x4f Reserved (future use) */ +#define CDC_DATA_PROTO_Q921M 0x50 /* Management protocol for Q.921 data link protocol */ +#define CDC_DATA_PROTO_Q921 0x51 /* Data link protocol for Q.931 */ +#define CDC_DATA_PROTO_Q921TM 0x52 /* TEI-multiplexor for Q.921 data link protocol */ + /* 0x53-0x8f Reserved (future use) */ +#define CDC_DATA_PROTO_V42BIS 0x90 /* Data compression procedures */ +#define CDC_DATA_PROTO_EUROISDN 0x91 /* Euro-ISDN protocol control */ +#define CDC_DATA_PROTO_V120 0x92 /* V.24 rate adaptation to ISDN */ +#define CDC_DATA_PROTO_CAPI 0x93 /* CAPI Commands */ + /* 0x94-0xfc Reserved (future use) */ +#define CDC_DATA_PROTO_HBD 0xfd /* Host based driver. */ +#define CDC_DATA_PROTO_PUFD 0xfe /* The protocol(s) are described using a Protocol Unit + * Functional Descriptors on Communication Class + * Interface. + */ +#define CDC_DATA_PROTO_VENDOR 0xff /* Vendor-specific */ + +/* Requests and Notifications ***************************************************************/ +/* Table 2: Requests, Direct Line Control Model */ + +#define DLC_SET_AUX_LINE_STATE 0x10 /* Request to connect or disconnect secondary jack from + * POTS circuit or CODEC, depending on hook state. + * (Optional). + */ +#define DLC_SET_HOOK_STATE 0x11 /* Select relay setting for on-hook, off-hook, and caller + * ID. (Required) + */ +#define DLC_PULSE_SETUP 0x12 /* Initiate pulse dialing preparation. (Optional). + */ +#define DLC_SEND_PULSE 0x13 /* Request number of make/break cycles to generate. + * (Optional) + */ +#define DLC_SET_PULSE_TIME 0x14 /* Setup value for time of make and break periods when + * pulse dialing. (Optional) + */ +#define DLC_RING_AUX_JACK 0x15 /* Request for a ring signal to be generated on secondary + * phone jack. (Optional) + */ +/* Table 3: Notifications, Direct Line Control Model */ + +#define DLC_AUX_JACK_HOOK_STATE 0x08 /* Indicates hook state of secondary device plugged + * into the auxiliary phone jack. (Optional) + */ +#define DLC_RING_DETECT 0x09 /* Message to notify host that ring voltage was + * detected on POTS interface. (Required) + */ +/* Table 4: Requests, Abstract Control Model */ + +#define ACM_SEND_COMMAND 0x00 /* Issues a command in the format of the supported + * control protocol. (Required) + */ +#define ACM_GET_RESPONSE 0x01 /* Requests a response in the format of the + * supported control protocol. (Required) + */ +#define ACM_SET_COMM_FEATURE 0x02 /* Controls the settings for a particular + * communication feature. (Optional) + */ +#define ACM_GET_COMM_FEATURE 0x03 /* Returns the current settings for the + * communication feature. (Optional) + */ +#define ACM_CLEAR_COMM_FEATURE 0x04 /* Clears the settings for a particular + * communication feature. (Optional) + */ +#define ACM_SET_LINE_CODING 0x20 /* Configures DTE rate, stop-bits, parity, and + * number-of-character bits. (Optional) + */ +#define ACM_GET_LINE_CODING 0x21 /* Requests current DTE rate, stop-bits, parity, and + * number-of-character bits. (Optional) + */ +#define ACM_SET_CTRL_LINE_STATE 0x22 /* RS-232 signal used to tell the DCE device the + * DTE device is now present. (Optional) + */ +#define ACM_SEND_BREAK 0x23 /* Sends special carrier + */ +/* Table 5: Notifications, Abstract Control Model */ + +#define ACM_NETWORK_CONNECTION 0x00 /* Notification to host of network connection status. + * (Optional) + */ +#define ACM_RESPONSE_AVAILABLE 0x01 /* Notification to host to issue a GET_ENCAPSULATED_RESPONSE + * request. (Required) + */ +#define ACM_SERIAL_STATE 0x20 /* Returns the current state of the carrier detect, DSR, + * break, and ring signal. (Optional) + */ +/* Table 6: Requests, Telephone Control Model */ + +#define TCM_SET_COMM_FEATURE 0x02 /* Used to set a unique communication feature, which is + * normally specific to a particular device. + * (Optional) + */ +#define TCM_GET_COMM_FEATURE 0x03 /* Returns the current settings for the communication + * feature. (Optional) + */ +#define TCM_CLEAR_COMM_FEATURE 0x04 /* Clears the settings for a particular communication + * feature. (Optional) + */ +#define TCM_SET_RINGER_PARMS 0x30 /* Configures the ringer for a telephone device. + * (Optional) + */ +#define TCM_GET_RINGER_PARMS 0x31 /* Gets the current ringer configuration for a telephone + * device. (Required) + */ +#define TCM_SET_OPERATION_PARMS 0x32 /* Configures the operational mode of the telephone. + * (Optional) + */ +#define TCM_GET_OPERATION_PARMS 0x33 /* Gets the current operational mode of the telephone. + * (Optional) + */ +#define TCM_SET_LINE_PARMS 0x34 /* Allows changing the current state of the line + * associated with the interface, providing basic call + * capabilities, such as dialing and answering calls. + * (Required) + */ +#define TCM_GET_LINE_PARMS 0x35 /* Gets current status of the line. (Required) + */ +#define TCM_DIAL_DIGITS 0x36 /* Dials digits on the network connection. (Required) + */ +/* Table 7: Notifications, Telephone Control Model */ + +#define TCM_CALL_STATE_CHANGE 0x28 /* DReports a state change on a call. (Required) + */ +#define TCM_LINE_STATE_CHANGE 0x29 /* DReports a state change on a line. (Optional) + */ +/* Table 8: Requests, Multi-Channel Model */ + +#define MCM_SET_UNIT_PARAM 0x37 /* Used to set a Unit specific parameter (Optional) + */ +#define MCM_GET_UNIT_PARAM 0x38 /* Used to retrieve a Unit specific parameter (Required) + */ +#define MCM_CLEAR_UNIT_PARAM 0x39 /* Used to set a Unit specific parameter to its default + * state. (Optional) + */ +/* Table 9: Request, CAPI Control Model */ + +#define CAPI_GET_PROFILE 0x3a /* Returns the implemented capabilities of the device + * (Required) + */ +/* Table 10: Requests, Ethernet Networking Control Model */ + +#define ECM_SEND_COMMAND 0x00 /* Issues a command in the format of the supported + * control protocol. The intent of this mechanism is + * to support networking devices (e.g., host-based + * cable modems) that require an additional vendor- + * defined interface for media specific hardware + * configuration and management. (Optional) + */ +#define ECM_GET_RESPONSE 0x01 /* equests a response in the format of the supported + * control protocol. + * (Optional) + */ +#define ECM_SET_MCAST_FILTERS 0x40 /* As applications are loaded and unloaded on the host, + * the networking transport will instruct the device’s MAC + * driver to change settings of the Networking device’s + * multicast filters. (Optional) + */ +#define ECM_SET_PM_PAT_FILTER 0x41 /* Some hosts are able to conserve energy and stay quiet + * in a “sleeping” state while not being used. USB + * Networking devices may provide special pattern filtering + * hardware that enables it to wake up the attached host + * on demand when something is attempting to contact the + * host (e.g., an incoming web browser connection). + * Primitives are needed in management plane to negotiate + * the setting of these special filters + * (Optional) + */ +#define ECM_GET_PM_PAT_FILTER 0x42 /* Retrieves the status of the above power management + * pattern filter setting + * (Optional) + */ +#define ECM_SET_PACKET_FILTER 0x43 /* Sets device filter for running a network analyzer + * application on the host machine (Required) + */ +#define ECM_GET_STATISTIC 0x44 /* Retrieves Ethernet device statistics such as frames + * transmitted, frames received, and bad frames received. + * (Optional) + */ +/* Table 11: Notifications, Ethernet Networking Control Model */ + +#define ECM_NETWORK_CONNECTION 0x00 /* Reports whether or not the physical layer (modem, + * Ethernet PHY, etc.) link is up. (Required) + */ +#define ECM_RESPONSE_AVAILABLE 0x01 /* Notification to host to issue a + * GET_ENCAPSULATED_RESPONSE request. (Optional) + */ +#define ECM_SPEED_CHANGE 0x2a /* Reports a change in upstream or downstream (Required) + */ +/* Table 12: Requests, ATM Networking Control Model */ + +#define ATM_SEND_COMMAND 0x00 /* Issues a command in the format of the supported control + * protocol. The intent of this mechanism is to support + * networking devices (e.g., host-based cable modems) + * that require an additional vendor-defined interface for + * media specific hardware configuration and + * management. (Optional) + */ +#define ATM_GET_RESPONSE 0x01 /* Requests a response in the format of the supported + * control protocol. (Optional) + */ +#define ATM_SET_DATA_FORMAT 0x50 /* Chooses which ATM data format will be exchanged + * between the host and the ATM Networking device. + * (Required) + */ +#define ATM_GET_DEV_STATISTICS 0x51 /* Retrieves global statistics from the ATM Networking + * device. (Required) + */ +#define ATM_SET_DEFAULT_VC 0x52 /* Pre-selects the VPI/VCI value for subsequent + * GetATMVCStatistics requests (Optional) + */ +#define ATM_GET_VC_STATISTICS 0x53 /* Retrieves statistics from the ATM Networking device for + * a particular VPI/VCI. (Optional) + */ +/* Table 13: Requests, Ethernet and ATM Networking Control Model */ + +#define ATM_NETWORK_CONNECTION 0x00 /* Reports whether or not the physical layer (modem, + * Ethernet PHY, etc.) link is up. (Required) + */ +#define ECM_NETWORK_CONNECTION ATM_NETWORK_CONNECTION +#define ATM_RESPONSE_AVAILABLE 0x01 /* Notification to host to issue a + * GET_ENCAPSULATED_RESPONSE request. (Optional) + */ +#define ECM_RESPONSE_AVAILABLE ATM_RESPONSE_AVAILABLE +#define ATM_SPEED_CHANGE 0x2a /* Reports a change in upstream or downstream speed of the + * networking device connection. (Required) + */ +#define ECM_SPEED_CHANGE ATM_SPEED_CHANGE + +/* Descriptors ******************************************************************************/ +/* Table 25: bDescriptor SubType in Functional Descriptors */ + +#define CDC_DSUBTYPE_HDR 0x00 /* Header Functional Descriptor, which marks the + * beginning of the concatenated set of functional + * descriptors for the interface. */ +#define CDC_DSUBTYPE_CALLMGMT 0x01 /* Call Management Functional Descriptor */ +#define CDC_DSUBTYPE_ACM 0x02 /* Abstract Control Management Functional Descriptor */ +#define CDC_DSUBTYPE_DLC 0x03 /* Direct Line Management Functional Descriptor */ +#define CDC_DSUBTYPE_TCMRINGER 0x04 /* Telephone Ringer Functional Descriptor */ +#define CDC_DSUBTYPE_TCMCALL 0x05 /* Telephone Call and Line State Reporting Capabilities + * Functional Descriptor. */ +#define CDC_DSUBTYPE_UNION 0x06 /* Union Functional descriptor */ +#define CDC_DSUBTYPE_COUNTRY 0x07 /* Country Selection Functional Descriptor */ +#define CDC_DSUBTYPE_TCMOPS 0x08 /* Telephone Operational Modes Functional Descriptor */ +#define CDC_DSUBTYPE_USBTERM 0x09 /* USB Terminal Functional Descriptor */ +#define CDC_DSUBTYPE_NETCHAN 0x0a /* Network Channel Terminal Descriptor */ +#define CDC_DSUBTYPE_PROTOUNIT 0x0b /* Protocol Unit Functional Descriptor */ +#define CDC_DSUBTYPE_EXTUNIT 0x0c /* Extension Unit Functional Descriptor */ +#define CDC_DSUBTYPE_MCM 0x0d /* Multi-Channel Management Functional Descriptor */ +#define CDC_DSUBTYPE_CAPI 0x0e /* CAPI Control Management Functional Descriptor */ +#define CDC_DSUBTYPE_ECM 0x0f /* Ethernet Networking Functional Descriptor */ +#define CDC_DSUBTYPE_ATM 0x10 /* ATM Networking Functional Descriptor */ + /* 0x11-0xff Reserved (future use) */ + +/* Table 42: Ethernet Statistics Capabilities */ + +#define ECMCAP_XMIT_OK (1 << 0) /* Frames transmitted without errors */ +#define ECMCAP_RVC_OK (1 << 1) /* Frames received without errors */ +#define ECMCAP_XMIT_ERROR (1 << 2) /* Frames not transmitted, or transmitted with errors */ +#define ECMCAP_RCV_ERROR (1 << 3) /* Frames received with errors that are not delivered + * to the USB host + */ +#define ECMCAP_RCV_NO_BUFFER (1 << 4) /* Frame missed, no buffers */ +#define ECMCAP_DIR_BYTES_XMIT (1 << 5) /* Directed bytes transmitted without errors */ +#define ECMCAP_DIR_FRAMES_XMIT (1 << 6) /* Directed frames transmitted without errors */ +#define ECMCAP_MCAST_BYTES_XMIT (1 << 7) /* Multicast bytes transmitted without errors */ +#define ECMCAP_MCAST_FRAMES_XMIT (1 << 8) /* Multicast frames transmitted without errors */ +#define ECMCAP_BCAST_BYTES_XMIT (1 << 9) /* Broadcast bytes transmitted without errors */ +#define ECMCAP_BCAST_FRAMES_XMIT (1 << 10) /* Broadcast frames transmitted without errors */ +#define ECMCAP_DIR_BYTES_RCV (1 << 11) /* Directed bytes received without errors */ +#define ECMCAP_DIR_FRAMES_RCV (1 << 12) /* Directed frames received without errors */ +#define ECMCAP_MCAST_BYTES_RCV (1 << 13) /* Multicast bytes received without errors */ +#define ECMCAP_MCAST_FRAMES_RCV (1 << 14) /* Multicast frames received without errors */ +#define ECMCAP_BCAST_BYTES_RCV (1 << 15) /* Broadcast bytes received without errors */ +#define ECMCAP_BCAST_FRAMES_RCV (1 << 16) /* Broadcast frames received without errors */ +#define ECMCAP_RCV_CRC_ERROR (1 << 17) /* Frames received with circular redundancy check + * (CRC) or frame check sequence (FCS) error + */ +#define ECMCAP_TRANSMIT_QUEUE_LENG (1 << 18) /* Length of transmit queue */ +#define ECMCAP_RCV_ERROR_ALIGNMENT (1 << 19) /* Frames received with alignment error */ +#define ECMCAP_XMIT_ONE_COLL (1 << 20) /* Frames transmitted with one collision */ +#define ECMCAP_XMIT_MORE_COLLS (1 << 21) /* Frames transmitted with more than one collision */ +#define ECMCAP_XMIT_DEFERRED (1 << 22) /* Frames transmitted after deferral */ +#define ECMCAP_XMIT_MAX_COLLS (1 << 23) /* Frames not transmitted due to collisions */ +#define ECMCAP_RCV_OVERRUN (1 << 24) /* Frames not received due to overrun */ +#define ECMCAP_XMIT_UNDERRUN (1 << 25) /* Frames not transmitted due to underrun */ +#define ECMCAP_XMIT_HB_FAILURE (1 << 26) /* Frames transmitted with heartbeat failure */ +#define ECMCAP_XMIT_TIMES_CRS_LOST (1 << 27) /* Times carrier sense signal lost during + * transmission + */ +#define ECMCAP_XMIT_LATE_COLLS (1 << 28) /* Late collisions detected */ + /* Bits 29-31 Resrved, Must be set to zero */ + +/* Table 47: Communication Feature Selector Codes */ + +#define FEATURE_ABSTRACT_STATE 0x01 /* Two bytes of data describing multiplexed state + * and idle state for this Abstract Model + * communications device + */ +#define FEATURE_COUNTRY_SETTING 0x02 /* Country code in hexadecimal format as defined in + * ISO 3166 + */ +/* Table 49: POTS Relay Configuration Values */ + +#define POTS_ON_HOOK 0x0000 +#define POTS_OFF_HOOK 0x0001 +#define POTS_SNOOPING 0x0002 + +/* Table 50: Line Coding Structure */ + +#define CDC_CHFMT_STOP1 0 /* One stop bit */ +#define CDC_CHFMT_STOP1p5 1 /* 1.5 stop bits */ +#define CDC_CHFMT_STOP2 2 /* 2 stop bits */ + +#define CDC_PARITY_NONE 0 /* No parity */ +#define CDC_PARITY_ODD 1 /* Odd parity */ +#define CDC_PARITY_EVEN 2 /* Even parity */ +#define CDC_PARITY_MARK 3 /* Mark parity */ +#define CDC_PARITY_SPACE 4 /* Space parity */ + +/* Table 58: Call State Value Definitions */ + +#define CDC_CALLST_IDLE 0x00 /* Call is idle */ +#define CDC_CALLST_DIAL 0x01 /* Typical dial tone */ +#define CDC_CALLST_INTDIAL 0x02 /* Interrupted dial tone */ +#define CDC_CALLST_DIALING 0x03 /* Dialing is in progress */ +#define CDC_CALLST_RINGBACK 0x04 /* Ringback */ +#define CDC_CALLST_CONNECTED 0x05 /* Connected */ +#define CDC_CALLSTINCOMING 0x06 /* Incoming call */ + +/* Table 62: Ethernet Packet Filter Bitmap */ + +#define PACKET_TYPE_PROMISCUOUS (1 << 0) +#define PACKET_TYPE_ALL_MULTICAST (1 << 1) +#define PACKET_TYPE_DIRECTED (1 << 2) +#define PACKET_TYPE_BROADCAST (1 << 3) +#define PACKET_TYPE_MULTICAST (1 << 4) + +/* Table 63: Ethernet Statistics Feature Selector Codes */ + +#define ECM_XMIT_OK 0x01 /* Frames transmitted without errors */ +#define ECM_RVC_OK 0x02 /* Frames received without errors */ +#define ECM_XMIT_ERROR 0x03 /* Frames not transmitted, or transmitted with errors */ +#define ECM_RCV_ERROR 0x04 /* Frames received with errors that are not delivered + * to the USB host + */ +#define ECM_RCV_NO_BUFFER 0x05 /* Frame missed, no buffers */ +#define ECM_DIR_BYTES_XMIT 0x06 /* Directed bytes transmitted without errors */ +#define ECM_DIR_FRAMES_XMIT 0x07 /* Directed frames transmitted without errors */ +#define ECM_MCAST_BYTES_XMIT 0x08 /* Multicast bytes transmitted without errors */ +#define ECM_MCAST_FRAMES_XMIT 0x09 /* Multicast frames transmitted without errors */ +#define ECM_BCAST_BYTES_XMIT 0x0a /* Broadcast bytes transmitted without errors */ +#define ECM_BCAST_FRAMES_XMIT 0x0b /* Broadcast frames transmitted without errors */ +#define ECM_DIR_BYTES_RCV 0x0c /* Directed bytes received without errors */ +#define ECM_DIR_FRAMES_RCV 0x0d /* Directed frames received without errors */ +#define ECM_MCAST_BYTES_RCV 0x0e /* Multicast bytes received without errors */ +#define ECM_MCAST_FRAMES_RCV 0x0f /* Multicast frames received without errors */ +#define ECM_BCAST_BYTES_RCV 0x10 /* Broadcast bytes received without errors */ +#define ECM_BCAST_FRAMES_RCV 0x11 /* Broadcast frames received without errors */ +#define ECM_RCV_CRC_ERROR 0x12 /* Frames received with circular redundancy check + * (CRC) or frame check sequence (FCS) error + */ +#define ECM_TRANSMIT_QUEUE_LENG 0x13 /* Length of transmit queue */ +#define ECM_RCV_ERROR_ALIGNMENT 0x14 /* Frames received with alignment error */ +#define ECM_XMIT_ONE_COLL 0x15 /* Frames transmitted with one collision */ +#define ECM_XMIT_MORE_COLLS 0x16 /* Frames transmitted with more than one collision */ +#define ECM_XMIT_DEFERRED 0x17 /* Frames transmitted after deferral */ +#define ECM_XMIT_MAX_COLLS 0x18 /* Frames not transmitted due to collisions */ +#define ECM_RCV_OVERRUN 0x19 /* Frames not received due to overrun */ +#define ECM_XMIT_UNDERRUN 0x1a /* Frames not transmitted due to underrun */ +#define ECM_XMIT_HB_FAILURE 0x1b /* Frames transmitted with heartbeat failure */ +#define ECM_XMIT_TIMES_CRS_LOST 0x1c /* Times carrier sense signal lost during + * transmission + */ +#define ECM_XMIT_LATE_COLLS 0x1d /* Late collisions detected */ + +/* Table 64: ATM Data Format */ + +#define ATM_FMT_TYPE1 1 /* Type 1 format: concatenated ATM cells */ +#define ATM_FMT_TYPE1 2 /* Type 2 format: ATM header template + concatenated ATM + * cell payloads + */ +#define ATM_FMT_TYPE1 3 /* Type 3 format: AAL 5 SDU */ + +/* Table 65: ATM Device Statistics Feature Selector Codes */ + +#define US_CELLS_SENT 0x01h /* The number of cells that have been sent + * upstream to the WAN link by the ATM layer. + */ +#define DS_CELLS_RECEIVED 0x02h /* The number of cells that have been received + * downstream from the WAN link by the ATM + * layer. + */ +#define DS_CELLS_USB_CONGESTION 0x03h /* The number of cells that have been received + * downstream from the WAN link by the ATM + * layer and discarded due to congestion on the + * USB link. + */ +#define DS_CELLS_AAL5_CRC_ERROR 0x04h /* The number of cells that have been received + * downstream from the WAN link by the ATM + * layer and discarded due to AAL5 CRC errors. + */ +#define DS_CELLS_HEC_ERROR 0x05h /* The number of cells that have been received + * downstream from the WAN link and discarded + * due to HEC errors in the cell header. + */ +#define DS_CELLS_HEC_ERROR_CORRECTED 0x06h /* The number of cells that have been received + * downstream from the WAN link and have + * been detected with HEC errors in the cell + * header and successfully corrected. + */ +/* Table 66: ATM VC Selector Codes */ + +#define VC_US_CELLS_SENT 0x01 /* The number of cells that have been sent upstream to + * the WAN link for the specified VPI/VCI since the + * device has been powered on or reset + */ +#define VC_DS_CELLS_RECEIVED 0x02 /* The number of cells that have been received + * downstream from the WAN link for the specified + * VPI/VCI since the device has been + * powered on or reset + */ +/* Notifications ****************************************************************************/ +/* Table 69: UART State Bitmap Values */ + + +#define CDC_UART_RXCARRIER (1 << 0) /* bRxCarrier State of receiver carrier detection + * mechanism of device. This signal corresponds to + * V.24 signal 109 and RS-232 signal DCD. + */ +#define CDC_UART_TXCARRIER (1 << 1) /* bTxCarrier State of transmission carrier. This + * signal corresponds to V.24 signal 106 and RS-232 + * signal DSR. + */ +#define CDC_UART_BREAK (1 << 2) /* bBreak State of break detection mechanism of the + * device. + */ +#define CDC_UART_RING (1 << 3) /* bRingSignal State of ring signal detection of the + * device. + */ +#define CDC_UART_FRAMING (1 << 4) /* bFraming A framing error has occurred */ +#define CDC_UART_PARITY (1 << 5) /* bParity A parity error has occurred */ +#define CDC_UART_OVERRUN (1 << 6) /* bOverRun Received data has been discarded due to + * overrun in the device. + */ +/* Table 70: Call State Change Value Definitions */ + +#define CDC_CALLST_IDLE 0x01 /* Call has become idle */ +#define CDC_CALLST_DIALING 0x02 /* Dialing */ +#define CDC_CALLST_RINGBACK 0x03 /* Ringback, with an extra byte of data provided to + * describe the type of ringback signaling + */ +#define CDC_CALLST_CONNECTED 0x04 /* Connected, with an extra byte of data provided to + * describe the type of connection + */ +#define CDC_CALLST_INCOMING 0x05 /* Incoming Call, with the extra bytes of data */ + +/* Table 71: Line State Change Values */ + +#define CDC_LINEST_IDLE 0x0000 /* Line has become idle */ +#define CDC_LINEST_HOLD 0x0001 /* Line connected to hold position */ +#define CDC_LINEST_OFFHOOK 0x0002 /* Hook-switch has gone off hook */ +#define CDC_LINEST_ONHOOK 0x0003 /* Hook-switch has gone on hook */ + +/******************************************************************************************** + * Public Types + ********************************************************************************************/ + +/* Table 1: Data Class Protocol Wrapper */ + +struct cdc_protowrapper_s +{ + uint8_t size[2]; /* Size of wrapper in bytes */ + uint8_t dstproto; /* bDstProtocol, Destination protocol ID */ + uint8_t srcproto; /* bSrcProtocol, Source protocol ID */ + uint8_t data[1]; /* Data payload, actual size depends of size of the wrapper */ +}; + +/* Functional Descriptors *******************************************************************/ +/* Table 23: Functional Descriptor General Format */ + +struct cdc_funcdesc_s +{ + uint8_t size; /* bFunctionLength, Size of this descriptor */ + uint8_t type; /* bDescriptorType, USB_DESC_TYPE_CSINTERFACE */ + uint8_t data[1]; /* Function-specific data follows */ +}; + +/* Table 26: Class-Specific Descriptor Header Format */ + +struct cdc_hdr_funcdesc_s +{ + uint8_t size; /* bFunctionLength, Size of this descriptor */ + uint8_t type; /* bDescriptorType, USB_DESC_TYPE_CSINTERFACE */ + uint8_t subtype; /* bDescriptorSubType, CDC_DSUBTYPE_HDR as defined in Table 25 */ + uint8_t cdc[2]; /* bcdCDC, USB Class Definitions for Communication Devices Specification release + * number in binary-coded decimal. + */ +}; +#define SIZEOF_HDR_FUNCDESC 5 + +/* Table 27: Call Management Functional Descriptor */ + +struct cdc_callmgmt_funcdesc_s +{ + uint8_t size; /* bFunctionLength, Size of this descriptor */ + uint8_t type; /* bDescriptorType, USB_DESC_TYPE_CSINTERFACE */ + uint8_t subtype; /* bDescriptorSubType, CDC_DSUBTYPE_CALLMGMT as defined in Table 25 */ + uint8_t caps; /* bmCapabilities: Bit encoded */ + uint8_t ifno; /* bDataInterface, Interface number of Data Class interface + * optionally used for call management + */ +}; +#define SIZEOF_CALLMGMT_FUNCDESC 5 + +/* Table 28: Abstract Control Management Functional Descriptor */ + +struct cdc_acm_funcdesc_s +{ + uint8_t size; /* bFunctionLength, Size of this descriptor */ + uint8_t type; /* bDescriptorType, USB_DESC_TYPE_CSINTERFACE */ + uint8_t subtype; /* bDescriptorSubType, CDC_DSUBTYPE_ACM as defined in Table 25 */ + uint8_t caps; /* bmCapabilities: Bit encoded */ +}; +#define SIZEOF_ACM_FUNCDESC 4 + +/* Table 29: Direct Line Management Functional Descriptor */ + +struct cdc_dlc_funcdesc_s +{ + uint8_t size; /* bFunctionLength, Size of this descriptor */ + uint8_t type; /* bDescriptorType, USB_DESC_TYPE_CSINTERFACE */ + uint8_t subtype; /* bDescriptorSubType, CDC_DSUBTYPE_DLC as defined in Table 25 */ + uint8_t caps; /* bmCapabilities: Bit encoded */ +}; +#define SIZEOF_DLC_FUNCDESC 4 + +/* Table 30: Telephone Ringer Functional Descriptor */ + +struct cdc_tcmr_funcdesc_s +{ + uint8_t size; /* bFunctionLength, Size of this descriptor */ + uint8_t type; /* bDescriptorType, USB_DESC_TYPE_CSINTERFACE */ + uint8_t subtype; /* bDescriptorSubType, CDC_DSUBTYPE_TCMRINGER as defined in Table 25 */ + uint8_t volsteps; /* bRingerVolSteps, Number of discrete steps in volume supported + * by the ringer. + */ + uint8_t npats; /* bNumRingerPatterns: Number of ringer patterns supported. */ +}; +#define SIZEOF_TCMR_FUNCDESC 5 + +/* Table 31: Telephone Operational Modes Functional Descriptor */ + +struct cdc_tcmops_funcdesc_s +{ + uint8_t size; /* bFunctionLength, Size of this descriptor */ + uint8_t type; /* bDescriptorType, USB_DESC_TYPE_CSINTERFACE */ + uint8_t subtype; /* bDescriptorSubType, CDC_DSUBTYPE_TCMOPS as defined in Table 25 */ + uint8_t caps; /* bmCapabilities: Bit encoded */ +}; +#define SIZEOF_TCMOPS_FUNCDESC 4 + +/* Table 32: Telephone Call State Reporting Capabilities Descriptor */ + +struct cdc_tcmc_funcdesc_s +{ + uint8_t size; /* bFunctionLength, Size of this descriptor */ + uint8_t type; /* bDescriptorType, USB_DESC_TYPE_CSINTERFACE */ + uint8_t subtype; /* bDescriptorSubType, CDC_DSUBTYPE_TCMCALL as defined in Table 25 */ + uint8_t caps; /* bmCapabilities: Bit encoded */ +}; +#define SIZEOF_TCMC_FUNCDESC 4 + +/* Table 33: Union Interface Functional Descriptor */ + +struct cdc_union_funcdesc_s +{ + uint8_t size; /* bFunctionLength, Size of this descriptor */ + uint8_t type; /* bDescriptorType, USB_DESC_TYPE_CSINTERFACE */ + uint8_t subtype; /* bDescriptorSubType, CDC_DSUBTYPE_UNION as defined in Table 25 */ + uint8_t master; /* bMasterInterface: The interface number of the Communication or Data + * Class interface, designated as the master or controlling interface + * for the union + */ + uint8_t slave[1]; /* bSlaveInterfaceN: Interface number of N slave or associated + * interface in the union + */ +}; +#define SIZEOF_UNION_FUNCDESC(n) ((n)+4) + +/* Table 34: Country Selection Functional Descriptor */ + +struct cdc_country_funcdesc_s +{ + uint8_t size; /* bFunctionLength, Size of this descriptor */ + uint8_t type; /* bDescriptorType, USB_DESC_TYPE_CSINTERFACE */ + uint8_t subtype; /* bDescriptorSubType, CDC_DSUBTYPE_COUNTRY as defined in Table 25 */ + uint8_t reldate; /* iCountryCodeRelDate: Index of a string giving the release date for the + * implemented ISO 3166 Country Codes + */ + uint16_t code[1]; /* wCountryCodeN: Country code in hexadecimal format as defined in ISO 3166, + * release date as specified in offset 3 for Nth country supported + */ +}; +#define SIZEOF_COUNTRY_FUNCDESC(n) (sizeof(uint16_t)*(n) + 4) + +/* Table 35: USB Terminal Functional Descriptor */ + +struct cdc_usbterm_funcdesc_s +{ + uint8_t size; /* bFunctionLength, Size of this descriptor */ + uint8_t type; /* bDescriptorType, USB_DESC_TYPE_CSINTERFACE */ + uint8_t subtype; /* bDescriptorSubType, CDC_DSUBTYPE_USBTERM as defined in Table 25 */ + uint8_t id; /* bEntityId, Constant uniquely identifying the Terminal */ + uint8_t ifno; /* bInInterfaceNo, The input interface number of the associated + * USB interface + */ + uint8_t outif; /* bOutInterfaceNo, The output interface number of the associated + * USB interface + */ + uint8_t options; /* bmOptions, bit-encoded options */ + uint8_t child[1]; /* Nth ID of lower Terminal or Unit to which this Terminal is connected. */ +}; +#define SIZEOF_USBTERM_FUNCDESC(n) ((n)+7) + +/* Table 36: Network Channel Terminal Functional Descriptor */ + +struct cdc_netchan_funcdesc_s +{ + uint8_t size; /* bFunctionLength, Size of this descriptor */ + uint8_t type; /* bDescriptorType, USB_DESC_TYPE_CSINTERFACE */ + uint8_t subtype; /* bDescriptorSubType, CDC_DSUBTYPE_NETCHAN as defined in Table 25 */ + uint8_t id; /* bEntityId, Constant uniquely identifying the Terminal */ + uint8_t name; /* iName, Index of string descriptor, describing the name of the Network + * Channel Terminal + */ + uint8_t index; /* bChannelIndex, The channel index of the associated network channel */ + uint8_t phyif; /* bPhysicalInterface, Type of physical interface */ +}; +#define SIZEOF_NETCHAN_FUNCDESC 7 + +/* Table 37: Protocol Unit Functional Descriptor */ + +struct cdc_protounit_funcdesc_s +{ + uint8_t size; /* bFunctionLength, Size of this descriptor */ + uint8_t type; /* bDescriptorType, USB_DESC_TYPE_CSINTERFACE */ + uint8_t subtype; /* bDescriptorSubType, CDC_DSUBTYPE_PROTOUNIT as defined in Table 25 */ + uint8_t id; /* bEntityId, Constant uniquely identifying the Unit */ + uint8_t proto; /* bProtocol, Protocol code as defined in Table 19 */ + uint8_t child[1]; /* Nth ID of lower Terminal or Unit to which this Terminal is connected */ +}; +#define SIZEOF_PROTOUNIT_FUNCDESC(n) ((n)+5) + +/* Table 38: Extension Unit Functional Descriptor */ + +struct cdc_extunit_funcdesc_s +{ + uint8_t size; /* bFunctionLength, Size of this descriptor */ + uint8_t type; /* bDescriptorType, USB_DESC_TYPE_CSINTERFACE */ + uint8_t subtype; /* bDescriptorSubType, CDC_DSUBTYPE_EXTUNIT as defined in Table 25 */ + uint8_t id; /* bEntityId, Constant uniquely identifying the Extension Unit */ + uint8_t code; /* bExtensionCode, Vendor specific code identifying the Extension Unit */ + uint8_t name; /* iName, Index of string descriptor, describing the name of the Extension Unit */ + uint8_t child[1]; /* Nth ID of lower Terminal or Unit to which this Terminal is connected */ +}; +#define SIZEOF_EXTUNIT_FUNCDESC(n) ((n)+6) + +/* Table 39: Multi-Channel Management Functional Descriptor */ + +struct cdc_mcm_funcdesc_s +{ + uint8_t size; /* bFunctionLength, Size of this descriptor */ + uint8_t type; /* bDescriptorType, USB_DESC_TYPE_CSINTERFACE */ + uint8_t subtype; /* bDescriptorSubType, CDC_DSUBTYPE_MCM as defined in Table 25 */ + uint8_t caps; /* bmCapabilities: Bit encoded */ +}; +#define SIZEOF_MCM_FUNCDESC 4 + +/* Table 40: CAPI Control Management Functional Descriptor */ + +struct cdc_capi_funcdesc_s +{ + uint8_t size; /* bFunctionLength, Size of this descriptor */ + uint8_t type; /* bDescriptorType, USB_DESC_TYPE_CSINTERFACE */ + uint8_t subtype; /* bDescriptorSubType, CDC_DSUBTYPE_CAPI as defined in Table 25 */ + uint8_t caps; /* bmCapabilities: Bit encoded */ +}; +#define SIZEOF_CAPI_FUNCDESC 4 + +/* Table 41: Ethernet Networking Functional Descriptor*/ + +struct cdc_ecm_funcdesc_s +{ + uint8_t size; /* bFunctionLength, Size of this descriptor */ + uint8_t type; /* bDescriptorType, USB_DESC_TYPE_CSINTERFACE */ + uint8_t subtype; /* bDescriptorSubType, CDC_DSUBTYPE_ECM as defined in Table 25 */ + uint8_t mac; /* iMACAddress, Index of teh 48bit Ethernet MAC address string descriptor */ + uint8_t stats[4]; /* bmEthernetStatistics, Indicates which Ethernet statistics functions + * the device collects. See Table 42. + */ + uint8_t maxseg[2]; /* wMaxSegmentSize, The maximum segment size that the Ethernet device is + * capable of supporting. + */ + uint8_t nmcflts[2]; /* wNumberMCFilters, Contains the number of multicast filters that can be + * configured by the host. + */ + uint8_t npwrflts; /* bNumberPowerFilters, Contains the number of pattern filters that are + * available for causing wake-up of the host. + */ +}; +#define SIZEOF_ECM_FUNCDESC 13 + +/* Table 43: ATM Networking Functional Descriptor */ + +struct cdc_atm_funcdesc_s +{ + uint8_t size; /* bFunctionLength, Size of this descriptor */ + uint8_t type; /* bDescriptorType, USB_DESC_TYPE_CSINTERFACE */ + uint8_t subtype; /* bDescriptorSubType, CDC_DSUBTYPE_ATM as defined in Table 25 */ + uint8_t endid; /* iEndSystemIdentifier, Index of End System Identifier string descriptor */ + uint8_t datacaps; /* bmDataCapabilities, The ATM data types the device supports */ + uint8_t devstats; /* bmATMDeviceStatistics, Indicates which optional statistics functions the + * device collects. + */ + uint8_t mxseg2[2]; /* wType2MaxSegmentSize, The maximum segment size that the Type 2 device is + * capable of supporting. + */ + uint8_t mxseg3[2]; /* wType3MaxSegmentSize, The maximum segment size that the Type 3 device is + * capable of supporting + */ + uint8_t mxvc[2]; /* wMaxVC, The maximum number of simultaneous virtual circuits the device is + * capable of supporting + */ +}; +#define SIZEOF_CALLMGMT_FUNCDESC 12 + +/* Descriptor Data Structures ***************************************************************/ +/* Table 50: Line Coding Structure */ + +struct cdc_linecoding_s +{ + uint8_t baud[4]; /* dwDTERate, Data terminal rate, in bits per second */ + uint8_t stop; /* bCharFormat 0=1, 1=1.5, 2=2 stop bits */ + uint8_t parity; /* bParityType, 0=None, 1=Odd, 2=Even, 3=Mark, 4=Space */ + uint8_t nbits; /* bDataBits, Data bits (5,6,7,8, or 16) */ +}; +#define SIZEOF_CDC_LINECODING 7 + +/* Table 55: Line Status Information Structure */ + +struct cdc_linestatus_s +{ + uint8_t size[2]; /* wLength, Size of this structure, in bytes */ + uint8_t ringer[4]; /* dwRingerBitmap, Ringer Configuration bitmap for this line */ + uint8_t line[4]; /* dwLineState, Defines current state of the line */ + uint32_t call[1]; /* dwCallStateN, Defines current state of call N on the line */ +}; + +/* Table 60: Unit Parameter Structure */ + +struct cdc_unitparm_s +{ + uint8_t id; /* bEntityId, Unit ID */ + uint8_t index; /* bParameterIndex, A zero based value indicating Unit parameter index */ +}; + +/* Table 61: Power Management Pattern Filter Structure */ + +/* Notification Data Structures *************************************************************/ +/* Table 72: ConnectionSpeedChange Data Structure */ + +struct cdc_speedchange_s +{ + uint8_t us[4]; /* Contains the upstream bit rate, in bits per second */ + uint8_t ds[4]; /* Contains the downstream bit rate, in bits per second */ +}; + +#endif /* __INCLUDE_NUTTX_USB_CDC_H */ diff --git a/nuttx/include/nuttx/usb/cdc_serial.h b/nuttx/include/nuttx/usb/cdc_serial.h index b516070eb..7d5a706b4 100644 --- a/nuttx/include/nuttx/usb/cdc_serial.h +++ b/nuttx/include/nuttx/usb/cdc_serial.h @@ -61,32 +61,46 @@ # define CONFIG_CDCSER_EPINTIN 2 #endif -#ifndef CONFIG_CDCSER_EPINTIN_SIZE -# define CONFIG_CDCSER_EPINTIN_SIZE 8 +#ifndef CONFIG_CDCSER_EPINTIN_FSSIZE +# define CONFIG_CDCSER_EPINTIN_FSSIZE 8 +#endif + +#ifndef CONFIG_CDCSER_EPINTIN_HSSIZE +# define CONFIG_CDCSER_EPINTIN_HSSIZE 8 #endif /* Endpoint number and size (in bytes) of the CDC device-to-host (IN) data - * bulk endpoint + * bulk endpoint. NOTE that difference sizes may be selected for full (FS) + * or high speed (HS) modes. */ #ifndef CONFIG_CDCSER_EPBULKIN # define CONFIG_CDCSER_EPBULKIN 3 #endif -#ifndef CONFIG_CDCSER_EPBULKIN_SIZE -# define CONFIG_CDCSER_EPBULKIN_SIZE 16 +#ifndef CONFIG_CDCSER_EPBULKIN_FSSIZE +# define CONFIG_CDCSER_EPBULKIN_FSSIZE 64 +#endif + +#ifndef CONFIG_CDCSER_EPBULKIN_HSSIZE +# define CONFIG_CDCSER_EPBULKIN_HSSIZE 512 #endif /* Endpoint number and size (in bytes) of the CDC host-to-device (OUT) data - * bulk endpoint + * bulk endpoint. NOTE that difference sizes may be selected for full (FS) + * or high speed (HS) modes. */ #ifndef CONFIG_CDCSER_EPBULKOUT # define CONFIG_CDCSER_EPBULKOUT 4 #endif -#ifndef CONFIG_CDCSER_EPBULKOUT_SIZE -# define CONFIG_CDCSER_EPBULKOUT_SIZE 16 +#ifndef CONFIG_CDCSER_EPBULKOUT_FSSIZE +# define CONFIG_CDCSER_EPBULKOUT_FSSIZE 64 +#endif + +#ifndef CONFIG_CDCSER_EPBULKOUT_HSSIZE +# define CONFIG_CDCSER_EPBULKOUT_HSSIZE 512 #endif /* Number of requests in the write queue */ @@ -101,10 +115,14 @@ # define CONFIG_CDCSER_NRDREQS 4 #endif -/* Write buffer size */ +/* TX/RX buffer sizes */ + +#ifndef CONFIG_CDCSER_RXBUFSIZE +# define CONFIG_CDCSER_RXBUFSIZE 256 +#endif -#ifndef CONFIG_CDCSER_WRBUFFERSIZE -# define CONFIG_CDCSER_WRBUFFERSIZE 1024 +#ifndef CONFIG_CDCSER_TXBUFSIZE +# define CONFIG_CDCSER_TXBUFSIZE 256 #endif /* Vendor and product IDs and strings */ diff --git a/nuttx/include/nuttx/usb/usb.h b/nuttx/include/nuttx/usb/usb.h index 9458d3eba..786f8d99a 100644 --- a/nuttx/include/nuttx/usb/usb.h +++ b/nuttx/include/nuttx/usb/usb.h @@ -72,19 +72,21 @@ /* Control Setup Packet. Byte 0=Request */ -#define USB_REQ_DIR_IN (0x80) /* Bit 7=1: IN */ -#define USB_REQ_DIR_OUT (0x00) /* Bit 7=0: OUT */ - -#define USB_REQ_TYPE_MASK (0x60) /* Bits 5:6: Request type */ -#define USB_REQ_TYPE_STANDARD (0x00) -#define USB_REQ_TYPE_CLASS (0x20) -#define USB_REQ_TYPE_VENDOR (0x40) - -#define USB_REQ_RECIPIENT_MASK (0x1f) /* Bits 0:4: Recipient */ -#define USB_REQ_RECIPIENT_DEVICE (0x00) -#define USB_REQ_RECIPIENT_INTERFACE (0x01) -#define USB_REQ_RECIPIENT_ENDPOINT (0x02) -#define USB_REQ_RECIPIENT_OTHER (0x03) +#define USB_REQ_DIR_IN (1 << 7) /* Bit 7=1: IN */ +#define USB_REQ_DIR_OUT (0 << 7) /* Bit 7=0: OUT */ + +#define USB_REQ_TYPE_SHIFT (5) /* Bits 5:6: Request type */ +# define USB_REQ_TYPE_MASK (3 << USB_REQ_TYPE_SHIFT) +# define USB_REQ_TYPE_STANDARD (0 << USB_REQ_TYPE_SHIFT) +# define USB_REQ_TYPE_CLASS (1 << USB_REQ_TYPE_SHIFT) +# define USB_REQ_TYPE_VENDOR (2 << USB_REQ_TYPE_SHIFT) + +#define USB_REQ_RECIPIENT_SHIFT (0) /* Bits 0:4: Recipient */ +#define USB_REQ_RECIPIENT_MASK (0x1f << USB_REQ_RECIPIENT_SHIFT) +# define USB_REQ_RECIPIENT_DEVICE (0 << USB_REQ_RECIPIENT_SHIFT) +# define USB_REQ_RECIPIENT_INTERFACE (1 << USB_REQ_RECIPIENT_SHIFT) +# define USB_REQ_RECIPIENT_ENDPOINT (2 << USB_REQ_RECIPIENT_SHIFT) +# define USB_REQ_RECIPIENT_OTHER (3 << USB_REQ_RECIPIENT_SHIFT) /* Control Setup Packet. Byte 1=Standard Request Codes */ diff --git a/nuttx/include/nuttx/usb/usbdev_trace.h b/nuttx/include/nuttx/usb/usbdev_trace.h index b69ff0f17..4ffd79057 100644 --- a/nuttx/include/nuttx/usb/usbdev_trace.h +++ b/nuttx/include/nuttx/usb/usbdev_trace.h @@ -216,7 +216,7 @@ #define USBSER_TRACEERR_SUBMITFAIL 0x001a #define USBSER_TRACEERR_UARTREGISTER 0x001b #define USBSER_TRACEERR_UNSUPPORTEDCTRLREQ 0x001c -#define USBSER_TRACEERR_UNSUPPORTEDRWREQ 0x001d +#define USBSER_TRACEERR_UNSUPPORTEDCLASSREQ 0x001d #define USBSER_TRACEERR_UNSUPPORTEDSTDREQ 0x001e #define USBSER_TRACEERR_UNSUPPORTEDTYPE 0x001f #define USBSER_TRACEERR_WRALLOCREQ 0x0020 diff --git a/nuttx/lib/stdio/lib_fopen.c b/nuttx/lib/stdio/lib_fopen.c index 4f841aefc..f90951fe2 100644 --- a/nuttx/lib/stdio/lib_fopen.c +++ b/nuttx/lib/stdio/lib_fopen.c @@ -108,14 +108,14 @@ static int lib_mode2oflags(FAR const char *mode) { /* Read from the beginning of the file; write to the end */ - oflags |= O_RDWR|O_CREAT; + oflags |= O_RDWR|O_CREAT|O_APPEND; mode++; } else { /* Write to the end of the file */ - oflags |= O_WROK|O_CREAT; + oflags |= O_WROK|O_CREAT|O_APPEND; } break; |