Extend USB_GetDeviceConfigDescriptor() routine to require the configuration number within the device to fetch, to add support for multi-configuration devices.

This commit is contained in:
Dean Camera 2009-06-19 03:37:47 +00:00
parent 0d8679cf6b
commit dfa547164a
17 changed files with 49 additions and 40 deletions

View file

@ -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),
};

View file

@ -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.