/*\r
LUFA Library\r
- Copyright (C) Dean Camera, 2009.\r
+ Copyright (C) Dean Camera, 2010.\r
\r
dean [at] fourwalledcubicle [dot] com\r
www.fourwalledcubicle.com\r
*/\r
\r
/*\r
- Copyright 2009 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
-\r
- Permission to use, copy, modify, and distribute this software\r
- and its documentation for any purpose and without fee is hereby\r
- granted, provided that the above copyright notice appear in all\r
- copies and that both that the copyright notice and this\r
- permission notice and warranty disclaimer appear in supporting\r
- documentation, and that the name of the author not be used in\r
- advertising or publicity pertaining to distribution of the\r
+ Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this \r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in \r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting \r
+ documentation, and that the name of the author not be used in \r
+ advertising or publicity pertaining to distribution of the \r
software without specific, written prior permission.\r
\r
The author disclaim all warranties with regard to this\r
this software.\r
*/\r
\r
+/** \file\r
+ * \brief USB standard descriptor definitions.\r
+ *\r
+ * This file contains structures and macros for the easy creation of standard USB descriptors in USB device projects.\r
+ *\r
+ * \note This file should not be included directly. It is automatically included as needed by the USB driver\r
+ * dispatch header located in LUFA/Drivers/USB/USB.h.\r
+ */\r
+\r
/** \ingroup Group_USB\r
* @defgroup Group_Descriptors USB Descriptors\r
*\r
/* Includes: */\r
#include <avr/pgmspace.h>\r
#include <stdbool.h>\r
+ #include <stddef.h>\r
\r
#include "../../../Common/Common.h"\r
#include "USBMode.h"\r
extern "C" {\r
#endif\r
\r
+ /* Preprocessor Checks: */\r
+ #if !defined(__INCLUDE_FROM_USB_DRIVER)\r
+ #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.\r
+ #endif\r
+ \r
/* Public Interface - May be used in end-application: */\r
/* Macros: */\r
/** Indicates that a given descriptor does not exist in the device. This can be used inside descriptors\r
#define USE_INTERNAL_SERIAL NO_DESCRIPTOR\r
#endif\r
\r
- /** Macro to calculate the power value for the device descriptor, from a given number of milliamps. */\r
- #define USB_CONFIG_POWER_MA(mA) (mA >> 1)\r
+ /** Macro to calculate the power value for the configuration descriptor, from a given number of milliamps. */\r
+ #define USB_CONFIG_POWER_MA(mA) ((mA) >> 1)\r
\r
/** Macro to calculate the Unicode length of a string with a given number of Unicode characters.\r
* Should be used in string descriptor's headers for giving the string descriptor's byte length.\r
*/\r
- #define USB_STRING_LEN(str) (sizeof(USB_Descriptor_Header_t) + (str << 1))\r
+ #define USB_STRING_LEN(str) (sizeof(USB_Descriptor_Header_t) + ((str) << 1))\r
\r
/** Macro to encode a given four digit floating point version number (e.g. 01.23) into Binary Coded\r
* Decimal format for descriptor fields requiring BCD encoding, such as the USB version number in the\r
* descriptor's ConfigAttributes value to indicate that the specified configuration can draw its power\r
* from the device's own power source.\r
*/\r
- #define USB_CONFIG_ATTR_SELFPOWERED 0xC0\r
+ #define USB_CONFIG_ATTR_SELFPOWERED 0x40\r
\r
/** Can be masked with other configuration descriptor attributes for a \ref USB_Descriptor_Configuration_Header_t\r
* descriptor's ConfigAttributes value to indicate that the specified configuration supports the\r
* remote wakeup feature of the USB standard, allowing a suspended USB device to wake up the host upon\r
* request.\r
*/\r
- #define USB_CONFIG_ATTR_REMOTEWAKEUP 0xA0\r
+ #define USB_CONFIG_ATTR_REMOTEWAKEUP 0x20\r
\r
/** Can be masked with other endpoint descriptor attributes for a \ref USB_Descriptor_Endpoint_t descriptor's\r
* Attributes value to indicate that the specified endpoint is not synchronized.\r
};\r
\r
/* Type Defines: */\r
- /** Type define for all descriptors standard header, indicating the descriptor's length and type. This structure\r
+ /** \brief Standard USB Descriptor Header (LUFA naming conventions).\r
+ *\r
+ * Type define for all descriptors' standard header, indicating the descriptor's length and type. This structure\r
* uses LUFA-specific element names to make each element's purpose clearer.\r
*\r
* \see \ref USB_StdDescriptor_Header_t for the version of this define with standard element names\r
*/\r
} USB_Descriptor_Header_t;\r
\r
- /** Type define for all descriptors standard header, indicating the descriptor's length and type. This structure\r
+ /** \brief Standard USB Descriptor Header (USB-IF naming conventions).\r
+ *\r
+ * Type define for all descriptors' standard header, indicating the descriptor's length and type. This structure\r
* uses the relevant standard's given element names to ensure compatibility with the standard.\r
*\r
* \see \ref USB_Descriptor_Header_t for the version of this define with non-standard LUFA specific element names\r
*/\r
} USB_StdDescriptor_Header_t;\r
\r
- /** Type define for a standard Device Descriptor. This structure uses LUFA-specific element names to make each\r
+ /** \brief Standard USB Device Descriptor (LUFA naming conventions).\r
+ *\r
+ * Type define for a standard Device Descriptor. This structure uses LUFA-specific element names to make each\r
* element's purpose clearer.\r
*\r
* \see \ref USB_StdDescriptor_Device_t for the version of this define with standard element names\r
*/\r
} USB_Descriptor_Device_t;\r
\r
- /** Type define for a standard Device Descriptor. This structure uses the relevant standard's given element names\r
+ /** \brief Standard USB Device Descriptor (USB-IF naming conventions).\r
+ *\r
+ * Type define for a standard Device Descriptor. This structure uses the relevant standard's given element names\r
* to ensure compatibility with the standard.\r
*\r
* \see \ref USB_Descriptor_Device_t for the version of this define with non-standard LUFA specific element names\r
*/\r
} USB_StdDescriptor_Device_t;\r
\r
- /** Type define for a standard Configuration Descriptor header. This structure uses LUFA-specific element names\r
+ /** \brief Standard USB Configuration Descriptor (LUFA naming conventions).\r
+ *\r
+ * Type define for a standard Configuration Descriptor header. This structure uses LUFA-specific element names\r
* to make each element's purpose clearer.\r
*\r
* \see \ref USB_StdDescriptor_Configuration_Header_t for the version of this define with standard element names\r
*/\r
} USB_Descriptor_Configuration_Header_t;\r
\r
- /** Type define for a standard Configuration Descriptor header. This structure uses the relevant standard's given element names\r
+ /** \brief Standard USB Configuration Descriptor (USB-IF naming conventions).\r
+ *\r
+ * Type define for a standard Configuration Descriptor header. This structure uses the relevant standard's given element names\r
* to ensure compatibility with the standard.\r
*\r
* \see \ref USB_Descriptor_Device_t for the version of this define with non-standard LUFA specific element names\r
*/\r
} USB_StdDescriptor_Configuration_Header_t;\r
\r
- /** Type define for a standard Interface Descriptor. This structure uses LUFA-specific element names\r
+ /** \brief Standard USB Interface Descriptor (LUFA naming conventions).\r
+ *\r
+ * Type define for a standard Interface Descriptor. This structure uses LUFA-specific element names\r
* to make each element's purpose clearer.\r
*\r
* \see \ref USB_StdDescriptor_Interface_t for the version of this define with standard element names\r
*/\r
} USB_Descriptor_Interface_t;\r
\r
- /** Type define for a standard Interface Descriptor. This structure uses the relevant standard's given element names\r
+ /** \brief Standard USB Interface Descriptor (USB-IF naming conventions).\r
+ *\r
+ * Type define for a standard Interface Descriptor. This structure uses the relevant standard's given element names\r
* to ensure compatibility with the standard.\r
*\r
* \see \ref USB_Descriptor_Interface_t for the version of this define with non-standard LUFA specific element names\r
*/\r
} USB_StdDescriptor_Interface_t;\r
\r
- /** Type define for a standard Interface Association Descriptor. This structure uses LUFA-specific element names\r
+ /** \brief Standard USB Interface Association Descriptor (LUFA naming conventions).\r
+ *\r
+ * Type define for a standard Interface Association Descriptor. This structure uses LUFA-specific element names\r
* to make each element's purpose clearer.\r
*\r
* This descriptor has been added as a supplement to the USB2.0 standard, in the ECN located at\r
*/\r
} USB_Descriptor_Interface_Association_t;\r
\r
- /** Type define for a standard Interface Association Descriptor. This structure uses the relevant standard's given\r
+ /** \brief Standard USB Interface Association Descriptor (USB-IF naming conventions).\r
+ *\r
+ * Type define for a standard Interface Association Descriptor. This structure uses the relevant standard's given\r
* element names to ensure compatibility with the standard.\r
*\r
* This descriptor has been added as a supplement to the USB2.0 standard, in the ECN located at\r
*/\r
} USB_StdDescriptor_Interface_Association_t;\r
\r
- /** Type define for a standard Endpoint Descriptor. This structure uses LUFA-specific element names\r
+ /** \brief Standard USB Endpoint Descriptor (LUFA naming conventions).\r
+ *\r
+ * Type define for a standard Endpoint Descriptor. This structure uses LUFA-specific element names\r
* to make each element's purpose clearer.\r
*\r
* \see \ref USB_StdDescriptor_Endpoint_t for the version of this define with standard element names\r
*/\r
} USB_Descriptor_Endpoint_t;\r
\r
- /** Type define for a standard Endpoint Descriptor. This structure uses the relevant standard's given\r
+ /** \brief Standard USB Endpoint Descriptor (USB-IF naming conventions).\r
+ *\r
+ * Type define for a standard Endpoint Descriptor. This structure uses the relevant standard's given\r
* element names to ensure compatibility with the standard.\r
*\r
* \see \ref USB_Descriptor_Endpoint_t for the version of this define with non-standard LUFA specific\r
*/\r
} USB_StdDescriptor_Endpoint_t;\r
\r
- /** Type define for a standard string descriptor. Unlike other standard descriptors, the length\r
+ /** \brief Standard USB String Descriptor (LUFA naming conventions).\r
+ *\r
+ * Type define for a standard string descriptor. Unlike other standard descriptors, the length\r
* of the descriptor for placement in the descriptor header must be determined by the \ref USB_STRING_LEN()\r
* macro rather than by the size of the descriptor structure, as the length is not fixed.\r
*\r
{\r
USB_Descriptor_Header_t Header; /**< Descriptor header, including type and size. */\r
\r
- int16_t UnicodeString[]; /**< String data, as unicode characters (alternatively,\r
- * string language IDs). If normal ASCII characters are\r
- * to be used, they must be added as an array of characters\r
- * rather than a normal C string so that they are widened to\r
- * Unicode size.\r
- *\r
- * Under GCC, strings prefixed with the "L" character (before\r
- * the opening string quotation mark) are considered to be\r
- * Unicode strings, and may be used instead of an explicit\r
- * array of ASCII characters.\r
- */\r
+ wchar_t UnicodeString[]; /**< String data, as unicode characters (alternatively,\r
+ * string language IDs). If normal ASCII characters are\r
+ * to be used, they must be added as an array of characters\r
+ * rather than a normal C string so that they are widened to\r
+ * Unicode size.\r
+ *\r
+ * Under GCC, strings prefixed with the "L" character (before\r
+ * the opening string quotation mark) are considered to be\r
+ * Unicode strings, and may be used instead of an explicit\r
+ * array of ASCII characters.\r
+ */\r
} USB_Descriptor_String_t;\r
\r
- /** Type define for a standard string descriptor. Unlike other standard descriptors, the length\r
+ /** \brief Standard USB String Descriptor (USB-IF naming conventions).\r
+ *\r
+ * Type define for a standard string descriptor. Unlike other standard descriptors, the length\r
* of the descriptor for placement in the descriptor header must be determined by the \ref USB_STRING_LEN()\r
* macro rather than by the size of the descriptor structure, as the length is not fixed.\r
*\r
/* Private Interface - For use in library only: */\r
#if !defined(__DOXYGEN__)\r
/* Macros: */\r
- #define VERSION_TENS(x) (int)(x / 10)\r
- #define VERSION_ONES(x) (int)(x - (10 * VERSION_TENS(x)))\r
- #define VERSION_TENTHS(x) (int)((x - (int)x) * 10)\r
- #define VERSION_HUNDREDTHS(x) (int)(((x - (int)x) * 100) - (10 * VERSION_TENTHS(x)))\r
+ #define VERSION_TENS(x) (int)((x) / 10)\r
+ #define VERSION_ONES(x) (int)((x) - (10 * VERSION_TENS(x)))\r
+ #define VERSION_TENTHS(x) (int)(((x) - (int)(x)) * 10)\r
+ #define VERSION_HUNDREDTHS(x) (int)((((x) - (int)(x)) * 100) - (10 * VERSION_TENTHS(x)))\r
#endif\r
\r
/* Disable C linkage for C++ Compilers: */\r