From dfa547164a1f9aefe202041e61075852f6e47191 Mon Sep 17 00:00:00 2001 From: Dean Camera Date: Fri, 19 Jun 2009 03:37:47 +0000 Subject: Extend USB_GetDeviceConfigDescriptor() routine to require the configuration number within the device to fetch, to add support for multi-configuration devices. --- LUFA/Drivers/USB/Class/Host/CDC.c | 4 ++-- LUFA/Drivers/USB/HighLevel/ConfigDescriptor.c | 4 ++-- LUFA/Drivers/USB/HighLevel/ConfigDescriptor.h | 7 +++++-- LUFA/ManPages/ChangeLog.txt | 2 +- LUFA/ManPages/MigrationInformation.txt | 7 ++++++- 5 files changed, 16 insertions(+), 8 deletions(-) (limited to 'LUFA') diff --git a/LUFA/Drivers/USB/Class/Host/CDC.c b/LUFA/Drivers/USB/Class/Host/CDC.c index 3a572f18f..aef5b3539 100644 --- a/LUFA/Drivers/USB/Class/Host/CDC.c +++ b/LUFA/Drivers/USB/Class/Host/CDC.c @@ -40,7 +40,7 @@ static uint8_t CDC_Host_ProcessConfigDescriptor(USB_ClassInfo_CDC_Host_t* CDCInt uint16_t ConfigDescriptorSize; uint8_t FoundEndpoints = 0; - if (USB_GetDeviceConfigDescriptor(&ConfigDescriptorSize, NULL) != HOST_SENDCONTROL_Successful) + if (USB_GetDeviceConfigDescriptor(1, &ConfigDescriptorSize, NULL) != HOST_SENDCONTROL_Successful) return CDC_ENUMERROR_ControlError; if (ConfigDescriptorSize > 512) @@ -48,7 +48,7 @@ static uint8_t CDC_Host_ProcessConfigDescriptor(USB_ClassInfo_CDC_Host_t* CDCInt ConfigDescriptorData = alloca(ConfigDescriptorSize); - USB_GetDeviceConfigDescriptor(&ConfigDescriptorSize, ConfigDescriptorData); + USB_GetDeviceConfigDescriptor(1, &ConfigDescriptorSize, ConfigDescriptorData); if (DESCRIPTOR_TYPE(ConfigDescriptorData) != DTYPE_Configuration) return CDC_ENUMERROR_InvalidConfigDataReturned; diff --git a/LUFA/Drivers/USB/HighLevel/ConfigDescriptor.c b/LUFA/Drivers/USB/HighLevel/ConfigDescriptor.c index bbe258b3a..47982b806 100644 --- a/LUFA/Drivers/USB/HighLevel/ConfigDescriptor.c +++ b/LUFA/Drivers/USB/HighLevel/ConfigDescriptor.c @@ -31,7 +31,7 @@ #include "ConfigDescriptor.h" #if defined(USB_CAN_BE_HOST) -uint8_t USB_GetDeviceConfigDescriptor(uint16_t* const ConfigSizePtr, void* BufferPtr) +uint8_t USB_GetDeviceConfigDescriptor(uint8_t ConfigNumber, uint16_t* const ConfigSizePtr, void* BufferPtr) { uint8_t ErrorCode; @@ -39,7 +39,7 @@ uint8_t USB_GetDeviceConfigDescriptor(uint16_t* const ConfigSizePtr, void* Buffe { .bmRequestType = (REQDIR_DEVICETOHOST | REQTYPE_STANDARD | REQREC_DEVICE), .bRequest = REQ_GetDescriptor, - .wValue = (DTYPE_Configuration << 8), + .wValue = ((DTYPE_Configuration << 8) | (ConfigNumber - 1)), .wIndex = 0, .wLength = sizeof(USB_Descriptor_Configuration_Header_t), }; diff --git a/LUFA/Drivers/USB/HighLevel/ConfigDescriptor.h b/LUFA/Drivers/USB/HighLevel/ConfigDescriptor.h index 5c2b6e2de..17b6378e9 100644 --- a/LUFA/Drivers/USB/HighLevel/ConfigDescriptor.h +++ b/LUFA/Drivers/USB/HighLevel/ConfigDescriptor.h @@ -182,6 +182,9 @@ /* Function Prototypes: */ /** Retrieves the configuration descriptor data or size from an attached device via a standard request. + * + * \param ConfigNumber Device configuration descriptor number to fetch from the device (usually set to 1 for + * single configuration devices) * * \param ConfigSizePtr Pointer to a uint16_t for either storing or retrieving the configuration * descriptor size @@ -192,8 +195,8 @@ * of bytes indicated by ConfigSizePtr of the configuration descriptor will be loaded * into the buffer */ - uint8_t USB_GetDeviceConfigDescriptor(uint16_t* const ConfigSizePtr, void* BufferPtr) - ATTR_NON_NULL_PTR_ARG(1); + uint8_t USB_GetDeviceConfigDescriptor(uint8_t ConfigNumber, uint16_t* const ConfigSizePtr, void* BufferPtr) + ATTR_NON_NULL_PTR_ARG(2); /** Skips to the next sub-descriptor inside the configuration descriptor of the specified type value. * The bytes remaining value is automatically decremented. diff --git a/LUFA/ManPages/ChangeLog.txt b/LUFA/ManPages/ChangeLog.txt index 3ef3a6e83..464418140 100644 --- a/LUFA/ManPages/ChangeLog.txt +++ b/LUFA/ManPages/ChangeLog.txt @@ -27,7 +27,7 @@ * - Make Pipe_ConfigurePipe() mask the given endpoint number against PIPE_EPNUM_MASK to ensure the endpoint IN direction bit is * cleared to prevent endpoint type corruption * - Fix documentation mentioning Pipe_GetCurrentToken() function when real name is Pipe_GetPipeToken() - * + * - Extend USB_GetDeviceConfigDescriptor() routine to require the configuration number within the device to fetch * * \section Sec_ChangeLog090605 Version 090605 * diff --git a/LUFA/ManPages/MigrationInformation.txt b/LUFA/ManPages/MigrationInformation.txt index ecd4e9e80..d46ddd02b 100644 --- a/LUFA/ManPages/MigrationInformation.txt +++ b/LUFA/ManPages/MigrationInformation.txt @@ -13,13 +13,18 @@ * \section Sec_MigrationXXXXXX Migrating from 090605 to XXXXXX * * All - * - The "Simple Scheduler" has been deprecated, as it was little more than an abtracted loop and caused much confusion. User + * - The "Simple Scheduler" has been deprecated, as it was little more than an abtracted loop and caused much confusion. User * applications using the scheduler should switch to regular loops instead. The scheduler code will be removed in a future * release. * - The "Dynamic Memory Block Allocator" has been removed, as it was unused in (and unrelated to) the LUFA library and never * used in user applications. The library is available from the author's website for those wishing to still use it in their * applications. * + * Host Mode + * - The USB_GetDeviceConfigDescriptor() function now requires the desired configuration index within the device as its first + * parameter, to add support for multi-configuration devices. Existing code should use a configuration index of 1 to indicate the + * first configuration descriptor within the device. + * * \section Sec_Migration090605 Migrating from 090510 to 090605 * * Device Mode -- cgit v1.2.3