
Cypress Semiconductor Corporation
SL811HS and SL811HST: Application Notes
©2001 Cypress Semiconductor Corporation. All rights reserved. The information
and specifications contained in this document are subject to change without
notice.
Date: 07/26/01
Revision: 1.21
Page: 35
if (ep==0 && pid != PID_SETUP) Cmd |= 0x40; else Cmd |= DToggl if (ep==0 && pid != PID_SETUP) Cmd |= 0x40; else Cmd |= DToggle[ep];e[ep];
retry = 1; rem = time_out = result = D0 = 0; retry = 1; rem = time_out = result = D0 = 0;
Cmd |= dbug; // set PRE for low speed Cmd |= dbug; // set PRE for low speed
while (1) while (1)
{ {
if (retry>0) if (retry>0)
{ {
SL11Write(IntStatus,0xff); SL11Write(IntStatus,0xff);
if (full_speed) if (full_speed)
{ {
if (SL11Read(0xf) > (BYTE)pl) if (SL11Read(0xf) > (BYTE)pl)
SL11Write(EP0Control,Cmd); // Enable ARM SL11Write(EP0Control,Cmd); // Enable ARM
else else
SL11Write(EP0Control,Cmd|0x20); // Enable ARM SL11Write(EP0Control,Cmd|0x20); // Enable ARM
} }
else else
SL11Write(EP0Control,Cmd); SL11Write(EP0Control,Cmd); // Enable ARM // Enable ARM
#ifdef REV13#ifdef REV13
if (dbug && pid==PID_IN) // handle low speed via Hub if (dbug && pid==PID_IN) // handle low speed via Hub
SL11Write(EP1Control,1); SL11Write(EP1Control,1);
#endif#endif
} }
retry++; retry++;
bLen = ((int)(len bLen = ((int)(len -- rLen) >= (int)payload) ? payload : (BYT rLen) >= (int)payload) ? payload : (BYTE)(len E)(len -- rLen); rLen);
addr = (D0 & 1) ? data0 : data1; // next ping pong buffer addr = (D0 & 1) ? data0 : data1; // next ping pong buffer
// Write ahead for ping pong buffer // Write ahead for ping pong buffer
if (pid == PID_OUT && retry <= 2 && bLen) if (pid == PID_OUT && retry <= 2 && bLen)
SL11BufWrite((short)(addr + cOFFSET), buf + rLen, bLen); SL11BufWrite((short)(addr + cOFFSET), buf + rLen, bLen);
if (Dela if (Delayms(TIMEOUT, 1)) yms(TIMEOUT, 1))
{ {
//printf("TIMEOUT: pid %x result %x //printf("TIMEOUT: pid %x result %x\\n", pid, SL11Read(EP0Status));n", pid, SL11Read(EP0Status));
result = 4; // indicate it is timeresult = 4; // indicate it is time--outout
} }
else else
{ {
result=SL11Read(EP0Status); result=SL11Read(EP0Status);
#ifdef REV12#ifdef REV12
if (pid==PID_IN && dbug && !(resul if (pid==PID_IN && dbug && !(result&0x40)) // handle low speed via hubt&0x40)) // handle low speed via hub
{ {
SL11Write(IntStatus,0xff); SL11Write(IntStatus,0xff);
SL11Write(EP0Control,9); SL11Write(EP0Control,9);
Delayms(1,1); Delayms(1,1);
} }
#endif#endif
} }
if (result & 1) if (result & 1)
{ {
D0++; D0++;
retry = 0; retry = 0;
Cmd Cmd ^= 0x40; ^= 0x40; // toggle DATA0/DATA1// toggle DATA0/DATA1
//Add for Shortpacket detection //Add for Shortpacket detection
if (pid==PID_IN) if (pid==PID_IN)
rem = (BYTE)SL11Read(EP0Counter); rem = (BYTE)SL11Read(EP0Counter);
len len --= rLen; // rLen = actual read/write= rLen; // rLen = actual read/write
if (bLen && len && rem==0) if (bLen && len && rem==0)
{ {
SL11Write(EP0XferLen, (BYTE)(cOFFSET+bLen)); SL11Write(EP0XferLen, (BYTE)(cOFFSET+bLen));
SL11Write(EP0Address, addr); // data addr SL11Write(EP0Address, addr); // data addr
SL11Write(IntStatus, 0xff); SL11Write(IntStatus, 0xff);
if (full_speed) if (full_speed)
{ {
if (SL11Rea if (SL11Read(0xf) > (BYTE)pl)d(0xf) > (BYTE)pl)
SL11Write(EP0Control,Cmd); // Enable ARM SL11Write(EP0Control,Cmd); // Enable ARM
else else
Kommentare zu diesen Handbüchern