X-Git-Url: http://git.linex4red.de/pub/USBasp.git/blobdiff_plain/5995c3f880899b2573f1026ed6dc1c3c3a8e93d2..0da99447d3e88e83f9977501bee56af5c7aa56c0:/Bootloaders/DFU/Descriptors.c?ds=sidebyside diff --git a/Bootloaders/DFU/Descriptors.c b/Bootloaders/DFU/Descriptors.c index 55449c606..3a1a2e2b3 100644 --- a/Bootloaders/DFU/Descriptors.c +++ b/Bootloaders/DFU/Descriptors.c @@ -1,13 +1,13 @@ /* 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 @@ -57,8 +57,8 @@ const USB_Descriptor_Device_t DeviceDescriptor = .ProductID = PRODUCT_ID_CODE, .ReleaseNumber = VERSION_BCD(00.00), - .ManufacturerStrIndex = NO_DESCRIPTOR, - .ProductStrIndex = 0x01, + .ManufacturerStrIndex = 0x01, + .ProductStrIndex = 0x02, .SerialNumStrIndex = NO_DESCRIPTOR, .NumberOfConfigurations = FIXED_NUM_CONFIGURATIONS @@ -81,7 +81,7 @@ const USB_Descriptor_Configuration_t ConfigurationDescriptor = .ConfigurationNumber = 1, .ConfigurationStrIndex = NO_DESCRIPTOR, - .ConfigAttributes = USB_CONFIG_ATTR_BUSPOWERED, + .ConfigAttributes = USB_CONFIG_ATTR_RESERVED, .MaxPowerConsumption = USB_CONFIG_POWER_MA(100) }, @@ -111,7 +111,7 @@ const USB_Descriptor_Configuration_t ConfigurationDescriptor = .DetachTimeout = 0x0000, .TransferSize = 0x0C00, - .DFUSpecification = VERSION_BCD(01.01) + .DFUSpecification = VERSION_BCD(01.10) } }; @@ -126,6 +126,17 @@ const USB_Descriptor_String_t LanguageString = .UnicodeString = {LANGUAGE_ID_ENG} }; +/** Manufacturer descriptor string. This is a Unicode string containing the manufacturer's details in human readable + * form, and is read out upon request by the host when the appropriate string ID is requested, listed in the Device + * Descriptor. + */ +const USB_Descriptor_String_t PROGMEM ManufacturerString = +{ + .Header = {.Size = USB_STRING_LEN(11), .Type = DTYPE_String}, + + .UnicodeString = L"Dean Camera" +}; + /** Product descriptor string. This is a Unicode string containing the product's details in human readable form, * and is read out upon request by the host when the appropriate string ID is requested, listed in the Device * Descriptor. @@ -147,29 +158,43 @@ uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue, const uint8_t wIndex, const void** const DescriptorAddress) { - const uint8_t DescriptorType = (wValue >> 8); - const uint8_t DescriptorNumber = (wValue & 0xFF); + const uint8_t DescriptorType = (wValue >> 8); + const uint8_t DescriptorNumber = (wValue & 0xFF); const void* Address = NULL; + uint16_t Size = NO_DESCRIPTOR; switch (DescriptorType) { case DTYPE_Device: Address = &DeviceDescriptor; + Size = sizeof(USB_Descriptor_Device_t); break; case DTYPE_Configuration: Address = &ConfigurationDescriptor; + Size = sizeof(USB_Descriptor_Configuration_t); break; case DTYPE_String: if (!(DescriptorNumber)) - Address = &LanguageString; - else - Address = &ProductString; + { + Address = &LanguageString; + Size = LanguageString.Header.Size; + } + else if (DescriptorNumber == 0x01) + { + Address = &ManufacturerString; + Size = ManufacturerString.Header.Size; + } + else if (DescriptorNumber == 0x02) + { + Address = &ProductString; + Size = ProductString.Header.Size; + } break; } *DescriptorAddress = Address; - return (Address != NULL) ? ((USB_Descriptor_Header_t*)Address)->Size : NO_DESCRIPTOR; + return Size; }