AN70983 Designing a Bulk Transfer Host Application for EZ-USB FX2LP™/FX3™.pdf

AN70983
Designing a Bulk Transfer Host Application for EZ-USB® FX2LP™/FX3™
Author: Gayathri Vasudevan
Associated Part Family: CY7C6801XA, CYUSB3014
Associated Code Examples: None
Related Resources: For a complete list, click here.
To get the latest version of this application note, or the associated project file, please visit
http://www.cypress.com/AN70983
b
Cypress provides software development tools for the host PC in the form of a Visual Studio .NET library. This library
simplifies USB coding at the Windows level. This application note introduces the .NET class library and shows how to
create a Windows example to send and retrieve data using a “bulkloop” firmware example running on an FX2LP or FX3
Development Kit (DVK).
Contents
Introduction .......................................................................1
Functional Overview ..........................................................2
Application Note Folder Layout .........................................3
Development Boards ....................................................3
Download Firmware into Development Board Using
USB Control Center......................................................4
Application Overview .........................................................6
Features .......................................................................6
Operating Instructions ..................................................7
Using the Cypress .NET Library ........................................8
Adding a Reference to CyUSB.dll ................................8
Source Code Overview.................................................9
Asynchronous Communication ................................... 10
Firmware ......................................................................... 11
FX2LP Bulkloop Firmware .......................................... 11
FX3 Bulkloop Firmware .............................................. 13
Troubleshooting .............................................................. 15
System Requirements ..................................................... 15
Hardware .................................................................... 15
Development Software ............................................... 15
Related Resources.......................................................... 15
Summary ......................................................................... 15
Glossary .......................................................................... 16
Appendix: Windows Install of FX2LP/FX3 DVK Driver .... 17
Document History............................................................ 19
Worldwide Sales and Design Support ............................. 20
Products .......................................................................... 20
®
PSoC Solutions ............................................................. 20
Introduction
This application note demonstrates how to use the Cypress library for Microsoft .NET languages to implement host PC
applications to communicate with Cypress’s FX2LP and FX3 devices. Using this library, a Visual C#, Visual Basic, or Visual
C++ program can communicate with an FX2LP or FX3-based device at a high level of abstraction. For example, the
USBDeviceList and CyUSBDevice classes (explained in the Source Code Overview section) expose devices and endpoints as
simple class members. Communicating with USB devices using this high-level model is a great improvement over multiple
low-level Win32 API calls. For example, you can program a complete USB device tree display with only 15 lines of C# code.
A Visual Studio solution along with this application note provides example projects in Visual C#, Visual Basic, and Visual C++
languages. The host projects are built and tested using Microsoft Visual Studio Express 2012. The host application writes to
the BULK IN and BULK OUT endpoints of FX2LP or FX3. The library classes communicate with the provided Cypress USB
driver CyUsb3.sys to access these devices and endpoints.
To exercise the Windows Visual Studio code, an example firmware called “bulkloop” is provided for FX2LP and FX3 evaluation
boards along with this application note. This firmware accepts host PC data and sends the same data back to the PC on
command.
www.cypress.com
Document No. 001-70983 Rev. *D
1
Designing a Bulk Transfer Host Application for EZ-USB® FX2LP™/FX3™
This application note gives an overview of the Windows and device sides of the USB connection. It explains the software
layout for the example code associated with this application note and provides details to prepare the FX2LP and FX3
evaluation boards as test targets. The application note also demonstrates how to test drive the pre-compiled Windows code.
This allows you to run the Windows application without Visual Studio.
Functional Overview
Figure 1. System Block Diagram
PC
: CyUSB.dll
Cypress Application Library
Cypress Driver: CYUSB3.sys
or
FX2 LP DVK
(bulkloop.hex)
FX 3 DVK
(USBBulkLoopAuto.img)
Note FX3 DVK shown in Figure 1 is only representative. CYUSB3KIT-001/CYUSB3KIT-003 can be used.
In Figure 1, the host PC connects to one of two Cypress target boards with a USB cable. The FX2LP or FX3 evaluation board
is loaded with firmware that accepts BULK data on Endpoint 2-OUT and copies it for PC retrieval to the Endpoint 6-IN buffer.
The firmware file name is shown at the bottom of each board in Figure 1.
Note USB direction is host-centric; therefore, OUT is PC to device and IN is device to PC.
The host application sends data to EP2-OUT by making library calls to CyUSB.dll, which in turn communicates with the
Cypress USB driver CYUSB3.sys. When the host issues an IN request to EP6, the BULK data travels back in reverse through
CyUsb3.sys and the CyUsb.dll library call, and finally reaches the host application for display. Bulk data sent and received is
displayed in a PC text box, along with the number of transferred bytes. This data flow is depicted in Figure 2.
The Microsoft Visual Studio solution contains projects for Visual C# (shown in Figure 1 as Bulkloop_VCS), Visual Basic, and
Visual C++. They produce identical results.
www.cypress.com
Document No. 001-70983 Rev. *D
2
Designing a Bulk Transfer Host Application for EZ-USB® FX2LP™/FX3™
Figure 2. Bulkloop Data Flow
PC
Bulkloop.VCS
Bulkloop.VB
Bulkloop.VCPP
CyUSB.dll
CYUSB3.sys
FX2LP or
FX3 Board
EP2-OUT
EP6-IN
Application Note Folder Layout
Figure 3. Application Note Folder Layout
Cypress provides suites of software tools to develop firmware and .NET-based applications to talk to the FX2LP and FX3
devices. For convenience, the files used in this application note are supplied in the accompanying zip file. To download the full
tool suites, visit the Cypress website.
Figure 3 shows the application note folder layout.

Bulkloop_Solution: This is a Microsoft .NET solution, which implements the bulkloop tester in three languages - Visual
Basic, Visual C#, and Visual C++.

Drivers: When you plug in an FX2LP or FX3 development board for the first time, Windows asks for the location of a
suitable driver. This folder contains drivers for Windows XP (“wxp”), Windows Vista (“wlh”), and Windows 7 (“win7”). Vista
and Windows 7 drivers are provided for 32-bit systems (“x86”) and 64-bit systems (“x64”). The driver is called cyusb3.sys
and works for both FX3 and FX2LP.
Note ezusb.sys and cyusb.sys are the legacy drivers distributed by Cypress for FX2LP family of devices. We do not
recommend ezusb.sys or cyusb.sys for new designs. For more details on migrating to cyusb3.sys, refer to Migration of an
®
EZ-USB FX2LP™ Driver from CyUSB.sys to CyUSB3.sys.

Firmware: This folder contains BULK loopback firmware for the FX2LP and FX3 boards. The source code is included so
you can study, modify, and compile the code after downloading the full development suites.

USB Control Center: This Visual C# application, taken from the EZ-USB FX3 Software Development Kit (SDK),
downloads FX2LP and FX3 firmware into the respective development boards. Preparing the USB Target
Development Boards
The FX2LP development board is included in the FX2LP Development Kit. The FX3 board is included in the FX3 Development
Kit (CYUSB3KIT-001 or CYUSB3KIT-003). Before running the Windows code, a development board must be prepared to
execute the loopback function shown on the right in Figure 3. The companion .zip file to this application note contains two
firmware directories, one for Cypress FX2LP (Bulkloop_FX2LP) and the other for Cypress FX3 (Bulkloop_FX3).
Before loading the loopback firmware, verify that the jumpers and switches are set according to Table 1 for the FX2LP board
and Table 2/Table 3 for the FX3 board.
www.cypress.com
Document No. 001-70983 Rev. *D
3
Designing a Bulk Transfer Host Application for EZ-USB® FX2LP™/FX3™
Table 1. FX2LP Evaluation Board Settings
Jumper/Switch
Purpose
Setting
JP1, JP10
3.3 V to EZ-USB chip
IN,IN
JP2
Vbus powered
IN
JP3
Activates 4 LEDS
IN(x4)
JP5
3.3 V current monitor
IN
JP6, JP7
FX2LP memory map
(int + ext RAM)
OUT, OUT
JP8
Secondary wakeup
x
SW1
Small/Large EEPROM
x
SW2
EEPROM enable
OFF (No EEPROM)
Table 2. FX3 Evaluation Board (CYUSB3KIT-001) Settings
Jumper/Switch
Purpose
Setting
PMODE switch
Select USB download
1,2: OFF(down),3,4: x
J96,J97
Select USB download
Upper two pins (2-3)
J98
Select USB download
Unconnected
J53
Vbus powered
IN
Table 3. FX3 Evaluation Board (CYUSB3KIT-003 Settings)
Jumper/Switch
Purpose
Setting
J3
Development board is powered from USB 3.0 VBUS
Short
J4
Select USB download
Short
J5
Deselect external SRAM
Open
When the boards are configured as shown in the tables, FX2LP and FX3 use internal logic to enumerate as a USB loader
device, ready to download user firmware over USB.
Download Firmware into Development Board Using USB Control Center
Double-clicking the CyControl.exe file in the USB Control Center folder brings up the USB Control Center console. Figure 4
shows how the FX2LP or FX3 boards appear in the left panel device list.
FX3 board appears as “Cypress USB Bootloader” (FX2LP board as “FX2LP Default Device: NO EEPROM”) if the CyUSB3.inf
file provided in the attachment is used.
Figure 4. USB Control Center Device List
If you do not see anything in the left panel, the development board may be configured incorrectly or the Windows driver may
not be installed. Refer to the Appendix for details.
www.cypress.com
Document No. 001-70983 Rev. *D
4
Designing a Bulk Transfer Host Application for EZ-USB® FX2LP™/FX3™
Note Some versions of the USB Control Center may list all connected USB devices in the left panel. To simplify the display,
click the Device Class Selection tab and deselect all but the Devices served by the CyUSB.sys drive… checkbox.
To download the bulkloop firmware into a development board, select the board you are using (Figure 4). Click the Program
item, select either the FX2 or FX3 item, and select RAM to download the firmware into the on-chip program memory. Then
navigate to the respective file as follows:
FX2: Firmware\Bulkloop_Fx2LP\bulkloop.hex
FX3: Firmware\Bulkloop_FX3\USBBulkLoopAuto\Debug\ USBBulkLoopAuto.img
Double-click the file to load the firmware. The USB loader device is replaced by the USB loopback device shown in Figure 5.
Figure 5. Bulkloop Device
This is EZ-USB ReNumeration in action. After the bulkloop firmware loads, the development board automatically disconnects
from the USB and reconnects as the device implemented by the downloaded firmware. The FX2LP or FX3 development board
is now ready to serve as the USB loopback peripheral for the PC example code in this application note.
www.cypress.com
Document No. 001-70983 Rev. *D
5
Designing a Bulk Transfer Host Application for EZ-USB® FX2LP™/FX3™
Application Overview
To test drive the application, double-click the executable file in the directory corresponding to your desired .NET language:



VB_Application\Application\Bulkloop_VB.exe
VC++_Application\Application\Bulkloop_VCPP.exe
VCS_Application\Application\Bulkloop_VCS.exe
Features
Figure 6 shows the user interface of the Bulkloop application.
Figure 6. User Interface
This application user interface is designed to show the
following:

Status: Reports whether the target device is currently
connected or disconnected.

Endpoint Pair OUT/IN: Endpoint pair on the target
device, currently in use as OUT and IN endpoints for
transferring data to and from the target. This is
informational only (not user-editable), reflecting the
settings in the source code.

Data Bytes (Hex): A user-selectable data pattern
(maximum allowed length of eight nibbles or four
bytes), which will be transferred in loopback fashion
during bulk-loop operation.
www.cypress.com

Bytes Transferred OUT: The log of bytes transferred
from the host PC to the target. Each line begins with
the starting address of bytes in the line.

Bytes Transferred IN: Same as OUT, except that the
bytes transferred are IN bytes from the target to the
host PC.

Number of Bytes transferred OUT: Number of bytes
transferred from the PC to the target.

Number of Bytes transferred IN: Number of bytes
transferred from the target to the PC.


Start/Stop: Bulk-loop operation start/stop button.
DeviceTreeView: Displays all the connected devices
bound to Cyusb3.sys.
Document No. 001-70983 Rev. *D
6
Designing a Bulk Transfer Host Application for EZ-USB® FX2LP™/FX3™
Operating Instructions
When a loopback device is detected, the Status box indicates “connected” and the left panel shows a tree indicating the
internal organization of the USB device. You can enter a byte pattern to transfer or accept the default 0x12345678 byte
pattern. Press the Start button; the loopback device sends and receives packets continuously.
Figure 7. Data Transfer from Bulkloop Application
Press Stop to terminate the transfers. The byte counters can be used to measure USB transfer bandwidth for this application
using various host controllers and PCs.
The remainder of this document describes the .NET language applications in detail.
www.cypress.com
Document No. 001-70983 Rev. *D
7
Designing a Bulk Transfer Host Application for EZ-USB® FX2LP™/FX3™
Using the Cypress .NET Library
Adding a Reference to CyUSB.dll
CyUSB.dll is a managed Microsoft .NET class library that
provides a high-level programming interface to USB
devices. You can access its classes and methods from
any of the Microsoft Visual Studio.NET managed
languages such as Visual Basic.NET, C#, Visual J#, and
managed C++.
If you have multiple projects in the ‘build’ operation, select
the language version by right-clicking the project name
and set it as the startup project. This is a quick way to
switch between languages.
Figure 9. Add CyUSB.dll Reference to All Three
Projects
Figure 8. Application Development with CyUSB.dll
To use the Cypress library, perform these two steps:
1.
Add a library reference to CyUSB.dll in your project.
2.
Add a line in your source file to include the library in
your program.
Figure 9 shows where the library references are listed in
the Visual Basic, VC++, and VC# projects in the
Bulkloop_Exerciser solution. If expanding the reference
item does not show CyUSB, right-click the project name,
select the “reference” item, and browse to the folder
containing CyUSB.dll. The projects supplied with this
application note use the path C:\AN70983\CyUSB.dll. If
you install the application note files elsewhere, these
references need to be updated to match your file location.
All the projects in the solution compile when you click the
Build button; any error messages apply to all three
projects. You can limit error messages to the project you
are using by excluding the other two projects from the
‘build’ operation. In the Solution Explorer panel, right-click
the solution name, select Properties, and uncheck the
projects you wish to exclude from the build operation.
www.cypress.com
Depending on the language, add a reference to the code
at the top of the file according to Table 4.
Table 4. Reference Syntax for .NET Languages
Language
File
Added line
Visual Basic
form1.vb
Imports CyUSB
Visual C#
form1.cs
Using CyUSB
Visual C++
form1.h
#using "..\..\..\Application\CyUSB.dll"
(or the respective path in your
computer)
Document No. 001-70983 Rev. *D
8
Designing a Bulk Transfer Host Application for EZ-USB® FX2LP™/FX3™
Source Code Overview
The following table explains the functionalities and important steps of the host application code.
Table 5. Code Overview
Action/Function
Object initialization
Device attach and
removal detection
RefreshDevice()
Data Transfer
Operation
Description

