Application Note
21 of 42
001-65209 Rev.*I
2021-03-19
Getting Started with FX2LP™
FX2LP Development Tools
•
dscr.a51
is an assembly language file containing the data necessary to enumerate the USB device. The file
comprises table data in the form of
.db
(define byte) statements. You edit this file to customize items such
as VID/PID and descriptive strings for your design.
•
USBJmpTb.OBJ
is a jump table required by the FX2LP architecture, never requiring modification.
•
EZUSB.LIB
contains a library of useful FX2LP functions, mostly dealing with I
2
C communication. The source
code is included with the FX2LP DVK in the
Target\Lib\LP
subfolder.
main() {
TD_init();
Enable Interrupts
while(1)
{
if(GotSUD)
TD_Poll();
}}
fw.c
Descriptors
Handle
EP0
dscr.a51
GET_DESCRIPTOR
bulkloop.c
BOOL DR_SetConfiguration(void)
BOOL DR_GetConfiguration(void)
BOOL DR_Set_Interface(void)
BOOL DR_Get_Interface(void)
TD_Init()
{
….}
TD_Poll()
{....}
void ISR_EP2inout(void)
void ISR_EP6inout(void)
void ISR_Sof(void)
Figure 22
USB Firmware Framework Structure
shows how the code modules fit together.
Fw.c
contains the
main
function. It performs much of the USB maintenance, such as enumeration, and it calls
specifically-named external functions in the application code (
bulkloop.c
) whenever customization is required.
Fw.c
mostly does not require your modification. After performing various housekeeping steps, it calls an
external function called
TD_init
,
which you provide in
bulkloop.c
. (The prefix TD
stands for “Task Dispatcher”.)
Then it enters an endless loop that checks for arrival of SETUP packets over CONTROL endpoint 0. The loop also
checks for the USB suspend event, but this is not used by the
bulkloop
application. Every time through the loop,
it calls the external
TD_Poll
function which you provide in
bulkloop.c
.
In this application the
TD_Poll
function
does the work of looping PC endpoint data through FX2LP.
Every USB peripheral receives two types of requests over its CONTROL endpoint: enumeration and operational.
Enumeration
When a USB device is attached, the host PC sends multiple
GET_DESCRIPTOR
requests to discover the device
type and its requirements as part of a process called enumeration. The
fw.c
code intercepts these requests and
handles them using the values stored in the
dscr.a51
file.
An advantage of using the USB Frameworks is that the code has been tested and verified to pass USB “Chapter
9” requirements. Chapter 9 refers to the chapter in the USB Specification that deals with devic
e requests (over
EP0) and their proper responses.
Operational
Wherever the user code is needed,
fw.c
calls a specifically-named external function with the DR prefix (Device
Request) that you provide in the
bulkloop.c
file. For a simple application such as
bulkloop
, there is only one
configuration and one interface, so the two
DR_Set-Get
function pairs in
Error! Reference source not found.
s