From 911a1d2fafcd6eff4c99765b184a6e82f816b312 Mon Sep 17 00:00:00 2001 From: patacongo Date: Mon, 12 Sep 2011 23:16:16 +0000 Subject: Working toward CDC serial USB device git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@3952 42af7a65-404d-4744-a932-0658087f49c3 --- nuttx/include/nuttx/usb/cdc.h | 45 ++++++++---------- nuttx/include/nuttx/usb/cdc_serial.h | 91 +++++++++++++++++++++++++++++++----- nuttx/include/nuttx/usb/usb.h | 24 +++++++--- 3 files changed, 117 insertions(+), 43 deletions(-) (limited to 'nuttx/include') diff --git a/nuttx/include/nuttx/usb/cdc.h b/nuttx/include/nuttx/usb/cdc.h index 87161ecaa..a6fee1817 100755 --- a/nuttx/include/nuttx/usb/cdc.h +++ b/nuttx/include/nuttx/usb/cdc.h @@ -318,11 +318,6 @@ #define ECM_SPEED_CHANGE ATM_SPEED_CHANGE /* Descriptors ******************************************************************************/ -/* Table 24: Type Values for the bDescriptorType Field */ - -#define CS_INTERFACE 0x24 -#define CS_ENDPOINT 0x25 - /* Table 25: bDescriptor SubType in Functional Descriptors */ #define CDC_DSUBTYPE_HDR 0x00 /* Header Functional Descriptor, which marks the @@ -577,7 +572,7 @@ struct cdc_protowrapper_s struct cdc_funcdesc_s { uint8_t size; /* bFunctionLength, Size of this descriptor */ - uint8_t type; /* bDescriptorType, CS_INTERFACE, as defined in Table 24 */ + uint8_t type; /* bDescriptorType, USB_DESC_TYPE_CSINTERFACE */ uint8_t data[1]; /* Function-specific data follows */ }; @@ -586,7 +581,7 @@ struct cdc_funcdesc_s struct cdc_hdr_funcdesc_s { uint8_t size; /* bFunctionLength, Size of this descriptor */ - uint8_t type; /* bDescriptorType, CS_INTERFACE, as defined in Table 24 */ + 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. @@ -599,7 +594,7 @@ struct cdc_hdr_funcdesc_s struct cdc_callmgmt_funcdesc_s { uint8_t size; /* bFunctionLength, Size of this descriptor */ - uint8_t type; /* bDescriptorType, CS_INTERFACE, as defined in Table 24 */ + 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 @@ -613,7 +608,7 @@ struct cdc_callmgmt_funcdesc_s struct cdc_acm_funcdesc_s { uint8_t size; /* bFunctionLength, Size of this descriptor */ - uint8_t type; /* bDescriptorType, CS_INTERFACE, as defined in Table 24 */ + 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 */ }; @@ -624,7 +619,7 @@ struct cdc_acm_funcdesc_s struct cdc_dlc_funcdesc_s { uint8_t size; /* bFunctionLength, Size of this descriptor */ - uint8_t type; /* bDescriptorType, CS_INTERFACE, as defined in Table 24 */ + 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 */ }; @@ -635,7 +630,7 @@ struct cdc_dlc_funcdesc_s struct cdc_tcmr_funcdesc_s { uint8_t size; /* bFunctionLength, Size of this descriptor */ - uint8_t type; /* bDescriptorType, CS_INTERFACE, as defined in Table 24 */ + 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. @@ -649,7 +644,7 @@ struct cdc_tcmr_funcdesc_s struct cdc_tcmops_funcdesc_s { uint8_t size; /* bFunctionLength, Size of this descriptor */ - uint8_t type; /* bDescriptorType, CS_INTERFACE, as defined in Table 24 */ + 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 */ }; @@ -660,7 +655,7 @@ struct cdc_tcmops_funcdesc_s struct cdc_tcmc_funcdesc_s { uint8_t size; /* bFunctionLength, Size of this descriptor */ - uint8_t type; /* bDescriptorType, CS_INTERFACE, as defined in Table 24 */ + 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 */ }; @@ -671,7 +666,7 @@ struct cdc_tcmc_funcdesc_s struct cdc_union_funcdesc_s { uint8_t size; /* bFunctionLength, Size of this descriptor */ - uint8_t type; /* bDescriptorType, CS_INTERFACE, as defined in Table 24 */ + 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 @@ -681,14 +676,14 @@ struct cdc_union_funcdesc_s * interface in the union */ }; -#define SIZEOF_CALLMGMT_FUNCDESC(n) ((n)+4) +#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, CS_INTERFACE, as defined in Table 24 */ + 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 @@ -697,14 +692,14 @@ struct cdc_country_funcdesc_s * release date as specified in offset 3 for Nth country supported */ }; -#define SIZEOF_CONTRY_FUNCDESC(n) (sizeof(uint16_t)*(n) + 4) +#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, CS_INTERFACE, as defined in Table 24 */ + 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 @@ -723,7 +718,7 @@ struct cdc_usbterm_funcdesc_s struct cdc_netchan_funcdesc_s { uint8_t size; /* bFunctionLength, Size of this descriptor */ - uint8_t type; /* bDescriptorType, CS_INTERFACE, as defined in Table 24 */ + 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 @@ -739,7 +734,7 @@ struct cdc_netchan_funcdesc_s struct cdc_protounit_funcdesc_s { uint8_t size; /* bFunctionLength, Size of this descriptor */ - uint8_t type; /* bDescriptorType, CS_INTERFACE, as defined in Table 24 */ + 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 */ @@ -752,7 +747,7 @@ struct cdc_protounit_funcdesc_s struct cdc_extunit_funcdesc_s { uint8_t size; /* bFunctionLength, Size of this descriptor */ - uint8_t type; /* bDescriptorType, CS_INTERFACE, as defined in Table 24 */ + 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 */ @@ -766,7 +761,7 @@ struct cdc_extunit_funcdesc_s struct cdc_mcm_funcdesc_s { uint8_t size; /* bFunctionLength, Size of this descriptor */ - uint8_t type; /* bDescriptorType, CS_INTERFACE, as defined in Table 24 */ + 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 */ }; @@ -777,7 +772,7 @@ struct cdc_mcm_funcdesc_s struct cdc_capi_funcdesc_s { uint8_t size; /* bFunctionLength, Size of this descriptor */ - uint8_t type; /* bDescriptorType, CS_INTERFACE, as defined in Table 24 */ + 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 */ }; @@ -788,7 +783,7 @@ struct cdc_capi_funcdesc_s struct cdc_ecm_funcdesc_s { uint8_t size; /* bFunctionLength, Size of this descriptor */ - uint8_t type; /* bDescriptorType, CS_INTERFACE, as defined in Table 24 */ + 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 @@ -811,7 +806,7 @@ struct cdc_ecm_funcdesc_s struct cdc_atm_funcdesc_s { uint8_t size; /* bFunctionLength, Size of this descriptor */ - uint8_t type; /* bDescriptorType, CS_INTERFACE, as defined in Table 24 */ + 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 */ diff --git a/nuttx/include/nuttx/usb/cdc_serial.h b/nuttx/include/nuttx/usb/cdc_serial.h index c42205c66..b516070eb 100644 --- a/nuttx/include/nuttx/usb/cdc_serial.h +++ b/nuttx/include/nuttx/usb/cdc_serial.h @@ -41,45 +41,112 @@ ****************************************************************************/ #include +#include /**************************************************************************** * Preprocessor definitions ****************************************************************************/ /* Configuration ************************************************************/ +/* EP0 max packet size */ + +#ifndef CONFIG_CDCSER_EP0MAXPACKET +# define CONFIG_CDCSER_EP0MAXPACKET 8 +#endif + /* Endpoint number and size (in bytes) of the CDC serial device-to-host (IN) * notification interrupt endpoint. */ -#ifndef CONFIG_CDCSER_INTIN_EP -# define CONFIG_CDCSER_INTIN_EP 2 +#ifndef CONFIG_CDCSER_EPINTIN +# define CONFIG_CDCSER_EPINTIN 2 #endif -#ifndef CONFIG_CDCSER_INTIN_EPSIZE -# define CONFIG_CDCSER_INTIN_EPSIZE 8 +#ifndef CONFIG_CDCSER_EPINTIN_SIZE +# define CONFIG_CDCSER_EPINTIN_SIZE 8 #endif /* Endpoint number and size (in bytes) of the CDC device-to-host (IN) data * bulk endpoint */ -#ifndef CONFIG_CDCSER_BULKIN_EP -# define CONFIG_CDCSER_BULKIN_EP 3 +#ifndef CONFIG_CDCSER_EPBULKIN +# define CONFIG_CDCSER_EPBULKIN 3 #endif -#ifndef CONFIG_CDCSER_BULKIN_EPSIZE -# define CONFIG_CDCSER_BULKIN_EPSIZE 16 +#ifndef CONFIG_CDCSER_EPBULKIN_SIZE +# define CONFIG_CDCSER_EPBULKIN_SIZE 16 #endif /* Endpoint number and size (in bytes) of the CDC host-to-device (OUT) data * bulk endpoint */ -#ifndef CONFIG_CDCSER_BULKOUT_EP -# define CONFIG_CDCSER_BULKOUT_EP 4 +#ifndef CONFIG_CDCSER_EPBULKOUT +# define CONFIG_CDCSER_EPBULKOUT 4 +#endif + +#ifndef CONFIG_CDCSER_EPBULKOUT_SIZE +# define CONFIG_CDCSER_EPBULKOUT_SIZE 16 +#endif + +/* Number of requests in the write queue */ + +#ifndef CONFIG_CDCSER_NWRREQS +# define CONFIG_CDCSER_NWRREQS 4 +#endif + +/* Number of requests in the read queue */ + +#ifndef CONFIG_CDCSER_NRDREQS +# define CONFIG_CDCSER_NRDREQS 4 +#endif + +/* Write buffer size */ + +#ifndef CONFIG_CDCSER_WRBUFFERSIZE +# define CONFIG_CDCSER_WRBUFFERSIZE 1024 +#endif + +/* Vendor and product IDs and strings */ + +#ifndef CONFIG_CDCSER_VENDORID +# define CONFIG_CDCSER_VENDORID 0x03eb +#endif + +#ifndef CONFIG_CDCSER_PRODUCTID +# define CONFIG_CDCSER_PRODUCTID 0x204b +#endif + +#ifndef CONFIG_CDCSER_VENDORSTR +# define CONFIG_CDCSER_VENDORSTR "NuttX" +#endif + +#ifndef CONFIG_CDCSER_PRODUCTSTR +# define CONFIG_CDCSER_PRODUCTSTR "USBdev Serial" +#endif + +#undef CONFIG_CDCSER_SERIALSTR +#define CONFIG_CDCSER_SERIALSTR "0" + +#undef CONFIG_CDCSER_CONFIGSTR +#define CONFIG_CDCSER_CONFIGSTR "Bulk" + +/* USB Controller */ + +#ifndef CONFIG_USBDEV_SELFPOWERED +# define SELFPOWERED USB_CONFIG_ATT_SELFPOWER +#else +# define SELFPOWERED (0) +#endif + +#ifndef CONFIG_USBDEV_REMOTEWAKEUP +# define REMOTEWAKEUP USB_CONFIG_ATTR_WAKEUP +#else +# define REMOTEWAKEUP (0) #endif -#ifndef CONFIG_CDCSER_BULKOUT_EPSIZE -# define CONFIG_CDCSER_BULKOUT_EPSIZE 16 +#ifndef CONFIG_USBDEV_MAXPOWER +# define CONFIG_USBDEV_MAXPOWER 100 #endif /**************************************************************************** diff --git a/nuttx/include/nuttx/usb/usb.h b/nuttx/include/nuttx/usb/usb.h index 125605cc0..9458d3eba 100644 --- a/nuttx/include/nuttx/usb/usb.h +++ b/nuttx/include/nuttx/usb/usb.h @@ -188,12 +188,24 @@ /* Endpoint descriptor attributes */ -#define USB_EP_ATTR_XFERTYPE_MASK (0x03) -#define USB_EP_ATTR_XFER_CONTROL (0x00) -#define USB_EP_ATTR_XFER_ISOC (0x01) -#define USB_EP_ATTR_XFER_BULK (0x02) -#define USB_EP_ATTR_XFER_INT (0x03) -#define USB_EP_ATTR_MAX_ADJUSTABLE (0x80) +#define USB_EP_ATTR_XFERTYPE_SHIFT (0) +#define USB_EP_ATTR_XFERTYPE_MASK (3 << USB_EP_ATTR_XFERTYPE_SHIFT) +# define USB_EP_ATTR_XFER_CONTROL (0 << USB_EP_ATTR_XFERTYPE_SHIFT) +# define USB_EP_ATTR_XFER_ISOC (1 << USB_EP_ATTR_XFERTYPE_SHIFT) +# define USB_EP_ATTR_XFER_BULK (2 << USB_EP_ATTR_XFERTYPE_SHIFT) +# define USB_EP_ATTR_XFER_INT (3 << USB_EP_ATTR_XFERTYPE_SHIFT) +#define USB_EP_ATTR_SYNC_SHIFT (2) +#define USB_EP_ATTR_SYNC_MASK (3 << USB_EP_ATTR_SYNC_SHIFT) +# define USB_EP_ATTR_NO_SYNC (0 << USB_EP_ATTR_SYNC_SHIFT) +# define USB_EP_ATTR_ASYNC (1 << USB_EP_ATTR_SYNC_SHIFT) +# define USB_EP_ATTR_ADAPTIVE (2 << USB_EP_ATTR_SYNC_SHIFT) +# define USB_EP_ATTR_SYNC (3 << USB_EP_ATTR_SYNC_SHIFT) +#define USB_EP_ATTR_USAGE_SHIFT (4) +#define USB_EP_ATTR_USAGE_MASK (3 << USB_EP_ATTR_USAGE_SHIFT) +# define USB_EP_ATTR_USAGE_DATA (0 << USB_EP_ATTR_USAGE_SHIFT) +# define USB_EP_ATTR_USAGE_FEEDBACK (1 << USB_EP_ATTR_USAGE_SHIFT) +# define USB_EP_ATTR_USAGE_IMPLICIT (2 << USB_EP_ATTR_USAGE_SHIFT) +#define USB_EP_ATTR_MAX_ADJUSTABLE (1 << 7) /************************************************************************************ * Public Types -- cgit v1.2.3