diff options
| author | Dean <Dean@d5102386-fcda-11dd-9fdb-3debd5008f28> | 2011-03-18 04:58:39 +0000 |
|---|---|---|
| committer | Dean <Dean@d5102386-fcda-11dd-9fdb-3debd5008f28> | 2011-03-18 04:58:39 +0000 |
| commit | 733632fd0c0c10115b560eefd085a1f4ecbb43d0 (patch) | |
| tree | afb928c49f72a334bd301f0d451d7fbcade7393d | |
| parent | 9d4d9637beb05bc343f6f908899baffd9fb0eb71 (diff) | |
Oops - Bootloader optimizations to GetDescriptor() don't work, as the Configuration Descriptor's header does not contain the full length of the descriptor, breaking full enumeration.
git-svn-id: http://lufa-lib.googlecode.com/svn/trunk@1719 d5102386-fcda-11dd-9fdb-3debd5008f28
| -rw-r--r-- | Bootloaders/CDC/Descriptors.c | 19 | ||||
| -rw-r--r-- | Bootloaders/DFU/Descriptors.c | 27 | ||||
| -rw-r--r-- | Bootloaders/HID/Descriptors.c | 26 | ||||
| -rw-r--r-- | LUFA/ManPages/FutureChanges.txt | 1 |
4 files changed, 50 insertions, 23 deletions
diff --git a/Bootloaders/CDC/Descriptors.c b/Bootloaders/CDC/Descriptors.c index 8973c4e9..ee2b0aa1 100644 --- a/Bootloaders/CDC/Descriptors.c +++ b/Bootloaders/CDC/Descriptors.c @@ -206,29 +206,38 @@ uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue, const uint8_t wIndex, const void** const DescriptorAddress) { - const uint8_t DescriptorType = (wValue >> 8); - const uint8_t DescriptorNumber = (wValue & 0xFF); + const uint8_t DescriptorType = (wValue >> 8); + const uint8_t DescriptorNumber = (wValue & 0xFF); const void* Address = NULL; + uint16_t Size = NO_DESCRIPTOR; switch (DescriptorType) { case DTYPE_Device: Address = &DeviceDescriptor; + Size = sizeof(USB_Descriptor_Device_t); break; case DTYPE_Configuration: Address = &ConfigurationDescriptor; + Size = sizeof(USB_Descriptor_Configuration_t); break; case DTYPE_String: if (!(DescriptorNumber)) - Address = &LanguageString; + { + Address = &LanguageString; + Size = LanguageString.Header.Size; + } else - Address = &ProductString; + { + Address = &ProductString; + Size = ProductString.Header.Size; + } break; } *DescriptorAddress = Address; - return (Address != NULL) ? ((USB_Descriptor_Header_t*)Address)->Size : NO_DESCRIPTOR; + return Size; } diff --git a/Bootloaders/DFU/Descriptors.c b/Bootloaders/DFU/Descriptors.c index 55449c60..b9c77aa9 100644 --- a/Bootloaders/DFU/Descriptors.c +++ b/Bootloaders/DFU/Descriptors.c @@ -147,29 +147,38 @@ uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue, const uint8_t wIndex, const void** const DescriptorAddress) { - const uint8_t DescriptorType = (wValue >> 8); - const uint8_t DescriptorNumber = (wValue & 0xFF); + const uint8_t DescriptorType = (wValue >> 8); + const uint8_t DescriptorNumber = (wValue & 0xFF); const void* Address = NULL; + uint16_t Size = NO_DESCRIPTOR; switch (DescriptorType) { case DTYPE_Device: Address = &DeviceDescriptor; + Size = sizeof(USB_Descriptor_Device_t); break; - case DTYPE_Configuration: + case DTYPE_Configuration: Address = &ConfigurationDescriptor; + Size = sizeof(USB_Descriptor_Configuration_t); break; - case DTYPE_String: + case DTYPE_String: if (!(DescriptorNumber)) - Address = &LanguageString; + { + Address = &LanguageString; + Size = LanguageString.Header.Size; + } else - Address = &ProductString; - + { + Address = &ProductString; + Size = ProductString.Header.Size; + } + break; } - + *DescriptorAddress = Address; - return (Address != NULL) ? ((USB_Descriptor_Header_t*)Address)->Size : NO_DESCRIPTOR; + return Size; } diff --git a/Bootloaders/HID/Descriptors.c b/Bootloaders/HID/Descriptors.c index f79d3468..fef43ab9 100644 --- a/Bootloaders/HID/Descriptors.c +++ b/Bootloaders/HID/Descriptors.c @@ -154,23 +154,33 @@ uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue, const uint8_t wIndex,
const void** const DescriptorAddress)
{
- const uint8_t DescriptorType = (wValue >> 8);
+ const uint8_t DescriptorType = (wValue >> 8);
const void* Address = NULL;
uint16_t Size = NO_DESCRIPTOR;
+ /* If/Else If chain compiles slightly smaller than a switch case */
if (DescriptorType == DTYPE_Device)
- Address = &DeviceDescriptor;
+ {
+ Address = &DeviceDescriptor;
+ Size = sizeof(USB_Descriptor_Device_t);
+ }
else if (DescriptorType == DTYPE_Configuration)
- Address = &ConfigurationDescriptor;
+ {
+ Address = &ConfigurationDescriptor;
+ Size = sizeof(USB_Descriptor_Configuration_t);
+ }
else if (DescriptorType == HID_DTYPE_HID)
- Address = &ConfigurationDescriptor.HID_VendorHID;
+ {
+ Address = &ConfigurationDescriptor.HID_VendorHID;
+ Size = sizeof(USB_HID_Descriptor_HID_t);
+ }
else
- Address = &HIDReport;
+ {
+ Address = &HIDReport;
+ Size = sizeof(HIDReport);
+ }
- if (Address != NULL)
- Size = (Address == &HIDReport) ? sizeof(HIDReport) : ((USB_Descriptor_Header_t*)Address)->Size;
-
*DescriptorAddress = Address;
return Size;
}
diff --git a/LUFA/ManPages/FutureChanges.txt b/LUFA/ManPages/FutureChanges.txt index 2f6bd974..41424065 100644 --- a/LUFA/ManPages/FutureChanges.txt +++ b/LUFA/ManPages/FutureChanges.txt @@ -17,7 +17,6 @@ * -# Investigate virtual hubs when in device mode instead of composite devices * -# Change makefiles to allow for absolute LUFA location to be used * -# Re-add interrupt Pipe/Endpoint support - * -# Investigate dynamically created device descriptors * -# Add makefile includes to reduce boilerplate in user makefiles * - Documentation/Support * -# Add detailed overviews of how each demo works |
