summaryrefslogtreecommitdiff
path: root/lib/lufa-descriptor-usbdualserial.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/lufa-descriptor-usbdualserial.c')
-rw-r--r--lib/lufa-descriptor-usbdualserial.c468
1 files changed, 221 insertions, 247 deletions
diff --git a/lib/lufa-descriptor-usbdualserial.c b/lib/lufa-descriptor-usbdualserial.c
index f270b5f..e26b5f9 100644
--- a/lib/lufa-descriptor-usbdualserial.c
+++ b/lib/lufa-descriptor-usbdualserial.c
@@ -1,13 +1,13 @@
/*
LUFA Library
- Copyright (C) Dean Camera, 2012.
+ Copyright (C) Dean Camera, 2014.
dean [at] fourwalledcubicle [dot] com
www.lufa-lib.org
*/
/*
- Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)
+ Copyright 2014 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
@@ -18,7 +18,7 @@
advertising or publicity pertaining to distribution of the
software without specific, written prior permission.
- The author disclaim all warranties with regard to this
+ The author disclaims all warranties with regard to this
software, including all implied warranties of merchantability
and fitness. In no event shall the author be liable for any
special, indirect or consequential damages or any damages
@@ -37,17 +37,6 @@
#include "lufa-descriptor-usbdualserial.h"
-/* On some devices, there is a factory set internal serial number which can be automatically sent to the host as
- * the device's serial number when the Device Descriptor's .SerialNumStrIndex entry is set to USE_INTERNAL_SERIAL.
- * This allows the host to track a device across insertions on different ports, allowing them to retain allocated
- * resources like COM port numbers and drivers. On demos using this feature, give a warning on unsupported devices
- * so that the user can supply their own serial number descriptor instead or remove the USE_INTERNAL_SERIAL value
- * from the Device Descriptor (forcing the host to generate a serial number for each device from the VID, PID and
- * port location).
- */
-#if (USE_INTERNAL_SERIAL == NO_DESCRIPTOR)
- #warning USE_INTERNAL_SERIAL is not available on this AVR - please manually construct a device serial descriptor.
-#endif
/** Device descriptor structure. This descriptor, located in FLASH memory, describes the overall
* device characteristics, including the supported USB version, control endpoint size and the
@@ -56,24 +45,24 @@
*/
const USB_Descriptor_Device_t PROGMEM DeviceDescriptor =
{
- .Header = {.Size = sizeof(USB_Descriptor_Device_t), .Type = DTYPE_Device},
+ .Header = {.Size = sizeof(USB_Descriptor_Device_t), .Type = DTYPE_Device},
- .USBSpecification = VERSION_BCD(01.10),
- .Class = USB_CSCP_IADDeviceClass,
- .SubClass = USB_CSCP_IADDeviceSubclass,
- .Protocol = USB_CSCP_IADDeviceProtocol,
+ .USBSpecification = VERSION_BCD(1,1,0),
+ .Class = USB_CSCP_IADDeviceClass,
+ .SubClass = USB_CSCP_IADDeviceSubclass,
+ .Protocol = USB_CSCP_IADDeviceProtocol,
- .Endpoint0Size = FIXED_CONTROL_ENDPOINT_SIZE,
+ .Endpoint0Size = FIXED_CONTROL_ENDPOINT_SIZE,
- .VendorID = 0x03EB,
- .ProductID = 0x204E,
- .ReleaseNumber = VERSION_BCD(00.01),
+ .VendorID = 0x03EB,
+ .ProductID = 0x204E,
+ .ReleaseNumber = VERSION_BCD(0,0,1),
- .ManufacturerStrIndex = 0x01,
- .ProductStrIndex = 0x02,
- .SerialNumStrIndex = USE_INTERNAL_SERIAL,
+ .ManufacturerStrIndex = STRING_ID_Manufacturer,
+ .ProductStrIndex = STRING_ID_Product,
+ .SerialNumStrIndex = USE_INTERNAL_SERIAL,
- .NumberOfConfigurations = FIXED_NUM_CONFIGURATIONS
+ .NumberOfConfigurations = FIXED_NUM_CONFIGURATIONS
};
/** Configuration descriptor structure. This descriptor, located in FLASH memory, describes the usage
@@ -83,264 +72,249 @@ const USB_Descriptor_Device_t PROGMEM DeviceDescriptor =
*/
const USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
{
- .Config =
- {
- .Header = {.Size = sizeof(USB_Descriptor_Configuration_Header_t), .Type = DTYPE_Configuration},
+ .Config =
+ {
+ .Header = {.Size = sizeof(USB_Descriptor_Configuration_Header_t), .Type = DTYPE_Configuration},
- .TotalConfigurationSize = sizeof(USB_Descriptor_Configuration_t),
- .TotalInterfaces = 4,
+ .TotalConfigurationSize = sizeof(USB_Descriptor_Configuration_t),
+ .TotalInterfaces = 4,
- .ConfigurationNumber = 1,
- .ConfigurationStrIndex = NO_DESCRIPTOR,
+ .ConfigurationNumber = 1,
+ .ConfigurationStrIndex = NO_DESCRIPTOR,
- .ConfigAttributes = (USB_CONFIG_ATTR_RESERVED | USB_CONFIG_ATTR_SELFPOWERED),
+ .ConfigAttributes = (USB_CONFIG_ATTR_RESERVED | USB_CONFIG_ATTR_SELFPOWERED),
- .MaxPowerConsumption = USB_CONFIG_POWER_MA(100)
- },
+ .MaxPowerConsumption = USB_CONFIG_POWER_MA(100)
+ },
- .CDC1_IAD =
- {
- .Header = {.Size = sizeof(USB_Descriptor_Interface_Association_t), .Type = DTYPE_InterfaceAssociation},
+ .CDC1_IAD =
+ {
+ .Header = {.Size = sizeof(USB_Descriptor_Interface_Association_t), .Type = DTYPE_InterfaceAssociation},
- .FirstInterfaceIndex = 0,
- .TotalInterfaces = 2,
+ .FirstInterfaceIndex = INTERFACE_ID_CDC1_CCI,
+ .TotalInterfaces = 2,
- .Class = CDC_CSCP_CDCClass,
- .SubClass = CDC_CSCP_ACMSubclass,
- .Protocol = CDC_CSCP_ATCommandProtocol,
+ .Class = CDC_CSCP_CDCClass,
+ .SubClass = CDC_CSCP_ACMSubclass,
+ .Protocol = CDC_CSCP_ATCommandProtocol,
- .IADStrIndex = NO_DESCRIPTOR
- },
+ .IADStrIndex = NO_DESCRIPTOR
+ },
- .CDC1_CCI_Interface =
- {
- .Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface},
+ .CDC1_CCI_Interface =
+ {
+ .Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface},
- .InterfaceNumber = 0,
- .AlternateSetting = 0,
+ .InterfaceNumber = INTERFACE_ID_CDC1_CCI,
+ .AlternateSetting = 0,
- .TotalEndpoints = 1,
+ .TotalEndpoints = 1,
- .Class = CDC_CSCP_CDCClass,
- .SubClass = CDC_CSCP_ACMSubclass,
- .Protocol = CDC_CSCP_ATCommandProtocol,
+ .Class = CDC_CSCP_CDCClass,
+ .SubClass = CDC_CSCP_ACMSubclass,
+ .Protocol = CDC_CSCP_ATCommandProtocol,
- .InterfaceStrIndex = NO_DESCRIPTOR
- },
+ .InterfaceStrIndex = NO_DESCRIPTOR
+ },
- .CDC1_Functional_Header =
- {
- .Header = {.Size = sizeof(USB_CDC_Descriptor_FunctionalHeader_t), .Type = DTYPE_CSInterface},
- .Subtype = CDC_DSUBTYPE_CSInterface_Header,
+ .CDC1_Functional_Header =
+ {
+ .Header = {.Size = sizeof(USB_CDC_Descriptor_FunctionalHeader_t), .Type = DTYPE_CSInterface},
+ .Subtype = CDC_DSUBTYPE_CSInterface_Header,
- .CDCSpecification = VERSION_BCD(01.10),
- },
+ .CDCSpecification = VERSION_BCD(1,1,0),
+ },
- .CDC1_Functional_ACM =
- {
- .Header = {.Size = sizeof(USB_CDC_Descriptor_FunctionalACM_t), .Type = DTYPE_CSInterface},
- .Subtype = CDC_DSUBTYPE_CSInterface_ACM,
+ .CDC1_Functional_ACM =
+ {
+ .Header = {.Size = sizeof(USB_CDC_Descriptor_FunctionalACM_t), .Type = DTYPE_CSInterface},
+ .Subtype = CDC_DSUBTYPE_CSInterface_ACM,
- .Capabilities = 0x06,
- },
+ .Capabilities = 0x06,
+ },
- .CDC1_Functional_Union =
- {
- .Header = {.Size = sizeof(USB_CDC_Descriptor_FunctionalUnion_t), .Type = DTYPE_CSInterface},
- .Subtype = CDC_DSUBTYPE_CSInterface_Union,
+ .CDC1_Functional_Union =
+ {
+ .Header = {.Size = sizeof(USB_CDC_Descriptor_FunctionalUnion_t), .Type = DTYPE_CSInterface},
+ .Subtype = CDC_DSUBTYPE_CSInterface_Union,
- .MasterInterfaceNumber = 0,
- .SlaveInterfaceNumber = 1,
- },
+ .MasterInterfaceNumber = INTERFACE_ID_CDC1_CCI,
+ .SlaveInterfaceNumber = INTERFACE_ID_CDC1_DCI,
+ },
- .CDC1_ManagementEndpoint =
- {
- .Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint},
+ .CDC1_ManagementEndpoint =
+ {
+ .Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint},
- .EndpointAddress = (ENDPOINT_DIR_IN | CDC1_NOTIFICATION_EPNUM),
- .Attributes = (EP_TYPE_INTERRUPT | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA),
- .EndpointSize = CDC_NOTIFICATION_EPSIZE,
- .PollingIntervalMS = 0xFF
- },
+ .EndpointAddress = CDC1_NOTIFICATION_EPADDR,
+ .Attributes = (EP_TYPE_INTERRUPT | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA),
+ .EndpointSize = CDC_NOTIFICATION_EPSIZE,
+ .PollingIntervalMS = 0xFF
+ },
- .CDC1_DCI_Interface =
- {
- .Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface},
+ .CDC1_DCI_Interface =
+ {
+ .Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface},
- .InterfaceNumber = 1,
- .AlternateSetting = 0,
+ .InterfaceNumber = INTERFACE_ID_CDC1_DCI,
+ .AlternateSetting = 0,
- .TotalEndpoints = 2,
+ .TotalEndpoints = 2,
- .Class = CDC_CSCP_CDCDataClass,
- .SubClass = CDC_CSCP_NoDataSubclass,
- .Protocol = CDC_CSCP_NoDataProtocol,
+ .Class = CDC_CSCP_CDCDataClass,
+ .SubClass = CDC_CSCP_NoDataSubclass,
+ .Protocol = CDC_CSCP_NoDataProtocol,
- .InterfaceStrIndex = NO_DESCRIPTOR
- },
+ .InterfaceStrIndex = NO_DESCRIPTOR
+ },
- .CDC1_DataOutEndpoint =
- {
- .Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint},
+ .CDC1_DataOutEndpoint =
+ {
+ .Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint},
- .EndpointAddress = (ENDPOINT_DIR_OUT | CDC1_RX_EPNUM),
- .Attributes = (EP_TYPE_BULK | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA),
- .EndpointSize = CDC_TXRX_EPSIZE,
- .PollingIntervalMS = 0x01
- },
+ .EndpointAddress = CDC1_RX_EPADDR,
+ .Attributes = (EP_TYPE_BULK | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA),
+ .EndpointSize = CDC_TXRX_EPSIZE,
+ .PollingIntervalMS = 0x05
+ },
- .CDC1_DataInEndpoint =
- {
- .Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint},
+ .CDC1_DataInEndpoint =
+ {
+ .Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint},
- .EndpointAddress = (ENDPOINT_DIR_IN | CDC1_TX_EPNUM),
- .Attributes = (EP_TYPE_BULK | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA),
- .EndpointSize = CDC_TXRX_EPSIZE,
- .PollingIntervalMS = 0x01
- },
+ .EndpointAddress = CDC1_TX_EPADDR,
+ .Attributes = (EP_TYPE_BULK | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA),
+ .EndpointSize = CDC_TXRX_EPSIZE,
+ .PollingIntervalMS = 0x05
+ },
- .CDC2_IAD =
- {
- .Header = {.Size = sizeof(USB_Descriptor_Interface_Association_t), .Type = DTYPE_InterfaceAssociation},
+ .CDC2_IAD =
+ {
+ .Header = {.Size = sizeof(USB_Descriptor_Interface_Association_t), .Type = DTYPE_InterfaceAssociation},
- .FirstInterfaceIndex = 2,
- .TotalInterfaces = 2,
+ .FirstInterfaceIndex = INTERFACE_ID_CDC2_CCI,
+ .TotalInterfaces = 2,
- .Class = CDC_CSCP_CDCClass,
- .SubClass = CDC_CSCP_ACMSubclass,
- .Protocol = CDC_CSCP_ATCommandProtocol,
+ .Class = CDC_CSCP_CDCClass,
+ .SubClass = CDC_CSCP_ACMSubclass,
+ .Protocol = CDC_CSCP_ATCommandProtocol,
- .IADStrIndex = NO_DESCRIPTOR
- },
+ .IADStrIndex = NO_DESCRIPTOR
+ },
- .CDC2_CCI_Interface =
- {
- .Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface},
+ .CDC2_CCI_Interface =
+ {
+ .Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface},
- .InterfaceNumber = 2,
- .AlternateSetting = 0,
+ .InterfaceNumber = INTERFACE_ID_CDC2_CCI,
+ .AlternateSetting = 0,
- .TotalEndpoints = 1,
+ .TotalEndpoints = 1,
- .Class = CDC_CSCP_CDCClass,
- .SubClass = CDC_CSCP_ACMSubclass,
- .Protocol = CDC_CSCP_ATCommandProtocol,
+ .Class = CDC_CSCP_CDCClass,
+ .SubClass = CDC_CSCP_ACMSubclass,
+ .Protocol = CDC_CSCP_ATCommandProtocol,
- .InterfaceStrIndex = NO_DESCRIPTOR
- },
+ .InterfaceStrIndex = NO_DESCRIPTOR
+ },
- .CDC2_Functional_Header =
- {
- .Header = {.Size = sizeof(USB_CDC_Descriptor_FunctionalHeader_t), .Type = DTYPE_CSInterface},
- .Subtype = CDC_DSUBTYPE_CSInterface_Header,
+ .CDC2_Functional_Header =
+ {
+ .Header = {.Size = sizeof(USB_CDC_Descriptor_FunctionalHeader_t), .Type = DTYPE_CSInterface},
+ .Subtype = CDC_DSUBTYPE_CSInterface_Header,
- .CDCSpecification = VERSION_BCD(01.10),
- },
+ .CDCSpecification = VERSION_BCD(1,1,0),
+ },
- .CDC2_Functional_ACM =
- {
- .Header = {.Size = sizeof(USB_CDC_Descriptor_FunctionalACM_t), .Type = DTYPE_CSInterface},
- .Subtype = CDC_DSUBTYPE_CSInterface_ACM,
+ .CDC2_Functional_ACM =
+ {
+ .Header = {.Size = sizeof(USB_CDC_Descriptor_FunctionalACM_t), .Type = DTYPE_CSInterface},
+ .Subtype = CDC_DSUBTYPE_CSInterface_ACM,
- .Capabilities = 0x06,
- },
+ .Capabilities = 0x06,
+ },
- .CDC2_Functional_Union =
- {
- .Header = {.Size = sizeof(USB_CDC_Descriptor_FunctionalUnion_t), .Type = DTYPE_CSInterface},
- .Subtype = CDC_DSUBTYPE_CSInterface_Union,
+ .CDC2_Functional_Union =
+ {
+ .Header = {.Size = sizeof(USB_CDC_Descriptor_FunctionalUnion_t), .Type = DTYPE_CSInterface},
+ .Subtype = CDC_DSUBTYPE_CSInterface_Union,
- .MasterInterfaceNumber = 2,
- .SlaveInterfaceNumber = 3,
- },
+ .MasterInterfaceNumber = INTERFACE_ID_CDC2_CCI,
+ .SlaveInterfaceNumber = INTERFACE_ID_CDC2_DCI,
+ },
- .CDC2_ManagementEndpoint =
- {
- .Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint},
+ .CDC2_ManagementEndpoint =
+ {
+ .Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint},
- .EndpointAddress = (ENDPOINT_DIR_IN | CDC2_NOTIFICATION_EPNUM),
- .Attributes = (EP_TYPE_INTERRUPT | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA),
- .EndpointSize = CDC_NOTIFICATION_EPSIZE,
- .PollingIntervalMS = 0xFF
- },
+ .EndpointAddress = CDC2_NOTIFICATION_EPADDR,
+ .Attributes = (EP_TYPE_INTERRUPT | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA),
+ .EndpointSize = CDC_NOTIFICATION_EPSIZE,
+ .PollingIntervalMS = 0xFF
+ },
- .CDC2_DCI_Interface =
- {
- .Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface},
+ .CDC2_DCI_Interface =
+ {
+ .Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface},
- .InterfaceNumber = 3,
- .AlternateSetting = 0,
+ .InterfaceNumber = INTERFACE_ID_CDC2_DCI,
+ .AlternateSetting = 0,
- .TotalEndpoints = 2,
+ .TotalEndpoints = 2,
- .Class = CDC_CSCP_CDCDataClass,
- .SubClass = CDC_CSCP_NoDataSubclass,
- .Protocol = CDC_CSCP_NoDataProtocol,
+ .Class = CDC_CSCP_CDCDataClass,
+ .SubClass = CDC_CSCP_NoDataSubclass,
+ .Protocol = CDC_CSCP_NoDataProtocol,
- .InterfaceStrIndex = NO_DESCRIPTOR
- },
-
- .CDC2_DataOutEndpoint =
- {
- .Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint},
-
- .EndpointAddress = (ENDPOINT_DIR_OUT | CDC2_RX_EPNUM),
- .Attributes = (EP_TYPE_BULK | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA),
- .EndpointSize = CDC_TXRX_EPSIZE,
- .PollingIntervalMS = 0x01
- },
+ .InterfaceStrIndex = NO_DESCRIPTOR
+ },
+
+ .CDC2_DataOutEndpoint =
+ {
+ .Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint},
+
+ .EndpointAddress = CDC2_RX_EPADDR,
+ .Attributes = (EP_TYPE_BULK | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA),
+ .EndpointSize = CDC_TXRX_EPSIZE,
+ .PollingIntervalMS = 0x05
+ },
- .CDC2_DataInEndpoint =
- {
- .Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint},
+ .CDC2_DataInEndpoint =
+ {
+ .Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint},
- .EndpointAddress = (ENDPOINT_DIR_IN | CDC2_TX_EPNUM),
- .Attributes = (EP_TYPE_BULK | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA),
- .EndpointSize = CDC_TXRX_EPSIZE,
- .PollingIntervalMS = 0x01
- }
+ .EndpointAddress = CDC2_TX_EPADDR,
+ .Attributes = (EP_TYPE_BULK | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA),
+ .EndpointSize = CDC_TXRX_EPSIZE,
+ .PollingIntervalMS = 0x05
+ }
};
/** Language descriptor structure. This descriptor, located in FLASH memory, is returned when the host requests
* the string descriptor with index 0 (the first index). It is actually an array of 16-bit integers, which indicate
* via the language ID table available at USB.org what languages the device supports for its string descriptors.
*/
-const USB_Descriptor_String_t PROGMEM LanguageString =
-{
- .Header = {.Size = USB_STRING_LEN(1), .Type = DTYPE_String},
-
- .UnicodeString = {LANGUAGE_ID_ENG}
-};
+const USB_Descriptor_String_t PROGMEM LanguageString = USB_STRING_DESCRIPTOR_ARRAY(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 =
-{
#ifndef USB_MANUFACTURER
- .Header = {.Size = USB_STRING_LEN(11), .Type = DTYPE_String},
- .UnicodeString = L"Dean Camera"
+const USB_Descriptor_String_t PROGMEM ManufacturerString = USB_STRING_DESCRIPTOR(L"Dean Camera");
#else
- .Header = {.Size = USB_STRING_LEN(USB_MANUFACTURER_LEN), .Type = DTYPE_String},
- .UnicodeString = USB_MANUFACTURER
+const USB_Descriptor_String_t PROGMEM ManufacturerString = USB_STRING_DESCRIPTOR(USB_MANUFACTURER);
#endif
-};
/** 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.
*/
-const USB_Descriptor_String_t PROGMEM ProductString =
-{
#ifndef USB_PRODUCT
- .Header = {.Size = USB_STRING_LEN(13), .Type = DTYPE_String},
- .UnicodeString = L"LUFA Dual CDC Demo"
+const USB_Descriptor_String_t PROGMEM ProductString = USB_STRING_DESCRIPTOR(L"LUFA Dual CDC Demo");
#else
- .Header = {.Size = USB_STRING_LEN(USB_PRODUCT_LEN), .Type = DTYPE_String},
- .UnicodeString = USB_PRODUCT
+const USB_Descriptor_String_t PROGMEM ProductString = USB_STRING_DESCRIPTOR(USB_PRODUCT);
#endif
-};
/** This function is called by the library when in device mode, and must be overridden (see library "USB Descriptors"
* documentation) by the application code so that the address and size of a requested descriptor can be given
@@ -352,43 +326,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 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:
- switch (DescriptorNumber)
- {
- case 0x00:
- Address = &LanguageString;
- Size = pgm_read_byte(&LanguageString.Header.Size);
- break;
- case 0x01:
- Address = &ManufacturerString;
- Size = pgm_read_byte(&ManufacturerString.Header.Size);
- break;
- case 0x02:
- Address = &ProductString;
- Size = pgm_read_byte(&ProductString.Header.Size);
- break;
- }
-
- break;
- }
-
- *DescriptorAddress = Address;
- return Size;
+ 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:
+ switch (DescriptorNumber)
+ {
+ case STRING_ID_Language:
+ Address = &LanguageString;
+ Size = pgm_read_byte(&LanguageString.Header.Size);
+ break;
+ case STRING_ID_Manufacturer:
+ Address = &ManufacturerString;
+ Size = pgm_read_byte(&ManufacturerString.Header.Size);
+ break;
+ case STRING_ID_Product:
+ Address = &ProductString;
+ Size = pgm_read_byte(&ProductString.Header.Size);
+ break;
+ }
+
+ break;
+ }
+
+ *DescriptorAddress = Address;
+ return Size;
}