我写了三个自定义请求,其中两个SC_SetData和SC_ReadData可以执行,但是只有发送两次命令才能正确得到结果,而SC_ResetFIFO:则直接不能用,发命令时interface提示:
Vendor Request failed
A device attached to the system is not functioning.
不知道什么原因,求老师给点指导。
case SC_SET_FEATURE: // *** Set Feature
if(DR_SetFeature())
switch(SETUPDAT[0])
{
case FT_DEVICE: // Device
if(SETUPDAT[2] == 1)
Rwuen = TRUE; // Enable Remote Wakeup
else if(SETUPDAT[2] == 2)
// Set Feature Test Mode. The core handles this request. However, it is
// necessary for the firmware to complete the handshake phase of the
// control transfer before the chip will enter test mode. It is also
// necessary for FX2 to be physically disconnected (D+ and D-)
// from the host before it will enter test mode.
break;
else
EZUSB_STALL_EP0(); // Stall End Point 0
break;
case FT_ENDPOINT: // End Point
*(BYTE xdata *) epcs(SETUPDAT[4]) |= bmEPSTALL;
break;
default:
EZUSB_STALL_EP0(); // Stall End Point 0
}
break;
//自定义请求的响应///////////////////////////////////////////////////////////////////////
case SC_SetData:
DR_SetData();
break;
case SC_ReadData:
DR_ReadData();
break;
case SC_ResetFIFO: //自定义请求,复位FIFO
DR_ResetFIFO(); //自定义请求的处理函数
break;
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
default: // *** Invalid Command
if(DR_VendorCmnd())
EZUSB_STALL_EP0(); // Stall End Point 0
我用EZ-USB Interface发送请求码0xB1值为cfff,总线没有正确响应,再发一遍请求码0xB1值为cfff,输出正确。我发送请求码0xB3,Value为0x0202,结果EZ-USB Interface提示:
Vendor Request failed
A device attached to the system is not functioning.