User guide
CY3687 MoBL-USB FX2LP18 Development Kit User Guide, Doc. # 001-68582 Rev. *B 77
MoBL-USB Development Kit Firmware Examples
8.6 Bulksrc Firmware Example
8.6.1 Description
This project illustrates the configuration of MoBL-USB FX2LP18 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 TD_init() function of
bulksrc.c to handle bulk transfer: Two OUT (EP2/EP4) endpoints and two IN (EP6/EP8) endpoint
are double buffered pairs. The fifth endpoint is EP1 which acts as both Bulk IN and OUT endpoint
with 64 bytes 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 fixed pattern of data starting with 0x2 irrespective of data sent on
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 TD_poll() function if there is packet content in EP2 then it is re-armed again discarding the cur-
rent data.
// if there is some data in EP2 OUT, re-arm it
if(!(EP2468STAT & bmEP2EMPTY))
{