X-Git-Url: http://git.linex4red.de/pub/USBasp.git/blobdiff_plain/1daa5e16f9a395fb2943906a715adb35b8106988..6e7fc21a94f29e09b4bdce7c17cade5b1322bc7d:/LUFA/Drivers/USB/Core/ConfigDescriptor.h diff --git a/LUFA/Drivers/USB/Core/ConfigDescriptor.h b/LUFA/Drivers/USB/Core/ConfigDescriptor.h index 2f0ac8e02..634dc8ff9 100644 --- a/LUFA/Drivers/USB/Core/ConfigDescriptor.h +++ b/LUFA/Drivers/USB/Core/ConfigDescriptor.h @@ -29,11 +29,8 @@ */ /** \file - * \brief Configuration descriptor parser API. - * - * This section of the library gives a friendly API which can be used in host applications to easily - * parse an attached device's configuration descriptor so that endpoint, interface and other descriptor - * data can be extracted and used as needed. + * \brief USB Configuration Descriptor definitions. + * \copydetails Group_ConfigDescriptorParser * * \note This file should not be included directly. It is automatically included as needed by the USB driver * dispatch header located in LUFA/Drivers/USB/USB.h. @@ -41,8 +38,11 @@ /** \ingroup Group_Descriptors * \defgroup Group_ConfigDescriptorParser Configuration Descriptor Parser + * \brief USB Configuration Descriptor definitions. * - * Functions, macros, variables, enums and types related to the parsing of Configuration Descriptors. + * This section of the library gives a friendly API which can be used in host applications to easily + * parse an attached device's configuration descriptor so that endpoint, interface and other descriptor + * data can be extracted and used as needed. * * @{ */ @@ -52,8 +52,8 @@ /* Includes: */ #include "../../../Common/Common.h" + #include "USBMode.h" #include "HostStandardReq.h" - #include "USBMode.h" #include "StdDescriptors.h" /* Enable C linkage for C++ Compilers: */ @@ -166,8 +166,10 @@ * * \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. @@ -254,7 +256,7 @@ */ uint8_t USB_GetNextDescriptorComp(uint16_t* const BytesRem, void** const CurrConfigLoc, - ConfigComparatorPtr_t const ComparatorRoutine); + const ConfigComparatorPtr_t const ComparatorRoutine); /* Inline Functions: */ /** Skips over the current sub-descriptor inside the configuration descriptor, so that the pointer then @@ -269,8 +271,11 @@ void** CurrConfigLoc) { uint16_t CurrDescriptorSize = DESCRIPTOR_CAST(*CurrConfigLoc, USB_Descriptor_Header_t).Size; + + if (*BytesRem < CurrDescriptorSize) + CurrDescriptorSize = *BytesRem; - *CurrConfigLoc = ((uint8_t*)*CurrConfigLoc) + CurrDescriptorSize; + *CurrConfigLoc = (void*)((uintptr_t)*CurrConfigLoc + CurrDescriptorSize); *BytesRem -= CurrDescriptorSize; }