User guide
70 CY3687 MoBL-USB FX2LP18 Development Kit User Guide, Doc. # 001-68582 Rev. *B
MoBL-USB Development Kit Firmware Examples
High-speed USB implements a PING-NAK mechanism for (Bulk and Control) OUT transfers. When
the host wishes to send an OUT data to an endpoint, and the previous data transfer was responded
by a NYET, it first sends a PING token to see if the endpoint is ready (for example, if it has an empty
buffer). If a buffer is not available, the FX2LP returns a NAK handshake. PING-NAK transactions
continue to occur until an OUT buffer is available, at which time the FX2LP answers a PING with an
ACK handshake and the host sends the OUT data to the endpoint. MoBL-USB FX2LP18 implements
PING-NAK interrupt as EP0PING, EP1PING, etc., one for each endpoint. The EPxPING interrupt is
asserted when the host PINGs an endpoint and the MoBL-USB FX2LP18 responds with a NAK
because the particular endpoint buffer memory is not available. The MoBL-USB FX2LP18 firmware
framework provides hooks for all the interrupts that it implements. The example project uses
ISR_Ep2pingnak and ISR_Ep4pingnak interrupt service routines to handle EP2PING and EP4PING
interrupts respectively.
void ISR_Ep2pingnak(void) interrupt 0
{
SYNCDELAY; // Re-arm endpoint 2
EP2BCL = 0x80;
EZUSB_IRQ_CLEAR(); // clear the EP2PING interrupt
NAKIRQ = bmEP2PING;
}
The ISR_Ep2pingnak discards the previous data that is stored in one of the buffers of Endpoint 2 by
re-arming the endpoint (that is, EP2BCL = 0x80). Therefore, EP2 can now receive the data that is
currently being sent by the host because there is space available in one of its buffers. It then clears
the interrupt by setting a particular bit in NAKIRQ because it has been serviced. The same operation
is carried to service the EP4PING interrupt in ISR_Ep4pingnak.
8.4.2 Building Firmware Example Code for MoBL-USB FX2LP18 Internal RAM and
EEPROM
Click on Build Target button at the top right corner of the IDE. The total Code bytes of pingnak firm-
ware example is less than 4k code limit Keil uVision2 IDE provided along with the kit. The output of
the Build Target is pingnak.hex and pingnak.iic files.
8.4.3 Method to Download Firmware Image to MoBL-USB FX2LP18 Internal RAM and
External EEPROM
Refer to section Method to Download Firmware Image to MoBL-USB Internal RAM Memory on
page 62 and Method to Download Firmware Image to External I2C EEPROM on page 63 and follow
similar procedure to download pingnak.hex to RAM memory or pingnak.iic to Large EEPROM using
CyConsole or CyControlCenter.Both images are located at <Installed_directory>\<Version>\Firm-
ware\pingnak.After downloading, the firmware re-enumerates with PC using its internal VID/PID-
0x04B4/0x1004.
8.4.4 Binding Cypress USB Driver for the Downloaded Firmware Image
The pingnak project uses vendor class (0xFF) with VID/PID-0x04B4/1004.This example should bind
with Cypress generic USB driver cyusb.sys and driver information file cyusbfx2lp18.inf which con-
tains the relevant VID/PID of this example. Follow the procedure outlined in section Binding Cypress
USB Driver to MoBL-USB Development Board on page 43 to manually bind the driver using Win-
dows Hardware Wizard. If the binding process is performed for anyone of the firmware example the
process can be skipped for this example.