aboutsummaryrefslogtreecommitdiffstats
path: root/LUFA/Drivers/USB
diff options
context:
space:
mode:
Diffstat (limited to 'LUFA/Drivers/USB')
-rw-r--r--LUFA/Drivers/USB/Class/Host/CDC.c11
-rw-r--r--LUFA/Drivers/USB/Class/Host/HID.c27
-rw-r--r--LUFA/Drivers/USB/Class/Host/HID.h12
-rw-r--r--LUFA/Drivers/USB/Class/Host/MassStorage.c17
-rw-r--r--LUFA/Drivers/USB/Class/Host/MassStorage.h1
-rw-r--r--LUFA/Drivers/USB/Class/Host/StillImage.h17
-rw-r--r--LUFA/Drivers/USB/HighLevel/ConfigDescriptor.c4
-rw-r--r--LUFA/Drivers/USB/HighLevel/ConfigDescriptor.h16
-rw-r--r--LUFA/Drivers/USB/HighLevel/StdDescriptors.h535
-rw-r--r--LUFA/Drivers/USB/LowLevel/DevChapter9.c11
-rw-r--r--LUFA/Drivers/USB/LowLevel/Host.c4
11 files changed, 380 insertions, 275 deletions
diff --git a/LUFA/Drivers/USB/Class/Host/CDC.c b/LUFA/Drivers/USB/Class/Host/CDC.c
index 68dddeacb..4a4d88461 100644
--- a/LUFA/Drivers/USB/Class/Host/CDC.c
+++ b/LUFA/Drivers/USB/Class/Host/CDC.c
@@ -50,12 +50,7 @@ uint8_t CDC_Host_ConfigurePipes(USB_ClassInfo_CDC_Host_t* CDCInterfaceInfo, uint
return CDC_ENUMERROR_NoCDCInterfaceFound;
}
- CDCInterfaceInfo->State.ControlInterfaceNumber =
-#if defined(USE_NONSTANDARD_DESCRIPTOR_NAMES)
- DESCRIPTOR_CAST(ConfigDescriptorData, USB_Descriptor_Interface_t).InterfaceNumber;
-#else
- DESCRIPTOR_CAST(ConfigDescriptorData, USB_Descriptor_Interface_t).bInterfaceNumber;
-#endif
+ CDCInterfaceInfo->State.ControlInterfaceNumber = DESCRIPTOR_CAST(ConfigDescriptorData, USB_Descriptor_Interface_t).InterfaceNumber;
while (FoundEndpoints != (CDC_FOUND_NOTIFICATION_IN | CDC_FOUND_DATAPIPE_IN | CDC_FOUND_DATAPIPE_OUT))
{
@@ -259,7 +254,7 @@ uint8_t CDC_Host_SendControlLineStateChange(USB_ClassInfo_CDC_Host_t* CDCInterfa
uint8_t CDC_Host_SendString(USB_ClassInfo_CDC_Host_t* CDCInterfaceInfo, char* Data, uint16_t Length)
{
if ((USB_HostState != HOST_STATE_Configured) || !(CDCInterfaceInfo->State.IsActive))
- return;
+ return PIPE_READYWAIT_NoError;
uint8_t ErrorCode;
@@ -274,7 +269,7 @@ uint8_t CDC_Host_SendString(USB_ClassInfo_CDC_Host_t* CDCInterfaceInfo, char* Da
uint8_t CDC_Host_SendByte(USB_ClassInfo_CDC_Host_t* CDCInterfaceInfo, uint8_t Data)
{
if ((USB_HostState != HOST_STATE_Configured) || !(CDCInterfaceInfo->State.IsActive))
- return;
+ return PIPE_READYWAIT_NoError;;
uint8_t ErrorCode;
diff --git a/LUFA/Drivers/USB/Class/Host/HID.c b/LUFA/Drivers/USB/Class/Host/HID.c
index 15106cee1..11dfb67ad 100644
--- a/LUFA/Drivers/USB/Class/Host/HID.c
+++ b/LUFA/Drivers/USB/Class/Host/HID.c
@@ -60,14 +60,16 @@ uint8_t HID_Host_ConfigurePipes(USB_ClassInfo_HID_Host_t* HIDInterfaceInfo, uint
} while (HIDInterfaceInfo->Config.HIDInterfaceProtocol &&
(CurrentHIDInterface->Protocol != HIDInterfaceInfo->Config.HIDInterfaceProtocol));
- HIDInterfaceInfo->State.InterfaceNumber =
- #if defined(USE_NONSTANDARD_DESCRIPTOR_NAMES)
- CurrentHIDInterface->InterfaceNumber;
- #else
- CurrentHIDInterface->bInterfaceNumber;
- #endif
+ HIDInterfaceInfo->State.InterfaceNumber = CurrentHIDInterface->InterfaceNumber;
HIDInterfaceInfo->State.SupportsBootSubClass = (CurrentHIDInterface->SubClass != 0);
+ if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData, DComp_NextHID) != DESCRIPTOR_SEARCH_COMP_Found)
+ {
+ return HID_ENUMERROR_NoHIDDescriptorFound;
+ }
+
+ HIDInterfaceInfo->State.HIDReportSize = DESCRIPTOR_CAST(ConfigDescriptorData, USB_HID_Descriptor_t).HIDReportLength;
+
while (FoundEndpoints != (HID_FOUND_DATAPIPE_IN | HID_FOUND_DATAPIPE_OUT))
{
if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData,
@@ -117,6 +119,16 @@ static uint8_t DComp_HID_Host_NextHIDInterface(void* CurrentDescriptor)
return DESCRIPTOR_SEARCH_NotFound;
}
+static uint8_t DComp_NextHID(void* CurrentDescriptor)
+{
+ if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_HID)
+ return DESCRIPTOR_SEARCH_Found;
+ else if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_Interface)
+ return DESCRIPTOR_SEARCH_Fail;
+ else
+ return DESCRIPTOR_SEARCH_NotFound;
+}
+
static uint8_t DComp_HID_Host_NextHIDInterfaceEndpoint(void* CurrentDescriptor)
{
if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_Endpoint)
@@ -170,6 +182,9 @@ uint8_t USB_HID_Host_SetProtocol(USB_ClassInfo_HID_Host_t* HIDInterfaceInfo, boo
Pipe_SelectPipe(PIPE_CONTROLPIPE);
+ if (UseReportProtocol && !(HIDInterfaceInfo->State.SupportsBootSubClass))
+ return MS_ERROR_UNSUPPORTED;
+
return USB_Host_SendControlRequest(NULL);
}
diff --git a/LUFA/Drivers/USB/Class/Host/HID.h b/LUFA/Drivers/USB/Class/Host/HID.h
index dd4a7537f..c1a68f819 100644
--- a/LUFA/Drivers/USB/Class/Host/HID.h
+++ b/LUFA/Drivers/USB/Class/Host/HID.h
@@ -55,6 +55,10 @@
#endif
/* Public Interface - May be used in end-application: */
+ /* Macros: */
+ /** Error code for some HID Host functions, indicating a logical (and not hardware) error */
+ #define MS_ERROR_UNSUPPORTED 0xC0
+
/* Type Defines: */
/** Class state structure. An instance of this structure should be made within the user application,
* and passed to each of the HID class driver functions as the HIDInterfaceInfo parameter. This
@@ -71,6 +75,8 @@
* boot subclass protocol is required (e.g. keyboard, mouse), or
* leave as 0 to match against the first HID interface found
*/
+ HID_ReportInfo_t* HIDParserData; /**< HID parser data to store the parsed HID report data, when boot protocol
+ * is not used */
} Config; /**< Config data for the USB class interface within the device. All elements in this section
* <b>must</b> be set or the interface will fail to enumerate and operate correctly.
*/
@@ -88,6 +94,7 @@
bool SupportsBootSubClass; /**< Indicates if the current interface instance supports the HID Boot
* Protocol when enabled via \ref USB_HID_Host_SetProtocol()
*/
+ uint16_t HIDReportSize; /**< Size in bytes of the HID report descriptor in the device */
} State; /**< State data for the USB class interface within the device. All elements in this section
* <b>may</b> be set to initial values, but may also be ignored to default to sane values when
* the interface is enumerated.
@@ -100,7 +107,8 @@
HID_ENUMERROR_NoError = 0, /**< Configuration Descriptor was processed successfully */
HID_ENUMERROR_InvalidConfigDescriptor = 1, /**< The device returned an invalid Configuration Descriptor */
HID_ENUMERROR_NoHIDInterfaceFound = 2, /**< A compatible HID interface was not found in the device's Configuration Descriptor */
- HID_ENUMERROR_EndpointsNotFound = 3, /**< Compatible HID endpoints were not found in the device's HID interface */
+ HID_ENUMERROR_NoHIDDescriptorFound = 3, /**< The HID descriptor was not found in the device's HID interface */
+ HID_ENUMERROR_EndpointsNotFound = 4, /**< Compatible HID endpoints were not found in the device's HID interface */
};
/* Function Prototypes: */
@@ -109,6 +117,7 @@
uint8_t* DeviceConfigDescriptor) ATTR_NON_NULL_PTR_ARG(1, 3);
bool HID_Host_IsReportReceived(USB_ClassInfo_HID_Host_t* HIDInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1);
+
uint8_t USB_HID_Host_SetProtocol(USB_ClassInfo_HID_Host_t* HIDInterfaceInfo, bool UseReportProtocol) ATTR_NON_NULL_PTR_ARG(1);
/* Private Interface - For use in library only: */
@@ -122,6 +131,7 @@
/* Function Prototypes: */
#if defined(INCLUDE_FROM_HID_CLASS_HOST_C)
static uint8_t DComp_HID_Host_NextHIDInterface(void* CurrentDescriptor) ATTR_NON_NULL_PTR_ARG(1);
+ static uint8_t DComp_NextHID(void* CurrentDescriptor) ATTR_NON_NULL_PTR_ARG(1);
static uint8_t DComp_HID_Host_NextHIDInterfaceEndpoint(void* CurrentDescriptor) ATTR_NON_NULL_PTR_ARG(1);
#endif
#endif
diff --git a/LUFA/Drivers/USB/Class/Host/MassStorage.c b/LUFA/Drivers/USB/Class/Host/MassStorage.c
index a812fa975..2d2f042b7 100644
--- a/LUFA/Drivers/USB/Class/Host/MassStorage.c
+++ b/LUFA/Drivers/USB/Class/Host/MassStorage.c
@@ -50,12 +50,7 @@ uint8_t MS_Host_ConfigurePipes(USB_ClassInfo_MS_Host_t* MSInterfaceInfo, uint16_
return MS_ENUMERROR_NoMSInterfaceFound;
}
- MSInterfaceInfo->State.InterfaceNumber =
- #if defined(USE_NONSTANDARD_DESCRIPTOR_NAMES)
- DESCRIPTOR_PCAST(DeviceConfigDescriptor, USB_Descriptor_Interface_t)->InterfaceNumber;
- #else
- DESCRIPTOR_PCAST(DeviceConfigDescriptor, USB_Descriptor_Interface_t)->bInterfaceNumber;
- #endif
+ MSInterfaceInfo->State.InterfaceNumber = DESCRIPTOR_PCAST(DeviceConfigDescriptor, USB_Descriptor_Interface_t)->InterfaceNumber;
while (FoundEndpoints != (MS_FOUND_DATAPIPE_IN | MS_FOUND_DATAPIPE_OUT))
{
@@ -150,7 +145,8 @@ static uint8_t MS_Host_SendCommand(USB_ClassInfo_MS_Host_t* MSInterfaceInfo, MS_
Pipe_SelectPipe(MSInterfaceInfo->Config.DataOUTPipeNumber);
Pipe_Unfreeze();
- if ((ErrorCode = Pipe_Write_Stream_LE(SCSICommandBlock, sizeof(MS_CommandBlockWrapper_t))) != PIPE_RWSTREAM_NoError)
+ if ((ErrorCode = Pipe_Write_Stream_LE(SCSICommandBlock, sizeof(MS_CommandBlockWrapper_t),
+ NO_STREAM_CALLBACK)) != PIPE_RWSTREAM_NoError)
return ErrorCode;
Pipe_ClearOUT();
@@ -238,7 +234,7 @@ static uint8_t MS_Host_SendReceiveData(USB_ClassInfo_MS_Host_t* MSInterfaceInfo,
Pipe_SelectPipe(MSInterfaceInfo->Config.DataINPipeNumber);
Pipe_Unfreeze();
- if ((ErrorCode = Pipe_Read_Stream_LE(BufferPtr, BytesRem)) != PIPE_RWSTREAM_NoError)
+ if ((ErrorCode = Pipe_Read_Stream_LE(BufferPtr, BytesRem, NO_STREAM_CALLBACK)) != PIPE_RWSTREAM_NoError)
return ErrorCode;
Pipe_ClearIN();
@@ -248,7 +244,7 @@ static uint8_t MS_Host_SendReceiveData(USB_ClassInfo_MS_Host_t* MSInterfaceInfo,
Pipe_SelectPipe(MSInterfaceInfo->Config.DataOUTPipeNumber);
Pipe_Unfreeze();
- if ((ErrorCode = Pipe_Write_Stream_LE(BufferPtr, BytesRem)) != PIPE_RWSTREAM_NoError)
+ if ((ErrorCode = Pipe_Write_Stream_LE(BufferPtr, BytesRem, NO_STREAM_CALLBACK)) != PIPE_RWSTREAM_NoError)
return ErrorCode;
Pipe_ClearOUT();
@@ -276,7 +272,8 @@ static uint8_t MS_Host_GetReturnedStatus(USB_ClassInfo_MS_Host_t* MSInterfaceInf
Pipe_SelectPipe(MSInterfaceInfo->Config.DataINPipeNumber);
Pipe_Unfreeze();
- if ((ErrorCode = Pipe_Read_Stream_LE(SCSICommandStatus, sizeof(MS_CommandStatusWrapper_t))) != PIPE_RWSTREAM_NoError)
+ if ((ErrorCode = Pipe_Read_Stream_LE(SCSICommandStatus, sizeof(MS_CommandStatusWrapper_t),
+ NO_STREAM_CALLBACK)) != PIPE_RWSTREAM_NoError)
return ErrorCode;
Pipe_ClearIN();
diff --git a/LUFA/Drivers/USB/Class/Host/MassStorage.h b/LUFA/Drivers/USB/Class/Host/MassStorage.h
index ff2e9019e..f6a1b61c2 100644
--- a/LUFA/Drivers/USB/Class/Host/MassStorage.h
+++ b/LUFA/Drivers/USB/Class/Host/MassStorage.h
@@ -55,6 +55,7 @@
/* Public Interface - May be used in end-application: */
/* Macros: */
+ /** Error code for some Mass Storage Host functions, indicating a logical (and not hardware) error */
#define MS_ERROR_LOGICAL_CMD_FAILED 0xC0
/* Type Defines: */
diff --git a/LUFA/Drivers/USB/Class/Host/StillImage.h b/LUFA/Drivers/USB/Class/Host/StillImage.h
index 0e1446978..66dc3925c 100644
--- a/LUFA/Drivers/USB/Class/Host/StillImage.h
+++ b/LUFA/Drivers/USB/Class/Host/StillImage.h
@@ -55,6 +55,7 @@
/* Public Interface - May be used in end-application: */
/* Macros: */
+ /** Error code for some Still Image Host functions, indicating a logical (and not hardware) error */
#define SI_ERROR_LOGICAL_CMD_FAILED 0xC0
/* Type Defines: */
@@ -134,7 +135,7 @@
* \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum, or \ref SI_ERROR_LOGICAL_CMD_FAILED if the device
* returned a logical command failure
*/
- uint8_t SImage_Host_OpenSession(USB_ClassInfo_SI_Host_t* SIInterfaceInfo);
+ uint8_t SImage_Host_OpenSession(USB_ClassInfo_SI_Host_t* SIInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1);
/** Closes an already opened PIMA session with the attached device. This should be used after all session-orientated
* PIMA commands have been issued to the device.
@@ -144,7 +145,7 @@
* \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum, or \ref SI_ERROR_LOGICAL_CMD_FAILED if the device
* returned a logical command failure
*/
- uint8_t SImage_Host_CloseSession(USB_ClassInfo_SI_Host_t* SIInterfaceInfo);
+ uint8_t SImage_Host_CloseSession(USB_ClassInfo_SI_Host_t* SIInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1);
/** Sends a given PIMA command to the attached device, filling out the PIMA command header automatically as required.
*
@@ -157,7 +158,7 @@
* returned a logical command failure
*/
uint8_t SImage_Host_SendCommand(USB_ClassInfo_SI_Host_t* SIInterfaceInfo, uint16_t Operation, uint8_t TotalParams,
- uint32_t* Params);
+ uint32_t* Params) ATTR_NON_NULL_PTR_ARG(1);
/** Receives and checks a response block from the attached PIMA device, once a command has been issued and all data
* associated with the command has been transferred.
@@ -167,7 +168,7 @@
* \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum, or \ref SI_ERROR_LOGICAL_CMD_FAILED if the device
* returned a logical command failure
*/
- uint8_t SImage_Host_ReceiveResponse(USB_ClassInfo_SI_Host_t* SIInterfaceInfo);
+ uint8_t SImage_Host_ReceiveResponse(USB_ClassInfo_SI_Host_t* SIInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1);
/** Indicates if the device has issued a PIMA event block to the host via the asynchronous events pipe.
*
@@ -175,7 +176,7 @@
*
* \return Boolean true if an event is waiting to be read, false otherwise
*/
- bool SImage_Host_IsEventReceived(USB_ClassInfo_SI_Host_t* SIInterfaceInfo);
+ bool SImage_Host_IsEventReceived(USB_ClassInfo_SI_Host_t* SIInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1);
/** Receives an asynchronous event block from the device via the asynchronous events pipe.
*
@@ -186,7 +187,7 @@
* returned a logical command failure
*/
uint8_t SImage_Host_ReceiveEventHeader(USB_ClassInfo_SI_Host_t* SIInterfaceInfo,
- SI_PIMA_Container_t* PIMAHeader);
+ SI_PIMA_Container_t* PIMAHeader) ATTR_NON_NULL_PTR_ARG(1, 2);
/** Sends arbitrary data to the attached device, for use in the data phase of PIMA commands which require data
* transfer beyond the regular PIMA command block parameters.
@@ -197,7 +198,7 @@
*
* \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum
*/
- uint8_t SImage_Host_SendData(USB_ClassInfo_SI_Host_t* SIInterfaceInfo, void* Buffer, uint16_t Bytes);
+ uint8_t SImage_Host_SendData(USB_ClassInfo_SI_Host_t* SIInterfaceInfo, void* Buffer, uint16_t Bytes) ATTR_NON_NULL_PTR_ARG(1, 2);
/** Receives arbitrary data from the attached device, for use in the data phase of PIMA commands which require data
* transfer beyond the regular PIMA command block parameters.
@@ -208,7 +209,7 @@
*
* \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum
*/
- uint8_t SImage_Host_ReadData(USB_ClassInfo_SI_Host_t* SIInterfaceInfo, void* Buffer, uint16_t Bytes);
+ uint8_t SImage_Host_ReadData(USB_ClassInfo_SI_Host_t* SIInterfaceInfo, void* Buffer, uint16_t Bytes) ATTR_NON_NULL_PTR_ARG(1, 2);
/* Private Interface - For use in library only: */
#if !defined(__DOXYGEN__)
diff --git a/LUFA/Drivers/USB/HighLevel/ConfigDescriptor.c b/LUFA/Drivers/USB/HighLevel/ConfigDescriptor.c
index 4c6fbfdab..6b20f4642 100644
--- a/LUFA/Drivers/USB/HighLevel/ConfigDescriptor.c
+++ b/LUFA/Drivers/USB/HighLevel/ConfigDescriptor.c
@@ -51,11 +51,7 @@ uint8_t USB_GetDeviceConfigDescriptor(uint8_t ConfigNumber, uint16_t* const Conf
if ((ErrorCode = USB_Host_SendControlRequest(ConfigHeader)) != HOST_SENDCONTROL_Successful)
return ErrorCode;
- #if defined(USE_NONSTANDARD_DESCRIPTOR_NAMES)
*ConfigSizePtr = DESCRIPTOR_CAST(ConfigHeader, USB_Descriptor_Configuration_Header_t).TotalConfigurationSize;
- #else
- *ConfigSizePtr = DESCRIPTOR_CAST(ConfigHeader, USB_Descriptor_Configuration_Header_t).wTotalLength;
- #endif
if (*ConfigSizePtr > BufferSize)
return HOST_GETCONFIG_BuffOverflow;
diff --git a/LUFA/Drivers/USB/HighLevel/ConfigDescriptor.h b/LUFA/Drivers/USB/HighLevel/ConfigDescriptor.h
index 9f7b1f60a..be24debba 100644
--- a/LUFA/Drivers/USB/HighLevel/ConfigDescriptor.h
+++ b/LUFA/Drivers/USB/HighLevel/ConfigDescriptor.h
@@ -98,18 +98,10 @@
* This value's meaning depends on the descriptor's placement in the descriptor, but standard type
* values can be accessed in the \ref USB_DescriptorTypes_t enum.
*/
- #if defined(USE_NONSTANDARD_DESCRIPTOR_NAMES) || defined(__DOXYGEN__)
- #define DESCRIPTOR_TYPE(DescriptorPtr) DESCRIPTOR_CAST(DescriptorPtr, USB_Descriptor_Header_t).Type
- #else
- #define DESCRIPTOR_TYPE(DescriptorPtr) DESCRIPTOR_CAST(DescriptorPtr, USB_Descriptor_Header_t).bDescriptorType
- #endif
+ #define DESCRIPTOR_TYPE(DescriptorPtr) DESCRIPTOR_CAST(DescriptorPtr, USB_Descriptor_Header_t).Type
/** Returns the descriptor's size, expressed as the 8-bit value indicating the number of bytes. */
- #if defined(USE_NONSTANDARD_DESCRIPTOR_NAMES) || defined(__DOXYGEN__)
- #define DESCRIPTOR_SIZE(DescriptorPtr) DESCRIPTOR_CAST(DescriptorPtr, USB_Descriptor_Header_t).Size
- #else
- #define DESCRIPTOR_SIZE(DescriptorPtr) DESCRIPTOR_CAST(DescriptorPtr, USB_Descriptor_Header_t).bLength
- #endif
+ #define DESCRIPTOR_SIZE(DescriptorPtr) DESCRIPTOR_CAST(DescriptorPtr, USB_Descriptor_Header_t).Size
/* Type Defines: */
/** Type define for a Configuration Descriptor comparator function (function taking a pointer to an array
@@ -268,11 +260,7 @@
static inline void USB_GetNextDescriptor(uint16_t* const BytesRem,
uint8_t** const CurrConfigLoc)
{
- #if defined(USE_NONSTANDARD_DESCRIPTOR_NAMES)
uint16_t CurrDescriptorSize = DESCRIPTOR_CAST(*CurrConfigLoc, USB_Descriptor_Header_t).Size;
- #else
- uint16_t CurrDescriptorSize = DESCRIPTOR_CAST(*CurrConfigLoc, USB_Descriptor_Header_t).bLength;
- #endif
*CurrConfigLoc += CurrDescriptorSize;
*BytesRem -= CurrDescriptorSize;
diff --git a/LUFA/Drivers/USB/HighLevel/StdDescriptors.h b/LUFA/Drivers/USB/HighLevel/StdDescriptors.h
index 0e0d1e9f4..0b56ab6d0 100644
--- a/LUFA/Drivers/USB/HighLevel/StdDescriptors.h
+++ b/LUFA/Drivers/USB/HighLevel/StdDescriptors.h
@@ -34,16 +34,6 @@
* Standard USB device descriptor defines and retrieval routines, for USB devices. This module contains
* structures and macros for the easy creation of standard USB descriptors in USB device projects.
*
- * All standard descriptors have their elements named in an identical manner to the official USB specification,
- * however slightly more verbose alternate (non-standard) names are also supplied if the macro
- * USE_NONSTANDARD_DESCRIPTOR_NAMES is defined in the user project makefile and passed to the compiler at
- * compilation time using the -D option.
- *
- * The non-standard names are documented here - if USE_NONSTANDARD_DESCRIPTOR_NAMES is not defined, then all
- * descriptors will contain elements named identically to the official USB specification. The alternately
- * named descriptor elements are placed in the same order inside the descriptor structures as their officially
- * named counterparts, thus they can be correlated easily with the official USB specification.
- *
* @{
*/
@@ -206,170 +196,232 @@
};
/* Type Defines: */
- /** Type define for all descriptor's header, indicating the descriptor's length and type.
+ /** Type define for all descriptors standard header, indicating the descriptor's length and type. This structure
+ * uses LUFA-specific element names to make each element's purpose clearer.
*
- * \note The non-standard structure element names are documented here. If the
- * USE_NONSTANDARD_DESCRIPTOR_NAMES token is not set, this structure contains elements
- * with names identical to those listed in the USB standard.
+ * \see \ref USB_StdDescriptor_Header_t for the version of this define with standard element names
*/
typedef struct
{
- #if defined(USE_NONSTANDARD_DESCRIPTOR_NAMES) || defined(__DOXYGEN__)
- uint8_t Size; /**< Size of the descriptor, in bytes. */
- uint8_t Type; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value
- * given by the specific class.
- */
- #else
- uint8_t bLength;
- uint8_t bDescriptorType;
- #endif
+ uint8_t Size; /**< Size of the descriptor, in bytes. */
+ uint8_t Type; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value
+ * given by the specific class.
+ */
} USB_Descriptor_Header_t;
- /** Type define for a standard device descriptor.
+ /** Type define for all descriptors standard header, indicating the descriptor's length and type. This structure
+ * uses the relevant standard's given element names to ensure compatibility with the standard.
+ *
+ * \see \ref USB_Descriptor_Header_t for the version of this define with non-standard LUFA specific element names
+ */
+ typedef struct
+ {
+ uint8_t bLength; /**< Size of the descriptor, in bytes. */
+ uint8_t bDescriptorType; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value
+ * given by the specific class.
+ */
+ } USB_StdDescriptor_Header_t;
+
+ /** Type define for a standard Device Descriptor. This structure uses LUFA-specific element names to make each
+ * element's purpose clearer.
*
- * \note The non-standard structure element names are documented here. If the
- * USE_NONSTANDARD_DESCRIPTOR_NAMES token is not set, this structure contains elements
- * with names identical to those listed in the USB standard.
+ * \see \ref USB_StdDescriptor_Device_t for the version of this define with standard element names
*/
typedef struct
{
- #if defined(USE_NONSTANDARD_DESCRIPTOR_NAMES) || defined(__DOXYGEN__)
USB_Descriptor_Header_t Header; /**< Descriptor header, including type and size. */
- uint16_t USBSpecification; /**< BCD of the supported USB specification. */
- uint8_t Class; /**< USB device class. */
- uint8_t SubClass; /**< USB device subclass. */
- uint8_t Protocol; /**< USB device protocol. */
+ uint16_t USBSpecification; /**< BCD of the supported USB specification. */
+ uint8_t Class; /**< USB device class. */
+ uint8_t SubClass; /**< USB device subclass. */
+ uint8_t Protocol; /**< USB device protocol. */
- uint8_t Endpoint0Size; /**< Size of the control (address 0) endpoint's bank in bytes. */
+ uint8_t Endpoint0Size; /**< Size of the control (address 0) endpoint's bank in bytes. */
- uint16_t VendorID; /**< Vendor ID for the USB product. */
- uint16_t ProductID; /**< Unique product ID for the USB product. */
- uint16_t ReleaseNumber; /**< Product release (version) number. */
+ uint16_t VendorID; /**< Vendor ID for the USB product. */
+ uint16_t ProductID; /**< Unique product ID for the USB product. */
+ uint16_t ReleaseNumber; /**< Product release (version) number. */
- uint8_t ManufacturerStrIndex; /**< String index for the manufacturer's name. The
- * host will request this string via a separate
- * control request for the string descriptor.
- *
- * \note If no string supplied, use \ref NO_DESCRIPTOR.
- */
- uint8_t ProductStrIndex; /**< String index for the product name/details.
- *
- * \see ManufacturerStrIndex structure entry.
- */
- uint8_t SerialNumStrIndex; /**< String index for the product's globally unique hexadecimal
- * serial number, in uppercase Unicode ASCII.
- *
- * \note On some AVR models, there is an embedded serial number
- * in the chip which can be used for the device serial number.
- * To use this serial number, set this to USE_INTERNAL_SERIAL.
- * On unsupported devices, this will evaluate to 0 and will cause
- * the host to generate a pseudo-unique value for the device upon
- * insertion.
- *
- * \see ManufacturerStrIndex structure entry.
- */
-
- uint8_t NumberOfConfigurations; /**< Total number of configurations supported by
- * the device.
- */
- #else
- uint8_t bLength;
- uint8_t bDescriptorType;
- uint16_t bcdUSB;
- uint8_t bDeviceClass;
- uint8_t bDeviceSubClass;
- uint8_t bDeviceProtocol;
- uint8_t bMaxPacketSize0;
- uint16_t idVendor;
- uint16_t idProduct;
- uint16_t bcdDevice;
- uint8_t iManufacturer;
- uint8_t iProduct;
- uint8_t iSerialNumber;
- uint8_t bNumConfigurations;
- #endif
+ uint8_t ManufacturerStrIndex; /**< String index for the manufacturer's name. The
+ * host will request this string via a separate
+ * control request for the string descriptor.
+ *
+ * \note If no string supplied, use \ref NO_DESCRIPTOR.
+ */
+ uint8_t ProductStrIndex; /**< String index for the product name/details.
+ *
+ * \see ManufacturerStrIndex structure entry.
+ */
+ uint8_t SerialNumStrIndex; /**< String index for the product's globally unique hexadecimal
+ * serial number, in uppercase Unicode ASCII.
+ *
+ * \note On some AVR models, there is an embedded serial number
+ * in the chip which can be used for the device serial number.
+ * To use this serial number, set this to USE_INTERNAL_SERIAL.
+ * On unsupported devices, this will evaluate to 0 and will cause
+ * the host to generate a pseudo-unique value for the device upon
+ * insertion.
+ *
+ * \see ManufacturerStrIndex structure entry.
+ */
+ uint8_t NumberOfConfigurations; /**< Total number of configurations supported by
+ * the device.
+ */
} USB_Descriptor_Device_t;
- /** Type define for a standard configuration descriptor.
+ /** Type define for a standard Device Descriptor. This structure uses the relevant standard's given element names
+ * to ensure compatibility with the standard.
*
- * \note The non-standard structure element names are documented here. If the
- * USE_NONSTANDARD_DESCRIPTOR_NAMES token is not set, this structure contains elements
- * with names identical to those listed in the USB standard.
+ * \see \ref USB_Descriptor_Device_t for the version of this define with non-standard LUFA specific element names
+ */
+ typedef struct
+ {
+ uint8_t bLength; /**< Size of the descriptor, in bytes. */
+ uint8_t bDescriptorType; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value
+ * given by the specific class.
+ */
+ uint16_t bcdUSB; /**< BCD of the supported USB specification. */
+ uint8_t bDeviceClass; /**< USB device class. */
+ uint8_t bDeviceSubClass; /**< USB device subclass. */
+ uint8_t bDeviceProtocol; /**< USB device protocol. */
+ uint8_t bMaxPacketSize0; /**< Size of the control (address 0) endpoint's bank in bytes. */
+ uint16_t idVendor; /**< Vendor ID for the USB product. */
+ uint16_t idProduct; /**< Unique product ID for the USB product. */
+ uint16_t bcdDevice; /**< Product release (version) number. */
+ uint8_t iManufacturer; /**< String index for the manufacturer's name. The
+ * host will request this string via a separate
+ * control request for the string descriptor.
+ *
+ * \note If no string supplied, use \ref NO_DESCRIPTOR.
+ */
+ uint8_t iProduct; /**< String index for the product name/details.
+ *
+ * \see ManufacturerStrIndex structure entry.
+ */
+ uint8_t iSerialNumber; /**< String index for the product's globally unique hexadecimal
+ * serial number, in uppercase Unicode ASCII.
+ *
+ * \note On some AVR models, there is an embedded serial number
+ * in the chip which can be used for the device serial number.
+ * To use this serial number, set this to USE_INTERNAL_SERIAL.
+ * On unsupported devices, this will evaluate to 0 and will cause
+ * the host to generate a pseudo-unique value for the device upon
+ * insertion.
+ *
+ * \see ManufacturerStrIndex structure entry.
+ */
+ uint8_t bNumConfigurations; /**< Total number of configurations supported by
+ * the device.
+ */
+ } USB_StdDescriptor_Device_t;
+
+ /** Type define for a standard Configuration Descriptor header. This structure uses LUFA-specific element names
+ * to make each element's purpose clearer.
+ *
+ * \see \ref USB_StdDescriptor_Configuration_Header_t for the version of this define with standard element names
*/
typedef struct
{
- #if defined(USE_NONSTANDARD_DESCRIPTOR_NAMES) || defined(__DOXYGEN__)
USB_Descriptor_Header_t Header; /**< Descriptor header, including type and size. */
- uint16_t TotalConfigurationSize; /**< Size of the configuration descriptor header,
- * and all sub descriptors inside the configuration.
- */
- uint8_t TotalInterfaces; /**< Total number of interfaces in the configuration. */
+ uint16_t TotalConfigurationSize; /**< Size of the configuration descriptor header,
+ * and all sub descriptors inside the configuration.
+ */
+ uint8_t TotalInterfaces; /**< Total number of interfaces in the configuration. */
- uint8_t ConfigurationNumber; /**< Configuration index of the current configuration. */
- uint8_t ConfigurationStrIndex; /**< Index of a string descriptor describing the configuration. */
+ uint8_t ConfigurationNumber; /**< Configuration index of the current configuration. */
+ uint8_t ConfigurationStrIndex; /**< Index of a string descriptor describing the configuration. */
- uint8_t ConfigAttributes; /**< Configuration attributes, comprised of a mask of zero or
- * more USB_CONFIG_ATTR_* masks.
- */
+ uint8_t ConfigAttributes; /**< Configuration attributes, comprised of a mask of zero or
+ * more USB_CONFIG_ATTR_* masks.
+ */
- uint8_t MaxPowerConsumption; /**< Maximum power consumption of the device while in the
- * current configuration, calculated by the \ref USB_CONFIG_POWER_MA()
- * macro.
- */
- #else
- uint8_t bLength;
- uint8_t bDescriptorType;
- uint16_t wTotalLength;
- uint8_t bNumInterfaces;
- uint8_t bConfigurationValue;
- uint8_t iConfiguration;
- uint8_t bmAttributes;
- uint8_t bMaxPower;
- #endif
+ uint8_t MaxPowerConsumption; /**< Maximum power consumption of the device while in the
+ * current configuration, calculated by the \ref USB_CONFIG_POWER_MA()
+ * macro.
+ */
} USB_Descriptor_Configuration_Header_t;
-
- /** Type define for a standard interface descriptor.
+
+ /** Type define for a standard Configuration Descriptor header. This structure uses the relevant standard's given element names
+ * to ensure compatibility with the standard.
*
- * \note The non-standard structure element names are documented here. If the
- * USE_NONSTANDARD_DESCRIPTOR_NAMES token is not set, this structure contains elements
- * with names identical to those listed in the USB standard.
+ * \see \ref USB_Descriptor_Device_t for the version of this define with non-standard LUFA specific element names
+ */
+ typedef struct
+ {
+ uint8_t bLength; /**< Size of the descriptor, in bytes. */
+ uint8_t bDescriptorType; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value
+ * given by the specific class.
+ */
+ uint16_t wTotalLength; /**< Size of the configuration descriptor header,
+ * and all sub descriptors inside the configuration.
+ */
+ uint8_t bNumInterfaces; /**< Total number of interfaces in the configuration. */
+ uint8_t bConfigurationValue; /**< Configuration index of the current configuration. */
+ uint8_t iConfiguration; /**< Index of a string descriptor describing the configuration. */
+ uint8_t bmAttributes; /**< Configuration attributes, comprised of a mask of zero or
+ * more USB_CONFIG_ATTR_* masks.
+ */
+ uint8_t bMaxPower; /**< Maximum power consumption of the device while in the
+ * current configuration, calculated by the \ref USB_CONFIG_POWER_MA()
+ * macro.
+ */
+ } USB_StdDescriptor_Configuration_Header_t;
+
+ /** Type define for a standard Interface Descriptor. This structure uses LUFA-specific element names
+ * to make each element's purpose clearer.
+ *
+ * \see \ref USB_StdDescriptor_Interface_t for the version of this define with standard element names
*/
typedef struct
{
- #if defined(USE_NONSTANDARD_DESCRIPTOR_NAMES) || defined(__DOXYGEN__)
USB_Descriptor_Header_t Header; /**< Descriptor header, including type and size. */
- uint8_t InterfaceNumber; /**< Index of the interface in the current configuration. */
- uint8_t AlternateSetting; /**< Alternate setting for the interface number. The same
- * interface number can have multiple alternate settings
- * with different endpoint configurations, which can be
- * selected by the host.
- */
- uint8_t TotalEndpoints; /**< Total number of endpoints in the interface. */
+ uint8_t InterfaceNumber; /**< Index of the interface in the current configuration. */
+ uint8_t AlternateSetting; /**< Alternate setting for the interface number. The same
+ * interface number can have multiple alternate settings
+ * with different endpoint configurations, which can be
+ * selected by the host.
+ */
+ uint8_t TotalEndpoints; /**< Total number of endpoints in the interface. */
- uint8_t Class; /**< Interface class ID. */
- uint8_t SubClass; /**< Interface subclass ID. */
- uint8_t Protocol; /**< Interface protocol ID. */
-
- uint8_t InterfaceStrIndex; /**< Index of the string descriptor describing the
- * interface.
- */
- #else
- uint8_t bLength;
- uint8_t bDescriptorType;
- uint8_t bInterfaceNumber;
- uint8_t bAlternateSetting;
- uint8_t bNumEndpoints;
- uint8_t bInterfaceClass;
- uint8_t bInterfaceSubClass;
- uint8_t bInterfaceProtocol;
- uint8_t iInterface;
- #endif
- } USB_Descriptor_Interface_t;
+ uint8_t Class; /**< Interface class ID. */
+ uint8_t SubClass; /**< Interface subclass ID. */
+ uint8_t Protocol; /**< Interface protocol ID. */
- /** Type define for a standard Interface Association descriptor.
+ uint8_t InterfaceStrIndex; /**< Index of the string descriptor describing the
+ * interface.
+ */
+ } USB_Descriptor_Interface_t;
+
+ /** Type define for a standard Interface Descriptor. This structure uses the relevant standard's given element names
+ * to ensure compatibility with the standard.
+ *
+ * \see \ref USB_Descriptor_Interface_t for the version of this define with non-standard LUFA specific element names
+ */
+ typedef struct
+ {
+ uint8_t bLength; /**< Size of the descriptor, in bytes. */
+ uint8_t bDescriptorType; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value
+ * given by the specific class.
+ */
+ uint8_t bInterfaceNumber; /**< Index of the interface in the current configuration. */
+ uint8_t bAlternateSetting; /**< Alternate setting for the interface number. The same
+ * interface number can have multiple alternate settings
+ * with different endpoint configurations, which can be
+ * selected by the host.
+ */
+ uint8_t bNumEndpoints; /**< Total number of endpoints in the interface. */
+ uint8_t bInterfaceClass; /**< Interface class ID. */
+ uint8_t bInterfaceSubClass; /**< Interface subclass ID. */
+ uint8_t bInterfaceProtocol; /**< Interface protocol ID. */
+ uint8_t iInterface; /**< Index of the string descriptor describing the
+ * interface.
+ */
+ } USB_StdDescriptor_Interface_t;
+
+ /** Type define for a standard Interface Association Descriptor. This structure uses LUFA-specific element names
+ * to make each element's purpose clearer.
*
* This descriptor has been added as a supplement to the USB2.0 standard, in the ECN located at
* <a>http://www.usb.org/developers/docs/InterfaceAssociationDescriptor_ecn.pdf</a>. It allows compound
@@ -377,72 +429,105 @@
* together at the point of enumeration, loading one generic driver for all the interfaces in the single
* function. Read the ECN for more information.
*
- * \note The non-standard structure element names are documented here. If the
- * USE_NONSTANDARD_DESCRIPTOR_NAMES token is not set, this structure contains elements
- * with names identical to those listed in the USB standard.
+ * \see \ref USB_StdDescriptor_Interface_Association_t for the version of this define with standard element names
*/
typedef struct
{
- #if defined(USE_NONSTANDARD_DESCRIPTOR_NAMES) || defined(__DOXYGEN__)
USB_Descriptor_Header_t Header; /**< Descriptor header, including type and size. */
- uint8_t FirstInterfaceIndex; /**< Index of the first associated interface. */
- uint8_t TotalInterfaces; /** Total number of associated interfaces. */
-
- uint8_t Class; /**< Interface class ID. */
- uint8_t SubClass; /**< Interface subclass ID. */
- uint8_t Protocol; /**< Interface protocol ID. */
-
- uint8_t IADStrIndex; /**< Index of the string descriptor describing the
- * interface association.
- */
- #else
- uint8_t bLength;
- uint8_t bDescriptorType;
- uint8_t bFirstInterface;
- uint8_t bInterfaceCount;
- uint8_t bFunctionClass;
- uint8_t bFunctionSubClass;
- uint8_t bFunctionProtocol;
- uint8_t iFunction;
- #endif
- } USB_Descriptor_Interface_Association_t;
+ uint8_t FirstInterfaceIndex; /**< Index of the first associated interface. */
+ uint8_t TotalInterfaces; /** Total number of associated interfaces. */
- /** Type define for a standard endpoint descriptor.
+ uint8_t Class; /**< Interface class ID. */
+ uint8_t SubClass; /**< Interface subclass ID. */
+ uint8_t Protocol; /**< Interface protocol ID. */
+
+ uint8_t IADStrIndex; /**< Index of the string descriptor describing the
+ * interface association.
+ */
+ } USB_Descriptor_Interface_Association_t;
+
+ /** Type define for a standard Interface Association Descriptor. This structure uses the relevant standard's given
+ * element names to ensure compatibility with the standard.
*
- * \note The non-standard structure element names are documented here. If the
- * USE_NONSTANDARD_DESCRIPTOR_NAMES token is not set, this structure contains elements
- * with names identical to those listed in the USB standard.
- */
+ * This descriptor has been added as a supplement to the USB2.0 standard, in the ECN located at
+ * <a>http://www.usb.org/developers/docs/InterfaceAssociationDescriptor_ecn.pdf</a>. It allows compound
+ * devices with multiple interfaces related to the same function to have the multiple interfaces bound
+ * together at the point of enumeration, loading one generic driver for all the interfaces in the single
+ * function. Read the ECN for more information.
+ *
+ * \see \ref USB_Descriptor_Interface_Association_t for the version of this define with non-standard LUFA specific
+ * element names
+ */
+ typedef struct
+ {
+ uint8_t bLength; /**< Size of the descriptor, in bytes. */
+ uint8_t bDescriptorType; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value
+ * given by the specific class.
+ */
+ uint8_t bFirstInterface; /**< Index of the first associated interface. */
+ uint8_t bInterfaceCount; /** Total number of associated interfaces. */
+ uint8_t bFunctionClass; /**< Interface class ID. */
+ uint8_t bFunctionSubClass; /**< Interface subclass ID. */
+ uint8_t bFunctionProtocol; /**< Interface protocol ID. */
+ uint8_t iFunction; /**< Index of the string descriptor describing the
+ * interface association.
+ */
+ } USB_StdDescriptor_Interface_Association_t;
+
+ /** Type define for a standard Endpoint Descriptor. This structure uses LUFA-specific element names
+ * to make each element's purpose clearer.
+ *
+ * \see \ref USB_StdDescriptor_Endpoint_t for the version of this define with standard element names
+ */
typedef struct
{
- #if defined(USE_NONSTANDARD_DESCRIPTOR_NAMES) || defined(__DOXYGEN__)
USB_Descriptor_Header_t Header; /**< Descriptor header, including type and size. */
- uint8_t EndpointAddress; /**< Logical address of the endpoint within the device
- * for the current configuration, including direction
- * mask.
- */
- uint8_t Attributes; /**< Endpoint attributes, comprised of a mask of the
- * endpoint type (EP_TYPE_*) and attributes (ENDPOINT_ATTR_*)
- * masks.
- */
- uint16_t EndpointSize; /**< Size of the endpoint bank, in bytes. This indicates the
- * maximum packet size that the endpoint can receive at a time.
- */
+ uint8_t EndpointAddress; /**< Logical address of the endpoint within the device
+ * for the current configuration, including direction
+ * mask.
+ */
+ uint8_t Attributes; /**< Endpoint attributes, comprised of a mask of the
+ * endpoint type (EP_TYPE_*) and attributes (ENDPOINT_ATTR_*)
+ * masks.
+ */
+ uint16_t EndpointSize; /**< Size of the endpoint bank, in bytes. This indicates the
+ * maximum packet size that the endpoint can receive at a time.
+ */
- uint8_t PollingIntervalMS; /**< Polling interval in milliseconds for the endpoint
- * if it is an INTERRUPT or ISOCHRONOUS type.
- */
- #else
- uint8_t bLength;
- uint8_t bDescriptorType;
- uint8_t bEndpointAddress;
- uint8_t bmAttributes;
- uint16_t wMaxPacketSize;
- uint8_t bInterval;
- #endif
+ uint8_t PollingIntervalMS; /**< Polling interval in milliseconds for the endpoint
+ * if it is an INTERRUPT or ISOCHRONOUS type.
+ */
} USB_Descriptor_Endpoint_t;
+
+ /** Type define for a standard Endpoint Descriptor. This structure uses the relevant standard's given
+ * element names to ensure compatibility with the standard.
+ *
+ * \see \ref USB_Descriptor_Endpoint_t for the version of this define with non-standard LUFA specific
+ * element names
+ */
+ typedef struct
+ {
+ uint8_t bLength; /**< Size of the descriptor, in bytes. */
+ uint8_t bDescriptorType; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value
+ * given by the specific class.
+ */
+ uint8_t bEndpointAddress; /**< Logical address of the endpoint within the device
+ * for the current configuration, including direction
+ * mask.
+ */
+ uint8_t bmAttributes; /**< Endpoint attributes, comprised of a mask of the
+ * endpoint type (EP_TYPE_*) and attributes (ENDPOINT_ATTR_*)
+ * masks.
+ */
+ uint16_t wMaxPacketSize; /**< Size of the endpoint bank, in bytes. This indicates the
+ * maximum packet size that the endpoint can receive at a time.
+ */
+ uint8_t bInterval; /**< Polling interval in milliseconds for the endpoint
+ * if it is an INTERRUPT or ISOCHRONOUS type.
+ */
+ } USB_StdDescriptor_Endpoint_t;
/** Type define for a standard string descriptor. Unlike other standard descriptors, the length
* of the descriptor for placement in the descriptor header must be determined by the \ref USB_STRING_LEN()
@@ -451,33 +536,59 @@
* This structure should also be used for string index 0, which contains the supported language IDs for
* the device as an array.
*
- * \note The non-standard structure element names are documented here. If the
- * USE_NONSTANDARD_DESCRIPTOR_NAMES token is not set, this structure contains elements
- * with names identical to those listed in the USB standard.
+ * This structure uses LUFA-specific element names to make each element's purpose clearer.
+ *
+ * \see \ref USB_StdDescriptor_String_t for the version of this define with standard element names
*/
typedef struct
{
- #if defined(USE_NONSTANDARD_DESCRIPTOR_NAMES) || defined(__DOXYGEN__)
USB_Descriptor_Header_t Header; /**< Descriptor header, including type and size. */
- int16_t UnicodeString[]; /**< String data, as unicode characters (alternatively,
- * string language IDs). If normal ASCII characters are
- * to be used, they must be added as an array of characters
- * rather than a normal C string so that they are widened to
- * Unicode size.
- *
- * Under GCC, strings prefixed with the "L" character (before
- * the opening string quotation mark) are considered to be
- * Unicode strings, and may be used instead of an explicit
- * array of ASCII characters.
- */
- #else
- uint8_t bLength;
- uint8_t bDescriptorType;
- int16_t bString[];
- #endif
+ int16_t UnicodeString[]; /**< String data, as unicode characters (alternatively,
+ * string language IDs). If normal ASCII characters are
+ * to be used, they must be added as an array of characters
+ * rather than a normal C string so that they are widened to
+ * Unicode size.
+ *
+ * Under GCC, strings prefixed with the "L" character (before
+ * the opening string quotation mark) are considered to be
+ * Unicode strings, and may be used instead of an explicit
+ * array of ASCII characters.
+ */
} USB_Descriptor_String_t;
+ /** Type define for a standard string descriptor. Unlike other standard descriptors, the length
+ * of the descriptor for placement in the descriptor header must be determined by the \ref USB_STRING_LEN()
+ * macro rather than by the size of the descriptor structure, as the length is not fixed.
+ *
+ * This structure should also be used for string index 0, which contains the supported language IDs for
+ * the device as an array.
+ *
+ * This structure uses the relevant standard's given element names to ensure compatibility with the standard.
+ *
+ * \see \ref USB_Descriptor_String_t for the version of this define with with non-standard LUFA specific
+ * element names
+ */
+ typedef struct
+ {
+ uint8_t bLength; /**< Size of the descriptor, in bytes. */
+ uint8_t bDescriptorType; /**< Type of the descriptor, either a value in
+ * \ref USB_DescriptorTypes_t or a value
+ * given by the specific class.
+ */
+ int16_t bString[]; /**< String data, as unicode characters (alternatively,
+ * string language IDs). If normal ASCII characters are
+ * to be used, they must be added as an array of characters
+ * rather than a normal C string so that they are widened to
+ * Unicode size.
+ *
+ * Under GCC, strings prefixed with the "L" character (before
+ * the opening string quotation mark) are considered to be
+ * Unicode strings, and may be used instead of an explicit
+ * array of ASCII characters.
+ */
+ } USB_StdDescriptor_String_t;
+
/* Private Interface - For use in library only: */
#if !defined(__DOXYGEN__)
/* Macros: */
diff --git a/LUFA/Drivers/USB/LowLevel/DevChapter9.c b/LUFA/Drivers/USB/LowLevel/DevChapter9.c
index fa35a1b61..50afb61be 100644
--- a/LUFA/Drivers/USB/LowLevel/DevChapter9.c
+++ b/LUFA/Drivers/USB/LowLevel/DevChapter9.c
@@ -232,14 +232,9 @@ static void USB_Device_GetInternalSerialDescriptor(void)
int16_t UnicodeString[20];
} SignatureDescriptor;
- #if defined(USE_NONSTANDARD_DESCRIPTOR_NAMES)
- SignatureDescriptor.Header.Size = sizeof(SignatureDescriptor);
- SignatureDescriptor.Header.Type = DTYPE_String;
- #else
- SignatureDescriptor.Header.bLength = sizeof(SignatureDescriptor);
- SignatureDescriptor.Header.bDescriptorType = DTYPE_String;
- #endif
-
+ SignatureDescriptor.Header.Size = sizeof(SignatureDescriptor);
+ SignatureDescriptor.Header.Type = DTYPE_String;
+
uint8_t SigReadAddress = 0x0E;
for (uint8_t SerialCharNum = 0; SerialCharNum < 20; SerialCharNum++)
diff --git a/LUFA/Drivers/USB/LowLevel/Host.c b/LUFA/Drivers/USB/LowLevel/Host.c
index 8a51ae5bf..2685f5f0b 100644
--- a/LUFA/Drivers/USB/LowLevel/Host.c
+++ b/LUFA/Drivers/USB/LowLevel/Host.c
@@ -137,11 +137,7 @@ void USB_Host_ProcessNextHostState(void)
break;
}
- #if defined(USE_NONSTANDARD_DESCRIPTOR_NAMES)
USB_ControlPipeSize = DataBuffer[offsetof(USB_Descriptor_Device_t, Endpoint0Size)];
- #else
- USB_ControlPipeSize = DataBuffer[offsetof(USB_Descriptor_Device_t, bMaxPacketSize0)];
- #endif
USB_Host_ResetDevice();