X-Git-Url: http://git.linex4red.de/pub/USBasp.git/blobdiff_plain/0d5baf9bb3e88ebcbc53cc9a71566582d585f7dd..b462f2d457ec2f0cfa22a1c3db198cb22f6809a1:/LUFA/Drivers/USB/LowLevel/DevChapter9.c diff --git a/LUFA/Drivers/USB/LowLevel/DevChapter9.c b/LUFA/Drivers/USB/LowLevel/DevChapter9.c index 785d10fac..feaabce46 100644 --- a/LUFA/Drivers/USB/LowLevel/DevChapter9.c +++ b/LUFA/Drivers/USB/LowLevel/DevChapter9.c @@ -106,7 +106,7 @@ void USB_Device_ProcessControlPacket(void) } if (!(RequestHandled)) - RAISE_EVENT(USB_UnhandledControlPacket); + EVENT_USB_UnhandledControlPacket(); if (Endpoint_IsSETUPReceived()) { @@ -137,7 +137,7 @@ static void USB_Device_SetConfiguration(void) #else USB_Descriptor_Device_t* DevDescriptorPtr; - if ((USB_GetDescriptor((DTYPE_Device << 8), 0, (void*)&DevDescriptorPtr) == NO_DESCRIPTOR) || + if ((CALLBACK_USB_GetDescriptor((DTYPE_Device << 8), 0, (void*)&DevDescriptorPtr) == NO_DESCRIPTOR) || #if defined(USE_RAM_DESCRIPTORS) ((uint8_t)USB_ControlRequest.wValue > DevDescriptorPtr->NumberOfConfigurations)) #elif defined (USE_EEPROM_DESCRIPTORS) @@ -157,9 +157,9 @@ static void USB_Device_SetConfiguration(void) Endpoint_ClearIN(); if (!(AlreadyConfigured) && USB_ConfigurationNumber) - RAISE_EVENT(USB_DeviceEnumerationComplete); + EVENT_USB_DeviceEnumerationComplete(); - RAISE_EVENT(USB_ConfigurationChanged); + EVENT_USB_ConfigurationChanged(); } void USB_Device_GetConfiguration(void) @@ -179,11 +179,66 @@ static void USB_Device_GetDescriptor(void) void* DescriptorPointer; uint16_t DescriptorSize; - if ((DescriptorSize = USB_GetDescriptor(USB_ControlRequest.wValue, USB_ControlRequest.wIndex, &DescriptorPointer)) == NO_DESCRIPTOR) - return; + #if !defined(NO_INTERNAL_SERIAL) && (defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR)) + if (USB_ControlRequest.wValue == ((DTYPE_String << 8) | USE_INTERNAL_SERIAL)) + { + struct + { + USB_Descriptor_Header_t Header; + int16_t UnicodeString[12]; + } SignatureDescriptor; + + #if defined(USE_NONSTANDARD_DESCRIPTOR_NAMES) + SignatureDescriptor.Header.Size = sizeof(SignatureDescriptor); + SignatureDescriptor.Header.Type = DTYPE_String; + #else + SignatureDescriptor.Header.bLength = sizeof(SignatureDescriptor); + SignatureDescriptor.Header.bDescriptorType = DTYPE_String; + #endif + + uint8_t SigReadAddress = 0x0E; + bool OddRead = false; + + for (uint8_t SerialCharNum = 0; SerialCharNum < 12; SerialCharNum++) + { + uint8_t SerialByte = boot_signature_byte_get(SigReadAddress); + + if (OddRead) + { + SerialByte >>= 4; + SigReadAddress++; + } + else + { + SerialByte &= 0x0F; + } + + OddRead = !(OddRead); + + if (SerialByte < 0x0A) + SerialByte += '0'; + else + SerialByte += ('A' - 0x0A); + + SignatureDescriptor.UnicodeString[SerialCharNum] = SerialByte; + } + + Endpoint_ClearSETUP(); + Endpoint_Write_Control_Stream_LE(&SignatureDescriptor, sizeof(SignatureDescriptor)); + Endpoint_ClearOUT(); + + return; + } + #endif - Endpoint_ClearSETUP(); + if ((DescriptorSize = CALLBACK_USB_GetDescriptor(USB_ControlRequest.wValue, USB_ControlRequest.wIndex, + &DescriptorPointer)) == NO_DESCRIPTOR) + { + return; + } + Endpoint_ClearSETUP(); + #if defined(USE_RAM_DESCRIPTORS) Endpoint_Write_Control_Stream_LE(DescriptorPointer, DescriptorSize); #else @@ -206,7 +261,7 @@ static void USB_Device_GetDescriptor(void) while (USB_ControlRequest.wLength && (Endpoint_BytesInEndpoint() < USB_ControlEndpointSize)) { #if defined (USE_EEPROM_DESCRIPTORS) - Endpoint_Write_Byte(eeprom_read_byte(DescriptorPointer++)); + Endpoint_Write_Byte(eeprom_read_byte(DescriptorPointer++)); #else Endpoint_Write_Byte(pgm_read_byte(DescriptorPointer++)); #endif