/*
LUFA Library
- Copyright (C) Dean Camera, 2011.
+ Copyright (C) Dean Camera, 2012.
dean [at] fourwalledcubicle [dot] com
www.lufa-lib.org
*/
/*
- Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)
+ Copyright 2012 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
* dispatch header located in LUFA/Drivers/USB/USB.h.
*/
-/** \ingroup Group_Descriptors
+/** \ingroup Group_StdDescriptors
* \defgroup Group_ConfigDescriptorParser Configuration Descriptor Parser
* \brief USB Configuration Descriptor definitions.
*
/* Includes: */
#include "../../../Common/Common.h"
- #include "HostStandardReq.h"
#include "USBMode.h"
+ #include "HostStandardReq.h"
#include "StdDescriptors.h"
/* Enable C linkage for C++ Compilers: */
/* Public Interface - May be used in end-application: */
/* Macros: */
- /** Mask for determining the type of an endpoint from an endpoint descriptor. This should then be compared
- * with the \c EP_TYPE_* masks to determine the exact type of the endpoint.
- */
- #define EP_TYPE_MASK 0x03
-
/** Casts a pointer to a descriptor inside the configuration descriptor into a pointer to the given
* descriptor type.
*
*
* \return A value from the \ref USB_Host_GetConfigDescriptor_ErrorCodes_t enum.
*/
- uint8_t USB_Host_GetDeviceConfigDescriptor(uint8_t ConfigNumber, uint16_t* const ConfigSizePtr, void* BufferPtr,
- uint16_t BufferSize) ATTR_NON_NULL_PTR_ARG(2) ATTR_NON_NULL_PTR_ARG(3);
+ uint8_t USB_Host_GetDeviceConfigDescriptor(const uint8_t ConfigNumber,
+ uint16_t* const ConfigSizePtr,
+ void* const BufferPtr,
+ const uint16_t BufferSize) ATTR_NON_NULL_PTR_ARG(2) ATTR_NON_NULL_PTR_ARG(3);
/** Skips to the next sub-descriptor inside the configuration descriptor of the specified type value.
* The bytes remaining value is automatically decremented.
{
uint16_t CurrDescriptorSize = DESCRIPTOR_CAST(*CurrConfigLoc, USB_Descriptor_Header_t).Size;
- *CurrConfigLoc = ((uint8_t*)*CurrConfigLoc) + CurrDescriptorSize;
+ if (*BytesRem < CurrDescriptorSize)
+ CurrDescriptorSize = *BytesRem;
+
+ *CurrConfigLoc = (void*)((uintptr_t)*CurrConfigLoc + CurrDescriptorSize);
*BytesRem -= CurrDescriptorSize;
}