X-Git-Url: http://git.linex4red.de/pub/USBasp.git/blobdiff_plain/2bd88ebc4f37baf81d550e79b3e3118b0843e61c..e0420015df848f18d5eb1672da4ccac578d454cf:/LUFA/Drivers/USB/LowLevel/DevChapter9.c diff --git a/LUFA/Drivers/USB/LowLevel/DevChapter9.c b/LUFA/Drivers/USB/LowLevel/DevChapter9.c index f02d32ba3..9acf30099 100644 --- a/LUFA/Drivers/USB/LowLevel/DevChapter9.c +++ b/LUFA/Drivers/USB/LowLevel/DevChapter9.c @@ -62,7 +62,8 @@ void USB_Device_ProcessControlPacket(void) break; case REQ_ClearFeature: case REQ_SetFeature: - if (bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_STANDARD | REQREC_ENDPOINT)) + if ((bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_STANDARD | REQREC_DEVICE)) || + (bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_STANDARD | REQREC_ENDPOINT))) { USB_Device_ClearSetFeature(); RequestHandled = true; @@ -105,7 +106,7 @@ void USB_Device_ProcessControlPacket(void) } if (!(RequestHandled)) - RAISE_EVENT(USB_UnhandledControlPacket); + EVENT_USB_UnhandledControlPacket(); if (Endpoint_IsSETUPReceived()) { @@ -118,8 +119,6 @@ static void USB_Device_SetAddress(void) { Endpoint_ClearSETUP(); - while (!(Endpoint_IsINReady())); - Endpoint_ClearIN(); while (!(Endpoint_IsINReady())); @@ -138,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) @@ -158,14 +157,14 @@ 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) { - Endpoint_ClearSETUP(); + Endpoint_ClearSETUP(); Endpoint_Write_Byte(USB_ConfigurationNumber); @@ -180,11 +179,44 @@ 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(USE_INTERNAL_SERIAL) + if (USB_ControlRequest.wValue == ((DTYPE_String << 8) | USE_INTERNAL_SERIAL)) + { + uint8_t SignatureDescriptor[2 + (sizeof(int16_t) * 20)]; + + SignatureDescriptor[0] = sizeof(SignatureDescriptor); + SignatureDescriptor[1] = DTYPE_String; + + uint16_t* SigUnicodeChars = (uint16_t*)&SignatureDescriptor[2]; + + for (uint8_t SerialByteNum = 0; SerialByteNum < 10; SerialByteNum++) + { + char ConvSigString[3]; + + itoa(boot_signature_byte_get(0x0E + SerialByteNum), ConvSigString, 16); + + SigUnicodeChars[0] = toupper(ConvSigString[0]); + SigUnicodeChars[1] = toupper(ConvSigString[1]); + + SigUnicodeChars += 2; + } + + Endpoint_ClearSETUP(); + Endpoint_Write_Control_Stream_LE(SignatureDescriptor, sizeof(SignatureDescriptor)); + Endpoint_ClearOUT(); + + return; + } + #endif + + 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 @@ -207,7 +239,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 @@ -299,7 +331,7 @@ static void USB_Device_ClearSetFeature(void) } else { - Endpoint_StallTransaction(); + Endpoint_StallTransaction(); } } } @@ -313,9 +345,6 @@ static void USB_Device_ClearSetFeature(void) Endpoint_ClearSETUP(); Endpoint_ClearIN(); - - while (!(Endpoint_IsOUTReceived())); - Endpoint_ClearOUT(); } #endif