阅读:1263回复:3
求助:SL811枚举设备时状态寄存器不对
我用51+SL811驱动USB,读写寄存器都正确,插上U盘时也能检测到,使用的是CY的例子程序
usbXfer()函数中: SL811Write(IntStatus,INT_CLEAR);// clear interrupt status result = SL811Read(EP0Status); // read EP0status register remainder = SL811Read(EP0Counter); // remainder value in last pkt xfer //-------------------------ACK---------------------------- if (result & EP0_ACK) // Transmission ACK { // SETUP TOKEN if(pid == PID_SETUP) // do nothing for SETUP/OUT token break; // exit while(1) immediately // OUT TOKEN else if(pid == PID_OUT) break; // IN TOKEN else if(pid == PID_IN) { // for IN token only wLen -= (WORD)xferLen; // update remainding wLen value cmd ^= 0x40; // toggle DATA0/DATA1 dataX++; // point to next dataX //------------------------------------------------ // If host requested for more data than the slave // have, and if the slave's data len is a multiple // of its endpoint payload size/last xferLen. Do // not overwrite data in previous buffer. //------------------------------------------------ if(remainder==xferLen) // empty data detected bufLen = 0; // do not overwriten previous data else // reset bufLen to zero bufLen = xferLen; // update previous buffer length //------------------------------------------------ // Arm for next data transfer when requested data // length have not reach zero, i.e. wLen!=0, and // last xferlen of data was completed, i.e. // remainder is equal to zero, not a short pkt //------------------------------------------------ if(!remainder && wLen) // remainder==0 when last xferLen { // was all completed or wLen!=0 addr = (dataX & 1) ? data1:data0;// select next address for data xferLen = (BYTE)(wLen>=wPayload) ? wPayload:wLen; // get data length required if (FULL_SPEED) // sync with SOF transfer cmd |= 0x20; // always sync SOF when FS, regardless SL811Write(EP0XferLen, xferLen); // select next xfer length SL811Write(EP0Address, addr); // data buffer addr SL811Write(IntStatus,INT_CLEAR);// is a LS is on Hub. SL811Write(EP0Control,cmd); // Enable USB transfer and re-arm } //------------------------------------------------ // Copy last IN token data pkt from prev transfer // Check if there was data available during the // last data transfer //------------------------------------------------ if(bufLen) { SL811BufRead(((dataX&1)?data0:data1), buffer, bufLen); buffer += bufLen; } //------------------------------------------------ // Terminate on short packets, i.e. remainder!=0 // a short packet or empty data packet OR when // requested data len have completed, i.e.wLen=0 // For a LOWSPEED device, the 1st device descp, // wPayload is default to 64-byte, LS device will // only send back a max of 8-byte device descp, // and host detect this as a short packet, and // terminate with OUT status stage //------------------------------------------------ if(remainder || !wLen) break; } } 在这里我读到的result一直是0x04,也就是传输超时,这是为什么呢?哪位高人帮我解释一下? |
|
沙发#
发布于:2007-08-27 10:08
楼主
你好,你的QQ是多少?探讨一下 |
|
板凳#
发布于:2007-06-21 15:49
cyan的单片机直接带usb主机,从机,otg接口,usb方面c源码免费提供。还有以太网接口,高速度12位a/d,d/a。开发简单方便。adl@loxford.com.cn
|
|
|
地板#
发布于:2007-06-21 15:37
问一下 SL811哪里能提供样品吗? 好像CY上已经停产了.
|
|