aboutsummaryrefslogtreecommitdiffstats
path: root/LUFA/Drivers/USB/HighLevel
diff options
context:
space:
mode:
authorDean Camera <dean@fourwalledcubicle.com>2010-05-08 03:12:14 +0000
committerDean Camera <dean@fourwalledcubicle.com>2010-05-08 03:12:14 +0000
commit071e02c6b6b4837fa9cf0b6d4c749994e02638d7 (patch)
tree960446788703b69f0bb285450be80c5b3d8cc22c /LUFA/Drivers/USB/HighLevel
parente331b531c6e6d93eb0eee42b9002074e8090ad18 (diff)
downloadlufa-071e02c6b6b4837fa9cf0b6d4c749994e02638d7.tar.gz
lufa-071e02c6b6b4837fa9cf0b6d4c749994e02638d7.tar.bz2
lufa-071e02c6b6b4837fa9cf0b6d4c749994e02638d7.zip
Add svn:eol-style property to source files, so that the line endings are correctly converted to the target system's native end of line style.
Diffstat (limited to 'LUFA/Drivers/USB/HighLevel')
-rw-r--r--LUFA/Drivers/USB/HighLevel/ConfigDescriptor.c282
-rw-r--r--LUFA/Drivers/USB/HighLevel/ConfigDescriptor.h572
-rw-r--r--LUFA/Drivers/USB/HighLevel/Events.c76
-rw-r--r--LUFA/Drivers/USB/HighLevel/Events.h724
-rw-r--r--LUFA/Drivers/USB/HighLevel/StdDescriptors.h1302
-rw-r--r--LUFA/Drivers/USB/HighLevel/StdRequestType.h452
-rw-r--r--LUFA/Drivers/USB/HighLevel/StreamCallbacks.h166
-rw-r--r--LUFA/Drivers/USB/HighLevel/USBMode.h274
-rw-r--r--LUFA/Drivers/USB/HighLevel/USBTask.c176
-rw-r--r--LUFA/Drivers/USB/HighLevel/USBTask.h408
10 files changed, 2216 insertions, 2216 deletions
diff --git a/LUFA/Drivers/USB/HighLevel/ConfigDescriptor.c b/LUFA/Drivers/USB/HighLevel/ConfigDescriptor.c
index 270a98aeb..f6a6e5ebe 100644
--- a/LUFA/Drivers/USB/HighLevel/ConfigDescriptor.c
+++ b/LUFA/Drivers/USB/HighLevel/ConfigDescriptor.c
@@ -1,141 +1,141 @@
-/*
- LUFA Library
- Copyright (C) Dean Camera, 2010.
-
- dean [at] fourwalledcubicle [dot] com
- www.fourwalledcubicle.com
-*/
-
-/*
- Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
-
- Permission to use, copy, modify, distribute, and sell this
- software and its documentation for any purpose is hereby granted
- without fee, provided that the above copyright notice appear in
- all copies and that both that the copyright notice and this
- permission notice and warranty disclaimer appear in supporting
- documentation, and that the name of the author not be used in
- advertising or publicity pertaining to distribution of the
- software without specific, written prior permission.
-
- The author disclaim all warranties with regard to this
- software, including all implied warranties of merchantability
- and fitness. In no event shall the author be liable for any
- special, indirect or consequential damages or any damages
- whatsoever resulting from loss of use, data or profits, whether
- in an action of contract, negligence or other tortious action,
- arising out of or in connection with the use or performance of
- this software.
-*/
-
-#define __INCLUDE_FROM_USB_DRIVER
-#include "ConfigDescriptor.h"
-
-#if defined(USB_CAN_BE_HOST)
-uint8_t USB_Host_GetDeviceConfigDescriptor(uint8_t ConfigNumber, uint16_t* const ConfigSizePtr,
- void* BufferPtr, uint16_t BufferSize)
-{
- uint8_t ErrorCode;
- uint8_t ConfigHeader[sizeof(USB_Descriptor_Configuration_Header_t)];
-
- USB_ControlRequest = (USB_Request_Header_t)
- {
- .bmRequestType = (REQDIR_DEVICETOHOST | REQTYPE_STANDARD | REQREC_DEVICE),
- .bRequest = REQ_GetDescriptor,
- .wValue = ((DTYPE_Configuration << 8) | (ConfigNumber - 1)),
- .wIndex = 0,
- .wLength = sizeof(USB_Descriptor_Configuration_Header_t),
- };
-
- Pipe_SelectPipe(PIPE_CONTROLPIPE);
-
- if ((ErrorCode = USB_Host_SendControlRequest(ConfigHeader)) != HOST_SENDCONTROL_Successful)
- return ErrorCode;
-
- *ConfigSizePtr = DESCRIPTOR_CAST(ConfigHeader, USB_Descriptor_Configuration_Header_t).TotalConfigurationSize;
-
- if (*ConfigSizePtr > BufferSize)
- return HOST_GETCONFIG_BuffOverflow;
-
- USB_ControlRequest.wLength = *ConfigSizePtr;
-
- if ((ErrorCode = USB_Host_SendControlRequest(BufferPtr)) != HOST_SENDCONTROL_Successful)
- return ErrorCode;
-
- if (DESCRIPTOR_TYPE(BufferPtr) != DTYPE_Configuration)
- return HOST_GETCONFIG_InvalidData;
-
- return HOST_GETCONFIG_Successful;
-}
-#endif
-
-void USB_GetNextDescriptorOfType(uint16_t* const BytesRem,
- void** const CurrConfigLoc,
- const uint8_t Type)
-{
- while (*BytesRem)
- {
- USB_GetNextDescriptor(BytesRem, CurrConfigLoc);
-
- if (DESCRIPTOR_TYPE(*CurrConfigLoc) == Type)
- return;
- }
-}
-
-void USB_GetNextDescriptorOfTypeBefore(uint16_t* const BytesRem,
- void** const CurrConfigLoc,
- const uint8_t Type,
- const uint8_t BeforeType)
-{
- while (*BytesRem)
- {
- USB_GetNextDescriptor(BytesRem, CurrConfigLoc);
-
- if (DESCRIPTOR_TYPE(*CurrConfigLoc) == Type)
- {
- return;
- }
- else if (DESCRIPTOR_TYPE(*CurrConfigLoc) == BeforeType)
- {
- *BytesRem = 0;
- return;
- }
- }
-}
-
-void USB_GetNextDescriptorOfTypeAfter(uint16_t* const BytesRem,
- void** const CurrConfigLoc,
- const uint8_t Type,
- const uint8_t AfterType)
-{
- USB_GetNextDescriptorOfType(BytesRem, CurrConfigLoc, AfterType);
-
- if (*BytesRem)
- USB_GetNextDescriptorOfType(BytesRem, CurrConfigLoc, Type);
-}
-
-uint8_t USB_GetNextDescriptorComp(uint16_t* BytesRem, void** CurrConfigLoc, ConfigComparatorPtr_t ComparatorRoutine)
-{
- uint8_t ErrorCode;
-
- while (*BytesRem)
- {
- uint8_t* PrevDescLoc = *CurrConfigLoc;
- uint16_t PrevBytesRem = *BytesRem;
-
- USB_GetNextDescriptor(BytesRem, CurrConfigLoc);
-
- if ((ErrorCode = ComparatorRoutine(*CurrConfigLoc)) != DESCRIPTOR_SEARCH_NotFound)
- {
- if (ErrorCode == DESCRIPTOR_SEARCH_Fail)
- {
- *CurrConfigLoc = PrevDescLoc;
- *BytesRem = PrevBytesRem;
- }
-
- return ErrorCode;
- }
- }
-
- return DESCRIPTOR_SEARCH_COMP_EndOfDescriptor;
-}
+/*
+ LUFA Library
+ Copyright (C) Dean Camera, 2010.
+
+ dean [at] fourwalledcubicle [dot] com
+ www.fourwalledcubicle.com
+*/
+
+/*
+ Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
+
+ Permission to use, copy, modify, distribute, and sell this
+ software and its documentation for any purpose is hereby granted
+ without fee, provided that the above copyright notice appear in
+ all copies and that both that the copyright notice and this
+ permission notice and warranty disclaimer appear in supporting
+ documentation, and that the name of the author not be used in
+ advertising or publicity pertaining to distribution of the
+ software without specific, written prior permission.
+
+ The author disclaim all warranties with regard to this
+ software, including all implied warranties of merchantability
+ and fitness. In no event shall the author be liable for any
+ special, indirect or consequential damages or any damages
+ whatsoever resulting from loss of use, data or profits, whether
+ in an action of contract, negligence or other tortious action,
+ arising out of or in connection with the use or performance of
+ this software.
+*/
+
+#define __INCLUDE_FROM_USB_DRIVER
+#include "ConfigDescriptor.h"
+
+#if defined(USB_CAN_BE_HOST)
+uint8_t USB_Host_GetDeviceConfigDescriptor(uint8_t ConfigNumber, uint16_t* const ConfigSizePtr,
+ void* BufferPtr, uint16_t BufferSize)
+{
+ uint8_t ErrorCode;
+ uint8_t ConfigHeader[sizeof(USB_Descriptor_Configuration_Header_t)];
+
+ USB_ControlRequest = (USB_Request_Header_t)
+ {
+ .bmRequestType = (REQDIR_DEVICETOHOST | REQTYPE_STANDARD | REQREC_DEVICE),
+ .bRequest = REQ_GetDescriptor,
+ .wValue = ((DTYPE_Configuration << 8) | (ConfigNumber - 1)),
+ .wIndex = 0,
+ .wLength = sizeof(USB_Descriptor_Configuration_Header_t),
+ };
+
+ Pipe_SelectPipe(PIPE_CONTROLPIPE);
+
+ if ((ErrorCode = USB_Host_SendControlRequest(ConfigHeader)) != HOST_SENDCONTROL_Successful)
+ return ErrorCode;
+
+ *ConfigSizePtr = DESCRIPTOR_CAST(ConfigHeader, USB_Descriptor_Configuration_Header_t).TotalConfigurationSize;
+
+ if (*ConfigSizePtr > BufferSize)
+ return HOST_GETCONFIG_BuffOverflow;
+
+ USB_ControlRequest.wLength = *ConfigSizePtr;
+
+ if ((ErrorCode = USB_Host_SendControlRequest(BufferPtr)) != HOST_SENDCONTROL_Successful)
+ return ErrorCode;
+
+ if (DESCRIPTOR_TYPE(BufferPtr) != DTYPE_Configuration)
+ return HOST_GETCONFIG_InvalidData;
+
+ return HOST_GETCONFIG_Successful;
+}
+#endif
+
+void USB_GetNextDescriptorOfType(uint16_t* const BytesRem,
+ void** const CurrConfigLoc,
+ const uint8_t Type)
+{
+ while (*BytesRem)
+ {
+ USB_GetNextDescriptor(BytesRem, CurrConfigLoc);
+
+ if (DESCRIPTOR_TYPE(*CurrConfigLoc) == Type)
+ return;
+ }
+}
+
+void USB_GetNextDescriptorOfTypeBefore(uint16_t* const BytesRem,
+ void** const CurrConfigLoc,
+ const uint8_t Type,
+ const uint8_t BeforeType)
+{
+ while (*BytesRem)
+ {
+ USB_GetNextDescriptor(BytesRem, CurrConfigLoc);
+
+ if (DESCRIPTOR_TYPE(*CurrConfigLoc) == Type)
+ {
+ return;
+ }
+ else if (DESCRIPTOR_TYPE(*CurrConfigLoc) == BeforeType)
+ {
+ *BytesRem = 0;
+ return;
+ }
+ }
+}
+
+void USB_GetNextDescriptorOfTypeAfter(uint16_t* const BytesRem,
+ void** const CurrConfigLoc,
+ const uint8_t Type,
+ const uint8_t AfterType)
+{
+ USB_GetNextDescriptorOfType(BytesRem, CurrConfigLoc, AfterType);
+
+ if (*BytesRem)
+ USB_GetNextDescriptorOfType(BytesRem, CurrConfigLoc, Type);
+}
+
+uint8_t USB_GetNextDescriptorComp(uint16_t* BytesRem, void** CurrConfigLoc, ConfigComparatorPtr_t ComparatorRoutine)
+{
+ uint8_t ErrorCode;
+
+ while (*BytesRem)
+ {
+ uint8_t* PrevDescLoc = *CurrConfigLoc;
+ uint16_t PrevBytesRem = *BytesRem;
+
+ USB_GetNextDescriptor(BytesRem, CurrConfigLoc);
+
+ if ((ErrorCode = ComparatorRoutine(*CurrConfigLoc)) != DESCRIPTOR_SEARCH_NotFound)
+ {
+ if (ErrorCode == DESCRIPTOR_SEARCH_Fail)
+ {
+ *CurrConfigLoc = PrevDescLoc;
+ *BytesRem = PrevBytesRem;
+ }
+
+ return ErrorCode;
+ }
+ }
+
+ return DESCRIPTOR_SEARCH_COMP_EndOfDescriptor;
+}
diff --git a/LUFA/Drivers/USB/HighLevel/ConfigDescriptor.h b/LUFA/Drivers/USB/HighLevel/ConfigDescriptor.h
index 232a9d111..099553335 100644
--- a/LUFA/Drivers/USB/HighLevel/ConfigDescriptor.h
+++ b/LUFA/Drivers/USB/HighLevel/ConfigDescriptor.h
@@ -1,286 +1,286 @@
-/*
- LUFA Library
- Copyright (C) Dean Camera, 2010.
-
- dean [at] fourwalledcubicle [dot] com
- www.fourwalledcubicle.com
-*/
-
-/*
- Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
-
- Permission to use, copy, modify, distribute, and sell this
- software and its documentation for any purpose is hereby granted
- without fee, provided that the above copyright notice appear in
- all copies and that both that the copyright notice and this
- permission notice and warranty disclaimer appear in supporting
- documentation, and that the name of the author not be used in
- advertising or publicity pertaining to distribution of the
- software without specific, written prior permission.
-
- The author disclaim all warranties with regard to this
- software, including all implied warranties of merchantability
- and fitness. In no event shall the author be liable for any
- special, indirect or consequential damages or any damages
- whatsoever resulting from loss of use, data or profits, whether
- in an action of contract, negligence or other tortious action,
- arising out of or in connection with the use or performance of
- this software.
-*/
-
-/** \file
- * \brief Configuration descriptor parser API.
- *
- * This section of the library gives a friendly API which can be used in host applications to easily
- * parse an attached device's configuration descriptor so that endpoint, interface and other descriptor
- * data can be extracted and used as needed.
- *
- * \note This file should not be included directly. It is automatically included as needed by the USB driver
- * dispatch header located in LUFA/Drivers/USB/USB.h.
- */
-
-/** \ingroup Group_Descriptors
- * @defgroup Group_ConfigDescriptorParser Configuration Descriptor Parser
- *
- * Functions, macros, variables, enums and types related to the parsing of Configuration Descriptors.
- *
- * @{
- */
-
-#ifndef __CONFIGDESCRIPTOR_H__
-#define __CONFIGDESCRIPTOR_H__
-
- /* Includes: */
- #include <avr/io.h>
-
- #include "../../../Common/Common.h"
- #include "../HighLevel/USBMode.h"
- #include "../LowLevel/HostChapter9.h"
- #include "../HighLevel/StdDescriptors.h"
-
- /* Enable C linkage for C++ Compilers: */
- #if defined(__cplusplus)
- extern "C" {
- #endif
-
- /* Preprocessor Checks: */
- #if !defined(__INCLUDE_FROM_USB_DRIVER)
- #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.
- #endif
-
- /* Public Interface - May be used in end-application: */
- /* Macros: */
- /** Mask for determining the type of an endpoint from an endpoint descriptor. This should then be compared
- * with the EP_TYPE_* masks to determine the exact type of the endpoint.
- */
- #define EP_TYPE_MASK 0x03
-
- /** Casts a pointer to a descriptor inside the configuration descriptor into a pointer to the given
- * descriptor type.
- *
- * Usage Example:
- * \code
- * uint8_t* CurrDescriptor = &ConfigDescriptor[0]; // Pointing to the configuration header
- * USB_Descriptor_Configuration_Header_t* ConfigHeaderPtr = DESCRIPTOR_PCAST(CurrDescriptor,
- * USB_Descriptor_Configuration_Header_t);
- *
- * // Can now access elements of the configuration header struct using the -> indirection operator
- * \endcode
- */
- #define DESCRIPTOR_PCAST(DescriptorPtr, Type) ((Type*)(DescriptorPtr))
-
- /** Casts a pointer to a descriptor inside the configuration descriptor into the given descriptor
- * type (as an actual struct instance rather than a pointer to a struct).
- *
- * Usage Example:
- * \code
- * uint8_t* CurrDescriptor = &ConfigDescriptor[0]; // Pointing to the configuration header
- * USB_Descriptor_Configuration_Header_t ConfigHeader = DESCRIPTOR_CAST(CurrDescriptor,
- * USB_Descriptor_Configuration_Header_t);
- *
- * // Can now access elements of the configuration header struct using the . operator
- * \endcode
- */
- #define DESCRIPTOR_CAST(DescriptorPtr, Type) (*DESCRIPTOR_PCAST(DescriptorPtr, Type))
-
- /** Returns the descriptor's type, expressed as the 8-bit type value in the header of the descriptor.
- * 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.
- */
- #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. */
- #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
- * of type void, returning a uint8_t value).
- *
- * \see \ref USB_GetNextDescriptorComp function for more details
- */
- typedef uint8_t (* const ConfigComparatorPtr_t)(void*);
-
- /* Function Prototypes: */
- /** Searches for the next descriptor in the given configuration descriptor using a premade comparator
- * function. The routine updates the position and remaining configuration descriptor bytes values
- * automatically. If a comparator routine fails a search, the descriptor pointer is retreated back
- * so that the next descriptor search invocation will start from the descriptor which first caused the
- * original search to fail. This behaviour allows for one comparator to be used immediately after another
- * has failed, starting the second search from the descriptor which failed the first.
- *
- * Comparator functions should be standard functions which accept a pointer to the header of the current
- * descriptor inside the configuration descriptor which is being compared, and should return a value from
- * the \ref DSearch_Return_ErrorCodes_t enum as a uint8_t value.
- *
- * \note This function is available in USB Host mode only.
- *
- * \param[in,out] BytesRem Pointer to an int storing the remaining bytes in the configuration descriptor
- * \param[in,out] CurrConfigLoc Pointer to the current position in the configuration descriptor
- * \param[in] ComparatorRoutine Name of the comparator search function to use on the configuration descriptor
- *
- * \return Value of one of the members of the \ref DSearch_Comp_Return_ErrorCodes_t enum
- *
- * Usage Example:
- * \code
- * uint8_t EndpointSearcher(void* CurrentDescriptor); // Comparator Prototype
- *
- * uint8_t EndpointSearcher(void* CurrentDescriptor)
- * {
- * if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_Endpoint)
- * return DESCRIPTOR_SEARCH_Found;
- * else
- * return DESCRIPTOR_SEARCH_NotFound;
- * }
- *
- * //...
- * // After retrieving configuration descriptor:
- * if (USB_Host_GetNextDescriptorComp(&BytesRemaining, &CurrentConfigLoc, EndpointSearcher) ==
- * Descriptor_Search_Comp_Found)
- * {
- * // Do something with the endpoint descriptor
- * }
- * \endcode
- */
- uint8_t USB_GetNextDescriptorComp(uint16_t* BytesRem, void** CurrConfigLoc, ConfigComparatorPtr_t ComparatorRoutine);
-
- /* Enums: */
- /** Enum for the possible return codes of the \ref USB_Host_GetDeviceConfigDescriptor() function. */
- enum USB_Host_GetConfigDescriptor_ErrorCodes_t
- {
- HOST_GETCONFIG_Successful = 0, /**< No error occurred while retrieving the configuration descriptor */
- HOST_GETCONFIG_DeviceDisconnect = 1, /**< The attached device was disconnected while retrieving the configuration
- * descriptor
- */
- HOST_GETCONFIG_PipeError = 2, /**< An error occurred in the pipe while sending the request */
- HOST_GETCONFIG_SetupStalled = 3, /**< The attached device stalled the request to retrieve the configuration
- * descriptor
- */
- HOST_GETCONFIG_SoftwareTimeOut = 4, /**< The request or data transfer timed out */
- HOST_GETCONFIG_BuffOverflow = 5, /**< The device's configuration descriptor is too large to fit into the allocated
- * buffer
- */
- HOST_GETCONFIG_InvalidData = 6, /**< The device returned invalid configuration descriptor data */
- };
-
- /** Enum for return values of a descriptor comparator function. */
- enum DSearch_Return_ErrorCodes_t
- {
- DESCRIPTOR_SEARCH_Found = 0, /**< Current descriptor matches comparator criteria. */
- DESCRIPTOR_SEARCH_Fail = 1, /**< No further descriptor could possibly match criteria, fail the search. */
- DESCRIPTOR_SEARCH_NotFound = 2, /**< Current descriptor does not match comparator criteria. */
- };
-
- /** Enum for return values of \ref USB_GetNextDescriptorComp(). */
- enum DSearch_Comp_Return_ErrorCodes_t
- {
- DESCRIPTOR_SEARCH_COMP_Found = 0, /**< Configuration descriptor now points to descriptor which matches
- * search criteria of the given comparator function. */
- DESCRIPTOR_SEARCH_COMP_Fail = 1, /**< Comparator function returned Descriptor_Search_Fail. */
- DESCRIPTOR_SEARCH_COMP_EndOfDescriptor = 2, /**< End of configuration descriptor reached before match found. */
- };
-
- /* Function Prototypes: */
- /** Retrieves the configuration descriptor data from an attached device via a standard request into a buffer,
- * including validity and size checking to prevent a buffer overflow.
- *
- * \param[in] ConfigNumber Device configuration descriptor number to fetch from the device (usually set to 1 for
- * single configuration devices)
- * \param[in,out] ConfigSizePtr Pointer to a uint16_t for storing the retrieved configuration descriptor size
- * \param[out] BufferPtr Pointer to the buffer for storing the configuration descriptor data.
- * \param[out] BufferSize Size of the allocated buffer where the configuration descriptor is to be stored
- *
- * \return A value from the \ref USB_Host_GetConfigDescriptor_ErrorCodes_t enum
- */
- uint8_t USB_Host_GetDeviceConfigDescriptor(uint8_t ConfigNumber, uint16_t* const ConfigSizePtr, void* BufferPtr,
- uint16_t BufferSize) ATTR_NON_NULL_PTR_ARG(2) ATTR_NON_NULL_PTR_ARG(3);
-
- /** Skips to the next sub-descriptor inside the configuration descriptor of the specified type value.
- * The bytes remaining value is automatically decremented.
- *
- * \param[in,out] BytesRem Pointer to the number of bytes remaining of the configuration descriptor
- * \param[in,out] CurrConfigLoc Pointer to the current descriptor inside the configuration descriptor
- * \param[in] Type Descriptor type value to search for
- */
- void USB_GetNextDescriptorOfType(uint16_t* const BytesRem,
- void** const CurrConfigLoc,
- const uint8_t Type)
- ATTR_NON_NULL_PTR_ARG(1) ATTR_NON_NULL_PTR_ARG(2);
-
- /** Skips to the next sub-descriptor inside the configuration descriptor of the specified type value,
- * which must come before a descriptor of the second given type value. If the BeforeType type
- * descriptor is reached first, the number of bytes remaining to process is set to zero and the
- * function exits. The bytes remaining value is automatically decremented.
- *
- * \param[in,out] BytesRem Pointer to the number of bytes remaining of the configuration descriptor
- * \param[in,out] CurrConfigLoc Pointer to the current descriptor inside the configuration descriptor
- * \param[in] Type Descriptor type value to search for
- * \param[in] BeforeType Descriptor type value which must not be reached before the given Type descriptor
- */
- void USB_GetNextDescriptorOfTypeBefore(uint16_t* const BytesRem,
- void** const CurrConfigLoc,
- const uint8_t Type,
- const uint8_t BeforeType)
- ATTR_NON_NULL_PTR_ARG(1) ATTR_NON_NULL_PTR_ARG(2);
-
- /** Skips to the next sub-descriptor inside the configuration descriptor of the specified type value,
- * which must come after a descriptor of the second given type value. The bytes remaining value is
- * automatically decremented.
- *
- * \param[in,out] BytesRem Pointer to the number of bytes remaining of the configuration descriptor
- * \param[in,out] CurrConfigLoc Pointer to the current descriptor inside the configuration descriptor
- * \param[in] Type Descriptor type value to search for
- * \param[in] AfterType Descriptor type value which must be reached before the given Type descriptor
- */
- void USB_GetNextDescriptorOfTypeAfter(uint16_t* const BytesRem,
- void** const CurrConfigLoc,
- const uint8_t Type,
- const uint8_t AfterType)
- ATTR_NON_NULL_PTR_ARG(1) ATTR_NON_NULL_PTR_ARG(2);
-
- /* Inline Functions: */
- /** Skips over the current sub-descriptor inside the configuration descriptor, so that the pointer then
- points to the next sub-descriptor. The bytes remaining value is automatically decremented.
- *
- * \param[in,out] BytesRem Pointer to the number of bytes remaining of the configuration descriptor
- * \param[in,out] CurrConfigLoc Pointer to the current descriptor inside the configuration descriptor
- */
- static inline void USB_GetNextDescriptor(uint16_t* const BytesRem,
- void** const CurrConfigLoc)
- ATTR_NON_NULL_PTR_ARG(1) ATTR_NON_NULL_PTR_ARG(2);
- static inline void USB_GetNextDescriptor(uint16_t* const BytesRem,
- void** const CurrConfigLoc)
- {
- uint16_t CurrDescriptorSize = DESCRIPTOR_CAST(*CurrConfigLoc, USB_Descriptor_Header_t).Size;
-
- *CurrConfigLoc += CurrDescriptorSize;
- *BytesRem -= CurrDescriptorSize;
- }
-
- /* Disable C linkage for C++ Compilers: */
- #if defined(__cplusplus)
- }
- #endif
-
-#endif
-
-/** @} */
+/*
+ LUFA Library
+ Copyright (C) Dean Camera, 2010.
+
+ dean [at] fourwalledcubicle [dot] com
+ www.fourwalledcubicle.com
+*/
+
+/*
+ Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
+
+ Permission to use, copy, modify, distribute, and sell this
+ software and its documentation for any purpose is hereby granted
+ without fee, provided that the above copyright notice appear in
+ all copies and that both that the copyright notice and this
+ permission notice and warranty disclaimer appear in supporting
+ documentation, and that the name of the author not be used in
+ advertising or publicity pertaining to distribution of the
+ software without specific, written prior permission.
+
+ The author disclaim all warranties with regard to this
+ software, including all implied warranties of merchantability
+ and fitness. In no event shall the author be liable for any
+ special, indirect or consequential damages or any damages
+ whatsoever resulting from loss of use, data or profits, whether
+ in an action of contract, negligence or other tortious action,
+ arising out of or in connection with the use or performance of
+ this software.
+*/
+
+/** \file
+ * \brief Configuration descriptor parser API.
+ *
+ * This section of the library gives a friendly API which can be used in host applications to easily
+ * parse an attached device's configuration descriptor so that endpoint, interface and other descriptor
+ * data can be extracted and used as needed.
+ *
+ * \note This file should not be included directly. It is automatically included as needed by the USB driver
+ * dispatch header located in LUFA/Drivers/USB/USB.h.
+ */
+
+/** \ingroup Group_Descriptors
+ * @defgroup Group_ConfigDescriptorParser Configuration Descriptor Parser
+ *
+ * Functions, macros, variables, enums and types related to the parsing of Configuration Descriptors.
+ *
+ * @{
+ */
+
+#ifndef __CONFIGDESCRIPTOR_H__
+#define __CONFIGDESCRIPTOR_H__
+
+ /* Includes: */
+ #include <avr/io.h>
+
+ #include "../../../Common/Common.h"
+ #include "../HighLevel/USBMode.h"
+ #include "../LowLevel/HostChapter9.h"
+ #include "../HighLevel/StdDescriptors.h"
+
+ /* Enable C linkage for C++ Compilers: */
+ #if defined(__cplusplus)
+ extern "C" {
+ #endif
+
+ /* Preprocessor Checks: */
+ #if !defined(__INCLUDE_FROM_USB_DRIVER)
+ #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.
+ #endif
+
+ /* Public Interface - May be used in end-application: */
+ /* Macros: */
+ /** Mask for determining the type of an endpoint from an endpoint descriptor. This should then be compared
+ * with the EP_TYPE_* masks to determine the exact type of the endpoint.
+ */
+ #define EP_TYPE_MASK 0x03
+
+ /** Casts a pointer to a descriptor inside the configuration descriptor into a pointer to the given
+ * descriptor type.
+ *
+ * Usage Example:
+ * \code
+ * uint8_t* CurrDescriptor = &ConfigDescriptor[0]; // Pointing to the configuration header
+ * USB_Descriptor_Configuration_Header_t* ConfigHeaderPtr = DESCRIPTOR_PCAST(CurrDescriptor,
+ * USB_Descriptor_Configuration_Header_t);
+ *
+ * // Can now access elements of the configuration header struct using the -> indirection operator
+ * \endcode
+ */
+ #define DESCRIPTOR_PCAST(DescriptorPtr, Type) ((Type*)(DescriptorPtr))
+
+ /** Casts a pointer to a descriptor inside the configuration descriptor into the given descriptor
+ * type (as an actual struct instance rather than a pointer to a struct).
+ *
+ * Usage Example:
+ * \code
+ * uint8_t* CurrDescriptor = &ConfigDescriptor[0]; // Pointing to the configuration header
+ * USB_Descriptor_Configuration_Header_t ConfigHeader = DESCRIPTOR_CAST(CurrDescriptor,
+ * USB_Descriptor_Configuration_Header_t);
+ *
+ * // Can now access elements of the configuration header struct using the . operator
+ * \endcode
+ */
+ #define DESCRIPTOR_CAST(DescriptorPtr, Type) (*DESCRIPTOR_PCAST(DescriptorPtr, Type))
+
+ /** Returns the descriptor's type, expressed as the 8-bit type value in the header of the descriptor.
+ * 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.
+ */
+ #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. */
+ #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
+ * of type void, returning a uint8_t value).
+ *
+ * \see \ref USB_GetNextDescriptorComp function for more details
+ */
+ typedef uint8_t (* const ConfigComparatorPtr_t)(void*);
+
+ /* Function Prototypes: */
+ /** Searches for the next descriptor in the given configuration descriptor using a premade comparator
+ * function. The routine updates the position and remaining configuration descriptor bytes values
+ * automatically. If a comparator routine fails a search, the descriptor pointer is retreated back
+ * so that the next descriptor search invocation will start from the descriptor which first caused the
+ * original search to fail. This behaviour allows for one comparator to be used immediately after another
+ * has failed, starting the second search from the descriptor which failed the first.
+ *
+ * Comparator functions should be standard functions which accept a pointer to the header of the current
+ * descriptor inside the configuration descriptor which is being compared, and should return a value from
+ * the \ref DSearch_Return_ErrorCodes_t enum as a uint8_t value.
+ *
+ * \note This function is available in USB Host mode only.
+ *
+ * \param[in,out] BytesRem Pointer to an int storing the remaining bytes in the configuration descriptor
+ * \param[in,out] CurrConfigLoc Pointer to the current position in the configuration descriptor
+ * \param[in] ComparatorRoutine Name of the comparator search function to use on the configuration descriptor
+ *
+ * \return Value of one of the members of the \ref DSearch_Comp_Return_ErrorCodes_t enum
+ *
+ * Usage Example:
+ * \code
+ * uint8_t EndpointSearcher(void* CurrentDescriptor); // Comparator Prototype
+ *
+ * uint8_t EndpointSearcher(void* CurrentDescriptor)
+ * {
+ * if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_Endpoint)
+ * return DESCRIPTOR_SEARCH_Found;
+ * else
+ * return DESCRIPTOR_SEARCH_NotFound;
+ * }
+ *
+ * //...
+ * // After retrieving configuration descriptor:
+ * if (USB_Host_GetNextDescriptorComp(&BytesRemaining, &CurrentConfigLoc, EndpointSearcher) ==
+ * Descriptor_Search_Comp_Found)
+ * {
+ * // Do something with the endpoint descriptor
+ * }
+ * \endcode
+ */
+ uint8_t USB_GetNextDescriptorComp(uint16_t* BytesRem, void** CurrConfigLoc, ConfigComparatorPtr_t ComparatorRoutine);
+
+ /* Enums: */
+ /** Enum for the possible return codes of the \ref USB_Host_GetDeviceConfigDescriptor() function. */
+ enum USB_Host_GetConfigDescriptor_ErrorCodes_t
+ {
+ HOST_GETCONFIG_Successful = 0, /**< No error occurred while retrieving the configuration descriptor */
+ HOST_GETCONFIG_DeviceDisconnect = 1, /**< The attached device was disconnected while retrieving the configuration
+ * descriptor
+ */
+ HOST_GETCONFIG_PipeError = 2, /**< An error occurred in the pipe while sending the request */
+ HOST_GETCONFIG_SetupStalled = 3, /**< The attached device stalled the request to retrieve the configuration
+ * descriptor
+ */
+ HOST_GETCONFIG_SoftwareTimeOut = 4, /**< The request or data transfer timed out */
+ HOST_GETCONFIG_BuffOverflow = 5, /**< The device's configuration descriptor is too large to fit into the allocated
+ * buffer
+ */
+ HOST_GETCONFIG_InvalidData = 6, /**< The device returned invalid configuration descriptor data */
+ };
+
+ /** Enum for return values of a descriptor comparator function. */
+ enum DSearch_Return_ErrorCodes_t
+ {
+ DESCRIPTOR_SEARCH_Found = 0, /**< Current descriptor matches comparator criteria. */
+ DESCRIPTOR_SEARCH_Fail = 1, /**< No further descriptor could possibly match criteria, fail the search. */
+ DESCRIPTOR_SEARCH_NotFound = 2, /**< Current descriptor does not match comparator criteria. */
+ };
+
+ /** Enum for return values of \ref USB_GetNextDescriptorComp(). */
+ enum DSearch_Comp_Return_ErrorCodes_t
+ {
+ DESCRIPTOR_SEARCH_COMP_Found = 0, /**< Configuration descriptor now points to descriptor which matches
+ * search criteria of the given comparator function. */
+ DESCRIPTOR_SEARCH_COMP_Fail = 1, /**< Comparator function returned Descriptor_Search_Fail. */
+ DESCRIPTOR_SEARCH_COMP_EndOfDescriptor = 2, /**< End of configuration descriptor reached before match found. */
+ };
+
+ /* Function Prototypes: */
+ /** Retrieves the configuration descriptor data from an attached device via a standard request into a buffer,
+ * including validity and size checking to prevent a buffer overflow.
+ *
+ * \param[in] ConfigNumber Device configuration descriptor number to fetch from the device (usually set to 1 for
+ * single configuration devices)
+ * \param[in,out] ConfigSizePtr Pointer to a uint16_t for storing the retrieved configuration descriptor size
+ * \param[out] BufferPtr Pointer to the buffer for storing the configuration descriptor data.
+ * \param[out] BufferSize Size of the allocated buffer where the configuration descriptor is to be stored
+ *
+ * \return A value from the \ref USB_Host_GetConfigDescriptor_ErrorCodes_t enum
+ */
+ uint8_t USB_Host_GetDeviceConfigDescriptor(uint8_t ConfigNumber, uint16_t* const ConfigSizePtr, void* BufferPtr,
+ uint16_t BufferSize) ATTR_NON_NULL_PTR_ARG(2) ATTR_NON_NULL_PTR_ARG(3);
+
+ /** Skips to the next sub-descriptor inside the configuration descriptor of the specified type value.
+ * The bytes remaining value is automatically decremented.
+ *
+ * \param[in,out] BytesRem Pointer to the number of bytes remaining of the configuration descriptor
+ * \param[in,out] CurrConfigLoc Pointer to the current descriptor inside the configuration descriptor
+ * \param[in] Type Descriptor type value to search for
+ */
+ void USB_GetNextDescriptorOfType(uint16_t* const BytesRem,
+ void** const CurrConfigLoc,
+ const uint8_t Type)
+ ATTR_NON_NULL_PTR_ARG(1) ATTR_NON_NULL_PTR_ARG(2);
+
+ /** Skips to the next sub-descriptor inside the configuration descriptor of the specified type value,
+ * which must come before a descriptor of the second given type value. If the BeforeType type
+ * descriptor is reached first, the number of bytes remaining to process is set to zero and the
+ * function exits. The bytes remaining value is automatically decremented.
+ *
+ * \param[in,out] BytesRem Pointer to the number of bytes remaining of the configuration descriptor
+ * \param[in,out] CurrConfigLoc Pointer to the current descriptor inside the configuration descriptor
+ * \param[in] Type Descriptor type value to search for
+ * \param[in] BeforeType Descriptor type value which must not be reached before the given Type descriptor
+ */
+ void USB_GetNextDescriptorOfTypeBefore(uint16_t* const BytesRem,
+ void** const CurrConfigLoc,
+ const uint8_t Type,
+ const uint8_t BeforeType)
+ ATTR_NON_NULL_PTR_ARG(1) ATTR_NON_NULL_PTR_ARG(2);
+
+ /** Skips to the next sub-descriptor inside the configuration descriptor of the specified type value,
+ * which must come after a descriptor of the second given type value. The bytes remaining value is
+ * automatically decremented.
+ *
+ * \param[in,out] BytesRem Pointer to the number of bytes remaining of the configuration descriptor
+ * \param[in,out] CurrConfigLoc Pointer to the current descriptor inside the configuration descriptor
+ * \param[in] Type Descriptor type value to search for
+ * \param[in] AfterType Descriptor type value which must be reached before the given Type descriptor
+ */
+ void USB_GetNextDescriptorOfTypeAfter(uint16_t* const BytesRem,
+ void** const CurrConfigLoc,
+ const uint8_t Type,
+ const uint8_t AfterType)
+ ATTR_NON_NULL_PTR_ARG(1) ATTR_NON_NULL_PTR_ARG(2);
+
+ /* Inline Functions: */
+ /** Skips over the current sub-descriptor inside the configuration descriptor, so that the pointer then
+ points to the next sub-descriptor. The bytes remaining value is automatically decremented.
+ *
+ * \param[in,out] BytesRem Pointer to the number of bytes remaining of the configuration descriptor
+ * \param[in,out] CurrConfigLoc Pointer to the current descriptor inside the configuration descriptor
+ */
+ static inline void USB_GetNextDescriptor(uint16_t* const BytesRem,
+ void** const CurrConfigLoc)
+ ATTR_NON_NULL_PTR_ARG(1) ATTR_NON_NULL_PTR_ARG(2);
+ static inline void USB_GetNextDescriptor(uint16_t* const BytesRem,
+ void** const CurrConfigLoc)
+ {
+ uint16_t CurrDescriptorSize = DESCRIPTOR_CAST(*CurrConfigLoc, USB_Descriptor_Header_t).Size;
+
+ *CurrConfigLoc += CurrDescriptorSize;
+ *BytesRem -= CurrDescriptorSize;
+ }
+
+ /* Disable C linkage for C++ Compilers: */
+ #if defined(__cplusplus)
+ }
+ #endif
+
+#endif
+
+/** @} */
diff --git a/LUFA/Drivers/USB/HighLevel/Events.c b/LUFA/Drivers/USB/HighLevel/Events.c
index 4d9990788..ee2030e1a 100644
--- a/LUFA/Drivers/USB/HighLevel/Events.c
+++ b/LUFA/Drivers/USB/HighLevel/Events.c
@@ -1,38 +1,38 @@
-/*
- LUFA Library
- Copyright (C) Dean Camera, 2010.
-
- dean [at] fourwalledcubicle [dot] com
- www.fourwalledcubicle.com
-*/
-
-/*
- Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
-
- Permission to use, copy, modify, distribute, and sell this
- software and its documentation for any purpose is hereby granted
- without fee, provided that the above copyright notice appear in
- all copies and that both that the copyright notice and this
- permission notice and warranty disclaimer appear in supporting
- documentation, and that the name of the author not be used in
- advertising or publicity pertaining to distribution of the
- software without specific, written prior permission.
-
- The author disclaim all warranties with regard to this
- software, including all implied warranties of merchantability
- and fitness. In no event shall the author be liable for any
- special, indirect or consequential damages or any damages
- whatsoever resulting from loss of use, data or profits, whether
- in an action of contract, negligence or other tortious action,
- arising out of or in connection with the use or performance of
- this software.
-*/
-
-#define __INCLUDE_FROM_EVENTS_C
-#define __INCLUDE_FROM_USB_DRIVER
-#include "Events.h"
-
-void USB_Event_Stub(void)
-{
-
-}
+/*
+ LUFA Library
+ Copyright (C) Dean Camera, 2010.
+
+ dean [at] fourwalledcubicle [dot] com
+ www.fourwalledcubicle.com
+*/
+
+/*
+ Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
+
+ Permission to use, copy, modify, distribute, and sell this
+ software and its documentation for any purpose is hereby granted
+ without fee, provided that the above copyright notice appear in
+ all copies and that both that the copyright notice and this
+ permission notice and warranty disclaimer appear in supporting
+ documentation, and that the name of the author not be used in
+ advertising or publicity pertaining to distribution of the
+ software without specific, written prior permission.
+
+ The author disclaim all warranties with regard to this
+ software, including all implied warranties of merchantability
+ and fitness. In no event shall the author be liable for any
+ special, indirect or consequential damages or any damages
+ whatsoever resulting from loss of use, data or profits, whether
+ in an action of contract, negligence or other tortious action,
+ arising out of or in connection with the use or performance of
+ this software.
+*/
+
+#define __INCLUDE_FROM_EVENTS_C
+#define __INCLUDE_FROM_USB_DRIVER
+#include "Events.h"
+
+void USB_Event_Stub(void)
+{
+
+}
diff --git a/LUFA/Drivers/USB/HighLevel/Events.h b/LUFA/Drivers/USB/HighLevel/Events.h
index 8daa8ea2b..edc7a8b36 100644
--- a/LUFA/Drivers/USB/HighLevel/Events.h
+++ b/LUFA/Drivers/USB/HighLevel/Events.h
@@ -1,362 +1,362 @@
-/*
- LUFA Library
- Copyright (C) Dean Camera, 2010.
-
- dean [at] fourwalledcubicle [dot] com
- www.fourwalledcubicle.com
-*/
-
-/*
- Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
-
- Permission to use, copy, modify, distribute, and sell this
- software and its documentation for any purpose is hereby granted
- without fee, provided that the above copyright notice appear in
- all copies and that both that the copyright notice and this
- permission notice and warranty disclaimer appear in supporting
- documentation, and that the name of the author not be used in
- advertising or publicity pertaining to distribution of the
- software without specific, written prior permission.
-
- The author disclaim all warranties with regard to this
- software, including all implied warranties of merchantability
- and fitness. In no event shall the author be liable for any
- special, indirect or consequential damages or any damages
- whatsoever resulting from loss of use, data or profits, whether
- in an action of contract, negligence or other tortious action,
- arising out of or in connection with the use or performance of
- this software.
-*/
-
-/** \file
- * \brief USB controller events manager.
- *
- * This file contains macros and functions relating to the management of library events, which are small
- * pieces of code similar to ISRs which are run when a given condition is met. Each event can be fired from
- * multiple places in the user or library code, which may or may not be inside an ISR, thus each handler
- * should be written to be as small and fast as possible to prevent possible problems.
- *
- * Events can be hooked by the user application by declaring a handler function with the same name and parameters
- * listed here. If an event with no user-associated handler is fired within the library, it by default maps to an
- * internal empty stub function.
- *
- * Each event must only have one associated event handler, but can be raised by multiple sources by calling the
- * event handler function (with any required event parameters).
- *
- * \note This file should not be included directly. It is automatically included as needed by the USB driver
- * dispatch header located in LUFA/Drivers/USB/USB.h.
- */
-
-/** \ingroup Group_USB
- * @defgroup Group_Events USB Events
- *
- * This module contains macros and functions relating to the management of library events, which are small
- * pieces of code similar to ISRs which are run when a given condition is met. Each event can be fired from
- * multiple places in the user or library code, which may or may not be inside an ISR, thus each handler
- * should be written to be as small and fast as possible to prevent possible problems.
- *
- * Events can be hooked by the user application by declaring a handler function with the same name and parameters
- * listed here. If an event with no user-associated handler is fired within the library, it by default maps to an
- * internal empty stub function.
- *
- * Each event must only have one associated event handler, but can be raised by multiple sources by calling the
- * event handler function (with any required event parameters).
- *
- * @{
- */
-
-#ifndef __USBEVENTS_H__
-#define __USBEVENTS_H__
-
- /* Includes: */
- #include <avr/io.h>
-
- #include "../../../Common/Common.h"
- #include "USBMode.h"
-
- /* Enable C linkage for C++ Compilers: */
- #if defined(__cplusplus)
- extern "C" {
- #endif
-
- /* Preprocessor Checks: */
- #if !defined(__INCLUDE_FROM_USB_DRIVER)
- #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.
- #endif
-
- /* Public Interface - May be used in end-application: */
- /* Pseudo-Functions for Doxygen: */
- #if !defined(__INCLUDE_FROM_EVENTS_C) || defined(__DOXYGEN__)
- /** Event for USB stack initialization failure. This event fires when the USB interface fails to
- * initialize correctly due to a hardware or software fault.
- *
- * \note This event only exists on USB AVR models which support dual role modes.
- *
- * \param[in] ErrorCode Error code indicating the failure reason, a value in \ref USB_InitErrorCodes_t
- */
- void EVENT_USB_InitFailure(const uint8_t ErrorCode);
-
- /** Event for USB mode pin level change. This event fires when the USB interface is set to dual role
- * mode, and the UID pin level has changed to indicate a new mode (device or host). This event fires
- * before the mode is switched to the newly indicated mode but after the \ref EVENT_USB_Device_Disconnect
- * event has fired (if connected before the role change).
- *
- * \note This event only exists on USB AVR models which support dual role modes.
- * \n\n
- *
- * \note This event does not exist if the USB_DEVICE_ONLY or USB_HOST_ONLY tokens have been supplied
- * to the compiler (see \ref Group_USBManagement documentation).
- */
- void EVENT_USB_UIDChange(void);
-
- /** Event for USB host error. This event fires when a hardware fault has occurred whilst the USB
- * interface is in host mode.
- *
- * \param[in] ErrorCode Error code indicating the failure reason, a value in \ref USB_Host_ErrorCodes_t
- *
- * \note This event only exists on USB AVR models which supports host mode.
- * \n\n
- *
- * \note This event does not exist if the USB_DEVICE_ONLY token is supplied to the compiler (see
- * \ref Group_USBManagement documentation).
- */
- void EVENT_USB_Host_HostError(const uint8_t ErrorCode);
-
- /** Event for USB device attachment. This event fires when a the USB interface is in host mode, and
- * a USB device has been connected to the USB interface. This is interrupt driven, thus fires before
- * the standard \ref EVENT_USB_Device_Connect() event and so can be used to programmatically start the USB
- * management task to reduce CPU consumption.
- *
- * \note This event only exists on USB AVR models which supports host mode.
- * \n\n
- *
- * \note This event does not exist if the USB_DEVICE_ONLY token is supplied to the compiler (see
- * \ref Group_USBManagement documentation).
- *
- * \see \ref USB_USBTask() for more information on the USB management task and reducing CPU usage.
- */
- void EVENT_USB_Host_DeviceAttached(void);
-
- /** Event for USB device removal. This event fires when a the USB interface is in host mode, and
- * a USB device has been removed the USB interface whether or not it has been enumerated. This
- * can be used to programmatically stop the USB management task to reduce CPU consumption.
- *
- * \note This event only exists on USB AVR models which supports host mode.
- * \n\n
- *
- * \note This event does not exist if the USB_DEVICE_ONLY token is supplied to the compiler (see
- * \ref Group_USBManagement documentation).
- *
- * \see \ref USB_USBTask() for more information on the USB management task and reducing CPU usage.
- */
- void EVENT_USB_Host_DeviceUnattached(void);
-
- /** Event for USB device enumeration failure. This event fires when a the USB interface is
- * in host mode, and an attached USB device has failed to enumerate completely.
- *
- * \param[in] ErrorCode Error code indicating the failure reason, a value in
- * \ref USB_Host_EnumerationErrorCodes_t
- *
- * \param[in] SubErrorCode Sub error code indicating the reason for failure - for example, if the
- * ErrorCode parameter indicates a control error, this will give the error
- * code returned by the \ref USB_Host_SendControlRequest() function.
- *
- * \note This event only exists on USB AVR models which supports host mode.
- * \n\n
- *
- * \note This event does not exist if the USB_DEVICE_ONLY token is supplied to the compiler (see
- * \ref Group_USBManagement documentation).
- */
- void EVENT_USB_Host_DeviceEnumerationFailed(const uint8_t ErrorCode, const uint8_t SubErrorCode);
-
- /** Event for USB device enumeration completion. This event fires when a the USB interface is
- * in host mode and an attached USB device has been completely enumerated and is ready to be
- * controlled by the user application.
- *
- * This event is time-critical; exceeding OS-specific delays within this event handler (typically of around
- * 1 second) when a transaction is waiting to be processed by the device will prevent break communications
- * and cause the host to reset the USB bus.
- */
- void EVENT_USB_Host_DeviceEnumerationComplete(void);
-
- /** Event for USB device connection. This event fires when the AVR in device mode and the device is connected
- * to a host, beginning the enumeration process, measured by a rising level on the AVR's VBUS pin.
- *
- * This event is time-critical; exceeding OS-specific delays within this event handler (typically of around
- * two seconds) will prevent the device from enumerating correctly.
- *
- * \note For the smaller series 2 USB AVRs with limited USB controllers, VBUS is not available to the USB controller.
- * this means that the current connection state is derived from the bus suspension and wake up events by default,
- * which is not always accurate (host may suspend the bus while still connected). If the actual connection state
- * needs to be determined, VBUS should be routed to an external pin, and the auto-detect behaviour turned off by
- * passing the NO_LIMITED_CONTROLLER_CONNECT token to the compiler via the -D switch at compile time. The connection
- * and disconnection events may be manually fired, and the \ref USB_DeviceState global changed manually.
- * \n\n
- *
- * \note This event may fire multiple times during device enumeration on the series 2 USB AVRs with limited USB controllers
- * if NO_LIMITED_CONTROLLER_CONNECT is not defined.
- *
- * \see USBTask.h for more information on the USB management task and reducing CPU usage.
- */
- void EVENT_USB_Device_Connect(void);
-
- /** Event for USB device disconnection. This event fires when the AVR in device mode and the device is disconnected
- * from a host, measured by a falling level on the AVR's VBUS pin.
- *
- * \note For the smaller series 2 USB AVRs with limited USB controllers, VBUS is not available to the USB controller.
- * this means that the current connection state is derived from the bus suspension and wake up events by default,
- * which is not always accurate (host may suspend the bus while still connected). If the actual connection state
- * needs to be determined, VBUS should be routed to an external pin, and the auto-detect behaviour turned off by
- * passing the NO_LIMITED_CONTROLLER_CONNECT token to the compiler via the -D switch at compile time. The connection
- * and disconnection events may be manually fired, and the \ref USB_DeviceState global changed manually.
- * \n\n
- *
- * \note This event may fire multiple times during device enumeration on the series 2 USB AVRs with limited USB controllers
- * if NO_LIMITED_CONTROLLER_CONNECT is not defined.
- *
- * \see USBTask.h for more information on the USB management task and reducing CPU usage.
- */
- void EVENT_USB_Device_Disconnect(void);
-
- /** Event for unhandled control requests. This event fires when a the USB host issues a control
- * request to the control endpoint (address 0) that the library does not handle. This may either
- * be a standard request that the library has no handler code for, or a class specific request
- * issued to the device which must be handled appropriately.
- *
- * This event is time-critical; each packet within the request transaction must be acknowledged or
- * sent within 50ms or the host will abort the transfer.
- *
- * The library interally handles all standard control requests with the exceptions of SYNC FRAME,
- * SET DESCRIPTOR and SET INTERFACE. These and all other non-standard control requests will be left
- * for the user to process via this event if desired. If not handled in the user application, requests
- * are automatically STALLed.
- *
- * \note This event does not exist if the USB_HOST_ONLY token is supplied to the compiler (see
- * \ref Group_USBManagement documentation).
- * \n\n
- *
- * \note Requests should be handled in the same manner as described in the USB 2.0 Specification,
- * or appropriate class specification. In all instances, the library has already read the
- * request SETUP parameters into the \ref USB_ControlRequest structure which should then be used
- * by the application to determine how to handle the issued request.
- */
- void EVENT_USB_Device_UnhandledControlRequest(void);
-
- /** Event for USB configuration number changed. This event fires when a the USB host changes the
- * selected configuration number while in device mode. This event should be hooked in device
- * applications to create the endpoints and configure the device for the selected configuration.
- *
- * This event is time-critical; exceeding OS-specific delays within this event handler (typically of around
- * one second) will prevent the device from enumerating correctly.
- *
- * This event fires after the value of \ref USB_ConfigurationNumber has been changed.
- *
- * \note This event does not exist if the USB_HOST_ONLY token is supplied to the compiler (see
- * \ref Group_USBManagement documentation).
- */
- void EVENT_USB_Device_ConfigurationChanged(void);
-
- /** Event for USB suspend. This event fires when a the USB host suspends the device by halting its
- * transmission of Start Of Frame pulses to the device. This is generally hooked in order to move
- * the device over to a low power state until the host wakes up the device. If the USB interface is
- * enumerated with the \ref USB_OPT_AUTO_PLL option set, the library will automatically suspend the
- * USB PLL before the event is fired to save power.
- *
- * \note This event does not exist if the USB_HOST_ONLY token is supplied to the compiler (see
- * \ref Group_USBManagement documentation).
- * \n\n
- *
- * \note This event does not exist on the series 2 USB AVRs when the NO_LIMITED_CONTROLLER_CONNECT
- * compile time token is not set - see \ref EVENT_USB_Device_Disconnect.
- *
- * \see \ref EVENT_USB_Device_WakeUp() event for accompanying Wake Up event.
- */
- void EVENT_USB_Device_Suspend(void);
-
- /** Event for USB wake up. This event fires when a the USB interface is suspended while in device
- * mode, and the host wakes up the device by supplying Start Of Frame pulses. This is generally
- * hooked to pull the user application out of a low power state and back into normal operating
- * mode. If the USB interface is enumerated with the \ref USB_OPT_AUTO_PLL option set, the library
- * will automatically restart the USB PLL before the event is fired.
- *
- * \note This event does not exist if the USB_HOST_ONLY token is supplied to the compiler (see
- * \ref Group_USBManagement documentation).
- * \n\n
- *
- * \note This event does not exist on the series 2 USB AVRs when the NO_LIMITED_CONTROLLER_CONNECT
- * compile time token is not set - see \ref EVENT_USB_Device_Connect.
- *
- * \see \ref EVENT_USB_Device_Suspend() event for accompanying Suspend event.
- */
- void EVENT_USB_Device_WakeUp(void);
-
- /** Event for USB interface reset. This event fires when the USB interface is in device mode, and
- * a the USB host requests that the device reset its interface. This event fires after the control
- * endpoint has been automatically configured by the library.
- *
- * This event is time-critical; exceeding OS-specific delays within this event handler (typically of around
- * two seconds) will prevent the device from enumerating correctly.
- *
- * \note This event does not exist if the USB_HOST_ONLY token is supplied to the compiler (see
- * \ref Group_USBManagement documentation).
- */
- void EVENT_USB_Device_Reset(void);
-
- /** Event for USB Start Of Frame detection, when enabled. This event fires at the start of each USB
- * frame, once per millisecond, and is synchronized to the USB bus. This can be used as an accurate
- * millisecond timer source when the USB bus is enumerated in device mode to a USB host.
- *
- * This event is time-critical; it is run once per millisecond and thus long handlers will significantly
- * degrade device performance. This event should only be enabled when needed to reduce device wakeups.
- *
- * \note This event is not normally active - it must be manually enabled and disabled via the
- * \ref USB_Device_EnableSOFEvents() and \ref USB_Device_DisableSOFEvents() commands after enumeration.
- * \n\n
- *
- * \note This event does not exist if the USB_HOST_ONLY token is supplied to the compiler (see
- * \ref Group_USBManagement documentation).
- */
- void EVENT_USB_Device_StartOfFrame(void);
- #endif
-
- /* Private Interface - For use in library only: */
- #if !defined(__DOXYGEN__)
- /* Function Prototypes: */
- #if defined(__INCLUDE_FROM_EVENTS_C)
- void USB_Event_Stub(void) ATTR_CONST;
-
- #if defined(USB_CAN_BE_BOTH)
- void EVENT_USB_InitFailure(const uint8_t ErrorCode) ATTR_WEAK ATTR_ALIAS(USB_Event_Stub);
- void EVENT_USB_UIDChange(void) ATTR_WEAK ATTR_ALIAS(USB_Event_Stub);
- #endif
-
- #if defined(USB_CAN_BE_HOST)
- void EVENT_USB_Host_HostError(const uint8_t ErrorCode) ATTR_WEAK ATTR_ALIAS(USB_Event_Stub);
- void EVENT_USB_Host_DeviceAttached(void) ATTR_WEAK ATTR_ALIAS(USB_Event_Stub);
- void EVENT_USB_Host_DeviceUnattached(void) ATTR_WEAK ATTR_ALIAS(USB_Event_Stub);
- void EVENT_USB_Host_DeviceEnumerationComplete(void) ATTR_WEAK ATTR_ALIAS(USB_Event_Stub);
- void EVENT_USB_Host_DeviceEnumerationFailed(const uint8_t ErrorCode, const uint8_t SubErrorCode)
- ATTR_WEAK ATTR_ALIAS(USB_Event_Stub);
- #endif
-
- #if defined(USB_CAN_BE_DEVICE)
- void EVENT_USB_Device_Connect(void) ATTR_WEAK ATTR_ALIAS(USB_Event_Stub);
- void EVENT_USB_Device_Disconnect(void) ATTR_WEAK ATTR_ALIAS(USB_Event_Stub);
- void EVENT_USB_Device_UnhandledControlRequest(void) ATTR_WEAK ATTR_ALIAS(USB_Event_Stub);
- void EVENT_USB_Device_ConfigurationChanged(void) ATTR_WEAK ATTR_ALIAS(USB_Event_Stub);
- void EVENT_USB_Device_Suspend(void) ATTR_WEAK ATTR_ALIAS(USB_Event_Stub);
- void EVENT_USB_Device_WakeUp(void) ATTR_WEAK ATTR_ALIAS(USB_Event_Stub);
- void EVENT_USB_Device_Reset(void) ATTR_WEAK ATTR_ALIAS(USB_Event_Stub);
- void EVENT_USB_Device_StartOfFrame(void) ATTR_WEAK ATTR_ALIAS(USB_Event_Stub);
- #endif
- #endif
- #endif
-
- /* Disable C linkage for C++ Compilers: */
- #if defined(__cplusplus)
- }
- #endif
-
-#endif
-
-/** @} */
+/*
+ LUFA Library
+ Copyright (C) Dean Camera, 2010.
+
+ dean [at] fourwalledcubicle [dot] com
+ www.fourwalledcubicle.com
+*/
+
+/*
+ Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
+
+ Permission to use, copy, modify, distribute, and sell this
+ software and its documentation for any purpose is hereby granted
+ without fee, provided that the above copyright notice appear in
+ all copies and that both that the copyright notice and this
+ permission notice and warranty disclaimer appear in supporting
+ documentation, and that the name of the author not be used in
+ advertising or publicity pertaining to distribution of the
+ software without specific, written prior permission.
+
+ The author disclaim all warranties with regard to this
+ software, including all implied warranties of merchantability
+ and fitness. In no event shall the author be liable for any
+ special, indirect or consequential damages or any damages
+ whatsoever resulting from loss of use, data or profits, whether
+ in an action of contract, negligence or other tortious action,
+ arising out of or in connection with the use or performance of
+ this software.
+*/
+
+/** \file
+ * \brief USB controller events manager.
+ *
+ * This file contains macros and functions relating to the management of library events, which are small
+ * pieces of code similar to ISRs which are run when a given condition is met. Each event can be fired from
+ * multiple places in the user or library code, which may or may not be inside an ISR, thus each handler
+ * should be written to be as small and fast as possible to prevent possible problems.
+ *
+ * Events can be hooked by the user application by declaring a handler function with the same name and parameters
+ * listed here. If an event with no user-associated handler is fired within the library, it by default maps to an
+ * internal empty stub function.
+ *
+ * Each event must only have one associated event handler, but can be raised by multiple sources by calling the
+ * event handler function (with any required event parameters).
+ *
+ * \note This file should not be included directly. It is automatically included as needed by the USB driver
+ * dispatch header located in LUFA/Drivers/USB/USB.h.
+ */
+
+/** \ingroup Group_USB
+ * @defgroup Group_Events USB Events
+ *
+ * This module contains macros and functions relating to the management of library events, which are small
+ * pieces of code similar to ISRs which are run when a given condition is met. Each event can be fired from
+ * multiple places in the user or library code, which may or may not be inside an ISR, thus each handler
+ * should be written to be as small and fast as possible to prevent possible problems.
+ *
+ * Events can be hooked by the user application by declaring a handler function with the same name and parameters
+ * listed here. If an event with no user-associated handler is fired within the library, it by default maps to an
+ * internal empty stub function.
+ *
+ * Each event must only have one associated event handler, but can be raised by multiple sources by calling the
+ * event handler function (with any required event parameters).
+ *
+ * @{
+ */
+
+#ifndef __USBEVENTS_H__
+#define __USBEVENTS_H__
+
+ /* Includes: */
+ #include <avr/io.h>
+
+ #include "../../../Common/Common.h"
+ #include "USBMode.h"
+
+ /* Enable C linkage for C++ Compilers: */
+ #if defined(__cplusplus)
+ extern "C" {
+ #endif
+
+ /* Preprocessor Checks: */
+ #if !defined(__INCLUDE_FROM_USB_DRIVER)
+ #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.
+ #endif
+
+ /* Public Interface - May be used in end-application: */
+ /* Pseudo-Functions for Doxygen: */
+ #if !defined(__INCLUDE_FROM_EVENTS_C) || defined(__DOXYGEN__)
+ /** Event for USB stack initialization failure. This event fires when the USB interface fails to
+ * initialize correctly due to a hardware or software fault.
+ *
+ * \note This event only exists on USB AVR models which support dual role modes.
+ *
+ * \param[in] ErrorCode Error code indicating the failure reason, a value in \ref USB_InitErrorCodes_t
+ */
+ void EVENT_USB_InitFailure(const uint8_t ErrorCode);
+
+ /** Event for USB mode pin level change. This event fires when the USB interface is set to dual role
+ * mode, and the UID pin level has changed to indicate a new mode (device or host). This event fires
+ * before the mode is switched to the newly indicated mode but after the \ref EVENT_USB_Device_Disconnect
+ * event has fired (if connected before the role change).
+ *
+ * \note This event only exists on USB AVR models which support dual role modes.
+ * \n\n
+ *
+ * \note This event does not exist if the USB_DEVICE_ONLY or USB_HOST_ONLY tokens have been supplied
+ * to the compiler (see \ref Group_USBManagement documentation).
+ */
+ void EVENT_USB_UIDChange(void);
+
+ /** Event for USB host error. This event fires when a hardware fault has occurred whilst the USB
+ * interface is in host mode.
+ *
+ * \param[in] ErrorCode Error code indicating the failure reason, a value in \ref USB_Host_ErrorCodes_t
+ *
+ * \note This event only exists on USB AVR models which supports host mode.
+ * \n\n
+ *
+ * \note This event does not exist if the USB_DEVICE_ONLY token is supplied to the compiler (see
+ * \ref Group_USBManagement documentation).
+ */
+ void EVENT_USB_Host_HostError(const uint8_t ErrorCode);
+
+ /** Event for USB device attachment. This event fires when a the USB interface is in host mode, and
+ * a USB device has been connected to the USB interface. This is interrupt driven, thus fires before
+ * the standard \ref EVENT_USB_Device_Connect() event and so can be used to programmatically start the USB
+ * management task to reduce CPU consumption.
+ *
+ * \note This event only exists on USB AVR models which supports host mode.
+ * \n\n
+ *
+ * \note This event does not exist if the USB_DEVICE_ONLY token is supplied to the compiler (see
+ * \ref Group_USBManagement documentation).
+ *
+ * \see \ref USB_USBTask() for more information on the USB management task and reducing CPU usage.
+ */
+ void EVENT_USB_Host_DeviceAttached(void);
+
+ /** Event for USB device removal. This event fires when a the USB interface is in host mode, and
+ * a USB device has been removed the USB interface whether or not it has been enumerated. This
+ * can be used to programmatically stop the USB management task to reduce CPU consumption.
+ *
+ * \note This event only exists on USB AVR models which supports host mode.
+ * \n\n
+ *
+ * \note This event does not exist if the USB_DEVICE_ONLY token is supplied to the compiler (see
+ * \ref Group_USBManagement documentation).
+ *
+ * \see \ref USB_USBTask() for more information on the USB management task and reducing CPU usage.
+ */
+ void EVENT_USB_Host_DeviceUnattached(void);
+
+ /** Event for USB device enumeration failure. This event fires when a the USB interface is
+ * in host mode, and an attached USB device has failed to enumerate completely.
+ *
+ * \param[in] ErrorCode Error code indicating the failure reason, a value in
+ * \ref USB_Host_EnumerationErrorCodes_t
+ *
+ * \param[in] SubErrorCode Sub error code indicating the reason for failure - for example, if the
+ * ErrorCode parameter indicates a control error, this will give the error
+ * code returned by the \ref USB_Host_SendControlRequest() function.
+ *
+ * \note This event only exists on USB AVR models which supports host mode.
+ * \n\n
+ *
+ * \note This event does not exist if the USB_DEVICE_ONLY token is supplied to the compiler (see
+ * \ref Group_USBManagement documentation).
+ */
+ void EVENT_USB_Host_DeviceEnumerationFailed(const uint8_t ErrorCode, const uint8_t SubErrorCode);
+
+ /** Event for USB device enumeration completion. This event fires when a the USB interface is
+ * in host mode and an attached USB device has been completely enumerated and is ready to be
+ * controlled by the user application.
+ *
+ * This event is time-critical; exceeding OS-specific delays within this event handler (typically of around
+ * 1 second) when a transaction is waiting to be processed by the device will prevent break communications
+ * and cause the host to reset the USB bus.
+ */
+ void EVENT_USB_Host_DeviceEnumerationComplete(void);
+
+ /** Event for USB device connection. This event fires when the AVR in device mode and the device is connected
+ * to a host, beginning the enumeration process, measured by a rising level on the AVR's VBUS pin.
+ *
+ * This event is time-critical; exceeding OS-specific delays within this event handler (typically of around
+ * two seconds) will prevent the device from enumerating correctly.
+ *
+ * \note For the smaller series 2 USB AVRs with limited USB controllers, VBUS is not available to the USB controller.
+ * this means that the current connection state is derived from the bus suspension and wake up events by default,
+ * which is not always accurate (host may suspend the bus while still connected). If the actual connection state
+ * needs to be determined, VBUS should be routed to an external pin, and the auto-detect behaviour turned off by
+ * passing the NO_LIMITED_CONTROLLER_CONNECT token to the compiler via the -D switch at compile time. The connection
+ * and disconnection events may be manually fired, and the \ref USB_DeviceState global changed manually.
+ * \n\n
+ *
+ * \note This event may fire multiple times during device enumeration on the series 2 USB AVRs with limited USB controllers
+ * if NO_LIMITED_CONTROLLER_CONNECT is not defined.
+ *
+ * \see USBTask.h for more information on the USB management task and reducing CPU usage.
+ */
+ void EVENT_USB_Device_Connect(void);
+
+ /** Event for USB device disconnection. This event fires when the AVR in device mode and the device is disconnected
+ * from a host, measured by a falling level on the AVR's VBUS pin.
+ *
+ * \note For the smaller series 2 USB AVRs with limited USB controllers, VBUS is not available to the USB controller.
+ * this means that the current connection state is derived from the bus suspension and wake up events by default,
+ * which is not always accurate (host may suspend the bus while still connected). If the actual connection state
+ * needs to be determined, VBUS should be routed to an external pin, and the auto-detect behaviour turned off by
+ * passing the NO_LIMITED_CONTROLLER_CONNECT token to the compiler via the -D switch at compile time. The connection
+ * and disconnection events may be manually fired, and the \ref USB_DeviceState global changed manually.
+ * \n\n
+ *
+ * \note This event may fire multiple times during device enumeration on the series 2 USB AVRs with limited USB controllers
+ * if NO_LIMITED_CONTROLLER_CONNECT is not defined.
+ *
+ * \see USBTask.h for more information on the USB management task and reducing CPU usage.
+ */
+ void EVENT_USB_Device_Disconnect(void);
+
+ /** Event for unhandled control requests. This event fires when a the USB host issues a control
+ * request to the control endpoint (address 0) that the library does not handle. This may either
+ * be a standard request that the library has no handler code for, or a class specific request
+ * issued to the device which must be handled appropriately.
+ *
+ * This event is time-critical; each packet within the request transaction must be acknowledged or
+ * sent within 50ms or the host will abort the transfer.
+ *
+ * The library interally handles all standard control requests with the exceptions of SYNC FRAME,
+ * SET DESCRIPTOR and SET INTERFACE. These and all other non-standard control requests will be left
+ * for the user to process via this event if desired. If not handled in the user application, requests
+ * are automatically STALLed.
+ *
+ * \note This event does not exist if the USB_HOST_ONLY token is supplied to the compiler (see
+ * \ref Group_USBManagement documentation).
+ * \n\n
+ *
+ * \note Requests should be handled in the same manner as described in the USB 2.0 Specification,
+ * or appropriate class specification. In all instances, the library has already read the
+ * request SETUP parameters into the \ref USB_ControlRequest structure which should then be used
+ * by the application to determine how to handle the issued request.
+ */
+ void EVENT_USB_Device_UnhandledControlRequest(void);
+
+ /** Event for USB configuration number changed. This event fires when a the USB host changes the
+ * selected configuration number while in device mode. This event should be hooked in device
+ * applications to create the endpoints and configure the device for the selected configuration.
+ *
+ * This event is time-critical; exceeding OS-specific delays within this event handler (typically of around
+ * one second) will prevent the device from enumerating correctly.
+ *
+ * This event fires after the value of \ref USB_ConfigurationNumber has been changed.
+ *
+ * \note This event does not exist if the USB_HOST_ONLY token is supplied to the compiler (see
+ * \ref Group_USBManagement documentation).
+ */
+ void EVENT_USB_Device_ConfigurationChanged(void);
+
+ /** Event for USB suspend. This event fires when a the USB host suspends the device by halting its
+ * transmission of Start Of Frame pulses to the device. This is generally hooked in order to move
+ * the device over to a low power state until the host wakes up the device. If the USB interface is
+ * enumerated with the \ref USB_OPT_AUTO_PLL option set, the library will automatically suspend the
+ * USB PLL before the event is fired to save power.
+ *
+ * \note This event does not exist if the USB_HOST_ONLY token is supplied to the compiler (see
+ * \ref Group_USBManagement documentation).
+ * \n\n
+ *
+ * \note This event does not exist on the series 2 USB AVRs when the NO_LIMITED_CONTROLLER_CONNECT
+ * compile time token is not set - see \ref EVENT_USB_Device_Disconnect.
+ *
+ * \see \ref EVENT_USB_Device_WakeUp() event for accompanying Wake Up event.
+ */
+ void EVENT_USB_Device_Suspend(void);
+
+ /** Event for USB wake up. This event fires when a the USB interface is suspended while in device
+ * mode, and the host wakes up the device by supplying Start Of Frame pulses. This is generally
+ * hooked to pull the user application out of a low power state and back into normal operating
+ * mode. If the USB interface is enumerated with the \ref USB_OPT_AUTO_PLL option set, the library
+ * will automatically restart the USB PLL before the event is fired.
+ *
+ * \note This event does not exist if the USB_HOST_ONLY token is supplied to the compiler (see
+ * \ref Group_USBManagement documentation).
+ * \n\n
+ *
+ * \note This event does not exist on the series 2 USB AVRs when the NO_LIMITED_CONTROLLER_CONNECT
+ * compile time token is not set - see \ref EVENT_USB_Device_Connect.
+ *
+ * \see \ref EVENT_USB_Device_Suspend() event for accompanying Suspend event.
+ */
+ void EVENT_USB_Device_WakeUp(void);
+
+ /** Event for USB interface reset. This event fires when the USB interface is in device mode, and
+ * a the USB host requests that the device reset its interface. This event fires after the control
+ * endpoint has been automatically configured by the library.
+ *
+ * This event is time-critical; exceeding OS-specific delays within this event handler (typically of around
+ * two seconds) will prevent the device from enumerating correctly.
+ *
+ * \note This event does not exist if the USB_HOST_ONLY token is supplied to the compiler (see
+ * \ref Group_USBManagement documentation).
+ */
+ void EVENT_USB_Device_Reset(void);
+
+ /** Event for USB Start Of Frame detection, when enabled. This event fires at the start of each USB
+ * frame, once per millisecond, and is synchronized to the USB bus. This can be used as an accurate
+ * millisecond timer source when the USB bus is enumerated in device mode to a USB host.
+ *
+ * This event is time-critical; it is run once per millisecond and thus long handlers will significantly
+ * degrade device performance. This event should only be enabled when needed to reduce device wakeups.
+ *
+ * \note This event is not normally active - it must be manually enabled and disabled via the
+ * \ref USB_Device_EnableSOFEvents() and \ref USB_Device_DisableSOFEvents() commands after enumeration.
+ * \n\n
+ *
+ * \note This event does not exist if the USB_HOST_ONLY token is supplied to the compiler (see
+ * \ref Group_USBManagement documentation).
+ */
+ void EVENT_USB_Device_StartOfFrame(void);
+ #endif
+
+ /* Private Interface - For use in library only: */
+ #if !defined(__DOXYGEN__)
+ /* Function Prototypes: */
+ #if defined(__INCLUDE_FROM_EVENTS_C)
+ void USB_Event_Stub(void) ATTR_CONST;
+
+ #if defined(USB_CAN_BE_BOTH)
+ void EVENT_USB_InitFailure(const uint8_t ErrorCode) ATTR_WEAK ATTR_ALIAS(USB_Event_Stub);
+ void EVENT_USB_UIDChange(void) ATTR_WEAK ATTR_ALIAS(USB_Event_Stub);
+ #endif
+
+ #if defined(USB_CAN_BE_HOST)
+ void EVENT_USB_Host_HostError(const uint8_t ErrorCode) ATTR_WEAK ATTR_ALIAS(USB_Event_Stub);
+ void EVENT_USB_Host_DeviceAttached(void) ATTR_WEAK ATTR_ALIAS(USB_Event_Stub);
+ void EVENT_USB_Host_DeviceUnattached(void) ATTR_WEAK ATTR_ALIAS(USB_Event_Stub);
+ void EVENT_USB_Host_DeviceEnumerationComplete(void) ATTR_WEAK ATTR_ALIAS(USB_Event_Stub);
+ void EVENT_USB_Host_DeviceEnumerationFailed(const uint8_t ErrorCode, const uint8_t SubErrorCode)
+ ATTR_WEAK ATTR_ALIAS(USB_Event_Stub);
+ #endif
+
+ #if defined(USB_CAN_BE_DEVICE)
+ void EVENT_USB_Device_Connect(void) ATTR_WEAK ATTR_ALIAS(USB_Event_Stub);
+ void EVENT_USB_Device_Disconnect(void) ATTR_WEAK ATTR_ALIAS(USB_Event_Stub);
+ void EVENT_USB_Device_UnhandledControlRequest(void) ATTR_WEAK ATTR_ALIAS(USB_Event_Stub);
+ void EVENT_USB_Device_ConfigurationChanged(void) ATTR_WEAK ATTR_ALIAS(USB_Event_Stub);
+ void EVENT_USB_Device_Suspend(void) ATTR_WEAK ATTR_ALIAS(USB_Event_Stub);
+ void EVENT_USB_Device_WakeUp(void) ATTR_WEAK ATTR_ALIAS(USB_Event_Stub);
+ void EVENT_USB_Device_Reset(void) ATTR_WEAK ATTR_ALIAS(USB_Event_Stub);
+ void EVENT_USB_Device_StartOfFrame(void) ATTR_WEAK ATTR_ALIAS(USB_Event_Stub);
+ #endif
+ #endif
+ #endif
+
+ /* Disable C linkage for C++ Compilers: */
+ #if defined(__cplusplus)
+ }
+ #endif
+
+#endif
+
+/** @} */
diff --git a/LUFA/Drivers/USB/HighLevel/StdDescriptors.h b/LUFA/Drivers/USB/HighLevel/StdDescriptors.h
index 5f54561dc..9764b45ad 100644
--- a/LUFA/Drivers/USB/HighLevel/StdDescriptors.h
+++ b/LUFA/Drivers/USB/HighLevel/StdDescriptors.h
@@ -1,651 +1,651 @@
-/*
- LUFA Library
- Copyright (C) Dean Camera, 2010.
-
- dean [at] fourwalledcubicle [dot] com
- www.fourwalledcubicle.com
-*/
-
-/*
- Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
-
- Permission to use, copy, modify, distribute, and sell this
- software and its documentation for any purpose is hereby granted
- without fee, provided that the above copyright notice appear in
- all copies and that both that the copyright notice and this
- permission notice and warranty disclaimer appear in supporting
- documentation, and that the name of the author not be used in
- advertising or publicity pertaining to distribution of the
- software without specific, written prior permission.
-
- The author disclaim all warranties with regard to this
- software, including all implied warranties of merchantability
- and fitness. In no event shall the author be liable for any
- special, indirect or consequential damages or any damages
- whatsoever resulting from loss of use, data or profits, whether
- in an action of contract, negligence or other tortious action,
- arising out of or in connection with the use or performance of
- this software.
-*/
-
-/** \file
- * \brief USB standard descriptor definitions.
- *
- * This file contains structures and macros for the easy creation of standard USB descriptors in USB device projects.
- *
- * \note This file should not be included directly. It is automatically included as needed by the USB driver
- * dispatch header located in LUFA/Drivers/USB/USB.h.
- */
-
-/** \ingroup Group_USB
- * @defgroup Group_Descriptors USB Descriptors
- *
- * 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.
- *
- * @{
- */
-
-#ifndef __USBDESCRIPTORS_H__
-#define __USBDESCRIPTORS_H__
-
- /* Includes: */
- #include <avr/pgmspace.h>
- #include <stdbool.h>
- #include <stddef.h>
-
- #include "../../../Common/Common.h"
- #include "USBMode.h"
- #include "Events.h"
-
- #if defined(USB_CAN_BE_DEVICE)
- #include "../LowLevel/Device.h"
- #endif
-
- /* Enable C linkage for C++ Compilers: */
- #if defined(__cplusplus)
- extern "C" {
- #endif
-
- /* Preprocessor Checks: */
- #if !defined(__INCLUDE_FROM_USB_DRIVER)
- #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.
- #endif
-
- /* Public Interface - May be used in end-application: */
- /* Macros: */
- /** Indicates that a given descriptor does not exist in the device. This can be used inside descriptors
- * for string descriptor indexes, or may be use as a return value for GetDescriptor when the specified
- * descriptor does not exist.
- */
- #define NO_DESCRIPTOR 0
-
- #if (!defined(NO_INTERNAL_SERIAL) && (defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR))) || defined(__DOXYGEN__)
- /** String descriptor index for the device's unique serial number string descriptor within the device.
- * This unique serial number is used by the host to associate resources to the device (such as drivers or COM port
- * number allocations) to a device regardless of the port it is plugged in to on the host. Some USB AVRs contain
- * a unique serial number internally, and setting the device descriptors serial number string index to this value
- * will cause it to use the internal serial number.
- *
- * On unsupported devices, this will evaluate to NO_DESCRIPTOR and so will force the host to create a pseudo-serial
- * number for the device.
- */
- #define USE_INTERNAL_SERIAL 0xDC
- #else
- #define USE_INTERNAL_SERIAL NO_DESCRIPTOR
- #endif
-
- /** Macro to calculate the power value for the configuration descriptor, from a given number of milliamps. */
- #define USB_CONFIG_POWER_MA(mA) ((mA) >> 1)
-
- /** Macro to calculate the Unicode length of a string with a given number of Unicode characters.
- * Should be used in string descriptor's headers for giving the string descriptor's byte length.
- */
- #define USB_STRING_LEN(str) (sizeof(USB_Descriptor_Header_t) + ((str) << 1))
-
- /** Macro to encode a given four digit floating point version number (e.g. 01.23) into Binary Coded
- * Decimal format for descriptor fields requiring BCD encoding, such as the USB version number in the
- * standard device descriptor.
- */
- #define VERSION_BCD(x) ((((VERSION_TENS(x) << 4) | VERSION_ONES(x)) << 8) | \
- ((VERSION_TENTHS(x) << 4) | VERSION_HUNDREDTHS(x)))
-
- /** String language ID for the English language. Should be used in \ref USB_Descriptor_String_t descriptors
- * to indicate that the English language is supported by the device in its string descriptors.
- */
- #define LANGUAGE_ID_ENG 0x0409
-
- /** Can be masked with an endpoint address for a \ref USB_Descriptor_Endpoint_t endpoint descriptor's
- * EndpointAddress value to indicate to the host that the endpoint is of the IN direction (i.e, from
- * device to host).
- */
- #define ENDPOINT_DESCRIPTOR_DIR_IN 0x80
-
- /** Can be masked with an endpoint address for a \ref USB_Descriptor_Endpoint_t endpoint descriptor's
- * EndpointAddress value to indicate to the host that the endpoint is of the OUT direction (i.e, from
- * host to device).
- */
- #define ENDPOINT_DESCRIPTOR_DIR_OUT 0x00
-
- /** Can be masked with other configuration descriptor attributes for a \ref USB_Descriptor_Configuration_Header_t
- * descriptor's ConfigAttributes value to indicate that the specified configuration can draw its power
- * from the host's VBUS line.
- */
- #define USB_CONFIG_ATTR_BUSPOWERED 0x80
-
- /** Can be masked with other configuration descriptor attributes for a \ref USB_Descriptor_Configuration_Header_t
- * descriptor's ConfigAttributes value to indicate that the specified configuration can draw its power
- * from the device's own power source.
- */
- #define USB_CONFIG_ATTR_SELFPOWERED 0x40
-
- /** Can be masked with other configuration descriptor attributes for a \ref USB_Descriptor_Configuration_Header_t
- * descriptor's ConfigAttributes value to indicate that the specified configuration supports the
- * remote wakeup feature of the USB standard, allowing a suspended USB device to wake up the host upon
- * request.
- */
- #define USB_CONFIG_ATTR_REMOTEWAKEUP 0x20
-
- /** Can be masked with other endpoint descriptor attributes for a \ref USB_Descriptor_Endpoint_t descriptor's
- * Attributes value to indicate that the specified endpoint is not synchronized.
- *
- * \see The USB specification for more details on the possible Endpoint attributes.
- */
- #define ENDPOINT_ATTR_NO_SYNC (0 << 2)
-
- /** Can be masked with other endpoint descriptor attributes for a \ref USB_Descriptor_Endpoint_t descriptor's
- * Attributes value to indicate that the specified endpoint is asynchronous.
- *
- * \see The USB specification for more details on the possible Endpoint attributes.
- */
- #define ENDPOINT_ATTR_ASYNC (1 << 2)
-
- /** Can be masked with other endpoint descriptor attributes for a \ref USB_Descriptor_Endpoint_t descriptor's
- * Attributes value to indicate that the specified endpoint is adaptive.
- *
- * \see The USB specification for more details on the possible Endpoint attributes.
- */
- #define ENDPOINT_ATTR_ADAPTIVE (2 << 2)
-
- /** Can be masked with other endpoint descriptor attributes for a \ref USB_Descriptor_Endpoint_t descriptor's
- * Attributes value to indicate that the specified endpoint is synchronized.
- *
- * \see The USB specification for more details on the possible Endpoint attributes.
- */
- #define ENDPOINT_ATTR_SYNC (3 << 2)
-
- /** Can be masked with other endpoint descriptor attributes for a \ref USB_Descriptor_Endpoint_t descriptor's
- * Attributes value to indicate that the specified endpoint is used for data transfers.
- *
- * \see The USB specification for more details on the possible Endpoint usage attributes.
- */
- #define ENDPOINT_USAGE_DATA (0 << 4)
-
- /** Can be masked with other endpoint descriptor attributes for a \ref USB_Descriptor_Endpoint_t descriptor's
- * Attributes value to indicate that the specified endpoint is used for feedback.
- *
- * \see The USB specification for more details on the possible Endpoint usage attributes.
- */
- #define ENDPOINT_USAGE_FEEDBACK (1 << 4)
-
- /** Can be masked with other endpoint descriptor attributes for a \ref USB_Descriptor_Endpoint_t descriptor's
- * Attributes value to indicate that the specified endpoint is used for implicit feedback.
- *
- * \see The USB specification for more details on the possible Endpoint usage attributes.
- */
- #define ENDPOINT_USAGE_IMPLICIT_FEEDBACK (2 << 4)
-
- /* Enums: */
- /** Enum for the possible standard descriptor types, as given in each descriptor's header. */
- enum USB_DescriptorTypes_t
- {
- DTYPE_Device = 0x01, /**< Indicates that the descriptor is a device descriptor. */
- DTYPE_Configuration = 0x02, /**< Indicates that the descriptor is a configuration descriptor. */
- DTYPE_String = 0x03, /**< Indicates that the descriptor is a string descriptor. */
- DTYPE_Interface = 0x04, /**< Indicates that the descriptor is an interface descriptor. */
- DTYPE_Endpoint = 0x05, /**< Indicates that the descriptor is an endpoint descriptor. */
- DTYPE_DeviceQualifier = 0x06, /**< Indicates that the descriptor is a device qualifier descriptor. */
- DTYPE_Other = 0x07, /**< Indicates that the descriptor is of other type. */
- DTYPE_InterfacePower = 0x08, /**< Indicates that the descriptor is an interface power descriptor. */
- DTYPE_InterfaceAssociation = 0x0B, /**< Indicates that the descriptor is an interface association descriptor. */
- };
-
- /* Type Defines: */
- /** \brief Standard USB Descriptor Header (LUFA naming conventions).
- *
- * 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.
- *
- * \see \ref USB_StdDescriptor_Header_t for the version of this define with standard element names
- */
- typedef struct
- {
- 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;
-
- /** \brief Standard USB Descriptor Header (USB-IF naming conventions).
- *
- * 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;
-
- /** \brief Standard USB Device Descriptor (LUFA naming conventions).
- *
- * Type define for a standard Device Descriptor. This structure uses LUFA-specific element names to make each
- * element's purpose clearer.
- *
- * \see \ref USB_StdDescriptor_Device_t for the version of this define with standard element names
- */
- typedef struct
- {
- 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. */
-
- 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. */
-
- 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;
-
- /** \brief Standard USB Device Descriptor (USB-IF naming conventions).
- *
- * Type define for a standard Device Descriptor. This structure uses the relevant standard's given element names
- * to ensure compatibility with the 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;
-
- /** \brief Standard USB Configuration Descriptor (LUFA naming conventions).
- *
- * 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
- {
- 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. */
-
- 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 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;
-
- /** \brief Standard USB Configuration Descriptor (USB-IF naming conventions).
- *
- * Type define for a standard Configuration Descriptor header. This structure uses the relevant standard's given element names
- * to ensure compatibility with the 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;
-
- /** \brief Standard USB Interface Descriptor (LUFA naming conventions).
- *
- * 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
- {
- 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 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.
- */
- } USB_Descriptor_Interface_t;
-
- /** \brief Standard USB Interface Descriptor (USB-IF naming conventions).
- *
- * 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;
-
- /** \brief Standard USB Interface Association Descriptor (LUFA naming conventions).
- *
- * 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
- * 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_StdDescriptor_Interface_Association_t for the version of this define with standard element names
- */
- typedef struct
- {
- 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.
- */
- } USB_Descriptor_Interface_Association_t;
-
- /** \brief Standard USB Interface Association Descriptor (USB-IF naming conventions).
- *
- * Type define for a standard Interface Association Descriptor. This structure uses the relevant standard's given
- * element names to ensure compatibility with the 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;
-
- /** \brief Standard USB Endpoint Descriptor (LUFA naming conventions).
- *
- * 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
- {
- 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 PollingIntervalMS; /**< Polling interval in milliseconds for the endpoint
- * if it is an INTERRUPT or ISOCHRONOUS type.
- */
- } USB_Descriptor_Endpoint_t;
-
- /** \brief Standard USB Endpoint Descriptor (USB-IF naming conventions).
- *
- * 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;
-
- /** \brief Standard USB String Descriptor (LUFA naming conventions).
- *
- * 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 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
- {
- USB_Descriptor_Header_t Header; /**< Descriptor header, including type and size. */
-
- wchar_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;
-
- /** \brief Standard USB String Descriptor (USB-IF naming conventions).
- *
- * 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: */
- #define VERSION_TENS(x) (int)((x) / 10)
- #define VERSION_ONES(x) (int)((x) - (10 * VERSION_TENS(x)))
- #define VERSION_TENTHS(x) (int)(((x) - (int)(x)) * 10)
- #define VERSION_HUNDREDTHS(x) (int)((((x) - (int)(x)) * 100) - (10 * VERSION_TENTHS(x)))
- #endif
-
- /* Disable C linkage for C++ Compilers: */
- #if defined(__cplusplus)
- }
- #endif
-
-#endif
-
-/** @} */
+/*
+ LUFA Library
+ Copyright (C) Dean Camera, 2010.
+
+ dean [at] fourwalledcubicle [dot] com
+ www.fourwalledcubicle.com
+*/
+
+/*
+ Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
+
+ Permission to use, copy, modify, distribute, and sell this
+ software and its documentation for any purpose is hereby granted
+ without fee, provided that the above copyright notice appear in
+ all copies and that both that the copyright notice and this
+ permission notice and warranty disclaimer appear in supporting
+ documentation, and that the name of the author not be used in
+ advertising or publicity pertaining to distribution of the
+ software without specific, written prior permission.
+
+ The author disclaim all warranties with regard to this
+ software, including all implied warranties of merchantability
+ and fitness. In no event shall the author be liable for any
+ special, indirect or consequential damages or any damages
+ whatsoever resulting from loss of use, data or profits, whether
+ in an action of contract, negligence or other tortious action,
+ arising out of or in connection with the use or performance of
+ this software.
+*/
+
+/** \file
+ * \brief USB standard descriptor definitions.
+ *
+ * This file contains structures and macros for the easy creation of standard USB descriptors in USB device projects.
+ *
+ * \note This file should not be included directly. It is automatically included as needed by the USB driver
+ * dispatch header located in LUFA/Drivers/USB/USB.h.
+ */
+
+/** \ingroup Group_USB
+ * @defgroup Group_Descriptors USB Descriptors
+ *
+ * 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.
+ *
+ * @{
+ */
+
+#ifndef __USBDESCRIPTORS_H__
+#define __USBDESCRIPTORS_H__
+
+ /* Includes: */
+ #include <avr/pgmspace.h>
+ #include <stdbool.h>
+ #include <stddef.h>
+
+ #include "../../../Common/Common.h"
+ #include "USBMode.h"
+ #include "Events.h"
+
+ #if defined(USB_CAN_BE_DEVICE)
+ #include "../LowLevel/Device.h"
+ #endif
+
+ /* Enable C linkage for C++ Compilers: */
+ #if defined(__cplusplus)
+ extern "C" {
+ #endif
+
+ /* Preprocessor Checks: */
+ #if !defined(__INCLUDE_FROM_USB_DRIVER)
+ #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.
+ #endif
+
+ /* Public Interface - May be used in end-application: */
+ /* Macros: */
+ /** Indicates that a given descriptor does not exist in the device. This can be used inside descriptors
+ * for string descriptor indexes, or may be use as a return value for GetDescriptor when the specified
+ * descriptor does not exist.
+ */
+ #define NO_DESCRIPTOR 0
+
+ #if (!defined(NO_INTERNAL_SERIAL) && (defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR))) || defined(__DOXYGEN__)
+ /** String descriptor index for the device's unique serial number string descriptor within the device.
+ * This unique serial number is used by the host to associate resources to the device (such as drivers or COM port
+ * number allocations) to a device regardless of the port it is plugged in to on the host. Some USB AVRs contain
+ * a unique serial number internally, and setting the device descriptors serial number string index to this value
+ * will cause it to use the internal serial number.
+ *
+ * On unsupported devices, this will evaluate to NO_DESCRIPTOR and so will force the host to create a pseudo-serial
+ * number for the device.
+ */
+ #define USE_INTERNAL_SERIAL 0xDC
+ #else
+ #define USE_INTERNAL_SERIAL NO_DESCRIPTOR
+ #endif
+
+ /** Macro to calculate the power value for the configuration descriptor, from a given number of milliamps. */
+ #define USB_CONFIG_POWER_MA(mA) ((mA) >> 1)
+
+ /** Macro to calculate the Unicode length of a string with a given number of Unicode characters.
+ * Should be used in string descriptor's headers for giving the string descriptor's byte length.
+ */
+ #define USB_STRING_LEN(str) (sizeof(USB_Descriptor_Header_t) + ((str) << 1))
+
+ /** Macro to encode a given four digit floating point version number (e.g. 01.23) into Binary Coded
+ * Decimal format for descriptor fields requiring BCD encoding, such as the USB version number in the
+ * standard device descriptor.
+ */
+ #define VERSION_BCD(x) ((((VERSION_TENS(x) << 4) | VERSION_ONES(x)) << 8) | \
+ ((VERSION_TENTHS(x) << 4) | VERSION_HUNDREDTHS(x)))
+
+ /** String language ID for the English language. Should be used in \ref USB_Descriptor_String_t descriptors
+ * to indicate that the English language is supported by the device in its string descriptors.
+ */
+ #define LANGUAGE_ID_ENG 0x0409
+
+ /** Can be masked with an endpoint address for a \ref USB_Descriptor_Endpoint_t endpoint descriptor's
+ * EndpointAddress value to indicate to the host that the endpoint is of the IN direction (i.e, from
+ * device to host).
+ */
+ #define ENDPOINT_DESCRIPTOR_DIR_IN 0x80
+
+ /** Can be masked with an endpoint address for a \ref USB_Descriptor_Endpoint_t endpoint descriptor's
+ * EndpointAddress value to indicate to the host that the endpoint is of the OUT direction (i.e, from
+ * host to device).
+ */
+ #define ENDPOINT_DESCRIPTOR_DIR_OUT 0x00
+
+ /** Can be masked with other configuration descriptor attributes for a \ref USB_Descriptor_Configuration_Header_t
+ * descriptor's ConfigAttributes value to indicate that the specified configuration can draw its power
+ * from the host's VBUS line.
+ */
+ #define USB_CONFIG_ATTR_BUSPOWERED 0x80
+
+ /** Can be masked with other configuration descriptor attributes for a \ref USB_Descriptor_Configuration_Header_t
+ * descriptor's ConfigAttributes value to indicate that the specified configuration can draw its power
+ * from the device's own power source.
+ */
+ #define USB_CONFIG_ATTR_SELFPOWERED 0x40
+
+ /** Can be masked with other configuration descriptor attributes for a \ref USB_Descriptor_Configuration_Header_t
+ * descriptor's ConfigAttributes value to indicate that the specified configuration supports the
+ * remote wakeup feature of the USB standard, allowing a suspended USB device to wake up the host upon
+ * request.
+ */
+ #define USB_CONFIG_ATTR_REMOTEWAKEUP 0x20
+
+ /** Can be masked with other endpoint descriptor attributes for a \ref USB_Descriptor_Endpoint_t descriptor's
+ * Attributes value to indicate that the specified endpoint is not synchronized.
+ *
+ * \see The USB specification for more details on the possible Endpoint attributes.
+ */
+ #define ENDPOINT_ATTR_NO_SYNC (0 << 2)
+
+ /** Can be masked with other endpoint descriptor attributes for a \ref USB_Descriptor_Endpoint_t descriptor's
+ * Attributes value to indicate that the specified endpoint is asynchronous.
+ *
+ * \see The USB specification for more details on the possible Endpoint attributes.
+ */
+ #define ENDPOINT_ATTR_ASYNC (1 << 2)
+
+ /** Can be masked with other endpoint descriptor attributes for a \ref USB_Descriptor_Endpoint_t descriptor's
+ * Attributes value to indicate that the specified endpoint is adaptive.
+ *
+ * \see The USB specification for more details on the possible Endpoint attributes.
+ */
+ #define ENDPOINT_ATTR_ADAPTIVE (2 << 2)
+
+ /** Can be masked with other endpoint descriptor attributes for a \ref USB_Descriptor_Endpoint_t descriptor's
+ * Attributes value to indicate that the specified endpoint is synchronized.
+ *
+ * \see The USB specification for more details on the possible Endpoint attributes.
+ */
+ #define ENDPOINT_ATTR_SYNC (3 << 2)
+
+ /** Can be masked with other endpoint descriptor attributes for a \ref USB_Descriptor_Endpoint_t descriptor's
+ * Attributes value to indicate that the specified endpoint is used for data transfers.
+ *
+ * \see The USB specification for more details on the possible Endpoint usage attributes.
+ */
+ #define ENDPOINT_USAGE_DATA (0 << 4)
+
+ /** Can be masked with other endpoint descriptor attributes for a \ref USB_Descriptor_Endpoint_t descriptor's
+ * Attributes value to indicate that the specified endpoint is used for feedback.
+ *
+ * \see The USB specification for more details on the possible Endpoint usage attributes.
+ */
+ #define ENDPOINT_USAGE_FEEDBACK (1 << 4)
+
+ /** Can be masked with other endpoint descriptor attributes for a \ref USB_Descriptor_Endpoint_t descriptor's
+ * Attributes value to indicate that the specified endpoint is used for implicit feedback.
+ *
+ * \see The USB specification for more details on the possible Endpoint usage attributes.
+ */
+ #define ENDPOINT_USAGE_IMPLICIT_FEEDBACK (2 << 4)
+
+ /* Enums: */
+ /** Enum for the possible standard descriptor types, as given in each descriptor's header. */
+ enum USB_DescriptorTypes_t
+ {
+ DTYPE_Device = 0x01, /**< Indicates that the descriptor is a device descriptor. */
+ DTYPE_Configuration = 0x02, /**< Indicates that the descriptor is a configuration descriptor. */
+ DTYPE_String = 0x03, /**< Indicates that the descriptor is a string descriptor. */
+ DTYPE_Interface = 0x04, /**< Indicates that the descriptor is an interface descriptor. */
+ DTYPE_Endpoint = 0x05, /**< Indicates that the descriptor is an endpoint descriptor. */
+ DTYPE_DeviceQualifier = 0x06, /**< Indicates that the descriptor is a device qualifier descriptor. */
+ DTYPE_Other = 0x07, /**< Indicates that the descriptor is of other type. */
+ DTYPE_InterfacePower = 0x08, /**< Indicates that the descriptor is an interface power descriptor. */
+ DTYPE_InterfaceAssociation = 0x0B, /**< Indicates that the descriptor is an interface association descriptor. */
+ };
+
+ /* Type Defines: */
+ /** \brief Standard USB Descriptor Header (LUFA naming conventions).
+ *
+ * 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.
+ *
+ * \see \ref USB_StdDescriptor_Header_t for the version of this define with standard element names
+ */
+ typedef struct
+ {
+ 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;
+
+ /** \brief Standard USB Descriptor Header (USB-IF naming conventions).
+ *
+ * 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;
+
+ /** \brief Standard USB Device Descriptor (LUFA naming conventions).
+ *
+ * Type define for a standard Device Descriptor. This structure uses LUFA-specific element names to make each
+ * element's purpose clearer.
+ *
+ * \see \ref USB_StdDescriptor_Device_t for the version of this define with standard element names
+ */
+ typedef struct
+ {
+ 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. */
+
+ 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. */
+
+ 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;
+
+ /** \brief Standard USB Device Descriptor (USB-IF naming conventions).
+ *
+ * Type define for a standard Device Descriptor. This structure uses the relevant standard's given element names
+ * to ensure compatibility with the 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;
+
+ /** \brief Standard USB Configuration Descriptor (LUFA naming conventions).
+ *
+ * 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
+ {
+ 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. */
+
+ 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 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;
+
+ /** \brief Standard USB Configuration Descriptor (USB-IF naming conventions).
+ *
+ * Type define for a standard Configuration Descriptor header. This structure uses the relevant standard's given element names
+ * to ensure compatibility with the 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;
+
+ /** \brief Standard USB Interface Descriptor (LUFA naming conventions).
+ *
+ * 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
+ {
+ 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 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.
+ */
+ } USB_Descriptor_Interface_t;
+
+ /** \brief Standard USB Interface Descriptor (USB-IF naming conventions).
+ *
+ * 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;
+
+ /** \brief Standard USB Interface Association Descriptor (LUFA naming conventions).
+ *
+ * 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
+ * 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_StdDescriptor_Interface_Association_t for the version of this define with standard element names
+ */
+ typedef struct
+ {
+ 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.
+ */
+ } USB_Descriptor_Interface_Association_t;
+
+ /** \brief Standard USB Interface Association Descriptor (USB-IF naming conventions).
+ *
+ * Type define for a standard Interface Association Descriptor. This structure uses the relevant standard's given
+ * element names to ensure compatibility with the 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;
+
+ /** \brief Standard USB Endpoint Descriptor (LUFA naming conventions).
+ *
+ * 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
+ {
+ 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 PollingIntervalMS; /**< Polling interval in milliseconds for the endpoint
+ * if it is an INTERRUPT or ISOCHRONOUS type.
+ */
+ } USB_Descriptor_Endpoint_t;
+
+ /** \brief Standard USB Endpoint Descriptor (USB-IF naming conventions).
+ *
+ * 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;
+
+ /** \brief Standard USB String Descriptor (LUFA naming conventions).
+ *
+ * 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 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
+ {
+ USB_Descriptor_Header_t Header; /**< Descriptor header, including type and size. */
+
+ wchar_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;
+
+ /** \brief Standard USB String Descriptor (USB-IF naming conventions).
+ *
+ * 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: */
+ #define VERSION_TENS(x) (int)((x) / 10)
+ #define VERSION_ONES(x) (int)((x) - (10 * VERSION_TENS(x)))
+ #define VERSION_TENTHS(x) (int)(((x) - (int)(x)) * 10)
+ #define VERSION_HUNDREDTHS(x) (int)((((x) - (int)(x)) * 100) - (10 * VERSION_TENTHS(x)))
+ #endif
+
+ /* Disable C linkage for C++ Compilers: */
+ #if defined(__cplusplus)
+ }
+ #endif
+
+#endif
+
+/** @} */
diff --git a/LUFA/Drivers/USB/HighLevel/StdRequestType.h b/LUFA/Drivers/USB/HighLevel/StdRequestType.h
index 164340bdc..505ccd3c2 100644
--- a/LUFA/Drivers/USB/HighLevel/StdRequestType.h
+++ b/LUFA/Drivers/USB/HighLevel/StdRequestType.h
@@ -1,226 +1,226 @@
-/*
- LUFA Library
- Copyright (C) Dean Camera, 2010.
-
- dean [at] fourwalledcubicle [dot] com
- www.fourwalledcubicle.com
-*/
-
-/*
- Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
-
- Permission to use, copy, modify, distribute, and sell this
- software and its documentation for any purpose is hereby granted
- without fee, provided that the above copyright notice appear in
- all copies and that both that the copyright notice and this
- permission notice and warranty disclaimer appear in supporting
- documentation, and that the name of the author not be used in
- advertising or publicity pertaining to distribution of the
- software without specific, written prior permission.
-
- The author disclaim all warranties with regard to this
- software, including all implied warranties of merchantability
- and fitness. In no event shall the author be liable for any
- special, indirect or consequential damages or any damages
- whatsoever resulting from loss of use, data or profits, whether
- in an action of contract, negligence or other tortious action,
- arising out of or in connection with the use or performance of
- this software.
-*/
-
-/** \file
- * \brief USB control endpoint request definitions.
- *
- * This file contains structures and macros for the easy creation and parsing of standard USB control requests.
- *
- * \note This file should not be included directly. It is automatically included as needed by the USB driver
- * dispatch header located in LUFA/Drivers/USB/USB.h.
- */
-
-/** \ingroup Group_USB
- * @defgroup Group_StdRequest Standard USB Requests
- *
- * This module contains definitions for the various control request parameters, so that the request
- * details (such as data direction, request recipient, etc.) can be extracted via masking.
- *
- * @{
- */
-
-#ifndef __STDREQTYPE_H__
-#define __STDREQTYPE_H__
-
- /* Preprocessor Checks: */
- #if !defined(__INCLUDE_FROM_USB_DRIVER)
- #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.
- #endif
-
- /* Public Interface - May be used in end-application: */
- /* Macros: */
- /** Mask for the request type parameter, to indicate the direction of the request data (Host to Device
- * or Device to Host). The result of this mask should then be compared to the request direction masks.
- *
- * \see REQDIR_* macros for masks indicating the request data direction.
- */
- #define CONTROL_REQTYPE_DIRECTION 0x80
-
- /** Mask for the request type parameter, to indicate the type of request (Device, Class or Vendor
- * Specific). The result of this mask should then be compared to the request type masks.
- *
- * \see REQTYPE_* macros for masks indicating the request type.
- */
- #define CONTROL_REQTYPE_TYPE 0x60
-
- /** Mask for the request type parameter, to indicate the recipient of the request (Standard, Class
- * or Vendor Specific). The result of this mask should then be compared to the request recipient
- * masks.
- *
- * \see REQREC_* macros for masks indicating the request recipient.
- */
- #define CONTROL_REQTYPE_RECIPIENT 0x1F
-
- /** Request data direction mask, indicating that the request data will flow from host to device.
- *
- * \see \ref CONTROL_REQTYPE_DIRECTION macro.
- */
- #define REQDIR_HOSTTODEVICE (0 << 7)
-
- /** Request data direction mask, indicating that the request data will flow from device to host.
- *
- * \see \ref CONTROL_REQTYPE_DIRECTION macro.
- */
- #define REQDIR_DEVICETOHOST (1 << 7)
-
- /** Request type mask, indicating that the request is a standard request.
- *
- * \see \ref CONTROL_REQTYPE_TYPE macro.
- */
- #define REQTYPE_STANDARD (0 << 5)
-
- /** Request type mask, indicating that the request is a class-specific request.
- *
- * \see \ref CONTROL_REQTYPE_TYPE macro.
- */
- #define REQTYPE_CLASS (1 << 5)
-
- /** Request type mask, indicating that the request is a vendor specific request.
- *
- * \see \ref CONTROL_REQTYPE_TYPE macro.
- */
- #define REQTYPE_VENDOR (2 << 5)
-
- /** Request recipient mask, indicating that the request is to be issued to the device as a whole.
- *
- * \see \ref CONTROL_REQTYPE_RECIPIENT macro.
- */
- #define REQREC_DEVICE (0 << 0)
-
- /** Request recipient mask, indicating that the request is to be issued to an interface in the
- * currently selected configuration.
- *
- * \see \ref CONTROL_REQTYPE_RECIPIENT macro.
- */
- #define REQREC_INTERFACE (1 << 0)
-
- /** Request recipient mask, indicating that the request is to be issued to an endpoint in the
- * currently selected configuration.
- *
- * \see \ref CONTROL_REQTYPE_RECIPIENT macro.
- */
- #define REQREC_ENDPOINT (2 << 0)
-
- /** Request recipient mask, indicating that the request is to be issued to an unspecified element
- * in the currently selected configuration.
- *
- * \see \ref CONTROL_REQTYPE_RECIPIENT macro.
- */
- #define REQREC_OTHER (3 << 0)
-
- /** Feature indicator for Clear Feature or Set Feature commands. When used in a Clear Feature
- * request this indicates that an endpoint (whose address is given elsewhere in the request
- * should have its stall condition cleared. If used in a similar manner inside a Set Feature
- * request, this stalls an endpoint.
- */
- #define FEATURE_ENDPOINT_HALT 0x00
-
- /** Feature indicator for Clear Feature or Set Feature commands. When used in a Clear Feature
- * request this indicates that the remote wakeup enabled device should not issue remote
- * wakeup requests until further notice. If used in a similar manner inside a Set Feature
- * request, this re-enabled the remote wakeup feature on the device.
- */
- #define FEATURE_REMOTE_WAKEUP 0x01
-
- /* Type Defines: */
- /** \brief Standard USB Control Request
- *
- * Type define for a standard USB control request.
- *
- * \see The USB 2.0 specification for more information on standard control requests.
- */
- typedef struct
- {
- uint8_t bmRequestType; /**< Type of the request. */
- uint8_t bRequest; /**< Request command code. */
- uint16_t wValue; /**< wValue parameter of the request. */
- uint16_t wIndex; /**< wIndex parameter of the request. */
- uint16_t wLength; /**< Length of the data to transfer in bytes. */
- } USB_Request_Header_t;
-
- /* Enums: */
- /** Enumeration for the various standard request commands. These commands are applicable when the
- * request type is \ref REQTYPE_STANDARD (with the exception of \ref REQ_GetDescriptor, which is always
- * handled regardless of the request type value).
- *
- * \see Chapter 9 of the USB 2.0 Specification.
- */
- enum USB_Control_Request_t
- {
- REQ_GetStatus = 0, /**< Implemented in the library for device, endpoint and interface
- * recipients. Passed to the user application for other recipients
- * via the \ref EVENT_USB_Device_UnhandledControlRequest() event when received in
- * device mode. */
- REQ_ClearFeature = 1, /**< Implemented in the library for device, endpoint and interface
- * recipients. Passed to the user application for other recipients
- * via the \ref EVENT_USB_Device_UnhandledControlRequest() event when received in
- * device mode. */
- REQ_SetFeature = 3, /**< Implemented in the library for device, endpoint and interface
- * recipients. Passed to the user application for other recipients
- * via the \ref EVENT_USB_Device_UnhandledControlRequest() event when received in
- * device mode. */
- REQ_SetAddress = 5, /**< Implemented in the library for the device recipient. Passed
- * to the user application for other recipients via the
- * \ref EVENT_USB_Device_UnhandledControlRequest() event when received in
- * device mode. */
- REQ_GetDescriptor = 6, /**< Implemented in the library for all recipients and all request
- * types. */
- REQ_SetDescriptor = 7, /**< Not implemented in the library, passed to the user application
- * via the \ref EVENT_USB_Device_UnhandledControlRequest() event when received in
- * device mode. */
- REQ_GetConfiguration = 8, /**< Implemented in the library for the device recipient. Passed
- * to the user application for other recipients via the
- * \ref EVENT_USB_Device_UnhandledControlRequest() event when received in
- * device mode. */
- REQ_SetConfiguration = 9, /**< Implemented in the library for the device recipient. Passed
- * to the user application for other recipients via the
- * \ref EVENT_USB_Device_UnhandledControlRequest() event when received in
- * device mode. */
- REQ_GetInterface = 10, /**< Not implemented in the library, passed to the user application
- * via the \ref EVENT_USB_Device_UnhandledControlRequest() event when received in
- * device mode. */
- REQ_SetInterface = 11, /**< Not implemented in the library, passed to the user application
- * via the \ref EVENT_USB_Device_UnhandledControlRequest() event when received in
- * device mode. */
- REQ_SynchFrame = 12, /**< Not implemented in the library, passed to the user application
- * via the \ref EVENT_USB_Device_UnhandledControlRequest() event when received in
- * device mode. */
- };
-
- /* Private Interface - For use in library only: */
- #if !defined(__DOXYGEN__)
- /* Macros: */
- #define FEATURE_SELFPOWERED_ENABLED (1 << 0)
- #define FEATURE_REMOTE_WAKEUP_ENABLED (1 << 1)
- #endif
-
-#endif
-
-/** @} */
+/*
+ LUFA Library
+ Copyright (C) Dean Camera, 2010.
+
+ dean [at] fourwalledcubicle [dot] com
+ www.fourwalledcubicle.com
+*/
+
+/*
+ Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
+
+ Permission to use, copy, modify, distribute, and sell this
+ software and its documentation for any purpose is hereby granted
+ without fee, provided that the above copyright notice appear in
+ all copies and that both that the copyright notice and this
+ permission notice and warranty disclaimer appear in supporting
+ documentation, and that the name of the author not be used in
+ advertising or publicity pertaining to distribution of the
+ software without specific, written prior permission.
+
+ The author disclaim all warranties with regard to this
+ software, including all implied warranties of merchantability
+ and fitness. In no event shall the author be liable for any
+ special, indirect or consequential damages or any damages
+ whatsoever resulting from loss of use, data or profits, whether
+ in an action of contract, negligence or other tortious action,
+ arising out of or in connection with the use or performance of
+ this software.
+*/
+
+/** \file
+ * \brief USB control endpoint request definitions.
+ *
+ * This file contains structures and macros for the easy creation and parsing of standard USB control requests.
+ *
+ * \note This file should not be included directly. It is automatically included as needed by the USB driver
+ * dispatch header located in LUFA/Drivers/USB/USB.h.
+ */
+
+/** \ingroup Group_USB
+ * @defgroup Group_StdRequest Standard USB Requests
+ *
+ * This module contains definitions for the various control request parameters, so that the request
+ * details (such as data direction, request recipient, etc.) can be extracted via masking.
+ *
+ * @{
+ */
+
+#ifndef __STDREQTYPE_H__
+#define __STDREQTYPE_H__
+
+ /* Preprocessor Checks: */
+ #if !defined(__INCLUDE_FROM_USB_DRIVER)
+ #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.
+ #endif
+
+ /* Public Interface - May be used in end-application: */
+ /* Macros: */
+ /** Mask for the request type parameter, to indicate the direction of the request data (Host to Device
+ * or Device to Host). The result of this mask should then be compared to the request direction masks.
+ *
+ * \see REQDIR_* macros for masks indicating the request data direction.
+ */
+ #define CONTROL_REQTYPE_DIRECTION 0x80
+
+ /** Mask for the request type parameter, to indicate the type of request (Device, Class or Vendor
+ * Specific). The result of this mask should then be compared to the request type masks.
+ *
+ * \see REQTYPE_* macros for masks indicating the request type.
+ */
+ #define CONTROL_REQTYPE_TYPE 0x60
+
+ /** Mask for the request type parameter, to indicate the recipient of the request (Standard, Class
+ * or Vendor Specific). The result of this mask should then be compared to the request recipient
+ * masks.
+ *
+ * \see REQREC_* macros for masks indicating the request recipient.
+ */
+ #define CONTROL_REQTYPE_RECIPIENT 0x1F
+
+ /** Request data direction mask, indicating that the request data will flow from host to device.
+ *
+ * \see \ref CONTROL_REQTYPE_DIRECTION macro.
+ */
+ #define REQDIR_HOSTTODEVICE (0 << 7)
+
+ /** Request data direction mask, indicating that the request data will flow from device to host.
+ *
+ * \see \ref CONTROL_REQTYPE_DIRECTION macro.
+ */
+ #define REQDIR_DEVICETOHOST (1 << 7)
+
+ /** Request type mask, indicating that the request is a standard request.
+ *
+ * \see \ref CONTROL_REQTYPE_TYPE macro.
+ */
+ #define REQTYPE_STANDARD (0 << 5)
+
+ /** Request type mask, indicating that the request is a class-specific request.
+ *
+ * \see \ref CONTROL_REQTYPE_TYPE macro.
+ */
+ #define REQTYPE_CLASS (1 << 5)
+
+ /** Request type mask, indicating that the request is a vendor specific request.
+ *
+ * \see \ref CONTROL_REQTYPE_TYPE macro.
+ */
+ #define REQTYPE_VENDOR (2 << 5)
+
+ /** Request recipient mask, indicating that the request is to be issued to the device as a whole.
+ *
+ * \see \ref CONTROL_REQTYPE_RECIPIENT macro.
+ */
+ #define REQREC_DEVICE (0 << 0)
+
+ /** Request recipient mask, indicating that the request is to be issued to an interface in the
+ * currently selected configuration.
+ *
+ * \see \ref CONTROL_REQTYPE_RECIPIENT macro.
+ */
+ #define REQREC_INTERFACE (1 << 0)
+
+ /** Request recipient mask, indicating that the request is to be issued to an endpoint in the
+ * currently selected configuration.
+ *
+ * \see \ref CONTROL_REQTYPE_RECIPIENT macro.
+ */
+ #define REQREC_ENDPOINT (2 << 0)
+
+ /** Request recipient mask, indicating that the request is to be issued to an unspecified element
+ * in the currently selected configuration.
+ *
+ * \see \ref CONTROL_REQTYPE_RECIPIENT macro.
+ */
+ #define REQREC_OTHER (3 << 0)
+
+ /** Feature indicator for Clear Feature or Set Feature commands. When used in a Clear Feature
+ * request this indicates that an endpoint (whose address is given elsewhere in the request
+ * should have its stall condition cleared. If used in a similar manner inside a Set Feature
+ * request, this stalls an endpoint.
+ */
+ #define FEATURE_ENDPOINT_HALT 0x00
+
+ /** Feature indicator for Clear Feature or Set Feature commands. When used in a Clear Feature
+ * request this indicates that the remote wakeup enabled device should not issue remote
+ * wakeup requests until further notice. If used in a similar manner inside a Set Feature
+ * request, this re-enabled the remote wakeup feature on the device.
+ */
+ #define FEATURE_REMOTE_WAKEUP 0x01
+
+ /* Type Defines: */
+ /** \brief Standard USB Control Request
+ *
+ * Type define for a standard USB control request.
+ *
+ * \see The USB 2.0 specification for more information on standard control requests.
+ */
+ typedef struct
+ {
+ uint8_t bmRequestType; /**< Type of the request. */
+ uint8_t bRequest; /**< Request command code. */
+ uint16_t wValue; /**< wValue parameter of the request. */
+ uint16_t wIndex; /**< wIndex parameter of the request. */
+ uint16_t wLength; /**< Length of the data to transfer in bytes. */
+ } USB_Request_Header_t;
+
+ /* Enums: */
+ /** Enumeration for the various standard request commands. These commands are applicable when the
+ * request type is \ref REQTYPE_STANDARD (with the exception of \ref REQ_GetDescriptor, which is always
+ * handled regardless of the request type value).
+ *
+ * \see Chapter 9 of the USB 2.0 Specification.
+ */
+ enum USB_Control_Request_t
+ {
+ REQ_GetStatus = 0, /**< Implemented in the library for device, endpoint and interface
+ * recipients. Passed to the user application for other recipients
+ * via the \ref EVENT_USB_Device_UnhandledControlRequest() event when received in
+ * device mode. */
+ REQ_ClearFeature = 1, /**< Implemented in the library for device, endpoint and interface
+ * recipients. Passed to the user application for other recipients
+ * via the \ref EVENT_USB_Device_UnhandledControlRequest() event when received in
+ * device mode. */
+ REQ_SetFeature = 3, /**< Implemented in the library for device, endpoint and interface
+ * recipients. Passed to the user application for other recipients
+ * via the \ref EVENT_USB_Device_UnhandledControlRequest() event when received in
+ * device mode. */
+ REQ_SetAddress = 5, /**< Implemented in the library for the device recipient. Passed
+ * to the user application for other recipients via the
+ * \ref EVENT_USB_Device_UnhandledControlRequest() event when received in
+ * device mode. */
+ REQ_GetDescriptor = 6, /**< Implemented in the library for all recipients and all request
+ * types. */
+ REQ_SetDescriptor = 7, /**< Not implemented in the library, passed to the user application
+ * via the \ref EVENT_USB_Device_UnhandledControlRequest() event when received in
+ * device mode. */
+ REQ_GetConfiguration = 8, /**< Implemented in the library for the device recipient. Passed
+ * to the user application for other recipients via the
+ * \ref EVENT_USB_Device_UnhandledControlRequest() event when received in
+ * device mode. */
+ REQ_SetConfiguration = 9, /**< Implemented in the library for the device recipient. Passed
+ * to the user application for other recipients via the
+ * \ref EVENT_USB_Device_UnhandledControlRequest() event when received in
+ * device mode. */
+ REQ_GetInterface = 10, /**< Not implemented in the library, passed to the user application
+ * via the \ref EVENT_USB_Device_UnhandledControlRequest() event when received in
+ * device mode. */
+ REQ_SetInterface = 11, /**< Not implemented in the library, passed to the user application
+ * via the \ref EVENT_USB_Device_UnhandledControlRequest() event when received in
+ * device mode. */
+ REQ_SynchFrame = 12, /**< Not implemented in the library, passed to the user application
+ * via the \ref EVENT_USB_Device_UnhandledControlRequest() event when received in
+ * device mode. */
+ };
+
+ /* Private Interface - For use in library only: */
+ #if !defined(__DOXYGEN__)
+ /* Macros: */
+ #define FEATURE_SELFPOWERED_ENABLED (1 << 0)
+ #define FEATURE_REMOTE_WAKEUP_ENABLED (1 << 1)
+ #endif
+
+#endif
+
+/** @} */
diff --git a/LUFA/Drivers/USB/HighLevel/StreamCallbacks.h b/LUFA/Drivers/USB/HighLevel/StreamCallbacks.h
index 228669e33..9b627e6cf 100644
--- a/LUFA/Drivers/USB/HighLevel/StreamCallbacks.h
+++ b/LUFA/Drivers/USB/HighLevel/StreamCallbacks.h
@@ -1,83 +1,83 @@
-/*
- LUFA Library
- Copyright (C) Dean Camera, 2010.
-
- dean [at] fourwalledcubicle [dot] com
- www.fourwalledcubicle.com
-*/
-
-/*
- Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
-
- Permission to use, copy, modify, distribute, and sell this
- software and its documentation for any purpose is hereby granted
- without fee, provided that the above copyright notice appear in
- all copies and that both that the copyright notice and this
- permission notice and warranty disclaimer appear in supporting
- documentation, and that the name of the author not be used in
- advertising or publicity pertaining to distribution of the
- software without specific, written prior permission.
-
- The author disclaim all warranties with regard to this
- software, including all implied warranties of merchantability
- and fitness. In no event shall the author be liable for any
- special, indirect or consequential damages or any damages
- whatsoever resulting from loss of use, data or profits, whether
- in an action of contract, negligence or other tortious action,
- arising out of or in connection with the use or performance of
- this software.
-*/
-
-/** \file
- * \brief USB endpoint/pipe stream callback management.
- *
- * This file contains definitions for the creation of optional callback routines which can be passed to the
- * endpoint and/or pipe stream APIs, to abort the transfer currently in progress when a condition is met.
- *
- * \note This file should not be included directly. It is automatically included as needed by the USB driver
- * dispatch header located in LUFA/Drivers/USB/USB.h.
- */
-
-/** \ingroup Group_USB
- * @defgroup Group_StreamCallbacks Endpoint and Pipe Stream Callbacks
- *
- * Macros and enums for the stream callback routines. This module contains the code required to easily set up
- * stream callback functions which can be used to force early abort of a stream read/write process. Each callback
- * should take no arguments, and return a value from the \ref StreamCallback_Return_ErrorCodes_t enum.
- *
- * @{
- */
-
-#ifndef __STREAMCALLBACK_H__
-#define __STREAMCALLBACK_H__
-
- /* Preprocessor Checks: */
- #if !defined(__INCLUDE_FROM_USB_DRIVER)
- #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.
- #endif
-
- /* Public Interface - May be used in end-application: */
- /* Macros: */
- /** Used with the Endpoint and Pipe stream functions as the callback function parameter, indicating that the stream
- * call has no callback function to be called between USB packets.
- */
- #define NO_STREAM_CALLBACK NULL
-
- /* Enums: */
- /** Enum for the possible error return codes of a stream callback function */
- enum StreamCallback_Return_ErrorCodes_t
- {
- STREAMCALLBACK_Continue = 0, /**< Continue sending or receiving the stream. */
- STREAMCALLBACK_Abort = 1, /**< Abort the stream send or receiving process. */
- };
-
- /* Type Defines: */
- /** Type define for a Stream Callback function (function taking no arguments and retuning a
- * uint8_t value). Stream callback functions should have an identical function signature if they
- * are to be used as the callback parameter of the stream functions.
- */
- typedef uint8_t (* const StreamCallbackPtr_t)(void);
-
-#endif
-
-/** @} */
+/*
+ LUFA Library
+ Copyright (C) Dean Camera, 2010.
+
+ dean [at] fourwalledcubicle [dot] com
+ www.fourwalledcubicle.com
+*/
+
+/*
+ Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
+
+ Permission to use, copy, modify, distribute, and sell this
+ software and its documentation for any purpose is hereby granted
+ without fee, provided that the above copyright notice appear in
+ all copies and that both that the copyright notice and this
+ permission notice and warranty disclaimer appear in supporting
+ documentation, and that the name of the author not be used in
+ advertising or publicity pertaining to distribution of the
+ software without specific, written prior permission.
+
+ The author disclaim all warranties with regard to this
+ software, including all implied warranties of merchantability
+ and fitness. In no event shall the author be liable for any
+ special, indirect or consequential damages or any damages
+ whatsoever resulting from loss of use, data or profits, whether
+ in an action of contract, negligence or other tortious action,
+ arising out of or in connection with the use or performance of
+ this software.
+*/
+
+/** \file
+ * \brief USB endpoint/pipe stream callback management.
+ *
+ * This file contains definitions for the creation of optional callback routines which can be passed to the
+ * endpoint and/or pipe stream APIs, to abort the transfer currently in progress when a condition is met.
+ *
+ * \note This file should not be included directly. It is automatically included as needed by the USB driver
+ * dispatch header located in LUFA/Drivers/USB/USB.h.
+ */
+
+/** \ingroup Group_USB
+ * @defgroup Group_StreamCallbacks Endpoint and Pipe Stream Callbacks
+ *
+ * Macros and enums for the stream callback routines. This module contains the code required to easily set up
+ * stream callback functions which can be used to force early abort of a stream read/write process. Each callback
+ * should take no arguments, and return a value from the \ref StreamCallback_Return_ErrorCodes_t enum.
+ *
+ * @{
+ */
+
+#ifndef __STREAMCALLBACK_H__
+#define __STREAMCALLBACK_H__
+
+ /* Preprocessor Checks: */
+ #if !defined(__INCLUDE_FROM_USB_DRIVER)
+ #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.
+ #endif
+
+ /* Public Interface - May be used in end-application: */
+ /* Macros: */
+ /** Used with the Endpoint and Pipe stream functions as the callback function parameter, indicating that the stream
+ * call has no callback function to be called between USB packets.
+ */
+ #define NO_STREAM_CALLBACK NULL
+
+ /* Enums: */
+ /** Enum for the possible error return codes of a stream callback function */
+ enum StreamCallback_Return_ErrorCodes_t
+ {
+ STREAMCALLBACK_Continue = 0, /**< Continue sending or receiving the stream. */
+ STREAMCALLBACK_Abort = 1, /**< Abort the stream send or receiving process. */
+ };
+
+ /* Type Defines: */
+ /** Type define for a Stream Callback function (function taking no arguments and retuning a
+ * uint8_t value). Stream callback functions should have an identical function signature if they
+ * are to be used as the callback parameter of the stream functions.
+ */
+ typedef uint8_t (* const StreamCallbackPtr_t)(void);
+
+#endif
+
+/** @} */
diff --git a/LUFA/Drivers/USB/HighLevel/USBMode.h b/LUFA/Drivers/USB/HighLevel/USBMode.h
index d894bbad7..1de2ef9bb 100644
--- a/LUFA/Drivers/USB/HighLevel/USBMode.h
+++ b/LUFA/Drivers/USB/HighLevel/USBMode.h
@@ -1,138 +1,138 @@
-/*
- LUFA Library
- Copyright (C) Dean Camera, 2010.
-
- dean [at] fourwalledcubicle [dot] com
- www.fourwalledcubicle.com
-*/
-
-/*
- Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
-
- Permission to use, copy, modify, distribute, and sell this
- software and its documentation for any purpose is hereby granted
- without fee, provided that the above copyright notice appear in
- all copies and that both that the copyright notice and this
- permission notice and warranty disclaimer appear in supporting
- documentation, and that the name of the author not be used in
- advertising or publicity pertaining to distribution of the
- software without specific, written prior permission.
-
- The author disclaim all warranties with regard to this
- software, including all implied warranties of merchantability
- and fitness. In no event shall the author be liable for any
- special, indirect or consequential damages or any damages
- whatsoever resulting from loss of use, data or profits, whether
- in an action of contract, negligence or other tortious action,
- arising out of or in connection with the use or performance of
- this software.
-*/
-
-/** \file
- * \brief USB mode and capability macros.
- *
- * This file defines macros indicating the type of USB controller the library is being compiled for, and its
- * capabilities. These macros may then be referenced in the user application to selectively enable or disable
- * code sections depending on if they are defined or not.
- *
- * \note This file should not be included directly. It is automatically included as needed by the USB driver
- * dispatch header located in LUFA/Drivers/USB/USB.h.
- */
-
-/** \ingroup Group_USB
- * @defgroup Group_USBMode USB Mode Tokens
- *
- * After the inclusion of the master USB driver header, one or more of the following
- * tokens may be defined, to allow the user code to conditionally enable or disable
- * code based on the USB controller family and allowable USB modes. These tokens may
- * be tested against to eliminate code relating to a USB mode which is not enabled for
- * the given compilation.
- *
- * @{
- */
-
-#ifndef __USBMODE_H__
-#define __USBMODE_H__
-
- /* Preprocessor Checks: */
- #if !defined(__INCLUDE_FROM_USB_DRIVER)
- #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.
- #endif
-
- /* Public Interface - May be used in end-application: */
- #if defined(__DOXYGEN__)
- /** Indicates that the target AVR microcontroller belongs to the Series 2 USB controller
- * (i.e. AT90USBXXX2 or ATMEGAXXU2) when defined.
- */
- #define USB_SERIES_2_AVR
-
- /** Indicates that the target AVR microcontroller belongs to the Series 4 USB controller
- * (i.e. ATMEGAXXU4) when defined.
- */
- #define USB_SERIES_4_AVR
-
- /** Indicates that the target AVR microcontroller belongs to the Series 6 USB controller
- * (i.e. AT90USBXXX6) when defined.
- */
- #define USB_SERIES_6_AVR
-
- /** Indicates that the target AVR microcontroller belongs to the Series 7 USB controller
- * (i.e. AT90USBXXX7) when defined.
- */
- #define USB_SERIES_7_AVR
-
- /** Indicates that the target AVR microcontroller and compilation settings allow for the
- * target to be configured in USB Device mode when defined.
- */
- #define USB_CAN_BE_DEVICE
-
- /** Indicates that the target AVR microcontroller and compilation settings allow for the
- * target to be configured in USB Host mode when defined.
- */
- #define USB_CAN_BE_HOST
-
- /** Indicates that the target AVR microcontroller and compilation settings allow for the
- * target to be configured in either USB Device or Host mode when defined.
- */
- #define USB_CAN_BE_BOTH
- #else
- /* Macros: */
- #if (defined(__AVR_AT90USB162__) || defined(__AVR_AT90USB82__) || \
- defined(__AVR_ATmega32U2__) || defined(__AVR_ATmega16U2__) || defined(__AVR_ATmega8U2__))
- #define USB_SERIES_2_AVR
- #elif (defined(__AVR_ATmega32U4__) || defined(__AVR_ATmega16U4__))
- #define USB_SERIES_4_AVR
- #elif (defined(__AVR_ATmega32U6__) || defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB1286__))
- #define USB_SERIES_6_AVR
- #elif (defined(__AVR_AT90USB647__) || defined(__AVR_AT90USB1287__))
- #define USB_SERIES_7_AVR
- #endif
-
- #if !defined(USB_SERIES_7_AVR)
- #if defined(USB_HOST_ONLY)
- #error USB_HOST_ONLY is not available for the currently selected USB AVR model.
- #endif
-
- #if !defined(USB_DEVICE_ONLY)
- #define USB_DEVICE_ONLY
- #endif
- #endif
-
- #if (!defined(USB_DEVICE_ONLY) && !defined(USB_HOST_ONLY))
- #define USB_CAN_BE_BOTH
- #define USB_CAN_BE_HOST
- #define USB_CAN_BE_DEVICE
- #elif defined(USB_HOST_ONLY)
- #define USB_CAN_BE_HOST
- #elif defined(USB_DEVICE_ONLY)
- #define USB_CAN_BE_DEVICE
- #endif
-
- #if (defined(USB_HOST_ONLY) && defined(USB_DEVICE_ONLY))
- #error USB_HOST_ONLY and USB_DEVICE_ONLY are mutually exclusive.
- #endif
- #endif
-
-#endif
-
+/*
+ LUFA Library
+ Copyright (C) Dean Camera, 2010.
+
+ dean [at] fourwalledcubicle [dot] com
+ www.fourwalledcubicle.com
+*/
+
+/*
+ Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
+
+ Permission to use, copy, modify, distribute, and sell this
+ software and its documentation for any purpose is hereby granted
+ without fee, provided that the above copyright notice appear in
+ all copies and that both that the copyright notice and this
+ permission notice and warranty disclaimer appear in supporting
+ documentation, and that the name of the author not be used in
+ advertising or publicity pertaining to distribution of the
+ software without specific, written prior permission.
+
+ The author disclaim all warranties with regard to this
+ software, including all implied warranties of merchantability
+ and fitness. In no event shall the author be liable for any
+ special, indirect or consequential damages or any damages
+ whatsoever resulting from loss of use, data or profits, whether
+ in an action of contract, negligence or other tortious action,
+ arising out of or in connection with the use or performance of
+ this software.
+*/
+
+/** \file
+ * \brief USB mode and capability macros.
+ *
+ * This file defines macros indicating the type of USB controller the library is being compiled for, and its
+ * capabilities. These macros may then be referenced in the user application to selectively enable or disable
+ * code sections depending on if they are defined or not.
+ *
+ * \note This file should not be included directly. It is automatically included as needed by the USB driver
+ * dispatch header located in LUFA/Drivers/USB/USB.h.
+ */
+
+/** \ingroup Group_USB
+ * @defgroup Group_USBMode USB Mode Tokens
+ *
+ * After the inclusion of the master USB driver header, one or more of the following
+ * tokens may be defined, to allow the user code to conditionally enable or disable
+ * code based on the USB controller family and allowable USB modes. These tokens may
+ * be tested against to eliminate code relating to a USB mode which is not enabled for
+ * the given compilation.
+ *
+ * @{
+ */
+
+#ifndef __USBMODE_H__
+#define __USBMODE_H__
+
+ /* Preprocessor Checks: */
+ #if !defined(__INCLUDE_FROM_USB_DRIVER)
+ #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.
+ #endif
+
+ /* Public Interface - May be used in end-application: */
+ #if defined(__DOXYGEN__)
+ /** Indicates that the target AVR microcontroller belongs to the Series 2 USB controller
+ * (i.e. AT90USBXXX2 or ATMEGAXXU2) when defined.
+ */
+ #define USB_SERIES_2_AVR
+
+ /** Indicates that the target AVR microcontroller belongs to the Series 4 USB controller
+ * (i.e. ATMEGAXXU4) when defined.
+ */
+ #define USB_SERIES_4_AVR
+
+ /** Indicates that the target AVR microcontroller belongs to the Series 6 USB controller
+ * (i.e. AT90USBXXX6) when defined.
+ */
+ #define USB_SERIES_6_AVR
+
+ /** Indicates that the target AVR microcontroller belongs to the Series 7 USB controller
+ * (i.e. AT90USBXXX7) when defined.
+ */
+ #define USB_SERIES_7_AVR
+
+ /** Indicates that the target AVR microcontroller and compilation settings allow for the
+ * target to be configured in USB Device mode when defined.
+ */
+ #define USB_CAN_BE_DEVICE
+
+ /** Indicates that the target AVR microcontroller and compilation settings allow for the
+ * target to be configured in USB Host mode when defined.
+ */
+ #define USB_CAN_BE_HOST
+
+ /** Indicates that the target AVR microcontroller and compilation settings allow for the
+ * target to be configured in either USB Device or Host mode when defined.
+ */
+ #define USB_CAN_BE_BOTH
+ #else
+ /* Macros: */
+ #if (defined(__AVR_AT90USB162__) || defined(__AVR_AT90USB82__) || \
+ defined(__AVR_ATmega32U2__) || defined(__AVR_ATmega16U2__) || defined(__AVR_ATmega8U2__))
+ #define USB_SERIES_2_AVR
+ #elif (defined(__AVR_ATmega32U4__) || defined(__AVR_ATmega16U4__))
+ #define USB_SERIES_4_AVR
+ #elif (defined(__AVR_ATmega32U6__) || defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB1286__))
+ #define USB_SERIES_6_AVR
+ #elif (defined(__AVR_AT90USB647__) || defined(__AVR_AT90USB1287__))
+ #define USB_SERIES_7_AVR
+ #endif
+
+ #if !defined(USB_SERIES_7_AVR)
+ #if defined(USB_HOST_ONLY)
+ #error USB_HOST_ONLY is not available for the currently selected USB AVR model.
+ #endif
+
+ #if !defined(USB_DEVICE_ONLY)
+ #define USB_DEVICE_ONLY
+ #endif
+ #endif
+
+ #if (!defined(USB_DEVICE_ONLY) && !defined(USB_HOST_ONLY))
+ #define USB_CAN_BE_BOTH
+ #define USB_CAN_BE_HOST
+ #define USB_CAN_BE_DEVICE
+ #elif defined(USB_HOST_ONLY)
+ #define USB_CAN_BE_HOST
+ #elif defined(USB_DEVICE_ONLY)
+ #define USB_CAN_BE_DEVICE
+ #endif
+
+ #if (defined(USB_HOST_ONLY) && defined(USB_DEVICE_ONLY))
+ #error USB_HOST_ONLY and USB_DEVICE_ONLY are mutually exclusive.
+ #endif
+ #endif
+
+#endif
+
/** @} */ \ No newline at end of file
diff --git a/LUFA/Drivers/USB/HighLevel/USBTask.c b/LUFA/Drivers/USB/HighLevel/USBTask.c
index afddcc1e5..5ec1746fd 100644
--- a/LUFA/Drivers/USB/HighLevel/USBTask.c
+++ b/LUFA/Drivers/USB/HighLevel/USBTask.c
@@ -1,88 +1,88 @@
-/*
- LUFA Library
- Copyright (C) Dean Camera, 2010.
-
- dean [at] fourwalledcubicle [dot] com
- www.fourwalledcubicle.com
-*/
-
-/*
- Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
-
- Permission to use, copy, modify, distribute, and sell this
- software and its documentation for any purpose is hereby granted
- without fee, provided that the above copyright notice appear in
- all copies and that both that the copyright notice and this
- permission notice and warranty disclaimer appear in supporting
- documentation, and that the name of the author not be used in
- advertising or publicity pertaining to distribution of the
- software without specific, written prior permission.
-
- The author disclaim all warranties with regard to this
- software, including all implied warranties of merchantability
- and fitness. In no event shall the author be liable for any
- special, indirect or consequential damages or any damages
- whatsoever resulting from loss of use, data or profits, whether
- in an action of contract, negligence or other tortious action,
- arising out of or in connection with the use or performance of
- this software.
-*/
-
-#define __INCLUDE_FROM_USBTASK_C
-#define __INCLUDE_FROM_USB_DRIVER
-#include "USBTask.h"
-
-volatile bool USB_IsInitialized;
-USB_Request_Header_t USB_ControlRequest;
-
-#if defined(USB_CAN_BE_HOST) && !defined(HOST_STATE_AS_GPIOR)
-volatile uint8_t USB_HostState;
-#endif
-
-#if defined(USB_CAN_BE_DEVICE) && !defined(DEVICE_STATE_AS_GPIOR)
-volatile uint8_t USB_DeviceState;
-#endif
-
-void USB_USBTask(void)
-{
- #if defined(USB_HOST_ONLY)
- USB_HostTask();
- #elif defined(USB_DEVICE_ONLY)
- USB_DeviceTask();
- #else
- if (USB_CurrentMode == USB_MODE_DEVICE)
- USB_DeviceTask();
- else if (USB_CurrentMode == USB_MODE_HOST)
- USB_HostTask();
- #endif
-}
-
-#if defined(USB_CAN_BE_DEVICE)
-static void USB_DeviceTask(void)
-{
- if (USB_DeviceState != DEVICE_STATE_Unattached)
- {
- uint8_t PrevEndpoint = Endpoint_GetCurrentEndpoint();
-
- Endpoint_SelectEndpoint(ENDPOINT_CONTROLEP);
-
- if (Endpoint_IsSETUPReceived())
- USB_Device_ProcessControlRequest();
-
- Endpoint_SelectEndpoint(PrevEndpoint);
- }
-}
-#endif
-
-#if defined(USB_CAN_BE_HOST)
-static void USB_HostTask(void)
-{
- uint8_t PrevPipe = Pipe_GetCurrentPipe();
-
- Pipe_SelectPipe(PIPE_CONTROLPIPE);
-
- USB_Host_ProcessNextHostState();
-
- Pipe_SelectPipe(PrevPipe);
-}
-#endif
+/*
+ LUFA Library
+ Copyright (C) Dean Camera, 2010.
+
+ dean [at] fourwalledcubicle [dot] com
+ www.fourwalledcubicle.com
+*/
+
+/*
+ Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
+
+ Permission to use, copy, modify, distribute, and sell this
+ software and its documentation for any purpose is hereby granted
+ without fee, provided that the above copyright notice appear in
+ all copies and that both that the copyright notice and this
+ permission notice and warranty disclaimer appear in supporting
+ documentation, and that the name of the author not be used in
+ advertising or publicity pertaining to distribution of the
+ software without specific, written prior permission.
+
+ The author disclaim all warranties with regard to this
+ software, including all implied warranties of merchantability
+ and fitness. In no event shall the author be liable for any
+ special, indirect or consequential damages or any damages
+ whatsoever resulting from loss of use, data or profits, whether
+ in an action of contract, negligence or other tortious action,
+ arising out of or in connection with the use or performance of
+ this software.
+*/
+
+#define __INCLUDE_FROM_USBTASK_C
+#define __INCLUDE_FROM_USB_DRIVER
+#include "USBTask.h"
+
+volatile bool USB_IsInitialized;
+USB_Request_Header_t USB_ControlRequest;
+
+#if defined(USB_CAN_BE_HOST) && !defined(HOST_STATE_AS_GPIOR)
+volatile uint8_t USB_HostState;
+#endif
+
+#if defined(USB_CAN_BE_DEVICE) && !defined(DEVICE_STATE_AS_GPIOR)
+volatile uint8_t USB_DeviceState;
+#endif
+
+void USB_USBTask(void)
+{
+ #if defined(USB_HOST_ONLY)
+ USB_HostTask();
+ #elif defined(USB_DEVICE_ONLY)
+ USB_DeviceTask();
+ #else
+ if (USB_CurrentMode == USB_MODE_DEVICE)
+ USB_DeviceTask();
+ else if (USB_CurrentMode == USB_MODE_HOST)
+ USB_HostTask();
+ #endif
+}
+
+#if defined(USB_CAN_BE_DEVICE)
+static void USB_DeviceTask(void)
+{
+ if (USB_DeviceState != DEVICE_STATE_Unattached)
+ {
+ uint8_t PrevEndpoint = Endpoint_GetCurrentEndpoint();
+
+ Endpoint_SelectEndpoint(ENDPOINT_CONTROLEP);
+
+ if (Endpoint_IsSETUPReceived())
+ USB_Device_ProcessControlRequest();
+
+ Endpoint_SelectEndpoint(PrevEndpoint);
+ }
+}
+#endif
+
+#if defined(USB_CAN_BE_HOST)
+static void USB_HostTask(void)
+{
+ uint8_t PrevPipe = Pipe_GetCurrentPipe();
+
+ Pipe_SelectPipe(PIPE_CONTROLPIPE);
+
+ USB_Host_ProcessNextHostState();
+
+ Pipe_SelectPipe(PrevPipe);
+}
+#endif
diff --git a/LUFA/Drivers/USB/HighLevel/USBTask.h b/LUFA/Drivers/USB/HighLevel/USBTask.h
index 5246bf60e..1637fb416 100644
--- a/LUFA/Drivers/USB/HighLevel/USBTask.h
+++ b/LUFA/Drivers/USB/HighLevel/USBTask.h
@@ -1,204 +1,204 @@
-/*
- LUFA Library
- Copyright (C) Dean Camera, 2010.
-
- dean [at] fourwalledcubicle [dot] com
- www.fourwalledcubicle.com
-*/
-
-/*
- Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
-
- Permission to use, copy, modify, distribute, and sell this
- software and its documentation for any purpose is hereby granted
- without fee, provided that the above copyright notice appear in
- all copies and that both that the copyright notice and this
- permission notice and warranty disclaimer appear in supporting
- documentation, and that the name of the author not be used in
- advertising or publicity pertaining to distribution of the
- software without specific, written prior permission.
-
- The author disclaim all warranties with regard to this
- software, including all implied warranties of merchantability
- and fitness. In no event shall the author be liable for any
- special, indirect or consequential damages or any damages
- whatsoever resulting from loss of use, data or profits, whether
- in an action of contract, negligence or other tortious action,
- arising out of or in connection with the use or performance of
- this software.
-*/
-
-/** \file
- * \brief Main USB service task management.
- *
- * This file contains the function definitions required for the main USB service task, which must be called
- * from the user application to ensure that the USB connection to or from a connected USB device is maintained.
- *
- * \note This file should not be included directly. It is automatically included as needed by the USB driver
- * dispatch header located in LUFA/Drivers/USB/USB.h.
- */
-
-#ifndef __USBTASK_H__
-#define __USBTASK_H__
-
- /* Includes: */
- #include <avr/io.h>
- #include <avr/interrupt.h>
- #include <stdbool.h>
-
- #include "../LowLevel/LowLevel.h"
- #include "Events.h"
- #include "StdRequestType.h"
- #include "StdDescriptors.h"
- #include "USBMode.h"
-
- #if defined(USB_CAN_BE_DEVICE)
- #include "../LowLevel/DevChapter9.h"
- #endif
-
- #if defined(USB_CAN_BE_HOST)
- #include "../LowLevel/HostChapter9.h"
- #endif
-
- /* Enable C linkage for C++ Compilers: */
- #if defined(__cplusplus)
- extern "C" {
- #endif
-
- /* Preprocessor Checks: */
- #if !defined(__INCLUDE_FROM_USB_DRIVER)
- #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.
- #endif
-
- /* Public Interface - May be used in end-application: */
- /* Global Variables: */
- /** Indicates if the USB interface is currently initialized but not necessarily connected to a host
- * or device (i.e. if \ref USB_Init() has been run). If this is false, all other library globals are invalid.
- *
- * \note This variable should be treated as read-only in the user application, and never manually
- * changed in value.
- *
- * \ingroup Group_USBManagement
- */
- extern volatile bool USB_IsInitialized;
-
- /** Structure containing the last received Control request when in Device mode (for use in user-applications
- * inside of the \ref EVENT_USB_Device_UnhandledControlRequest() event, or for filling up with a control request to issue when
- * in Host mode before calling \ref USB_Host_SendControlRequest().
- *
- * \ingroup Group_USBManagement
- */
- extern USB_Request_Header_t USB_ControlRequest;
-
- #if defined(USB_CAN_BE_HOST) || defined(__DOXYGEN__)
- #if !defined(HOST_STATE_AS_GPIOR) || defined(__DOXYGEN__)
- /** Indicates the current host state machine state. When in host mode, this indicates the state
- * via one of the values of the \ref USB_Host_States_t enum values.
- *
- * This value may be altered by the user application to implement the \ref HOST_STATE_Addressed,
- * \ref HOST_STATE_Configured and \ref HOST_STATE_Suspended states which are not implemented by
- * the library.
- *
- * To reduce program size and speed up checks of this global, it can be placed into one of the AVR's
- * GPIOR hardware registers instead of RAM by defining the HOST_STATE_AS_GPIOR token to a value
- * between 0 and 2 in the project makefile and passing it to the compiler via the -D switch. When
- * defined, the corresponding GPIOR register should not be used in the user application except
- * implicitly via the library APIs.
- *
- * \note This global is only present if the user application can be a USB host.
- *
- * \see \ref USB_Host_States_t for a list of possible device states
- *
- * \ingroup Group_Host
- */
- extern volatile uint8_t USB_HostState;
- #else
- #define _GET_HOST_GPIOR_NAME2(y) GPIOR ## y
- #define _GET_HOST_GPIOR_NAME(x) _GET_HOST_GPIOR_NAME2(x)
- #define USB_HostState _GET_HOST_GPIOR_NAME(HOST_STATE_AS_GPIOR)
- #endif
- #endif
-
- #if defined(USB_CAN_BE_DEVICE) || defined(__DOXYGEN__)
- #if !defined(DEVICE_STATE_AS_GPIOR) || defined(__DOXYGEN__)
- /** Indicates the current device state machine state. When in device mode, this indicates the state
- * via one of the values of the \ref USB_Device_States_t enum values.
- *
- * This value should not be altered by the user application as it is handled automatically by the
- * library. The only exception to this rule is if the NO_LIMITED_CONTROLLER_CONNECT token is used
- * (see \ref EVENT_USB_Device_Connect() and \ref EVENT_USB_Device_Disconnect() events).
- *
- * To reduce program size and speed up checks of this global, it can be placed into one of the AVR's
- * GPIOR hardware registers instead of RAM by defining the DEVICE_STATE_AS_GPIOR token to a value
- * between 0 and 2 in the project makefile and passing it to the compiler via the -D switch. When
- * defined, the corresponding GPIOR register should not be used in the user application except
- * implicitly via the library APIs.
- *
- * \note This global is only present if the user application can be a USB device.
- * \n\n
- *
- * \note This variable should be treated as read-only in the user application, and never manually
- * changed in value except in the circumstances outlined above.
- *
- * \see \ref USB_Device_States_t for a list of possible device states
- *
- * \ingroup Group_Device
- */
- extern volatile uint8_t USB_DeviceState;
- #else
- #define _GET_DEVICE_GPIOR_NAME2(y) GPIOR ## y
- #define _GET_DEVICE_GPIOR_NAME(x) _GET_DEVICE_GPIOR_NAME2(x)
- #define USB_DeviceState _GET_DEVICE_GPIOR_NAME(DEVICE_STATE_AS_GPIOR)
- #endif
- #endif
-
- /* Function Prototypes: */
- /** This is the main USB management task. The USB driver requires that this task be executed
- * continuously when the USB system is active (device attached in host mode, or attached to a host
- * in device mode) in order to manage USB communications. This task may be executed inside an RTOS,
- * fast timer ISR or the main user application loop.
- *
- * The USB task must be serviced within 30ms while in device mode, or within 1ms while in host mode.
- * The task may be serviced at all times, or (for minimum CPU consumption):
- *
- * - In device mode, it may be disabled at start-up, enabled on the firing of the \ref EVENT_USB_Device_Connect()
- * event and disabled again on the firing of the \ref EVENT_USB_Device_Disconnect() event.
- *
- * - In host mode, it may be disabled at start-up, enabled on the firing of the \ref EVENT_USB_Host_DeviceAttached()
- * event and disabled again on the firing of the \ref EVENT_USB_Host_DeviceEnumerationComplete() or
- * \ref EVENT_USB_Host_DeviceEnumerationFailed() events.
- *
- * If in device mode (only), the control endpoint can instead be managed via interrupts entirely by the library
- * by defining the INTERRUPT_CONTROL_ENDPOINT token and passing it to the compiler via the -D switch.
- *
- * \see \ref Group_Events for more information on the USB events.
- *
- * \ingroup Group_USBManagement
- */
- void USB_USBTask(void);
-
- /* Private Interface - For use in library only: */
- #if !defined(__DOXYGEN__)
- /* Function Prototypes: */
- #if defined(__INCLUDE_FROM_USBTASK_C)
- #if defined(USB_CAN_BE_HOST)
- static void USB_HostTask(void);
- #endif
-
- #if defined(USB_CAN_BE_DEVICE)
- static void USB_DeviceTask(void);
- #endif
- #endif
-
- /* Macros: */
- #define HOST_TASK_NONBLOCK_WAIT(duration, nextstate) MACROS{ USB_HostState = HOST_STATE_WaitForDevice; \
- WaitMSRemaining = (duration); \
- PostWaitState = (nextstate); }MACROE
- #endif
-
- /* Disable C linkage for C++ Compilers: */
- #if defined(__cplusplus)
- }
- #endif
-
-#endif
+/*
+ LUFA Library
+ Copyright (C) Dean Camera, 2010.
+
+ dean [at] fourwalledcubicle [dot] com
+ www.fourwalledcubicle.com
+*/
+
+/*
+ Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
+
+ Permission to use, copy, modify, distribute, and sell this
+ software and its documentation for any purpose is hereby granted
+ without fee, provided that the above copyright notice appear in
+ all copies and that both that the copyright notice and this
+ permission notice and warranty disclaimer appear in supporting
+ documentation, and that the name of the author not be used in
+ advertising or publicity pertaining to distribution of the
+ software without specific, written prior permission.
+
+ The author disclaim all warranties with regard to this
+ software, including all implied warranties of merchantability
+ and fitness. In no event shall the author be liable for any
+ special, indirect or consequential damages or any damages
+ whatsoever resulting from loss of use, data or profits, whether
+ in an action of contract, negligence or other tortious action,
+ arising out of or in connection with the use or performance of
+ this software.
+*/
+
+/** \file
+ * \brief Main USB service task management.
+ *
+ * This file contains the function definitions required for the main USB service task, which must be called
+ * from the user application to ensure that the USB connection to or from a connected USB device is maintained.
+ *
+ * \note This file should not be included directly. It is automatically included as needed by the USB driver
+ * dispatch header located in LUFA/Drivers/USB/USB.h.
+ */
+
+#ifndef __USBTASK_H__
+#define __USBTASK_H__
+
+ /* Includes: */
+ #include <avr/io.h>
+ #include <avr/interrupt.h>
+ #include <stdbool.h>
+
+ #include "../LowLevel/LowLevel.h"
+ #include "Events.h"
+ #include "StdRequestType.h"
+ #include "StdDescriptors.h"
+ #include "USBMode.h"
+
+ #if defined(USB_CAN_BE_DEVICE)
+ #include "../LowLevel/DevChapter9.h"
+ #endif
+
+ #if defined(USB_CAN_BE_HOST)
+ #include "../LowLevel/HostChapter9.h"
+ #endif
+
+ /* Enable C linkage for C++ Compilers: */
+ #if defined(__cplusplus)
+ extern "C" {
+ #endif
+
+ /* Preprocessor Checks: */
+ #if !defined(__INCLUDE_FROM_USB_DRIVER)
+ #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.
+ #endif
+
+ /* Public Interface - May be used in end-application: */
+ /* Global Variables: */
+ /** Indicates if the USB interface is currently initialized but not necessarily connected to a host
+ * or device (i.e. if \ref USB_Init() has been run). If this is false, all other library globals are invalid.
+ *
+ * \note This variable should be treated as read-only in the user application, and never manually
+ * changed in value.
+ *
+ * \ingroup Group_USBManagement
+ */
+ extern volatile bool USB_IsInitialized;
+
+ /** Structure containing the last received Control request when in Device mode (for use in user-applications
+ * inside of the \ref EVENT_USB_Device_UnhandledControlRequest() event, or for filling up with a control request to issue when
+ * in Host mode before calling \ref USB_Host_SendControlRequest().
+ *
+ * \ingroup Group_USBManagement
+ */
+ extern USB_Request_Header_t USB_ControlRequest;
+
+ #if defined(USB_CAN_BE_HOST) || defined(__DOXYGEN__)
+ #if !defined(HOST_STATE_AS_GPIOR) || defined(__DOXYGEN__)
+ /** Indicates the current host state machine state. When in host mode, this indicates the state
+ * via one of the values of the \ref USB_Host_States_t enum values.
+ *
+ * This value may be altered by the user application to implement the \ref HOST_STATE_Addressed,
+ * \ref HOST_STATE_Configured and \ref HOST_STATE_Suspended states which are not implemented by
+ * the library.
+ *
+ * To reduce program size and speed up checks of this global, it can be placed into one of the AVR's
+ * GPIOR hardware registers instead of RAM by defining the HOST_STATE_AS_GPIOR token to a value
+ * between 0 and 2 in the project makefile and passing it to the compiler via the -D switch. When
+ * defined, the corresponding GPIOR register should not be used in the user application except
+ * implicitly via the library APIs.
+ *
+ * \note This global is only present if the user application can be a USB host.
+ *
+ * \see \ref USB_Host_States_t for a list of possible device states
+ *
+ * \ingroup Group_Host
+ */
+ extern volatile uint8_t USB_HostState;
+ #else
+ #define _GET_HOST_GPIOR_NAME2(y) GPIOR ## y
+ #define _GET_HOST_GPIOR_NAME(x) _GET_HOST_GPIOR_NAME2(x)
+ #define USB_HostState _GET_HOST_GPIOR_NAME(HOST_STATE_AS_GPIOR)
+ #endif
+ #endif
+
+ #if defined(USB_CAN_BE_DEVICE) || defined(__DOXYGEN__)
+ #if !defined(DEVICE_STATE_AS_GPIOR) || defined(__DOXYGEN__)
+ /** Indicates the current device state machine state. When in device mode, this indicates the state
+ * via one of the values of the \ref USB_Device_States_t enum values.
+ *
+ * This value should not be altered by the user application as it is handled automatically by the
+ * library. The only exception to this rule is if the NO_LIMITED_CONTROLLER_CONNECT token is used
+ * (see \ref EVENT_USB_Device_Connect() and \ref EVENT_USB_Device_Disconnect() events).
+ *
+ * To reduce program size and speed up checks of this global, it can be placed into one of the AVR's
+ * GPIOR hardware registers instead of RAM by defining the DEVICE_STATE_AS_GPIOR token to a value
+ * between 0 and 2 in the project makefile and passing it to the compiler via the -D switch. When
+ * defined, the corresponding GPIOR register should not be used in the user application except
+ * implicitly via the library APIs.
+ *
+ * \note This global is only present if the user application can be a USB device.
+ * \n\n
+ *
+ * \note This variable should be treated as read-only in the user application, and never manually
+ * changed in value except in the circumstances outlined above.
+ *
+ * \see \ref USB_Device_States_t for a list of possible device states
+ *
+ * \ingroup Group_Device
+ */
+ extern volatile uint8_t USB_DeviceState;
+ #else
+ #define _GET_DEVICE_GPIOR_NAME2(y) GPIOR ## y
+ #define _GET_DEVICE_GPIOR_NAME(x) _GET_DEVICE_GPIOR_NAME2(x)
+ #define USB_DeviceState _GET_DEVICE_GPIOR_NAME(DEVICE_STATE_AS_GPIOR)
+ #endif
+ #endif
+
+ /* Function Prototypes: */
+ /** This is the main USB management task. The USB driver requires that this task be executed
+ * continuously when the USB system is active (device attached in host mode, or attached to a host
+ * in device mode) in order to manage USB communications. This task may be executed inside an RTOS,
+ * fast timer ISR or the main user application loop.
+ *
+ * The USB task must be serviced within 30ms while in device mode, or within 1ms while in host mode.
+ * The task may be serviced at all times, or (for minimum CPU consumption):
+ *
+ * - In device mode, it may be disabled at start-up, enabled on the firing of the \ref EVENT_USB_Device_Connect()
+ * event and disabled again on the firing of the \ref EVENT_USB_Device_Disconnect() event.
+ *
+ * - In host mode, it may be disabled at start-up, enabled on the firing of the \ref EVENT_USB_Host_DeviceAttached()
+ * event and disabled again on the firing of the \ref EVENT_USB_Host_DeviceEnumerationComplete() or
+ * \ref EVENT_USB_Host_DeviceEnumerationFailed() events.
+ *
+ * If in device mode (only), the control endpoint can instead be managed via interrupts entirely by the library
+ * by defining the INTERRUPT_CONTROL_ENDPOINT token and passing it to the compiler via the -D switch.
+ *
+ * \see \ref Group_Events for more information on the USB events.
+ *
+ * \ingroup Group_USBManagement
+ */
+ void USB_USBTask(void);
+
+ /* Private Interface - For use in library only: */
+ #if !defined(__DOXYGEN__)
+ /* Function Prototypes: */
+ #if defined(__INCLUDE_FROM_USBTASK_C)
+ #if defined(USB_CAN_BE_HOST)
+ static void USB_HostTask(void);
+ #endif
+
+ #if defined(USB_CAN_BE_DEVICE)
+ static void USB_DeviceTask(void);
+ #endif
+ #endif
+
+ /* Macros: */
+ #define HOST_TASK_NONBLOCK_WAIT(duration, nextstate) MACROS{ USB_HostState = HOST_STATE_WaitForDevice; \
+ WaitMSRemaining = (duration); \
+ PostWaitState = (nextstate); }MACROE
+ #endif
+
+ /* Disable C linkage for C++ Compilers: */
+ #if defined(__cplusplus)
+ }
+ #endif
+
+#endif