Update UC3 platform driver support to use the bitmasks defined in the header files...
[pub/USBasp.git] / Bootloaders / CDC / Descriptors.c
index 8973c4e..7516a7b 100644 (file)
@@ -104,7 +104,7 @@ const USB_Descriptor_Configuration_t ConfigurationDescriptor =
 
        .CDC_Functional_Header =
                {
-                       .Header                 = {.Size = sizeof(USB_Descriptor_CDC_FunctionalHeader_t), .Type = DTYPE_CSInterface},
+                       .Header                 = {.Size = sizeof(USB_CDC_Descriptor_FunctionalHeader_t), .Type = DTYPE_CSInterface},
                        .Subtype                = 0x00,
 
                        .CDCSpecification       = VERSION_BCD(01.10),
@@ -112,7 +112,7 @@ const USB_Descriptor_Configuration_t ConfigurationDescriptor =
 
        .CDC_Functional_ACM =
                {
-                       .Header                 = {.Size = sizeof(USB_Descriptor_CDC_FunctionalACM_t), .Type = DTYPE_CSInterface},
+                       .Header                 = {.Size = sizeof(USB_CDC_Descriptor_FunctionalACM_t), .Type = DTYPE_CSInterface},
                        .Subtype                = 0x02,
 
                        .Capabilities           = 0x04,
@@ -120,7 +120,7 @@ const USB_Descriptor_Configuration_t ConfigurationDescriptor =
 
        .CDC_Functional_Union =
                {
-                       .Header                 = {.Size = sizeof(USB_Descriptor_CDC_FunctionalUnion_t), .Type = DTYPE_CSInterface},
+                       .Header                 = {.Size = sizeof(USB_CDC_Descriptor_FunctionalUnion_t), .Type = DTYPE_CSInterface},
                        .Subtype                = 0x06,
 
                        .MasterInterfaceNumber  = 0,
@@ -206,29 +206,38 @@ 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;
+                       {
+                               Address = &LanguageString;
+                               Size    = LanguageString.Header.Size;
+                       }
                        else
-                         Address = &ProductString;
+                       {
+                               Address = &ProductString;
+                               Size    = ProductString.Header.Size;
+                       }
 
                        break;
        }
 
        *DescriptorAddress = Address;
-       return (Address != NULL) ? ((USB_Descriptor_Header_t*)Address)->Size : NO_DESCRIPTOR;
+       return Size;
 }