Creates and initializes instances of the classes
USBDeviceList, CyUSBDevice, CyBulkEndPoint, and
other required variables.

“usbDevices” represents a dynamic list of USB devices
that are accessible via the class library. It populates
itself with USBDevice objects representing all USB
devices bound to Cyusb3.sys, served by the device
selector mask, “DEVICES_CYUSB”.

When the connection between the host and the target
hardware is established, the event_handler function
usbDevices_DeviceAttached() is called.

When the target device is disconnected, the
event_handler function usbDevices_DeviceRemoved()
is called.

Both of these event handlers in turn call function
RefreshDevice().

Instantiates “myDevice” with the device of interest,
based on the VID and PID of the device. The bulkloop
firmware used in this example uses the VID/PID:
0x04B4/0x00F0.

If there are multiple devices with this VID/PID,
“myDevice” will be instantiated with the handle to the
first connected device.

Enables or disables the status label and the Start/Stop
button.

If the device of interest is found, instantiates the
“BulkOutEndpt” and “BulkInEndpt” with endpoints EP2
and EP6, respectively, because the bulkloop firmware in
this example uses the same endpoints.

Clears and updates the tree view with the latest list of
devices bound to Cyusb3.sys.

StartBtn_Click() eventhandler is invoked on clicking the
Start button

This function first takes the user’s value from the ‘Data
Bytes(Hex)’ field of the application user interface,
changes the text of the button to “Stop”, and starts the
thread “tXfers” where the data communication is
actually carried out.

www.cypress.com
CyUSB.dll API

USBDeviceList represents a dynamic list of
USB devices that are accessible via the class
library. When an instance of USBDeviceList is
created, it populates itself with USBDevice
objects representing all the USB devices
served by the indicated device selector mask.
These USBDevice objects are initialized
correctly and are ready for use.

The CyUSBDevice class represents a USB
device attached to the Cyusb3.sys device
driver.

CyBulkEndPoint is a subclass of the
CyUSBEndPoint abstract class.


USBDeviceList[int VID, int PID]: This index
operator provides access to elements of the
USBDeviceList based on the VendorID and
ProductID properties of the USBDevice
objects in the list.

EndpointOf( byte addr ): Returns the
CyUSBEndPoint object whose Address
property is equal to addr. Returns null if no
endpoint with Address = addr is found.

The other parent thread only take cares of application
user interface events and other OS events.
Document No. 001-70983 Rev. *D
9
Designing a Bulk Transfer Host Application for EZ-USB® FX2LP™/FX3™
Action/Function
Description

CyUSB.dll API
If the thread is already running, this eventhandler aborts
the thread and changes the text of the button back to
“Start”.
TransfersThread()
SetOutputData()
StatusUpdate()
XferData(ref byte[] buf, ref int len): The XferData
method sends or receives len bytes of data
from/into buf. This is the primary I/O method of the
library for transferring data. It performs
synchronous (blocking) I/O operations and does
not return until the transaction completes or the
endpoint's TimeOut has elapsed. Returns true if the
transaction successfully completes before TimeOut
has elapsed. The number of bytes actually
transferred is passed back in len.

Calls SetOutputData() to set up the data for OUT
transfers.

After the thread is started, data transfers in the OUT
and IN direction are started using the XferData() API.

It takes the user-given data in the ‘Data Bytes(Hex)’
field of the application user interface and fills the
‘outData[]’ buffer with these bytes, which are transferred
out in the OUT transfers.


This is the call back function for updating the UI and is
called from TransfersThread. This updates the
textboxes in the UI with the Bytes transferred and
number of Bytes transferred.

Asynchronous Communication
This application uses synchronous communication to move data between the host and the target. In this method, the data
transfer function ‘XferData’ does not return until the full data is transferred. In other words, the application is blocked until the
full data transfer completes. After that, the next data transfer operation starts. This method is suitable for most applications.
But with applications that need to use the full data bandwidth available for transfers, the more advanced asynchronous
communication method is used. Asynchronous transfers are more complex, suitable for advanced users. The ‘Streamer’
example that comes with the Cypress USBSuite shows how to use the asynchronous communication method.
www.cypress.com
Document No. 001-70983 Rev. *D
10
Designing a Bulk Transfer Host Application for EZ-USB® FX2LP™/FX3™
Firmware
The firmware configures the endpoints and the interface to carry out bulk data loopback operation. Two endpoints are
configured to handle bulk transfer: the OUT endpoint and IN endpoint. Data sent from the host is stored in an OUT endpoint
buffer. This data is transferred to the IN endpoint and then sent back to the host on request.
FX2LP Bulkloop Firmware
The following code snippets explain important code functionalities of the FX2LP bulkloop firmware.
Action
Descriptor
Information
Description







File Name


dscr.a51
TD_Init()
bulkloop.c
PID: 0x00F0
Device class: Vendor
Number of configurations: 1
Number of interfaces: 1
Number of endpoints: 2
Endpoints supported:
EP2 BULK OUT, 512 byte maxpacket size
EP6 BULK IN, 512 bytes maxpacket size
Different component initialization of the FX2LPbased target is done in the TD_Init() function. This
function is called from main() for initialization.

