Content originally posted in LPCWare by danhauck on Fri Mar 15 02:17:08 MST 2013
Ive solved it
you only have to add the index (in my case 0x04) in the usb descriptor and add the following code in CALLBACK_USB_GetDescriptor
switch (DescriptorNumber)...
case 0x04:
Address = SerialNoStringPtr;
Size = pgm_read_byte(&SerialNoStringPtr->Header.Size);
then you have to add the string
uint8_t SerialNoString[] =
{
USB_STRING_LEN(12),
DTYPE_String,
WBVAL('U'),
WBVAL('C'),
WBVAL('R'),
WBVAL('0'),
WBVAL('0'),
WBVAL('0'),
WBVAL('0'),
WBVAL('0'),
WBVAL('0'),
WBVAL('0'),
WBVAL('0'),
WBVAL('0'),
};
USB_Descriptor_String_t *SerialNoStringPtr = (USB_Descriptor_String_t*)SerialNoString;
and then you have to add and call a init function (in my case USB_DescriptorInit) which reads the UID
void DescriptorInit(void){
unsigned int *pd = IO_IAP_GetDeviceUID(); // Eindeutige einmalige ID des Prozessors laden
unsigned int p = pd[0]^pd[1]^pd[2]^pd[3]; // 128bit sind mir zuviel ich mach 32bit draus
char b[8];
mysprintf(b,"%08x",p); // In String wandeln
// In den Deskriptor laden
SerialNoString[10] = b[0];
SerialNoString[12] = b[1];
SerialNoString[14] = b[2];
SerialNoString[16] = b[3];
SerialNoString[18] = b[4];
SerialNoString[20] = b[5];
SerialNoString[22] = b[6];
SerialNoString[24] = b[7];
}
The IO_IAP_GetDeviceUID-function you can find in the attachment
regards
daniel