{\r
bool AlreadyConfigured = (USB_ConfigurationNumber != 0);\r
\r
-#if defined(USE_SINGLE_DEVICE_CONFIGURATION)\r
- if ((uint8_t)USB_ControlRequest.wValue > 1)\r
+#if defined(TOTAL_NUM_CONFIGURATIONS)\r
+ if ((uint8_t)USB_ControlRequest.wValue > TOTAL_NUM_CONFIGURATIONS)\r
+ return;\r
#else\r
+ #if !defined(USE_FLASH_DESCRIPTORS) && !defined(USE_EEPROM_DESCRIPTORS) && !defined(USE_RAM_DESCRIPTORS)\r
+ uint8_t MemoryAddressSpace;\r
+ #endif\r
+ \r
USB_Descriptor_Device_t* DevDescriptorPtr;\r
\r
- if ((CALLBACK_USB_GetDescriptor((DTYPE_Device << 8), 0, (void*)&DevDescriptorPtr) == NO_DESCRIPTOR) ||\r
+ if (CALLBACK_USB_GetDescriptor((DTYPE_Device << 8), 0, (void*)&DevDescriptorPtr\r
+ #if !defined(USE_FLASH_DESCRIPTORS) && !defined(USE_EEPROM_DESCRIPTORS) && !defined(USE_RAM_DESCRIPTORS)\r
+ , &MemoryAddressSpace) == NO_DESCRIPTOR)\r
+ #endif\r
+ {\r
+ return;\r
+ }\r
+ \r
#if defined(USE_RAM_DESCRIPTORS)\r
- ((uint8_t)USB_ControlRequest.wValue > DevDescriptorPtr->NumberOfConfigurations))\r
+ if ((uint8_t)USB_ControlRequest.wValue > DevDescriptorPtr->NumberOfConfigurations)\r
+ return;\r
#elif defined (USE_EEPROM_DESCRIPTORS)\r
- ((uint8_t)USB_ControlRequest.wValue > eeprom_read_byte(&DevDescriptorPtr->NumberOfConfigurations)))\r
+ if ((uint8_t)USB_ControlRequest.wValue > eeprom_read_byte(&DevDescriptorPtr->NumberOfConfigurations))\r
+ return;\r
+ #elif defined (USE_FLASH_DESCRIPTORS)\r
+ if ((uint8_t)USB_ControlRequest.wValue > pgm_read_byte(&DevDescriptorPtr->NumberOfConfigurations))\r
+ return;\r
#else\r
- ((uint8_t)USB_ControlRequest.wValue > pgm_read_byte(&DevDescriptorPtr->NumberOfConfigurations)))\r
- #endif\r
-#endif\r
+ if (MemoryAddressSpace == MEMSPACE_FLASH)\r
{\r
- return;\r
+ if (((uint8_t)USB_ControlRequest.wValue > pgm_read_byte(&DevDescriptorPtr->NumberOfConfigurations)))\r
+ return;\r
}\r
+ else if (MemoryAddressSpace == MEMSPACE_EEPROM)\r
+ {\r
+ if (((uint8_t)USB_ControlRequest.wValue > eeprom_read_byte(&DevDescriptorPtr->NumberOfConfigurations)))\r
+ return;\r
+ }\r
+ else\r
+ {\r
+ if ((uint8_t)USB_ControlRequest.wValue > DevDescriptorPtr->NumberOfConfigurations)\r
+ return;\r
+ }\r
+ #endif\r
+#endif\r
\r
Endpoint_ClearSETUP();\r
\r
void* DescriptorPointer;\r
uint16_t DescriptorSize;\r
\r
+ #if !defined(USE_FLASH_DESCRIPTORS) && !defined(USE_EEPROM_DESCRIPTORS) && !defined(USE_RAM_DESCRIPTORS)\r
+ uint8_t DescriptorAddressSpace;\r
+ #endif\r
+ \r
#if !defined(NO_INTERNAL_SERIAL) && (defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR))\r
if (USB_ControlRequest.wValue == ((DTYPE_String << 8) | USE_INTERNAL_SERIAL))\r
{\r
#endif\r
\r
if ((DescriptorSize = CALLBACK_USB_GetDescriptor(USB_ControlRequest.wValue, USB_ControlRequest.wIndex,\r
- &DescriptorPointer)) == NO_DESCRIPTOR)\r
+ &DescriptorPointer\r
+ #if !defined(USE_FLASH_DESCRIPTORS) && !defined(USE_EEPROM_DESCRIPTORS) && !defined(USE_RAM_DESCRIPTORS)\r
+ , &DescriptorAddressSpace\r
+ #endif\r
+ )) == NO_DESCRIPTOR)\r
{\r
return;\r
}\r
Endpoint_Write_Control_Stream_LE(DescriptorPointer, DescriptorSize);\r
#elif defined(USE_EEPROM_DESCRIPTORS)\r
Endpoint_Write_Control_EStream_LE(DescriptorPointer, DescriptorSize);\r
- #else\r
+ #elif defined(USE_FLASH_DESCRIPTORS)\r
Endpoint_Write_Control_PStream_LE(DescriptorPointer, DescriptorSize); \r
+ #else\r
+ if (DescriptorAddressSpace == MEMSPACE_FLASH)\r
+ Endpoint_Write_Control_PStream_LE(DescriptorPointer, DescriptorSize); \r
+ else if (DescriptorAddressSpace == MEMSPACE_EEPROM)\r
+ Endpoint_Write_Control_EStream_LE(DescriptorPointer, DescriptorSize);\r
+ else\r
+ Endpoint_Write_Control_Stream_LE(DescriptorPointer, DescriptorSize); \r
#endif\r
\r
Endpoint_ClearOUT();\r