?? usbgetdescriptor.c
字號:
#ifndef _USB_DEFINE
#include "USB.c"
#endif
void USBGetDescriptor(void)
{
switch (USBSetup->wValue&0x00ff)
{
case USB_GET_DESC_DEVICE :
USBEP0Buffer.Out=USBDeviceDescriptor;
USBEP0Buffer.OutLength=USBDeviceDescriptor[0]; //設備描述表長度
break;
case USB_GET_DESC_CONFIGURATION :
USBEP0Buffer.Out=USBConfigurationDescriptor;
if (USBSetup->wLength>0x1800) //配置描述標的長度
USBEP0Buffer.OutLength=sizeof(USBConfigurationDescriptor)
+ sizeof(USBInterfaceDescriptor)
+ sizeof(USBEndpoint1Descriptor)
+ sizeof(USBEndpoint2Descriptor);
else
USBEP0Buffer.OutLength=USBConfigurationDescriptor[0];
break;
case USB_GET_DESC_STRING :
switch (USBEP0Buffer.In[2])
{
case 0x00 :
USBEP0Buffer.Out=USBString1Descriptor;
USBEP0Buffer.OutLength=sizeof(USBString1Descriptor);
break;
case 0x01 :
USBEP0Buffer.Out=USBString3Descriptor;
USBEP0Buffer.OutLength=sizeof(USBString3Descriptor);
break;
case 0x02 :
USBEP0Buffer.Out=USBString3Descriptor;
USBEP0Buffer.OutLength=sizeof(USBString3Descriptor);
break;
case 0x03 :
USBEP0Buffer.Out=USBString3Descriptor;
USBEP0Buffer.OutLength=sizeof(USBString3Descriptor);
break;
}
break;
case USB_GET_DESC_INTERFACE :
USBEP0Buffer.Out=USBInterfaceDescriptor;
USBEP0Buffer.OutLength=sizeof(USBInterfaceDescriptor);
break;
case USB_GET_DESC_ENDPOINT :
USBEP0Buffer.Out=USBEndpoint1Descriptor;
USBEP0Buffer.OutLength=sizeof(USBEndpoint1Descriptor);
break;
default :
break;
}
USBEP0WritePacket();
if (USBEP0Buffer.OutLength==0x20&&USBSetup->wLength>0x2000) //發送0字節包
{
SET_BIT_7(UEPSTAX); //設置DIR
SET_BIT_4(UEPSTAX); //設置TXRDY
while(!( UEPSTAX & 0x01 )); //等待TXCMP
CLEAR_BIT_0(UEPSTAX); //清除TXCMP
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -