?? usbsetup.c
字號:
}
}
switch(ep0State)
{
case EP0_STATE_INIT:
break;
// GET_DESCRIPTOR:DEVICE
case EP0_STATE_GD_DEV_0:
DbgPrintf("[GDD0]");
WrPktEp0((UINT8T *)&descDev+0,8); //EP0_PKT_SIZE
SET_EP0_IN_PKT_RDY();
ep0State=EP0_STATE_GD_DEV_1;
break;
case EP0_STATE_GD_DEV_1:
DbgPrintf("[GDD1]");
WrPktEp0((UINT8T *)&descDev+0x8,8);
SET_EP0_IN_PKT_RDY();
ep0State=EP0_STATE_GD_DEV_2;
break;
case EP0_STATE_GD_DEV_2:
DbgPrintf("[GDD2]");
WrPktEp0((UINT8T *)&descDev+0x10,2); //8+8+2=0x12
SET_EP0_INPKTRDY_DATAEND();
ep0State=EP0_STATE_INIT;
break;
//=== GET_DESCRIPTOR:CONFIGURATION+INTERFACE+ENDPOINT0+ENDPOINT1 ===
//Windows98 gets these 4 descriptors all together by issuing only a request.
//Windows2000 gets each descriptor seperately.
case EP0_STATE_GD_CFG_0:
DbgPrintf("[GDC0]");
WrPktEp0((UINT8T *)&descConf+0,8); //EP0_PKT_SIZE
SET_EP0_IN_PKT_RDY();
ep0State=EP0_STATE_GD_CFG_1;
break;
case EP0_STATE_GD_CFG_1:
DbgPrintf("[GDC1]");
WrPktEp0((UINT8T *)&descConf+8,1);
WrPktEp0((UINT8T *)&descIf+0,7);
SET_EP0_IN_PKT_RDY();
ep0State=EP0_STATE_GD_CFG_2;
break;
case EP0_STATE_GD_CFG_2:
DbgPrintf("[GDC2]");
WrPktEp0((UINT8T *)&descIf+7,2);
WrPktEp0((UINT8T *)&descEndpt0+0,6);
SET_EP0_IN_PKT_RDY();
ep0State=EP0_STATE_GD_CFG_3;
break;
case EP0_STATE_GD_CFG_3:
DbgPrintf("[GDC3]");
WrPktEp0((UINT8T *)&descEndpt0+6,1);
WrPktEp0((UINT8T *)&descEndpt1+0,7);
SET_EP0_IN_PKT_RDY();
ep0State=EP0_STATE_GD_CFG_4;
break;
case EP0_STATE_GD_CFG_4:
DbgPrintf("[GDC4]");
//zero length data packit
SET_EP0_INPKTRDY_DATAEND();
ep0State=EP0_STATE_INIT;
break;
// GET_DESCRIPTOR:CONFIGURATION ONLY
case EP0_STATE_GD_CFG_ONLY_0:
DbgPrintf("[GDCO0]");
WrPktEp0((UINT8T *)&descConf+0,8); //EP0_PKT_SIZE
SET_EP0_IN_PKT_RDY();
ep0State=EP0_STATE_GD_CFG_ONLY_1;
break;
case EP0_STATE_GD_CFG_ONLY_1:
DbgPrintf("[GDCO1]");
WrPktEp0((UINT8T *)&descConf+8,1);
SET_EP0_INPKTRDY_DATAEND();
ep0State=EP0_STATE_INIT;
break;
// GET_DESCRIPTOR:INTERFACE ONLY
case EP0_STATE_GD_IF_ONLY_0:
DbgPrintf("[GDI0]");
WrPktEp0((UINT8T *)&descIf+0,8);
SET_EP0_IN_PKT_RDY();
ep0State=EP0_STATE_GD_IF_ONLY_1;
break;
case EP0_STATE_GD_IF_ONLY_1:
DbgPrintf("[GDI1]");
WrPktEp0((UINT8T *)&descIf+8,1);
SET_EP0_INPKTRDY_DATAEND();
ep0State=EP0_STATE_INIT;
break;
// GET_DESCRIPTOR:ENDPOINT 0 ONLY
case EP0_STATE_GD_EP0_ONLY_0:
DbgPrintf("[GDE00]");
WrPktEp0((UINT8T *)&descEndpt0+0,7);
SET_EP0_INPKTRDY_DATAEND();
ep0State=EP0_STATE_INIT;
break;
// GET_DESCRIPTOR:ENDPOINT 1 ONLY
case EP0_STATE_GD_EP1_ONLY_0:
DbgPrintf("[GDE10]");
WrPktEp0((UINT8T *)&descEndpt1+0,7);
SET_EP0_INPKTRDY_DATAEND();
ep0State=EP0_STATE_INIT;
break;
// GET_DESCRIPTOR:STRING
case EP0_STATE_GD_STR_I0:
DbgPrintf("[GDS0_0]");
WrPktEp0((UINT8T *)descStr0, 4 );
SET_EP0_INPKTRDY_DATAEND();
ep0State=EP0_STATE_INIT;
ep0SubState=0;
break;
case EP0_STATE_GD_STR_I1:
DbgPrintf("[GDS1_%d]",ep0SubState);
if( (ep0SubState*EP0_PKT_SIZE+EP0_PKT_SIZE)<sizeof(descStr1) )
{
WrPktEp0((UINT8T *)descStr1+(ep0SubState*EP0_PKT_SIZE),EP0_PKT_SIZE);
SET_EP0_IN_PKT_RDY();
ep0State=EP0_STATE_GD_STR_I1;
ep0SubState++;
}
else
{
WrPktEp0((UINT8T *)descStr1+(ep0SubState*EP0_PKT_SIZE),
sizeof(descStr1)-(ep0SubState*EP0_PKT_SIZE));
SET_EP0_INPKTRDY_DATAEND();
ep0State=EP0_STATE_INIT;
ep0SubState=0;
}
break;
case EP0_STATE_GD_STR_I2:
DbgPrintf("[GDS2_%d]",ep0SubState);
if( (ep0SubState*EP0_PKT_SIZE+EP0_PKT_SIZE)<sizeof(descStr2) )
{
WrPktEp0((UINT8T *)descStr2+(ep0SubState*EP0_PKT_SIZE),EP0_PKT_SIZE);
SET_EP0_IN_PKT_RDY();
ep0State=EP0_STATE_GD_STR_I2;
ep0SubState++;
}
else
{
DbgPrintf("[E]");
WrPktEp0((UINT8T *)descStr2+(ep0SubState*EP0_PKT_SIZE),
sizeof(descStr2)-(ep0SubState*EP0_PKT_SIZE));
SET_EP0_INPKTRDY_DATAEND();
ep0State=EP0_STATE_INIT;
ep0SubState=0;
}
break;
default:
DbgPrintf("UE:G?D");
break;
}
}
/*********************************************************************************************
* name: PrintEp0Pkt
* func: Print the Ep0's packet
* para: UINT8T *pt -- pointer to Ep0's packet
* ret: none
* modify:
* comment:
*********************************************************************************************/
void PrintEp0Pkt(UINT8T *pt)
{
int i;
DbgPrintf("[RCV:");
for(i=0;i<EP0_PKT_SIZE;i++)
DbgPrintf("%x,",pt[i]);
DbgPrintf("]");
}
/*********************************************************************************************
* name: InitDescriptorTable
* func: Initialization of USB Descriptor Table
* para: none
* ret: none
* modify:
* comment:
*********************************************************************************************/
void InitDescriptorTable(void)
{
//Standard device descriptor
descDev.bLength=0x12; //EP0_DEV_DESC_SIZE=0x12 bytes
descDev.bDescriptorType=DEVICE_TYPE;
descDev.bcdUSBL=0x10;
descDev.bcdUSBH=0x01; //Ver 1.10
descDev.bDeviceClass=0xFF; //0x0
descDev.bDeviceSubClass=0x0;
descDev.bDeviceProtocol=0x0;
descDev.bMaxPacketSize0=0x8;
descDev.idVendorL=0x45;
descDev.idVendorH=0x53;
descDev.idProductL=0x34;
descDev.idProductH=0x12;
descDev.bcdDeviceL=0x00;
descDev.bcdDeviceH=0x01;
descDev.iManufacturer=0x1; //index of string descriptor
descDev.iProduct=0x2; //index of string descriptor
descDev.iSerialNumber=0x0;
descDev.bNumConfigurations=0x1;
//Standard configuration descriptor
descConf.bLength=0x9;
descConf.bDescriptorType=CONFIGURATION_TYPE;
descConf.wTotalLengthL=0x20; //<cfg desc>+<if desc>+<endp0 desc>+<endp1 desc>
descConf.wTotalLengthH=0;
descConf.bNumInterfaces=1;
//dbg descConf.bConfigurationValue=2; why 2? There's no reason.
descConf.bConfigurationValue=1;
descConf.iConfiguration=0;
descConf.bmAttributes=CONF_ATTR_DEFAULT; //bus powered only.
descConf.maxPower=25; //draws 50mA current from the USB bus.
//Standard interface descriptor
descIf.bLength=0x9;
descIf.bDescriptorType=INTERFACE_TYPE;
descIf.bInterfaceNumber=0x0;
descIf.bAlternateSetting=0x0;
descIf.bNumEndpoints=2; //# of endpoints except EP0
descIf.bInterfaceClass=0xff; //0x0 ?
descIf.bInterfaceSubClass=0x0;
descIf.bInterfaceProtocol=0x0;
descIf.iInterface=0x0;
//Standard endpoint0 descriptor
descEndpt0.bLength=0x7;
descEndpt0.bDescriptorType=ENDPOINT_TYPE;
descEndpt0.bEndpointAddress=1|EP_ADDR_IN; // 2400Xendpoint 1 is IN endpoint.
descEndpt0.bmAttributes=EP_ATTR_BULK;
descEndpt0.wMaxPacketSizeL=EP1_PKT_SIZE; //64
descEndpt0.wMaxPacketSizeH=0x0;
descEndpt0.bInterval=0x0; //not used
//Standard endpoint1 descriptor
descEndpt1.bLength=0x7;
descEndpt1.bDescriptorType=ENDPOINT_TYPE;
descEndpt1.bEndpointAddress=3|EP_ADDR_OUT; // 2400X endpoint 3 is OUT endpoint.
descEndpt1.bmAttributes=EP_ATTR_BULK;
descEndpt1.wMaxPacketSizeL=EP3_PKT_SIZE; //64
descEndpt1.wMaxPacketSizeH=0x0;
descEndpt1.bInterval=0x0; //not used
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -