AN1325
APPLICATION NOTE
USING THE ST7 USB LOW-SPEED LIBRARY V4.2x
by Microcontroller Division Applications
This application note describes how to use the ST7 USB Low-Speed Library V4.2x. Starting
from version 4.20 the Library supports the DFU class layer.
Caution:
The DFU class and the HID class layers are not included in the Library. The Library
contains only the standard USB request layers. You will find the DFU and HID layers in the
ST7 USB Low-Speed DFU EvalKit firmware.
Note:
In this document the names “Hiware” and “MetroWerks” refer to the same compiler
manufacturer.
1 OVERVIEW
The ST7 USB Low-Speed Firmware Library is written in C language and is compatible with
both Cosmic and Metrowerks compilers.
This Library provides a complete USB protocol layer for the ST7 USB Low-Speed microcon-
trollers (such as the ST7261, ST7262, ST7263 and ST7263B). The source code is available
free to STMicroelectronics customers.
This Library is supplied in a ZIP file. Starting from version 4.10, the Library contains only the
files that are common for all the projects. This new architecture has been choosen in order to
better separate what is really the Library and what is related to a project. This architecture will
also facilitate the upgrade of different projects with new Library versions in the future.
AN1325
/
0203
1/15
1
USING THE ST7 USB LOW-SPEED LIBRARY V4.2x
2 LIBRARY
2.1 DIRECTORIES ARCHITECTURE
The files which compose the Library are placed into 4 distinct directories :
Docs, Macro,
Micro,
and
Usb
:
ST7USBLS-Library-V4.2x/
|--- Docs/
|--- Macro/
|--- Micro/
|--- Usb/
The files inside these directories cannot be used alone. You have to use them within a project.
To do so, you have to include in your project setting files the path of these directories (Mak file
for Cosmic and Default.env for Metrowerks). This way you will be able to use easily the same
Library for different projects.
Example in a MAK file for Cosmic :
MACRO_PATH = D:\ST7USBLS-Library-V4.2x\Macro
MICRO_PATH = D:\ST7USBLS-Library-V4.2x\Micro
USB_PATH = D:\ST7USBLS-Library-V4.2x\Usb
Example in Default.env file for Metrowerks :
GENPATH=\
D:\ST7USBLS-Library-V4.2x\Macro;\
D:\ST7USBLS-Library-V4.2x\Micro;\
D:\ST7USBLS-Library-V4.2x\Usb;
Normally there is no need to change any of the files present in these directories. All the
changes must be done inside your project files.
The following chapters will explain in detail the content of all this directories.
2/15
2
USING THE ST7 USB LOW-SPEED LIBRARY V4.2x
2.2 DOCS DIRECTORY
This directory contains all documentations related to the Library: ReleaseNote.txt, FlowChart,
etc...
2.3 MACRO DIRECTORY
This directory contains all the files containing the macro definitions shared between the Li-
brary and the different projects. It contains also the Unicode table used for the definition of the
String descriptors. For example you will find the description of “EnableInterrupts” and “Disa-
bleInterrupts” macro. All these files are common for Cosmic and Metrowerks compilers with
the exception of the “Hidef.h” file wich is used only for Metrowerks.
2.4 MICRO DIRECTORY
This directory contains all the files which are related to the microcontrollers. You will find here
all the MAP files for the ST726X microcontrollers family (ST7261, ST7262, ST7263 and
ST7263B) . All these MAP files are common for Cosmic and Metrowerks compilers.
Important Note : For Metrowerks, all the H/W registers addresses are written inside the PRM
files of each project. For Cosmic, all these informations are written directly inside the MAP
files.
2.5 USB DIRECTORY
This directory contains the USB Library core files for Cosmic and Metrowerks compilers.
These file don’t need to be changed by the customer.
This USB Library can be seen as a ToolBox where the Application picks up the “tools” it needs
(calls the functions it needs). Note that there is no callback functions from the Library (the user
doesn’t need to create specific functions that could be called by the Library).
2.6 USB CORE FILES
All the following files are placed inside Usb directory. These files are really what we call THE
Library.
3/15
USING THE ST7 USB LOW-SPEED LIBRARY V4.2x
File
USB.c
USB.h
USB_Def.h
USB_Rwu.c
USB_Rwu.h
USB_Lib.c
USB_Lib.h
USB_Rc.c
USB_Rc.h
USB_Var.c
USB_Var.h
USB_JumpTable_Cosmic.asm
USB_JumpTable_Hiware.asm
Description
Library core functions
Library core prototypes
Description of all aliases and variables shared between
the Library and the Application layer
Remote Wake-Up functions
Prototypes for Remote Wake-Up functions
Library functions to be called by Application layer code
Prototypes of all the Library functions to be called by the
Application layer code
Hardware abstraction layer
Prototypes for Hardware abstraction layer
Library variables declaration
Prototypes for Library variables
Contains Jump to USB functions (for DFU only)
Contains Jump to USB functions (for DFU only)
The 2 assembly files (USB_JumpTable_xxx.asm) contain a jump table used by the application
to access the Library functions. These files are only used for DFU.
2.7 FILES ORGANIZATION
Application Code
(main.c, Hid_layer.c, User_var.c, ...)
USB_Lib.h
USB_Def.h
USB_Rc.c
USB.c
As you can see on this chart :
USB_Lib.h
and
USB_Def.h
are the only files from the Library
that your project needs to refer to.
4/15
USING THE ST7 USB LOW-SPEED LIBRARY V4.2x
3 PROJECT
This chapter describes an example of a project architecture. You are not obliged to follow this
architecture to use the USB Low-Speed Library.
3.1 DIRECTORIES ARCHITECTURE
The project directories architecture has been simplified. You will now have only the following
directories :
ProjectName/
|--- Docs/
|--- Appli/
|--- Config/
|--- Cosmic/
|--- Hiware/
|--- Objects/
|--- Cosmic/
|--- Hiware/
|---
ST7USBLS-Library-V4.2x/
3.2 DOCS DIRECTORY
This directory contains all documentations related to the project. You can use this directory to
put all your project documents.
3.3 APPLI DIRECTORY
All the application-specific files have to be located inside this directory.
Here is a description of the files that are in this directory initially:
File Name
Main.c
Main.h
Descript.c
Descript.h
Description
Entry module. Calls the Initialization functions and contains the infinite loop.
USB Descriptor files for the application: you have to modify them according to
your application (the initial values filled in apply to the Library firmware).
5/15