u8 Setup0_Process(void)
{
union
{
u8* b;
u16* w;
} pBuf;
pBuf.b = PMAAddr + (u8 *)(_GetEPRxAddr(ENDP0) * 2); /* *2 for 32 bits addr */
#ifdef USB_DEBUG0
printf("\r\nSETUP0中断-->控制传输.建立过程\r\n");
#endif /* USB_DEBUG0 */
if (pInformation->ControlState != PAUSE)
{
#ifdef USB_DEBUG0
printf("设备可以接收新的数据\r\n");
#endif /* USB_DEBUG0 */
pInformation->USBbmRequestType = *pBuf.b++; /* bmRequestType */
pInformation->USBbRequest = *pBuf.b++; /* bRequest */
pBuf.w++; /* word not accessed because of 32 bits addressing */
pInformation->USBwValue = ByteSwap(*pBuf.w++); /* wValue */
pBuf.w++; /* word not accessed because of 32 bits addressing */
pInformation->USBwIndex = ByteSwap(*pBuf.w++); /* wIndex */
pBuf.w++; /* word not accessed because of 32 bits addressing */
pInformation->USBwLength = *pBuf.w; /* wLength */
}
#ifdef USB_DEBUG0
printf("设备接收数据如下:\r\n");
printf("0x%x ",pInformation->USBbmRequestType);
printf("0x%x ",pInformation->USBbRequest);
printf("0x%x ",pInformation->USBwValue0);
printf("0x%x ",pInformation->USBwValue1);
printf("0x%x ",pInformation->USBwIndex0);
printf("0x%x ",pInformation->USBwIndex1);
printf("0x%x ",pInformation->USBwLength1);
printf("0x%x ",pInformation->USBwLength0);
printf("\r\n");
#endif /* USB_DEBUG0 */
pInformation->ControlState = SETTING_UP;
if (pInformation->USBwLength == 0)
{
/* Setup with no data stage */
NoData_Setup0();
}
else
{
/* Setup with data stage */
Data_Setup0();
}
return Post0_Process();
}