uint_8 USB_Desc_Get_Descriptor (
uint_8 controller_ID, /* [IN] Controller ID */
uint_8 type, /* [IN] type of descriptor requested */
uint_8 str_num, /* [IN] string index for string descriptor */
uint_16 index, /* [IN] string descriptor language Id */
uint_8_ptr *descriptor, /* [OUT] output descriptor pointer */
USB_PACKET_SIZE *size /* [OUT] size of descriptor returned */
)
{
UNUSED (controller_ID)
/* string descriptors are handled saperately */
if (type == USB_STRING_DESCRIPTOR)
{
switch (str_num)
{
case 0:
*descriptor = (uint_8_ptr)USB_STR_0;
*size = USB_STR_0[0];
break;
case 1:
*descriptor = (uint_8_ptr)USB_STR_1;
*size = USB_STR_1[0];
break;
case 2:
*descriptor = (uint_8_ptr)USB_STR_2;
*size = USB_STR_2[0];
break;
case 3:
*descriptor = (uint_8_ptr)USB_STR_3;
*size = USB_STR_3[0];
break;
case 0xEE:
*descriptor = (uint_8_ptr)USB_STR_EE;
*size = USB_STR_EE[0];
break;
default:
break;
}
}
else if (type < USB_MAX_STD_DESCRIPTORS+1)
{
/* set return val for descriptor and size*/
*descriptor = (uint_8_ptr)g_std_descriptors [type];
/* if there is no descriptor then return error */
if(*descriptor == NULL)
{
return USBERR_INVALID_REQ_TYPE;
}
*size = g_std_desc_size[type];
}
else /* invalid descriptor */
{
return USBERR_INVALID_REQ_TYPE;
}
return USB_OK;
}
uint_8_ptr const g_string_descriptors[USB_MAX_STRING_DESCRIPTORS+1] =
{
(uint_8_ptr const)USB_STR_0,
(uint_8_ptr const)USB_STR_1,
(uint_8_ptr const)USB_STR_2,
(uint_8_ptr const)USB_STR_3,
(uint_8_ptr const)USB_STR_n
};
uint_8 USB_STR_0[] =
{
USB_STR_SIZE(2),
USB_STRING_DESCRIPTOR,
0x09, 0x04 /*equiavlent to 0x0409*/
};
uint_8 USB_STR_1[] =
{
USB_STR_SIZE(11),
USB_STRING_DESCRIPTOR,
'E',0,
'S',0,
'C',0,
'O',0,
'R',0,
'T',0,
' ',0,
'I',0,
'n',0,
'c',0,
'.',0
};
uint_8 USB_STR_2[] =
{
USB_STR_SIZE(15),
USB_STRING_DESCRIPTOR,
'R',0,
'e',0,
'd',0,
'l',0,
'i',0,
'n',0,
'e',0,
' ',0,
'E',0,
'x',0,
' ',0,
'I',0,
'n',0,
't',0,
'l',0
};
uint_8 USB_STR_3[] =
{
USB_STR_SIZE(
,
USB_STRING_DESCRIPTOR,
'0',0,
'0',0,
'0',0,
'0',0,
'0',0,
'0',0,
'0',0,
'0',0
};
uint_8 USB_STR_EE[] =
{
USB_STR_SIZE(
,
USB_STRING_DESCRIPTOR,
'M', 0x00,
'S', 0x00,
'F', 0x00,
'T', 0x00,
'1', 0x00,
'0', 0x00,
'0', 0x00,
MSFT_VENDOR_CODE, 0x01
};
uint_8 USB_STR_n[] =
{
USB_STR_SIZE(16),
USB_STRING_DESCRIPTOR,
'B',0,
'A',0,
'D',0,
' ',0,
'S',0,
'T',0,
'R',0,
'I',0,
'N',0,
'G',0,
' ',0,
'I',0,
'N',0,
'D',0,
'E',0,
'X',0
};