Add CDC ACM serial class device driver

git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@3953 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
patacongo 2011-09-13 19:04:13 +00:00
parent 6fc0c99569
commit a96e7ec9d5
13 changed files with 1431 additions and 1141 deletions

View file

@ -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.

View file

@ -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 &quot;NuttX&quot;
</li>
<li>
<code>CONFIG_CDCSER_PRODUCTID</code> and <code>CONFIG_CDCSER_PRODUCTSTR</code>: The product ID code/string. Default 0x204b and &quot;CDC/ACM Serial&quot;
</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>

22
TODO
View file

@ -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/)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

View file

@ -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

View file

@ -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

View file

@ -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

File diff suppressed because it is too large Load diff

View file

@ -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);
}
}
}

File diff suppressed because it is too large Load diff

View file

@ -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_WRBUFFERSIZE
# define CONFIG_CDCSER_WRBUFFERSIZE 1024
#ifndef CONFIG_CDCSER_RXBUFSIZE
# define CONFIG_CDCSER_RXBUFSIZE 256
#endif
#ifndef CONFIG_CDCSER_TXBUFSIZE
# define CONFIG_CDCSER_TXBUFSIZE 256
#endif
/* Vendor and product IDs and strings */

View file

@ -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_DIR_IN (1 << 7) /* Bit 7=1: IN */
#define USB_REQ_DIR_OUT (0 << 7) /* 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_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_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_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 */

View file

@ -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

View file

@ -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;