Sets the CPU clock to 48 MHz
CPUCS =((CPUCS &
~bmCLKSPD) |
bmCLKSPD1);



IFCONFIG |= 0x40;
Configures the interface of the FX2LP.
FX2LP is configured in the slave FIFO mode
Interface clock is chosen to be internal 48MHz clock.
The endpoints are configured as follows:
Initialization
Function
Name
VID: 0x04B4



Code Snippets



Endpoint 2 – OUT, Bulk, double buffered, 512 bytes
Endpoint 6 – IN, Bulk, double buffered, 512 bytes
The OUT endpoints, after configuring, need to be
armed to accept packets from the host. Because the
endpoints are double-buffered, two packets must be
skipped to arm the endpoint. Arming is essentially
freeing up the buffers and making them available to
the host to receive packets.

By writing a ‘1’ to bit 7 of the byte count register, the
packet is skipped.

Enables the AUTO pointer used for data transfer in
the TD_Poll function.
www.cypress.com
EP2CFG = 0xA2;
SYNCDELAY;
EP6CFG = 0xE2;
SYNCDELAY;
EP2BCL = 0x80;
SYNCDELAY;
EP2BCL = 0x80;
SYNCDELAY;
AUTOPTRSETUP |= 0x01;
Document No. 001-70983 Rev. *D
11
Designing a Bulk Transfer Host Application for EZ-USB® FX2LP™/FX3™
Description
Code Snippets

The bulkloop implementation is carried out in the TD_Poll()
function. This function is called repeatedly when the device
is idle

Checks Endpoint 2 to see if it has data. This is done by
reading the Endpoint 2 empty bit in the endpoint status
register (EP2468STAT).

If Endpoint 2 has data (sent from the host), checks the
capability of Endpoint 6 to receive the data. This is done by
reading the endpoint 6 ‘Full’ flag indicated by a full bit in the
endpoint status register.
if(!(EP2468STAT &
bmEP6FULL))
If Endpoint 6 is not full, then the data is transferred.
}

Function
Name
File Name

