78
EZ-USB Development Kit User Guide, Doc. # 001-66390 Rev. *D
EZ-USB Development Kit Firmware Examples
EP4BCL = 0x80;// arm EP4OUT by writing byte count
w/skip.
SYNCDELAY;
EP4BCL = 0x80;
The above lines arm the two OUT endpoints by skipping two packets of data making the buffers
available to receive OUT data.
AUTOPTRSETUP |= 0x01;
This enables the AUTO pointer used for data transfer in the TD_Poll function.The data loopback is
implemented in the TD_Poll function that is called repeatedly when the device is idle. Endpoints 2
and 4 are armed to accept data from the host. This data is transferred to endpoint 6 and endpoint 8
respectively. To implement this, endpoint 2 is first checked to see if it has data. This is done by read-
ing the endpoint 2 empty bit in the endpoint status register (EP2468STAT). If endpoint 2 has data
(that is sent from the host), the capability of endpoint 6 to receive the data is checked. This is done
by reading the endpoint 6 Full bit in the endpoint status register. If endpoint 6 is not full, then the data
is transferred. This decision is executed by the following statements:
if (!(EP2468STAT & bmEP2EMPTY))
{// check EP2 EMPTY (busy) bit in EP2468STAT (SFR), core set's this bit
when
// FIFO is empty
if (!(EP2468STAT & bmEP6FULL))
{// check EP6 FULL (busy) bit in EP2468STAT (SFR), core set's this bit
// when FIFO is full
The data pointers are initialized to the corresponding buffers. The first auto pointer is initialized to the
first byte of the endpoint 2 FIFO buffer. The second auto-pointer is initialized to the first byte of the
endpoint 6 FIFO buffer. The number of bytes to be transferred is read from the byte count registers
of Endpoint 2. The registers EP2BCL, EP2BCH contain the number of bytes written into the FIFO
buffer by the host. These two registers give the byte count of the data transferred to the FIFO in an
OUT transaction as long as the data is not committed to the peripheral side. This data pointer initial-
ization and loading of the count is done in the following statements:
APTR1H = MSB( &EP2FIFOBUF ); // Initializing the first data pointer
APTR1L = LSB( &EP2FIFOBUF );
AUTOPTRH2 = MSB( &EP6FIFOBUF ); // Initializing the second data pointer
AUTOPTRL2 = LSB( &EP6FIFOBUF );
count = (EP2BCH << 8) + EP2BCL; // The count value is loaded from the byte
// count registers
The data transfer is carried out by the execution of the following loop:
for( i = 0x0000; i < count; i++ )
{
// setup to transfer EP2OUT buffer to EP6IN buffer using AUTOPOINTER(s)
EXTAUTODAT2 = EXTAUTODAT1;
}
Because auto pointers have been enabled, the pointers increment automatically, and the statement
EXTAUTODAT2 = EXTAUTODAT1;
transfers data from endpoint 2 to endpoint 6. Each time the above statement is executed, the auto
pointer is incremented. The above statement is executed repeatedly to transfer each byte from end-
point 2 to 6. After the data is transferred, endpoint 2 has to be 'rearmed' to accept a new packet from
the host. Endpoint 6 has to be 'committed', that is, make the FIFO buffers available to the host for
reading data from endpoint 6.
Summary of Contents for CY3674
Page 18: ...18 EZ USB Development Kit User Guide Doc 001 66390 Rev D Getting Started...
Page 34: ...34 EZ USB Development Kit User Guide Doc 001 66390 Rev D Development Kit Contents...
Page 54: ...54 EZ USB Development Kit User Guide Doc 001 66390 Rev D Cypress USB Drivers for EZ USB Kits...
Page 110: ...110 EZ USB Development Kit User Guide Doc 001 66390 Rev D Resources...
Page 113: ...EZ USB Development Kit User Guide Doc 001 66390 Rev D 113 A 2 Board Layout...