Hello,
I am using the latest LPCopen, v1.03. And I think I found a bug
in the examples where the descriptors will be set.
E.g. take a look in the Descriptors.c of the "KeyboardDevice".
For the ConfigurationDescriptor, TotalConfigurationSize, 1 will be
subtracted because of the termination byte.
But this is missing in the CALLBACK, here the code looks like:
case DTYPE_Configuration:
Address = &ConfigurationDescriptor;
Size = sizeof(USB_Descriptor_Configuration_t);
break;
I think the code should be changed to:
case DTYPE_Device:
Address = &DeviceDescriptor;
Size = DeviceDescriptor.Header.Size;
break;
case DTYPE_Configuration:
Address = &ConfigurationDescriptor;
Size = ConfigurationDescriptor.Config.TotalConfigurationSize;
break;
Best regards,
Michael
I've added a bug tracker issue for this at http://www.lpcware.com/content/bugtrackerissue/lpcusblib-descriptor-size-bug
Hello Micheal,
We agree with you, this is an issue! Our software will fail if host requests for device configuration with length equal to 0xFF, in this case, the block found by Vitah does not help!
Thank you, Micheal and Vitah! We will update the fix in next release!
With best regards,
Hello vitah,
the Problem is that the size is wrong reported. Here
I have checked it with an USB analyzer, and the size
was marked as wrong.
Best regards,
Michael
Hello Michael,
I thought like you too, but after digged into source code. I found that USBLIB will not always send descriptor data with the size specified in "Size" variable. Inside function Endpoint_Write_Control_Stream_LE, USBLIB will check for minimum number of Descriptor Struct size and requested length from host. So that I guess, in this case, the terminal byte will not be sent b/c host only requests size = TotalConfigurationSize.
Endpoint_Stream.c
...
uint8_t Endpoint_Write_Control_Stream_LE(uint8_t corenum, const void *const Buffer,
uint16_t Length)
{
Endpoint_Write_Stream_LE(corenum, (uint8_t *) Buffer, MIN(Length, USB_ControlRequest.wLength), NULL);
Endpoint_ClearIN(corenum);
...