if(!(EP2468STAT &
bmEP2EMPTY))
{
{
}
APTR1H = MSB(

Data
Loopback

To transfer data, 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.
);
APTR1L = LSB(
&EP2FIFOBUF
);
AUTOPTRH2 = MSB(
&EP6FIFOBUF
);
AUTOPTRL2 = LSB(
);



The number of bytes to be transferred is read from the byte
count registers of Endpoint 2. The EP2BCL and EP2BCH
registers 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 and OUT transaction
as long as the data is not committed to the peripheral side.
Because auto pointers are enabled, the pointers increment
automatically and the statement EXTAUTODAT2 =
EXTAUTODAT1 transfers data from Endpoint 2 to
Endpoint 6. Each time this statement is executed, the auto
pointer is incremented. This statement is executed
repeatedly to transfer each byte from Endpoint 2 to 6.
After the data is transferred, Endpoint 2 must be re-armed
to accept a new packet from the host. Endpoint 6 is
“committed”, that is, the FIFO buffers are made available to
the host for reading data from Endpoint 6
&EP2FIFOBUF
bulkloop.c
TD_Poll()
&EP6FIFOBUF
count = (EP2BCH <<
8) + EP2BCL;
for( i = 0x0000; i <
count; i++ )
{
}
EXTAUTODAT2 =
EXTAUTODAT1;
EP6BCH = EP2BCH;
SYNCDELAY;

EP6BCL = EP2BCL;
SYNCDELAY;
EP2BCL = 0x80;
www.cypress.com
Document No. 001-70983 Rev. *D
12
Designing a Bulk Transfer Host Application for EZ-USB® FX2LP™/FX3™
FX3 Bulkloop Firmware
The following code snippets explain code functionalities of the FX3 bulkloop firmware.
Description
Descriptor
Information
Initialization







FX3 APIs
cyfxbulklpdscr.c
Device class: Vendor
Number of configurations: 1
Number of interfaces: 1

Number of endpoints: 2
Endpoints supported:

EP2 BULK OUT, maxpacket size of 1024 byte for
SS, 512 byte for HS

EP6 BULK IN, maxpacket size of 1024 bytes for
SS, 512 byte for HS

The RTOS kernel is invoked next from the
main(). This is a non-returning call and sets up
the Threadx kernel. This function needs to be
invoked as the last function from the main ()
function

FX3 application definition function is invoked
from the system module after the device and all
the modules are initialized. The application
threads and other required OS primitives can be
created here. At least one thread must be
CyU3PThreadCreate()
created. This function should not be explicitly
invoked.
Sets the functional mode of the 61 I/O pins
available in FX3

BulkLpAppThread_Entry is the application
thread created.

CyFxBulkLpApplnDebugInit() initializes the
debug module

CyFxBulkLpApplnInit() initializes the bulkloop
application

Starts the USB device mode driver in the USB
3.0 platform and creates the DMA channels
required for the control endpoint

Registers a USB setup request handler with the
USB driver.
www.cypress.com

PID: 0x00F0
FX3 device is initialized

File name
VID: 0x04B4



Function Name
Registers a USB event callback function with the
USB driver. CyFxBulkLpApplnUSBEventCB is
registered in this application.
Registers a USB 3.0 LPM request handler
callback.
CyU3PDeviceInit()
CyU3PDeviceConfigureI
main()
OMatrix()
CyU3PKernelEntry()
CyFxApplicationDef
ine()
cyfxbulklpauto.c



CyU3PUsbStart()

CyU3PUsbRegisterE
ventCallback()

CyU3PUsbRegisterL
PMRequestCallback
()
BulkLpAppThread_
Entry()
CyU3PUsbRegisterS
etupCallback()
Document No. 001-70983 Rev. *D
CyFxBulkLpApplnIn
it()
13
Designing a Bulk Transfer Host Application for EZ-USB® FX2LP™/FX3™
Description

FX3 APIs
Registers USB descriptors with the USB driver.
The driver is capable of remembering one
descriptor each of the various supported types
as well as up to eight different string descriptors.
The driver only stores the descriptor pointers
that are passed into this function; it does not
make copies of the descriptors. Therefore, the
caller should not free up these descriptor buffers
while the USB driver is active.

Enable/disable the USB connection. This
function is used to enable or disable the USB
PHYs on the USB 3.0 platform and to control the
connection to the USB host in that manner.

CyFxBulkLpApplnStart () is called upon Set
Configuration event, which in turn configures
USB endpoint's properties.

Creates a DMA channel. A DMA channel
requires a producer socket, a consumer socket,
a set of buffers, and a callback function. In this
example, an auto channel is created between
EP2 as producer socket and EP6 as consumer
socket. Whenever, EP2 receives any data it will
be automatically committed to EP6.
Data
Loopback

www.cypress.com


CyU3PUsbSetDesc()

CyU3PSetEpConfig(
)

CCyU3PDmaChannelC
reate()

Function Name
File name
CyU3PConnectState
()
CyU3PDmaChannelSe
tXfer()
CyFxBulkLpApplnS
tart ()
CyFxBulkLpApplnS
tart ()
Set a transfer on the DMA channel. The function
starts a transaction the selected DMA channel.
Document No. 001-70983 Rev. *D
14
Designing a Bulk Transfer Host Application for EZ-USB® FX2LP™/FX3™
Troubleshooting
Related Resources
1.
The host application will fail to compile and the
CyUSB.dll APIs will not be accessible if the CyUSB.dll
is not properly added and included for reference.
Follow the instructions provided in Adding a
Reference to CyUSB.dll.
2.
If any of the CyUSB APIs fail, check the return code
for the respective API. The return code values and
their meaning is documented in the CyUSB.dll
documentation located at “<InstallDirectory>\Cypress
Suite USB 3.4.x\CyUSB.NET\CyUSB.NET” after
installing SuiteUSB.
3.
4.
If the XferData/BeginDataXfer APIs fail, use the
“UsbdStatus” or “UsbdStatusString()” to get the error
code from the last call to the XferData or
BeginDataXfer APIs

UsbSuiteQuickStartGuide helps in getting started with
developing host applications in Visual C# using
CyUSB.dll; and Visual C++ using CyAPI.lib.

Programmer’s Reference C# library (CyUSB.NET.pdf)
is available with Cypress USB Suite.

More application examples are provided with the
Cypress USB Suite and FX3 SDK such as:


EZ-USB FX2LP/FX3 Developing Bulk-Loop Example
on Linux describes how you can use libusb to develop
a USB host application on a Linux-based operating
system for Cypress EZ-USB FX2LP/FX3 products.
This application note is provided only for reference.
Cypress also provides Linux SDK which can be found
at FX3 SDK web page.

EZ-USB FX2LP - Developing USB Application on
MAC OS X using LIBUSB describes how libusb-1.0
can be used to develop USB host applications (Cocoa
Application) on MAC OS X 10.6/10.7 for Cypress EZUSB FX2LP products. This application note is
provided only for reference. Cypress also provides
MAC SDK which can be found at FX3 SDK web page.

For complete list of USB SuperSpeed Code
Examples, visit http://www.cypress.com/101781 and
for complete list of USB Hi-Speed Code Examples,
visit http://www.cypress.com/101782.
System Requirements
FX2LP
An FX2LP DVK (CY3684) board is used as the
development and testing platform for this example for
FX2LP. A detailed schematic of the DVK is provided in the
hardware folder after FX2LP DVK install. More information
about the board is available in the ‘EZ-USB Advanced
Development Board’ section of the EZ-USB_Getting
Started document available with the FX2LP DVK.
FX3
An FX3 DVK (CYUSB3KIT-001 or CYUSB3KIT-003)
board can be used as the development and testing
platform for this example for FX3. A detailed schematic of
the DVK is provided in the hardware folder (after you
install the appropriate FX3 DVK).
Development Software


Control Center: User interface to communicate
with USB devices served by CyUSB3.sys.

If APIs are unable to access the device, ensure the
device handle is properly assigned
Hardware
Streamer: Can be used to test the data transfer.
Summary
This application note discusses the various aspects to
build host PC applications using the Cypress library for
Microsoft .NET languages to implement to communicate
with Cypress's FX2LP and FX3 devices.
Microsoft .NET framework 4.5
ControlCenter – Available by installing the Cypress
USB Suite.

Keil uVision 2 – The 4K-byte evaluation version is
available with the CY3684 DVK. For the full version,
contact Keil.


Eclipse IDE – Available by installing FX3 SDK.
Microsoft Visual Studio 2010 or 2012.
www.cypress.com
Document No. 001-70983 Rev. *D
15
Designing a Bulk Transfer Host Application for EZ-USB® FX2LP™/FX3™
Glossary
Term
Meaning
Microsoft Visual Studio
Microsoft Visual Studio is an integrated development environment (IDE) from Microsoft. It is used
to develop console and graphical user interface applications along with Windows Forms or WPF
applications in both native code together with managed code for all platforms supported
by Microsoft Windows, Windows Mobile, Windows CE, .NET Framework,.NET Compact
Framework, and Microsoft Silverlight.
Microsoft Visual C#
The Microsoft version of the C# language designed for managed environments.
Microsoft Visual C++
Commercial IDE product from Microsoft for the C, C++, and C++/CLI programming languages.
Microsoft Visual Basic
Visual Basic .NET (VB.NET) is an object-oriented computer programming language that can be
viewed as an evolution of the classic Visual Basic (VB), implemented on the .NET Framework.
Visual Basic is a third-generation event-driven programming language and IDE from Microsoft for
its COM programming model
CYy3684 DVK
Cypress development kit for the EZ-USB FX2LP family. For more information, see the Cypress
website.
CYUSB3KIT – 001/ CYUSB3KIT – 003
Cypress development kit for the EZ-USB FX3. For more information, see CYUSB3KIT-001 or
(EZ-USB® FX3™ SuperSpeed Explorer
CYUSB3KIT-003.
Kit)
EZ-USB
Generic name for all Cypress high-speed USB products such as FX2LP.
FX2LP
Cypress high-speed USB controllers. For more information, see the CYUSB3KIT-001 or
CYUSB3KIT-003.
FX3
Cypress’s EZ-USB FX3 is the next-generation USB 3.0 peripheral controller, providing integrated
and flexible features. For more information, see the Cypress website.
Cypress USB Suite
Cypress USB development tools for Visual Studio. For more information, see the Cypress
website.
CyUSB.dll
Cypress library for software development using .NET technologies. For more information, see the
Programmer’s Reference C# library (CyUSB.NET.pdf) that is available with Cypress USB Suite.
Cyusb3.sys
Cypress Windows driver for USB communication. For more information, see the Cypress
CyUsb3.sys Programmers Reference.
USB Control Center
Cypress application for general-purpose USB functionality such as device identification and code
image downloads. The application is available through Cypress USB Suite.
Keil uVision
The 4K-byte evaluation version is available with the CY3684 DVK. For the full version, contact
Keil.
Eclipse IDE
As part of the development tools, the FX3 SDK provides the Eclipse IDE for C/C++ developers. It
comprises the Eclipse base platform and the CPP feature. This firmware development
environment helps you to develop, build, and debug firmware applications for FX3.
www.cypress.com
Document No. 001-70983 Rev. *D
16
Designing a Bulk Transfer Host Application for EZ-USB® FX2LP™/FX3™
Appendix: Windows Install of FX2LP/FX3 DVK Driver
Figure 12. FX3 as WestBridge
If you have not already installed the FX2LP/FX3 DVK on a
Windows computer, you will see the following message
when you connect the DVK to the computer for the first
time.
Figure 10. Driver Software Installation
Close the message box and navigate to the Windows
Device Manager. To do this, click the Start button, rightclick Computer in the right panel, and select Properties
to bring up System Information. Click Device Manager in
the left panel. In the Device Manager, FX2LP shows up as
“Unknown Device” and FX3 as “WestBridge”.
Right-click the device (with the exclamation mark) and
select Update Driver.
Select Browse my computer for driver software.
Browse to select the driver software folder and click Next.
Figure 13. Update Driver
Figure 11. FX2LP as Unknown Device
www.cypress.com
Document No. 001-70983 Rev. *D
17
Designing a Bulk Transfer Host Application for EZ-USB® FX2LP™/FX3™
Click the Have Disk button, browse to the location
AN70983_Project\Drivers to choose CyUSB3.inf, and click
OK.
Use
the
inf
from
the
folder
(AN70983_Project\Drivers), as shown in the following
table for the respective operating system.
Operating System
Click Next and continue to install the driver. After installing
the driver, the Device Manager window should remove the
entry with the yellow exclamation mark and show the
recognized devices, successfully bound to the driver.
Figure 15. Cypress Device after Binding Driver
Folder Path
Windows XP 32-bit
wxp\x86
Windows 7 32-bit
win7\x86
Windows 7 64-bit
win7\x64
Windows Vista 32-bit
wlh\x86
Windows Vista 64-bit
wlh\x64
Figure 14. Click Have Disk to Select CyUSB3.inf
www.cypress.com
Document No. 001-70983 Rev. *D
18
Designing a Bulk Transfer Host Application for EZ-USB® FX2LP™/FX3™
Document History
®
Document Title: AN70983 – Designing a Bulk Transfer Host Application for EZ-USB FX2LP™/FX3™
Document Number: 001-70983
ECN
Orig. of
Change
**
3315759
SSJO/GAYA
07/15/2011
New Application Note
*A
3521406
GAYA
02/09/2012
Converted code example to application note.
*B
4023136
GAYA
06/07/2013
Updated document. Added VB and VC++ examples using CyUSB.dll, that can
communicate with FX2LP and FX3.
*C
4218438
RSKV
12/12/2013
Revision
Submission
Date
Description of Change
Restructured the Microsoft .NET code into a single solution containing three
projects, one for each language.
Major rewrite of the document.
Updated the document as per new template.
Updated Abstract.
Added hyperlink to refer the complete list of USB SuperSpeed Code Examples
and complete list of USB Hi-Speed Code Examples, in Abstract (page 1).
Added a note for FX3 DVK in Functional Overview.
Updated Figure 1. System Block Diagram.
*D
4690485
GAYA
09/16/2015
Added a note in Application Note Folder Layout.
Added Troubleshooting.
Updated FX3.
Updated Table 2 title.
Added Table 3.
Updated the Term “CYUSB3KIT-001” to “CYUSB3KIT-001/CYUSB3KIT-003 (EZUSB® FX3™ SuperSpeed Explorer Kit) and its Meaning in Glossary.
Updated Related Resources.
www.cypress.com
Document No. 001-70983 Rev. *D
19
Designing a Bulk Transfer Host Application for EZ-USB® FX2LP™/FX3™
Worldwide Sales and Design Support
Cypress maintains a worldwide network of offices, solution centers, manufacturer’s representatives, and distributors. To find
the office closest to you, visit us at Cypress Locations.
PSoC® Solutions
Products
Automotive
cypress.com/go/automotive
psoc.cypress.com/solutions
Clocks & Buffers
cypress.com/go/clocks
PSoC 1 | PSoC 3 | PSoC 4 | PSoC 5LP
Interface
cypress.com/go/interface
Lighting & Power Control
cypress.com/go/powerpsoc
Memory
cypress.com/go/memory
PSoC
cypress.com/go/psoc
Touch Sensing
cypress.com/go/touch
USB Controllers
cypress.com/go/usb
Wireless/RF
cypress.com/go/wireless
Cypress Developer Community
Community | Forums | Blogs | Video | Training
Technical Support
cypress.com/go/support
EZ-USB is a registered trademark of Cypress Semiconductor Corp. FX2LP and FX3 are trademarks of Cypress Semiconductor Corp. All other
trademarks or registered trademarks referenced herein are the property of their respective owners.
Cypress Semiconductor
198 Champion Court
San Jose, CA 95134-1709
Phone : 408-943-2600
Fax : 408-943-4730
Website : www.cypress.com
© Cypress Semiconductor Corporation, 2011-2015. The information contained herein is subject to change without notice. Cypress Semiconductor
Corporation assumes no responsibility for the use of any circuitry other than circuitry embodied in a Cypress product. Nor does it convey or imply any
license under patent or other rights. Cypress products are not warranted nor intended to be used for medical, life support, life saving, critical control or
safety applications, unless pursuant to an express written agreement with Cypress. Furthermore, Cypress does not authorize its products for use as
critical components in life-support systems where a malfunction or failure may reasonably be expected to result in significant injury to the user. The
inclusion of Cypress products in life-support systems application implies that the manufacturer assumes all risk of such use and in doing so indemnifies
Cypress against all charges.
This Source Code (software and/or firmware) is owned by Cypress Semiconductor Corporation (Cypress) and is protected by and subject to worldwide
patent protection (United States and foreign), United States copyright laws and international treaty provisions. Cypress hereby grants to licensee a
personal, non-exclusive, non-transferable license to copy, use, modify, create derivative works of, and compile the Cypress Source Code and derivative
works for the sole purpose of creating custom software and or firmware in support of licensee product to be used only in conjunction with a Cypress
integrated circuit as specified in the applicable agreement. Any reproduction, modification, translation, compilation, or representation of this Source
Code except as specified above is prohibited without the express written permission of Cypress.
Disclaimer: CYPRESS MAKES NO WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, WITH REGARD TO THIS MATERIAL, INCLUDING, BUT
NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. Cypress reserves the
right to make changes without further notice to the materials described herein. Cypress does not assume any liability arising out of the application or
use of any product or circuit described herein. Cypress does not authorize its products for use as critical components in life-support systems where a
malfunction or failure may reasonably be expected to result in significant injury to the user. The inclusion of Cypress’ product in a life-support systems
application implies that the manufacturer assumes all risk of such use and in doing so indemnifies Cypress against all charges.
Use may be limited by and subject to the applicable Cypress software license agreement.
www.cypress.com
Document No. 001-70983 Rev. *D
20
Similar pages