Re-add signature byte defines to the DFU and CDC class bootloaders -- the SIGNATURE_x...
[pub/USBasp.git] / LUFA / Drivers / USB / LowLevel / DevChapter9.c
index 9bba234..9acf300 100644 (file)
@@ -179,14 +179,44 @@ static void USB_Device_GetDescriptor(void)
        void*    DescriptorPointer;\r
        uint16_t DescriptorSize;\r
        \r
-       if ((DescriptorSize = CALLBACK_USB_GetDescriptor(USB_ControlRequest.wValue,\r
-                                                        USB_ControlRequest.wIndex, &DescriptorPointer)) == NO_DESCRIPTOR)\r
+       #if defined(USE_INTERNAL_SERIAL)\r
+       if (USB_ControlRequest.wValue == ((DTYPE_String << 8) | USE_INTERNAL_SERIAL))\r
        {\r
+               uint8_t SignatureDescriptor[2 + (sizeof(int16_t) * 20)];\r
+\r
+               SignatureDescriptor[0] = sizeof(SignatureDescriptor);\r
+               SignatureDescriptor[1] = DTYPE_String;\r
+               \r
+               uint16_t* SigUnicodeChars = (uint16_t*)&SignatureDescriptor[2];\r
+\r
+               for (uint8_t SerialByteNum = 0; SerialByteNum < 10; SerialByteNum++)\r
+               {\r
+                       char ConvSigString[3];\r
+\r
+                       itoa(boot_signature_byte_get(0x0E + SerialByteNum), ConvSigString, 16);\r
+                       \r
+                       SigUnicodeChars[0] = toupper(ConvSigString[0]);\r
+                       SigUnicodeChars[1] = toupper(ConvSigString[1]);\r
+                       \r
+                       SigUnicodeChars += 2;\r
+               }\r
+               \r
+               Endpoint_ClearSETUP();\r
+               Endpoint_Write_Control_Stream_LE(SignatureDescriptor, sizeof(SignatureDescriptor));\r
+               Endpoint_ClearOUT();\r
+\r
                return;\r
        }\r
+       #endif\r
        \r
-       Endpoint_ClearSETUP();\r
+       if ((DescriptorSize = CALLBACK_USB_GetDescriptor(USB_ControlRequest.wValue, USB_ControlRequest.wIndex,\r
+                                                        &DescriptorPointer)) == NO_DESCRIPTOR)\r
+       {\r
+               return;\r
+       }\r
        \r
+       Endpoint_ClearSETUP();\r
+\r
        #if defined(USE_RAM_DESCRIPTORS)\r
        Endpoint_Write_Control_Stream_LE(DescriptorPointer, DescriptorSize);\r
        #else\r
@@ -209,7 +239,7 @@ static void USB_Device_GetDescriptor(void)
                while (USB_ControlRequest.wLength && (Endpoint_BytesInEndpoint() < USB_ControlEndpointSize))\r
                {\r
                        #if defined (USE_EEPROM_DESCRIPTORS)\r
-                       Endpoint_Write_Byte(eeprom_read_byte(DescriptorPointer++));                     \r
+                       Endpoint_Write_Byte(eeprom_read_byte(DescriptorPointer++));             \r
                        #else\r
                        Endpoint_Write_Byte(pgm_read_byte(DescriptorPointer++));\r
                        #endif\r