From b095177e2051cdc47620d770ce854c6e9ce3f912 Mon Sep 17 00:00:00 2001 From: Dean Camera Date: Mon, 27 Jan 2014 22:28:53 +1100 Subject: Fix incorrect descriptor length when using USB_STRING_DESCRIPTOR macros. --- LUFA/Drivers/USB/Core/StdDescriptors.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'LUFA') diff --git a/LUFA/Drivers/USB/Core/StdDescriptors.h b/LUFA/Drivers/USB/Core/StdDescriptors.h index d611bf37f..e0a1a37f4 100644 --- a/LUFA/Drivers/USB/Core/StdDescriptors.h +++ b/LUFA/Drivers/USB/Core/StdDescriptors.h @@ -91,13 +91,13 @@ * * \param[in] String String to initialize a USB String Descriptor structure with. */ - #define USB_STRING_DESCRIPTOR(String) { .Header = {.Size = (sizeof(String) - 2), .Type = DTYPE_String}, .UnicodeString = String } + #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((uint16_t){__VA_ARGS__}), .Type = DTYPE_String}, .UnicodeString = {__VA_ARGS__} } + #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. -- cgit v1.2.3