--- /dev/null
+/***********************************************************************\r
+* $Id:: mw_usbd.h 575 2012-11-20 01:35:56Z usb10131 $\r
+*\r
+* Project: USB device ROM Stack\r
+*\r
+* Description:\r
+* USB Definitions.\r
+*\r
+***********************************************************************\r
+* Copyright(C) 2011, NXP Semiconductor\r
+* All rights reserved.\r
+*\r
+* Software that is described herein is for illustrative purposes only\r
+* which provides customers with programming information regarding the\r
+* products. This software is supplied "AS IS" without any warranties.\r
+* NXP Semiconductors assumes no responsibility or liability for the\r
+* use of the software, conveys no license or title under any patent,\r
+* copyright, or mask work right to the product. NXP Semiconductors\r
+* reserves the right to make changes in the software without\r
+* notification. NXP Semiconductors also make no representation or\r
+* warranty that such application will be suitable for the specified\r
+* use without further testing or modification.\r
+**********************************************************************/\r
+\r
+#ifndef __USBD_H__\r
+#define __USBD_H__\r
+\r
+/** \file\r
+ * \brief Common definitions and declarations for the USB stack.\r
+ *\r
+ * Common definitions and declarations for the USB stack.\r
+ * \addtogroup USBD_Core \r
+ * @{\r
+ */\r
+\r
+#include "lpc_types.h"\r
+\r
+#if defined(__GNUC__)\r
+/* As per http://gcc.gnu.org/onlinedocs/gcc/Attribute-Syntax.html#Attribute-Syntax,\r
+6.29 Attributes Syntax\r
+"An attribute specifier list may appear as part of a struct, union or\r
+enum specifier. It may go either immediately after the struct, union\r
+or enum keyword, or after the closing brace. The former syntax is\r
+preferred. Where attribute specifiers follow the closing brace, they\r
+are considered to relate to the structure, union or enumerated type\r
+defined, not to any enclosing declaration the type specifier appears\r
+in, and the type defined is not complete until after the attribute\r
+specifiers."\r
+So use POST_PACK immediately after struct keyword\r
+*/\r
+#define PRE_PACK\r
+#define POST_PACK __attribute__((__packed__))\r
+#define ALIGNED(n) __attribute__((aligned (n)))\r
+\r
+#elif defined(__arm)\r
+#define PRE_PACK __packed\r
+#define POST_PACK\r
+#define ALIGNED(n) __align(n)\r
+\r
+#elif defined(__ICCARM__)\r
+#define PRE_PACK __packed\r
+#define POST_PACK\r
+#define PRAGMA_ALIGN_4096 _Pragma("data_alignment=4096")\r
+#define PRAGMA_ALIGN_2048 _Pragma("data_alignment=2048")\r
+#define PRAGMA_ALIGN_256 _Pragma("data_alignment=256")\r
+#define PRAGMA_ALIGN_128 _Pragma("data_alignment=128")\r
+#define PRAGMA_ALIGN_64 _Pragma("data_alignment=64")\r
+#define PRAGMA_ALIGN_48 _Pragma("data_alignment=48")\r
+#define PRAGMA_ALIGN_32 _Pragma("data_alignment=32")\r
+#define PRAGMA_ALIGN_4 _Pragma("data_alignment=4")\r
+#define ALIGNED(n) PRAGMA_ALIGN_##n\r
+\r
+#pragma diag_suppress=Pe021\r
+#endif\r
+\r
+/** Structure to pack lower and upper byte to form 16 bit word. */\r
+PRE_PACK struct POST_PACK _WB_T\r
+{\r
+ uint8_t L; /**< lower byte */\r
+ uint8_t H; /**< upper byte */\r
+};\r
+/** Structure to pack lower and upper byte to form 16 bit word.*/\r
+typedef struct _WB_T WB_T;\r
+\r
+/** Union of \ref _WB_T struct and 16 bit word.*/\r
+PRE_PACK union POST_PACK __WORD_BYTE\r
+{\r
+ uint16_t W; /**< data member to do 16 bit access */\r
+ WB_T WB; /**< data member to do 8 bit access */\r
+} ;\r
+/** Union of \ref _WB_T struct and 16 bit word.*/\r
+typedef union __WORD_BYTE WORD_BYTE;\r
+\r
+/** bmRequestType.Dir defines \r
+ * @{ \r
+ */\r
+/** Request from host to device */\r
+#define REQUEST_HOST_TO_DEVICE 0\r
+/** Request from device to host */\r
+#define REQUEST_DEVICE_TO_HOST 1\r
+/** @} */\r
+\r
+/** bmRequestType.Type defines \r
+ * @{ \r
+ */\r
+/** Standard Request */\r
+#define REQUEST_STANDARD 0\r
+/** Class Request */\r
+#define REQUEST_CLASS 1\r
+/** Vendor Request */\r
+#define REQUEST_VENDOR 2\r
+/** Reserved Request */\r
+#define REQUEST_RESERVED 3\r
+/** @} */\r
+\r
+/** bmRequestType.Recipient defines \r
+ * @{ \r
+ */\r
+/** Request to device */\r
+#define REQUEST_TO_DEVICE 0\r
+/** Request to interface */\r
+#define REQUEST_TO_INTERFACE 1\r
+/** Request to endpoint */\r
+#define REQUEST_TO_ENDPOINT 2\r
+/** Request to other */\r
+#define REQUEST_TO_OTHER 3\r
+/** @} */\r
+\r
+/** Structure to define 8 bit USB request.*/\r
+PRE_PACK struct POST_PACK _BM_T\r
+{\r
+ uint8_t Recipient : 5; /**< Recipient type. */\r
+ uint8_t Type : 2; /**< Request type. */\r
+ uint8_t Dir : 1; /**< Direction type. */\r
+};\r
+/** Structure to define 8 bit USB request.*/\r
+typedef struct _BM_T BM_T;\r
+\r
+/** Union of \ref _BM_T struct and 8 bit byte.*/\r
+PRE_PACK union POST_PACK _REQUEST_TYPE\r
+{\r
+ uint8_t B; /**< byte wide access memeber */\r
+ BM_T BM; /**< bitfield structure access memeber */\r
+} ;\r
+/** Union of \ref _BM_T struct and 8 bit byte.*/\r
+typedef union _REQUEST_TYPE REQUEST_TYPE;\r
+\r
+/** USB Standard Request Codes \r
+ * @{ \r
+ */\r
+/** GET_STATUS request */\r
+#define USB_REQUEST_GET_STATUS 0\r
+/** CLEAR_FEATURE request */\r
+#define USB_REQUEST_CLEAR_FEATURE 1\r
+/** SET_FEATURE request */\r
+#define USB_REQUEST_SET_FEATURE 3\r
+/** SET_ADDRESS request */\r
+#define USB_REQUEST_SET_ADDRESS 5\r
+/** GET_DESCRIPTOR request */\r
+#define USB_REQUEST_GET_DESCRIPTOR 6\r
+/** SET_DESCRIPTOR request */\r
+#define USB_REQUEST_SET_DESCRIPTOR 7\r
+/** GET_CONFIGURATION request */\r
+#define USB_REQUEST_GET_CONFIGURATION 8\r
+/** SET_CONFIGURATION request */\r
+#define USB_REQUEST_SET_CONFIGURATION 9\r
+/** GET_INTERFACE request */\r
+#define USB_REQUEST_GET_INTERFACE 10\r
+/** SET_INTERFACE request */\r
+#define USB_REQUEST_SET_INTERFACE 11\r
+/** SYNC_FRAME request */\r
+#define USB_REQUEST_SYNC_FRAME 12\r
+/** @} */\r
+\r
+/** USB GET_STATUS Bit Values \r
+ * @{ \r
+ */\r
+/** SELF_POWERED status*/\r
+#define USB_GETSTATUS_SELF_POWERED 0x01\r
+/** REMOTE_WAKEUP capable status*/\r
+#define USB_GETSTATUS_REMOTE_WAKEUP 0x02\r
+/** ENDPOINT_STALL status*/\r
+#define USB_GETSTATUS_ENDPOINT_STALL 0x01\r
+/** @} */\r
+\r
+/** USB Standard Feature selectors \r
+ * @{ \r
+ */\r
+/** ENDPOINT_STALL feature*/\r
+#define USB_FEATURE_ENDPOINT_STALL 0\r
+/** REMOTE_WAKEUP feature*/\r
+#define USB_FEATURE_REMOTE_WAKEUP 1\r
+/** TEST_MODE feature*/\r
+#define USB_FEATURE_TEST_MODE 2\r
+/** @} */\r
+\r
+/** USB Default Control Pipe Setup Packet*/\r
+PRE_PACK struct POST_PACK _USB_SETUP_PACKET\r
+{\r
+ REQUEST_TYPE bmRequestType; /**< This bitmapped field identifies the characteristics\r
+ of the specific request. \sa _BM_T.\r
+ */\r
+ uint8_t bRequest; /**< This field specifies the particular request. The \r
+ Type bits in the bmRequestType field modify the meaning \r
+ of this field. \sa USBD_REQUEST.\r
+ */\r
+ WORD_BYTE wValue; /**< Used to pass a parameter to the device, specific\r
+ to the request.\r
+ */\r
+ WORD_BYTE wIndex; /**< Used to pass a parameter to the device, specific\r
+ to the request. The wIndex field is often used in \r
+ requests to specify an endpoint or an interface.\r
+ */\r
+ uint16_t wLength; /**< This field specifies the length of the data \r
+ transferred during the second phase of the control \r
+ transfer.\r
+ */\r
+} ;\r
+/** USB Default Control Pipe Setup Packet*/\r
+typedef struct _USB_SETUP_PACKET USB_SETUP_PACKET;\r
+\r
+\r
+/** USB Descriptor Types \r
+ * @{ \r
+ */\r
+/** Device descriptor type */\r
+#define USB_DEVICE_DESCRIPTOR_TYPE 1\r
+/** Configuration descriptor type */\r
+#define USB_CONFIGURATION_DESCRIPTOR_TYPE 2\r
+/** String descriptor type */\r
+#define USB_STRING_DESCRIPTOR_TYPE 3\r
+/** Interface descriptor type */\r
+#define USB_INTERFACE_DESCRIPTOR_TYPE 4\r
+/** Endpoint descriptor type */\r
+#define USB_ENDPOINT_DESCRIPTOR_TYPE 5\r
+/** Device qualifier descriptor type */\r
+#define USB_DEVICE_QUALIFIER_DESCRIPTOR_TYPE 6\r
+/** Other speed configuration descriptor type */\r
+#define USB_OTHER_SPEED_CONFIG_DESCRIPTOR_TYPE 7\r
+/** Interface power descriptor type */\r
+#define USB_INTERFACE_POWER_DESCRIPTOR_TYPE 8\r
+/** OTG descriptor type */\r
+#define USB_OTG_DESCRIPTOR_TYPE 9\r
+/** Debug descriptor type */\r
+#define USB_DEBUG_DESCRIPTOR_TYPE 10\r
+/** Interface association descriptor type */\r
+#define USB_INTERFACE_ASSOCIATION_DESCRIPTOR_TYPE 11\r
+/** @} */\r
+\r
+/** USB Device Classes \r
+ * @{ \r
+ */\r
+/** Reserved device class */\r
+#define USB_DEVICE_CLASS_RESERVED 0x00\r
+/** Audio device class */\r
+#define USB_DEVICE_CLASS_AUDIO 0x01\r
+/** Communications device class */\r
+#define USB_DEVICE_CLASS_COMMUNICATIONS 0x02\r
+/** Human interface device class */\r
+#define USB_DEVICE_CLASS_HUMAN_INTERFACE 0x03\r
+/** monitor device class */\r
+#define USB_DEVICE_CLASS_MONITOR 0x04\r
+/** physical interface device class */\r
+#define USB_DEVICE_CLASS_PHYSICAL_INTERFACE 0x05\r
+/** power device class */\r
+#define USB_DEVICE_CLASS_POWER 0x06\r
+/** Printer device class */\r
+#define USB_DEVICE_CLASS_PRINTER 0x07\r
+/** Storage device class */\r
+#define USB_DEVICE_CLASS_STORAGE 0x08\r
+/** Hub device class */\r
+#define USB_DEVICE_CLASS_HUB 0x09\r
+/** miscellaneous device class */\r
+#define USB_DEVICE_CLASS_MISCELLANEOUS 0xEF\r
+/** Application device class */\r
+#define USB_DEVICE_CLASS_APP 0xFE\r
+/** Vendor specific device class */\r
+#define USB_DEVICE_CLASS_VENDOR_SPECIFIC 0xFF\r
+/** @} */\r
+\r
+/** bmAttributes in Configuration Descriptor \r
+ * @{ \r
+ */\r
+/** Power field mask */\r
+#define USB_CONFIG_POWERED_MASK 0x40\r
+/** Bus powered */\r
+#define USB_CONFIG_BUS_POWERED 0x80\r
+/** Self powered */\r
+#define USB_CONFIG_SELF_POWERED 0xC0\r
+/** remote wakeup */\r
+#define USB_CONFIG_REMOTE_WAKEUP 0x20\r
+/** @} */\r
+\r
+/** bMaxPower in Configuration Descriptor */\r
+#define USB_CONFIG_POWER_MA(mA) ((mA)/2)\r
+\r
+/** bEndpointAddress in Endpoint Descriptor \r
+ * @{ \r
+ */\r
+/** Endopint address mask */\r
+#define USB_ENDPOINT_DIRECTION_MASK 0x80\r
+/** Macro to convert OUT endopint number to endpoint address value. */\r
+#define USB_ENDPOINT_OUT(addr) ((addr) | 0x00)\r
+/** Macro to convert IN endopint number to endpoint address value. */\r
+#define USB_ENDPOINT_IN(addr) ((addr) | 0x80)\r
+/** @} */\r
+\r
+/** bmAttributes in Endpoint Descriptor \r
+ * @{ \r
+ */\r
+/** Endopint type mask */\r
+#define USB_ENDPOINT_TYPE_MASK 0x03\r
+/** Control Endopint type */\r
+#define USB_ENDPOINT_TYPE_CONTROL 0x00\r
+/** isochronous Endopint type */\r
+#define USB_ENDPOINT_TYPE_ISOCHRONOUS 0x01\r
+/** bulk Endopint type */\r
+#define USB_ENDPOINT_TYPE_BULK 0x02\r
+/** interrupt Endopint type */\r
+#define USB_ENDPOINT_TYPE_INTERRUPT 0x03\r
+/** Endopint sync type mask */\r
+#define USB_ENDPOINT_SYNC_MASK 0x0C\r
+/** no synchronization Endopint */\r
+#define USB_ENDPOINT_SYNC_NO_SYNCHRONIZATION 0x00\r
+/** Asynchronous sync Endopint */\r
+#define USB_ENDPOINT_SYNC_ASYNCHRONOUS 0x04\r
+/** Adaptive sync Endopint */\r
+#define USB_ENDPOINT_SYNC_ADAPTIVE 0x08\r
+/** Synchronous sync Endopint */\r
+#define USB_ENDPOINT_SYNC_SYNCHRONOUS 0x0C\r
+/** Endopint usage type mask */\r
+#define USB_ENDPOINT_USAGE_MASK 0x30\r
+/** Endopint data usage type */\r
+#define USB_ENDPOINT_USAGE_DATA 0x00\r
+/** Endopint feedback usage type */\r
+#define USB_ENDPOINT_USAGE_FEEDBACK 0x10\r
+/** Endopint implicit feedback usage type */\r
+#define USB_ENDPOINT_USAGE_IMPLICIT_FEEDBACK 0x20\r
+/** Endopint reserved usage type */\r
+#define USB_ENDPOINT_USAGE_RESERVED 0x30\r
+/** @} */\r
+\r
+/** Control endopint EP0's maximum packet size in high-speed mode.*/\r
+#define USB_ENDPOINT_0_HS_MAXP 64\r
+/** Control endopint EP0's maximum packet size in low-speed mode.*/\r
+#define USB_ENDPOINT_0_LS_MAXP 8\r
+/** Bulk endopint's maximum packet size in high-speed mode.*/\r
+#define USB_ENDPOINT_BULK_HS_MAXP 512\r
+\r
+/** USB Standard Device Descriptor */\r
+PRE_PACK struct POST_PACK _USB_DEVICE_DESCRIPTOR\r
+{\r
+ uint8_t bLength; /**< Size of this descriptor in bytes. */\r
+ uint8_t bDescriptorType; /**< DEVICE Descriptor Type. */\r
+ uint16_t bcdUSB; /**< BUSB Specification Release Number in\r
+ Binary-Coded Decimal (i.e., 2.10 is 210H).\r
+ This field identifies the release of the USB\r
+ Specification with which the device and its\r
+ descriptors are compliant.\r
+ */\r
+ uint8_t bDeviceClass; /**< Class code (assigned by the USB-IF).\r
+ If this field is reset to zero, each interface\r
+ within a configuration specifies its own\r
+ class information and the various\r
+ interfaces operate independently.\n\r
+ If this field is set to a value between 1 and\r
+ FEH, the device supports different class\r
+ specifications on different interfaces and\r
+ the interfaces may not operate\r
+ independently. This value identifies the\r
+ class definition used for the aggregate\r
+ interfaces. \n\r
+ If this field is set to FFH, the device class\r
+ is vendor-specific.\r
+ */\r
+ uint8_t bDeviceSubClass; /**< Subclass code (assigned by the USB-IF).\r
+ These codes are qualified by the value of\r
+ the bDeviceClass field. \n\r
+ If the bDeviceClass field is reset to zero,\r
+ this field must also be reset to zero. \n\r
+ If the bDeviceClass field is not set to FFH,\r
+ all values are reserved for assignment by\r
+ the USB-IF. \r
+ */\r
+ uint8_t bDeviceProtocol; /**< Protocol code (assigned by the USB-IF).\r
+ These codes are qualified by the value of\r
+ the bDeviceClass and the\r
+ bDeviceSubClass fields. If a device\r
+ supports class-specific protocols on a\r
+ device basis as opposed to an interface\r
+ basis, this code identifies the protocols\r
+ that the device uses as defined by the\r
+ specification of the device class. \n\r
+ If this field is reset to zero, the device\r
+ does not use class-specific protocols on a\r
+ device basis. However, it may use classspecific\r
+ protocols on an interface basis. \n\r
+ If this field is set to FFH, the device uses a\r
+ vendor-specific protocol on a device basis. \r
+ */\r
+ uint8_t bMaxPacketSize0; /**< Maximum packet size for endpoint zero\r
+ (only 8, 16, 32, or 64 are valid). For HS devices\r
+ is fixed to 64.\r
+ */\r
+\r
+ uint16_t idVendor; /**< Vendor ID (assigned by the USB-IF). */\r
+ uint16_t idProduct; /**< Product ID (assigned by the manufacturer). */\r
+ uint16_t bcdDevice; /**< Device release number in binary-coded decimal. */\r
+ uint8_t iManufacturer; /**< Index of string descriptor describing manufacturer. */\r
+ uint8_t iProduct; /**< Index of string descriptor describing product. */\r
+ uint8_t iSerialNumber; /**< Index of string descriptor describing the device\92s \r
+ serial number.\r
+ */\r
+ uint8_t bNumConfigurations; /**< Number of possible configurations. */\r
+} ;\r
+/** USB Standard Device Descriptor */\r
+typedef struct _USB_DEVICE_DESCRIPTOR USB_DEVICE_DESCRIPTOR;\r
+\r
+/** USB 2.0 Device Qualifier Descriptor */\r
+PRE_PACK struct POST_PACK _USB_DEVICE_QUALIFIER_DESCRIPTOR\r
+{\r
+ uint8_t bLength; /**< Size of descriptor */\r
+ uint8_t bDescriptorType; /**< Device Qualifier Type */\r
+ uint16_t bcdUSB; /**< USB specification version number (e.g., 0200H for V2.00) */\r
+ uint8_t bDeviceClass; /**< Class Code */\r
+ uint8_t bDeviceSubClass; /**< SubClass Code */\r
+ uint8_t bDeviceProtocol; /**< Protocol Code */\r
+ uint8_t bMaxPacketSize0; /**< Maximum packet size for other speed */\r
+ uint8_t bNumConfigurations; /**< Number of Other-speed Configurations */\r
+ uint8_t bReserved; /**< Reserved for future use, must be zero */\r
+} ;\r
+/** USB 2.0 Device Qualifier Descriptor */\r
+typedef struct _USB_DEVICE_QUALIFIER_DESCRIPTOR USB_DEVICE_QUALIFIER_DESCRIPTOR;\r
+\r
+/** USB Standard Configuration Descriptor */\r
+PRE_PACK struct POST_PACK _USB_CONFIGURATION_DESCRIPTOR\r
+{\r
+ uint8_t bLength; /**< Size of this descriptor in bytes */\r
+ uint8_t bDescriptorType; /**< CONFIGURATION Descriptor Type*/\r
+ uint16_t wTotalLength; /**< Total length of data returned for this\r
+ configuration. Includes the combined length\r
+ of all descriptors (configuration, interface,\r
+ endpoint, and class- or vendor-specific)\r
+ returned for this configuration.*/\r
+ uint8_t bNumInterfaces; /**< Number of interfaces supported by this configuration*/\r
+ uint8_t bConfigurationValue; /**< Value to use as an argument to the\r
+ SetConfiguration() request to select this \r
+ configuration. */\r
+ uint8_t iConfiguration; /**< Index of string descriptor describing this\r
+ configuration*/\r
+ uint8_t bmAttributes; /**< Configuration characteristics \n\r
+ D7: Reserved (set to one)\n\r
+ D6: Self-powered \n\r
+ D5: Remote Wakeup \n\r
+ D4...0: Reserved (reset to zero) \n\r
+ D7 is reserved and must be set to one for\r
+ historical reasons. \n\r
+ A device configuration that uses power from\r
+ the bus and a local source reports a non-zero\r
+ value in bMaxPower to indicate the amount of\r
+ bus power required and sets D6. The actual\r
+ power source at runtime may be determined\r
+ using the GetStatus(DEVICE) request (see\r
+ USB 2.0 spec Section 9.4.5). \n\r
+ If a device configuration supports remote\r
+ wakeup, D5 is set to one.*/\r
+ uint8_t bMaxPower; /**< Maximum power consumption of the USB\r
+ device from the bus in this specific\r
+ configuration when the device is fully\r
+ operational. Expressed in 2 mA units\r
+ (i.e., 50 = 100 mA). \n\r
+ Note: A device configuration reports whether\r
+ the configuration is bus-powered or selfpowered.\r
+ Device status reports whether the\r
+ device is currently self-powered. If a device is\r
+ disconnected from its external power source, it\r
+ updates device status to indicate that it is no\r
+ longer self-powered. \n\r
+ A device may not increase its power draw\r
+ from the bus, when it loses its external power\r
+ source, beyond the amount reported by its\r
+ configuration. \n\r
+ If a device can continue to operate when\r
+ disconnected from its external power source, it\r
+ continues to do so. If the device cannot\r
+ continue to operate, it fails operations it can\r
+ no longer support. The USB System Software\r
+ may determine the cause of the failure by\r
+ checking the status and noting the loss of the\r
+ device\92s power source.*/\r
+} ;\r
+/** USB Standard Configuration Descriptor */\r
+typedef struct _USB_CONFIGURATION_DESCRIPTOR USB_CONFIGURATION_DESCRIPTOR;\r
+\r
+/** USB Standard Interface Association Descriptor */\r
+PRE_PACK struct POST_PACK _USB_IAD_DESCRIPTOR\r
+{\r
+ uint8_t bLength; /**< Size of this descriptor in bytes*/\r
+ uint8_t bDescriptorType; /**< INTERFACE ASSOCIATION Descriptor Type*/\r
+ uint8_t bFirstInterface; /**< Interface number of the first interface that is\r
+ associated with this function.*/\r
+ uint8_t bInterfaceCount; /**< Number of contiguous interfaces that are\r
+ associated with this function. */\r
+ uint8_t bFunctionClass; /**< Class code (assigned by USB-IF). \n\r
+ A value of zero is not allowed in this descriptor.\r
+ If this field is FFH, the function class is vendorspecific.\r
+ All other values are reserved for assignment by\r
+ the USB-IF.*/\r
+ uint8_t bFunctionSubClass; /**< Subclass code (assigned by USB-IF). \n\r
+ If the bFunctionClass field is not set to FFH all\r
+ values are reserved for assignment by the USBIF.*/\r
+ uint8_t bFunctionProtocol; /**< Protocol code (assigned by the USB). \n\r
+ These codes are qualified by the values of the\r
+ bFunctionClass and bFunctionSubClass fields.*/\r
+ uint8_t iFunction; /**< Index of string descriptor describing this function.*/\r
+} ;\r
+/** USB Standard Interface Association Descriptor */\r
+typedef struct _USB_IAD_DESCRIPTOR USB_IAD_DESCRIPTOR;\r
+\r
+/** USB Standard Interface Descriptor */\r
+PRE_PACK struct POST_PACK _USB_INTERFACE_DESCRIPTOR\r
+{\r
+ uint8_t bLength; /**< Size of this descriptor in bytes*/\r
+ uint8_t bDescriptorType; /**< INTERFACE Descriptor Type*/\r
+ uint8_t bInterfaceNumber; /**< Number of this interface. Zero-based\r
+ value identifying the index in the array of\r
+ concurrent interfaces supported by this\r
+ configuration.*/\r
+ uint8_t bAlternateSetting; /**< Value used to select this alternate setting\r
+ for the interface identified in the prior field*/\r
+ uint8_t bNumEndpoints; /**< Number of endpoints used by this\r
+ interface (excluding endpoint zero). If this\r
+ value is zero, this interface only uses the\r
+ Default Control Pipe.*/\r
+ uint8_t bInterfaceClass; /**< Class code (assigned by the USB-IF). \n\r
+ A value of zero is reserved for future\r
+ standardization. \n\r
+ If this field is set to FFH, the interface\r
+ class is vendor-specific. \n\r
+ All other values are reserved for\r
+ assignment by the USB-IF.*/\r
+ uint8_t bInterfaceSubClass; /**< Subclass code (assigned by the USB-IF). \n\r
+ These codes are qualified by the value of\r
+ the bInterfaceClass field. \n\r
+ If the bInterfaceClass field is reset to zero,\r
+ this field must also be reset to zero. \n\r
+ If the bInterfaceClass field is not set to\r
+ FFH, all values are reserved for\r
+ assignment by the USB-IF.*/\r
+ uint8_t bInterfaceProtocol; /**< Protocol code (assigned by the USB). \n\r
+ These codes are qualified by the value of\r
+ the bInterfaceClass and the\r
+ bInterfaceSubClass fields. If an interface\r
+ supports class-specific requests, this code\r
+ identifies the protocols that the device\r
+ uses as defined by the specification of the\r
+ device class. \n\r
+ If this field is reset to zero, the device\r
+ does not use a class-specific protocol on\r
+ this interface. \n\r
+ If this field is set to FFH, the device uses\r
+ a vendor-specific protocol for this\r
+ interface.*/\r
+ uint8_t iInterface; /**< Index of string descriptor describing this interface*/\r
+} ;\r
+/** USB Standard Interface Descriptor */\r
+typedef struct _USB_INTERFACE_DESCRIPTOR USB_INTERFACE_DESCRIPTOR;\r
+\r
+/** USB Standard Endpoint Descriptor */\r
+PRE_PACK struct POST_PACK _USB_ENDPOINT_DESCRIPTOR\r
+{\r
+ uint8_t bLength; /**< Size of this descriptor in bytes*/\r
+ uint8_t bDescriptorType; /**< ENDPOINT Descriptor Type*/\r
+ uint8_t bEndpointAddress; /**< The address of the endpoint on the USB device\r
+ described by this descriptor. The address is\r
+ encoded as follows: \n\r
+ Bit 3...0: The endpoint number \n\r
+ Bit 6...4: Reserved, reset to zero \n\r
+ Bit 7: Direction, ignored for control endpoints\r
+ 0 = OUT endpoint\r
+ 1 = IN endpoint. \n \sa USBD_ENDPOINT_ADR_Type*/\r
+ uint8_t bmAttributes; /**< This field describes the endpoint\92s attributes when it is\r
+ configured using the bConfigurationValue. \n\r
+ Bits 1..0: Transfer Type\r
+ \li 00 = Control\r
+ \li 01 = Isochronous\r
+ \li 10 = Bulk\r
+ \li 11 = Interrupt \n\r
+ If not an isochronous endpoint, bits 5..2 are reserved\r
+ and must be set to zero. If isochronous, they are\r
+ defined as follows: \n\r
+ Bits 3..2: Synchronization Type\r
+ \li 00 = No Synchronization\r
+ \li 01 = Asynchronous\r
+ \li 10 = Adaptive\r
+ \li 11 = Synchronous \n\r
+ Bits 5..4: Usage Type\r
+ \li 00 = Data endpoint\r
+ \li 01 = Feedback endpoint\r
+ \li 10 = Implicit feedback Data endpoint\r
+ \li 11 = Reserved \n\r
+ Refer to Chapter 5 of USB 2.0 specification for more information. \n\r
+ All other bits are reserved and must be reset to zero.\r
+ Reserved bits must be ignored by the host.\r
+ \n \sa USBD_EP_ATTR_Type*/\r
+ uint16_t wMaxPacketSize; /**< Maximum packet size this endpoint is capable of\r
+ sending or receiving when this configuration is\r
+ selected. \n\r
+ For isochronous endpoints, this value is used to\r
+ reserve the bus time in the schedule, required for the\r
+ per-(micro)frame data payloads. The pipe may, on an\r
+ ongoing basis, actually use less bandwidth than that\r
+ reserved. The device reports, if necessary, the actual\r
+ bandwidth used via its normal, non-USB defined\r
+ mechanisms. \n\r
+ For all endpoints, bits 10..0 specify the maximum\r
+ packet size (in bytes). \n\r
+ For high-speed isochronous and interrupt endpoints: \n\r
+ Bits 12..11 specify the number of additional transaction\r
+ opportunities per microframe: \n\r
+ \li 00 = None (1 transaction per microframe)\r
+ \li 01 = 1 additional (2 per microframe)\r
+ \li 10 = 2 additional (3 per microframe)\r
+ \li 11 = Reserved \n\r
+ Bits 15..13 are reserved and must be set to zero.*/\r
+ uint8_t bInterval; /**< Interval for polling endpoint for data transfers.\r
+ Expressed in frames or microframes depending on the\r
+ device operating speed (i.e., either 1 millisecond or\r
+ 125 µs units). \r
+ \li For full-/high-speed isochronous endpoints, this value\r
+ must be in the range from 1 to 16. The bInterval value\r
+ is used as the exponent for a \f$ 2^(bInterval-1) \f$ value; e.g., a\r
+ bInterval of 4 means a period of 8 (\f$ 2^(4-1) \f$). \r
+ \li For full-/low-speed interrupt endpoints, the value of\r
+ this field may be from 1 to 255.\r
+ \li For high-speed interrupt endpoints, the bInterval value\r
+ is used as the exponent for a \f$ 2^(bInterval-1) \f$ value; e.g., a\r
+ bInterval of 4 means a period of 8 (\f$ 2^(4-1) \f$) . This value\r
+ must be from 1 to 16.\r
+ \li For high-speed bulk/control OUT endpoints, the\r
+ bInterval must specify the maximum NAK rate of the\r
+ endpoint. A value of 0 indicates the endpoint never\r
+ NAKs. Other values indicate at most 1 NAK each\r
+ bInterval number of microframes. This value must be\r
+ in the range from 0 to 255. \n\r
+ Refer to Chapter 5 of USB 2.0 specification for more information.\r
+ */\r
+} ;\r
+/** USB Standard Endpoint Descriptor */\r
+typedef struct _USB_ENDPOINT_DESCRIPTOR USB_ENDPOINT_DESCRIPTOR;\r
+\r
+/** USB String Descriptor */\r
+PRE_PACK struct POST_PACK _USB_STRING_DESCRIPTOR\r
+{\r
+ uint8_t bLength; /**< Size of this descriptor in bytes*/\r
+ uint8_t bDescriptorType; /**< STRING Descriptor Type*/\r
+ uint16_t bString/*[]*/; /**< UNICODE encoded string */\r
+} ;\r
+/** USB String Descriptor */\r
+typedef struct _USB_STRING_DESCRIPTOR USB_STRING_DESCRIPTOR;\r
+\r
+/** USB Common Descriptor */\r
+PRE_PACK struct POST_PACK _USB_COMMON_DESCRIPTOR\r
+{\r
+ uint8_t bLength; /**< Size of this descriptor in bytes*/\r
+ uint8_t bDescriptorType; /**< Descriptor Type*/\r
+} ;\r
+/** USB Common Descriptor */\r
+typedef struct _USB_COMMON_DESCRIPTOR USB_COMMON_DESCRIPTOR;\r
+\r
+/** USB Other Speed Configuration */\r
+PRE_PACK struct POST_PACK _USB_OTHER_SPEED_CONFIGURATION\r
+{\r
+ uint8_t bLength; /**< Size of descriptor*/\r
+ uint8_t bDescriptorType; /**< Other_speed_Configuration Type*/\r
+ uint16_t wTotalLength; /**< Total length of data returned*/\r
+ uint8_t bNumInterfaces; /**< Number of interfaces supported by this speed configuration*/\r
+ uint8_t bConfigurationValue; /**< Value to use to select configuration*/\r
+ uint8_t IConfiguration; /**< Index of string descriptor*/\r
+ uint8_t bmAttributes; /**< Same as Configuration descriptor*/\r
+ uint8_t bMaxPower; /**< Same as Configuration descriptor*/\r
+} ;\r
+/** USB Other Speed Configuration */\r
+typedef struct _USB_OTHER_SPEED_CONFIGURATION USB_OTHER_SPEED_CONFIGURATION;\r
+\r
+/** \ingroup USBD_Core \r
+ * USB device stack/module handle. \r
+ */\r
+typedef void* USBD_HANDLE_T;\r
+\r
+#define WBVAL(x) ((x) & 0xFF),(((x) >> 8) & 0xFF)\r
+#define B3VAL(x) ((x) & 0xFF),(((x) >> 8) & 0xFF),(((x) >> 16) & 0xFF)\r
+\r
+#define USB_DEVICE_DESC_SIZE (sizeof(USB_DEVICE_DESCRIPTOR))\r
+#define USB_CONFIGURATION_DESC_SIZE (sizeof(USB_CONFIGURATION_DESCRIPTOR))\r
+#define USB_INTERFACE_DESC_SIZE (sizeof(USB_INTERFACE_DESCRIPTOR))\r
+#define USB_INTERFACE_ASSOC_DESC_SIZE (sizeof(USB_IAD_DESCRIPTOR))\r
+#define USB_ENDPOINT_DESC_SIZE (sizeof(USB_ENDPOINT_DESCRIPTOR))\r
+#define USB_DEVICE_QUALI_SIZE (sizeof(USB_DEVICE_QUALIFIER_DESCRIPTOR))\r
+#define USB_OTHER_SPEED_CONF_SIZE (sizeof(USB_OTHER_SPEED_CONFIGURATION))\r
+\r
+/** @}*/\r
+\r
+#endif /* __USBD_H__ */\r