EZ-USB Development Kit User Guide, Doc. # 001-66390 Rev. *D 83
EZ-USB Development Kit Firmware Examples
8.6 Bulksrc Firmware Example
8.6.1 Description
This project illustrates the configuration of EZ-USB device to accept bulk data from the host and loop
it back to the host. Click on bulksrc.Uv2 located at <Installed_directory>\<Ver-
sion>\Firmware\Bulksrc and observe the code. Five endpoints are configured in the TD_init()
function of bulksrc.c to handle bulk transfer: Two OUT (EP2/EP4) endpoints and two IN (EP6/EP8)
endpoints are double-buffered pairs. The fifth endpoint is EP1, which acts as both the Bulk IN and
Bulk OUT endpoint with a 64-byte buffer. These are defined in the descriptor file (dscr.a51). The
endpoints are configured in this TD_init function. This is done by the following statements:
EP1OUTCFG = 0xA0;
EP1INCFG = 0xA0;
SYNCDELAY; // see TRM section 15.14
EP2CFG = 0xA2;
SYNCDELAY; //
EP4CFG = 0xA0;
SYNCDELAY; //
EP6CFG = 0xE2;
SYNCDELAY; //
EP8CFG = 0xE0;
After configuration, the OUT endpoints are 'armed' to accept data from the host. An OUT endpoint is
said to be armed if it is ready to accept data from the host. Each endpoint is configured as double-
buffered.
// since the defaults are double buffered we must write dummy byte counts
twice
SYNCDELAY; //
EP2BCL = 0x80; // arm EP2OUT by writing byte count w/skip.
SYNCDELAY; //
EP4BCL = 0x80;
SYNCDELAY; //
EP2BCL = 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.
The IN endpoint, EP6, is armed with a fixed pattern of data starting with 0x2, irrespective of the data
sent on the EP2 Bulk OUT endpoint, as shown in the following code.
for (i=0;i<512;i++)
EP6FIFOBUF[i] = i+2;
SYNCDELAY; //
EP6BCH = 0x02;
SYNCDELAY; //
EP6BCL = 0x00;
}
In the TD_poll() function, if there is packet content in EP2, then it is re-armed discarding the current
data.
// if there is some data in EP2 OUT, re-arm it
if(!(EP2468STAT & bmEP2EMPTY))
{