CI: Build on Arch (bleeding-ege) and Ubuntu (stable) AVR-GCC toolchains.
[pub/USBasp.git] / Bootloaders / MassStorage / Descriptors.c
index 4de1207..654fada 100644 (file)
@@ -1,13 +1,13 @@
 /*
              LUFA Library
-     Copyright (C) Dean Camera, 2013.
+     Copyright (C) Dean Camera, 2018.
 
   dean [at] fourwalledcubicle [dot] com
            www.lufa-lib.org
 */
 
 /*
-  Copyright 2013  Dean Camera (dean [at] fourwalledcubicle [dot] com)
+  Copyright 2018  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
@@ -38,7 +38,7 @@
 #include "Descriptors.h"
 
 
-/** Device descriptor structure. This descriptor, located in FLASH memory, describes the overall
+/** Device descriptor structure. This descriptor, located in SRAM memory, describes the overall
  *  device characteristics, including the supported USB version, control endpoint size and the
  *  number of device configurations. The descriptor is read out by the USB host when the enumeration
  *  process begins.
@@ -47,7 +47,7 @@ const USB_Descriptor_Device_t DeviceDescriptor =
 {
        .Header                 = {.Size = sizeof(USB_Descriptor_Device_t), .Type = DTYPE_Device},
 
-       .USBSpecification       = VERSION_BCD(01.10),
+       .USBSpecification       = VERSION_BCD(1,1,0),
        .Class                  = USB_CSCP_NoDeviceClass,
        .SubClass               = USB_CSCP_NoDeviceSubclass,
        .Protocol               = USB_CSCP_NoDeviceProtocol,
@@ -56,11 +56,11 @@ const USB_Descriptor_Device_t DeviceDescriptor =
 
        .VendorID               = 0x03EB,
        .ProductID              = 0x2045,
-       .ReleaseNumber          = VERSION_BCD(00.01),
+       .ReleaseNumber          = VERSION_BCD(0,0,1),
 
        .ManufacturerStrIndex   = NO_DESCRIPTOR,
        .ProductStrIndex        = NO_DESCRIPTOR,
-       .SerialNumStrIndex      = USE_INTERNAL_SERIAL,
+       .SerialNumStrIndex      = NO_DESCRIPTOR,
 
        .NumberOfConfigurations = FIXED_NUM_CONFIGURATIONS
 };
@@ -91,7 +91,7 @@ const USB_Descriptor_Configuration_t ConfigurationDescriptor =
                {
                        .Header                 = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface},
 
-                       .InterfaceNumber        = 0,
+                       .InterfaceNumber        = INTERFACE_ID_MassStorage,
                        .AlternateSetting       = 0,
 
                        .TotalEndpoints         = 2,
@@ -124,17 +124,6 @@ const USB_Descriptor_Configuration_t ConfigurationDescriptor =
                }
 };
 
-/** 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 LanguageString =
-{
-       .Header                 = {.Size = USB_STRING_LEN(1), .Type = DTYPE_String},
-
-       .UnicodeString          = {LANGUAGE_ID_ENG}
-};
-
 /** 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
  *  to the USB library. When the device receives a Get Descriptor request on the control endpoint, this function
@@ -142,33 +131,24 @@ const USB_Descriptor_String_t LanguageString =
  *  USB host.
  */
 uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue,
-                                    const uint8_t wIndex,
+                                    const uint16_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 void* Address = NULL;
        uint16_t    Size    = NO_DESCRIPTOR;
 
-       switch (DescriptorType)
+       /* If/Else If chain compiles slightly smaller than a switch case */
+       if (DescriptorType == DTYPE_Device)
+       {
+               Address = &DeviceDescriptor;
+               Size    = sizeof(USB_Descriptor_Device_t);
+       }
+       else if (DescriptorType == DTYPE_Configuration)
        {
-               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;
-                                       Size    = pgm_read_byte(&LanguageString.Header.Size);
-                       }
-
-                       break;
+               Address = &ConfigurationDescriptor;
+               Size    = sizeof(USB_Descriptor_Configuration_t);
        }
 
        *DescriptorAddress = Address;