Сами дескрипторы в usb.h
CODE
const char devDescriptor[] = {
0x12, // bLength // Device descriptor
0x01, // bDescriptorType
0x10, // bcdUSBL
0x01, //
0xFF, // bDeviceClass: CDC class code
0x00, // bDeviceSubclass: CDC class sub code
0x00, // bDeviceProtocol: CDC Device protocol
0x08, // bMaxPacketSize0
0xEB, // idVendorL
0x03, //
0x55, // idProductL
0x03, //
0x01, // bcdDeviceL
0x00, //
0x01, // iManufacturer // 0x01
0x02, // iProduct
0x03, // SerialNumber
0x01 // bNumConfigs
};
const char strDescriptor_IDL[]={
/* String_IDLanguages Descriptor */
0x04, // bLength
0x03, // bDescriptorType
0x09, // wLANGID[0]
0x04
};
const char strDescriptor_IMan[]={
/* String_IManufacturer Descriptor */
0x02+0x02*12, // bLength
0x03, // bDescriptorType
'O'<<8, 'r'<<8, 'g'<<8, 'a'<<8, 'n'<<8, 'i'<<8, 'z'<<8, 'a'<<8, 't'<<8, 'i'<<8, 'o'<<8, 'n'<<8 // bString
};
const char strDescriptor_IPro[]={
/* String_IProduct Descriptor */
0x02+0x02*9, // bLength
0x03, // bDescriptorType
'I'<<8, 'n'<<8, 't'<<8, 'e'<<8, 'r'<<8, 'f'<<8, 'a'<<8, 'c'<<8, 'e'<<8 //bString
};
const char strDescriptor_ISer[]={
/* String_ISerialNumber Descriptor */
0x02+0x02*11, // bLength
0x03, // bDescriptorType
'1'<<8,'2'<<8,'3'<<8,'-'<<8,'4'<<8,'5'<<8,'6'<<8,'-'<<8,'7'<<8,'8'<<8,'9'<<8 //bString
};
static char devDescriptor_ram[sizeof(devDescriptor)];
static char cfgDescriptor_ram[sizeof(cfgDescriptor)];
static char strDescriptor_IDL_ram[sizeof(strDescriptor_IDL)];
static char strDescriptor_IMan_ram[sizeof(strDescriptor_IMan)];
static char strDescriptor_IPro_ram[sizeof(strDescriptor_IPro)];
static char strDescriptor_ISer_ram[sizeof(strDescriptor_ISer)];
Обработка запроса GET_DESCRIPTOR в usb.c
CODE
...
if(!(pUDP->UDP_CSR[0] & AT91C_UDP_RXSETUP))return;
bmRequestType = pUDP->UDP_FDR[0];
bRequest = pUDP->UDP_FDR[0];
wValue = (pUDP->UDP_FDR[0] & 0xFF);
wValue |= (pUDP->UDP_FDR[0] << 8);
wIndex = (pUDP->UDP_FDR[0] & 0xFF);
wIndex |= (pUDP->UDP_FDR[0] << 8);
wLength = (pUDP->UDP_FDR[0] & 0xFF);
wLength |= (pUDP->UDP_FDR[0] << 8);
if(bmRequestType & 0x80)
{
while(!(pUDP->UDP_CSR[0] & AT91C_UDP_DIR))
pUDP->UDP_CSR[0] |= AT91C_UDP_DIR;
}
while((pUDP->UDP_CSR[0] & AT91C_UDP_RXSETUP))
pUDP->UDP_CSR[0] &= ~AT91C_UDP_RXSETUP;
switch ((bRequest << 8) | bmRequestType) // Handle supported standard device request Cf Table 9-3 in USB specification Rev 1.1
{
case STD_GET_DESCRIPTOR:
switch (wValue)
{
case 0x100: AT91F_USB_SendData(pUDP, devDescriptor_ram, MIN(sizeof(devDescriptor_ram), wLength)); break;
case 0x200: AT91F_USB_SendData(pUDP, cfgDescriptor_ram, MIN(sizeof(cfgDescriptor_ram), wLength)); break;
case 0x300: AT91F_USB_SendData(pUDP, strDescriptor_IDL_ram, MIN(sizeof(strDescriptor_IDL_ram), wLength)); break;
case 0x301: AT91F_USB_SendData(pUDP, strDescriptor_IMan_ram, MIN(sizeof(strDescriptor_IMan_ram), wLength)); break;
case 0x302: AT91F_USB_SendData(pUDP, strDescriptor_IPro_ram, MIN(sizeof(strDescriptor_IPro_ram), wLength)); break;
case 0x303: AT91F_USB_SendData(pUDP, strDescriptor_ISer_ram, MIN(sizeof(strDescriptor_ISer_ram), wLength)); break;
default: AT91F_USB_SendStall(pUDP); break;
}
break;
...
Индексы в дескрипторе устройства прописал, все запросы строковых дескрипторов обрабатываю, но при этом ни один из строковых
дескрипторов не приходит. Не подскажите, в чем тут может быть проблема.
Заранее благодарен.
Сообщение отредактировал Bulat - Jan 3 2011, 05:40