Newer AS7 integration binary, with ASF detection fixes and newer image assets.
[pub/USBasp.git] / LUFA / Drivers / USB / Core / StdDescriptors.h
index d7f0ca3..130b6be 100644 (file)
@@ -1,13 +1,13 @@
 /*
              LUFA Library
-     Copyright (C) Dean Camera, 2013.
+     Copyright (C) Dean Camera, 2015.
 
   dean [at] fourwalledcubicle [dot] com
            www.lufa-lib.org
 */
 
 /*
-  Copyright 2013  Dean Camera (dean [at] fourwalledcubicle [dot] com)
+  Copyright 2015  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
                         */
                        #define USB_STRING_LEN(UnicodeChars)      (sizeof(USB_Descriptor_Header_t) + ((UnicodeChars) << 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.
+                       /** Convenience macro to easily create \ref USB_Descriptor_String_t instances from a wide character string.
+                        *
+                        *  \note This macro is for little-endian systems only.
+                        *
+                        *  \param[in] String  String to initialize a USB String Descriptor structure with.
+                        */
+                       #define USB_STRING_DESCRIPTOR(String)     { .Header = {.Size = sizeof(USB_Descriptor_Header_t) + (sizeof(String) - 2), .Type = DTYPE_String}, .UnicodeString = String }
+
+                       /** Convenience macro to easily create \ref USB_Descriptor_String_t instances from an array of characters.
+                        *
+                        *  \param[in] ...  Characters to initialize a USB String Descriptor structure with.
+                        */
+                       #define USB_STRING_DESCRIPTOR_ARRAY(...)  { .Header = {.Size = sizeof(USB_Descriptor_Header_t) + sizeof((uint16_t){__VA_ARGS__}), .Type = DTYPE_String}, .UnicodeString = {__VA_ARGS__} }
+
+                       /** Macro to encode a given major/minor/revision version number into Binary Coded Decimal format for descriptor
+                        *  fields requiring BCD encoding, such as the USB version number in the standard device descriptor.
                         *
                         *  \note This value is automatically converted into Little Endian, suitable for direct use inside device
                         *        descriptors on all architectures without endianness conversion macros.
                         *
-                        *  \param[in]  x  Version number to encode as a 16-bit little-endian number, as a floating point number.
+                        *  \param[in]  Major     Major version number to encode.
+                        *  \param[in]  Minor     Minor version number to encode.
+                        *  \param[in]  Revision  Revision version number to encode.
                         */
-                       #define VERSION_BCD(x)                    CPU_TO_LE16((VERSION_TENS(x) << 12)  | (VERSION_ONES(x) << 8) | \
-                                                                             (VERSION_TENTHS(x) << 4) | (VERSION_HUNDREDTHS(x) << 0) )
+                       #define VERSION_BCD(Major, Minor, Revision) \
+                                                                 CPU_TO_LE16( ((Major & 0xFF) << 8) | \
+                                                                              ((Minor & 0x0F) << 4) | \
+                                                                              (Revision & 0x0F) )
 
                        /** 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.
                                                     */
                        } ATTR_PACKED USB_StdDescriptor_String_t;
 
-       /* Private Interface - For use in library only: */
-       #if !defined(__DOXYGEN__)
-               /* Macros: */
-                       #define VERSION_TENS(x)                   (int)((int)(x) / 10)
-                       #define VERSION_ONES(x)                   (int)((int)(x) % 10)
-                       #define VERSION_TENTHS(x)                 (int)((x - (int)x) * 10)
-                       #define VERSION_HUNDREDTHS(x)             (int)((x * 100) - ((int)(x * 10) * 10))
-       #endif
 
        /* Disable C linkage for C++ Compilers: */
                #if defined(__cplusplus)