The ST UHF library (STSW-ST25RU-SDK) is a middleware software stack written in ANSI C, to build RAIN® RFID enabled
applications for reader devices based on ST25RU3993. This document describes the usage of the ST UHF library software API.
Along with this package, a comprehensive demonstration source code is available to illustrate the usage of the ST UHF library
for Windows® and Linux® platforms. The complete software stack is ANSI C and POSIX compatible and enables fast and
straightforward porting to other operating systems and/or toolchains.
UHF application
STUHFL
Standards
EPC UHF
Gen2V2
...
Device
HAL
ST25RU3993-HPEV board firmware
Protocol
Bus
UM2618 - Rev 4 - April 2021
For further information contact your local STMicroelectronics sales office.
www.st.com
1System overview
The ST UHF library (STUHFL) design is a classic middleware software stack running on a host system. It
provides a simple software API to abstract low-level communication details. As shown in the simplified system
overview the system is made up of two hardware components running the involved software components.
UM2618
System overview
Figure 1. System overview
UHF application
Host
STUHFL
STUHFL EVAL API
ST25RU3993 firmware
SPI
Device/reader module
The first component (device/reader module) runs the firmware with low-level driver implementation to operate
the ST25RU3993 reader IC and various protocols. The firmware implements a software interface to the ST UHF
library.
The second component (host side) runs the ST UHF library and abstracts the low-level functionality. It provides a
clean software API for UHF applications.
The ST UHF library runs on host systems with an operating system as well as on embedded systems (with OS
or native), with limited resources. Even a design without a dedicated host module is possible, where the complete
system runs on the reader module only.
1.1
Note:Arm is a registered trademark of Arm Limited (or its subsidiaries) in the US and/or elsewhere.
General information
The software described in this document supports Arm®-based device.
ST25RU3993
IRQ
1.2Features
•Comprehensive middleware to build RAIN® RFID enabled applications for reader devices based on
ST25RU3993
•Mirrored host and device library API
•Written in pure ANSI C99
•POSIX compatible
UM2618 - Rev 4
page 2/24
•Straightforward portability across different platforms (MCUs/RTOSs/OSs)
•Compatible with main UHF standards
–EPC UHF Gen2v2
–GB/T 29768
•Source code example implementation available
–Windows
–Linux® (Raspberry Pi 3B)
–Further sample platform implementations underway
®
1.3Hardware requirements
The main purpose of the ST UHF library is to simplify the ST25RU3993 low-level hardware driver, and to provide
an easy-to-use software interface. Therefore, the ST UHF software library operates only with the ST25RU3993based demonstration boards listed below and their corresponding firmware:
•ST25RU3993 EVAL board
•ST25RU3993 ELANCE module
It is anyway possible to port the low-level hardware driver to other devices hosting a suitable MCU to drive the
firmware.
UM2618
Hardware requirements
1.4Building environment
Currently all host side software components and demonstration codes are generated by using Microsoft Visual
Studio 2017 (VS2017). The package contains a VS2017 solution hosting projects for two different platforms. The
first project for Win32 platforms is suitable for generating code running on Windows 7 platform (and newer ones).
The second project is for Arm platforms running on Linux devices. The Arm project uses the possibility to do
remote compilation with VS2017. This requires a properly configured Arm device accessible in the same network.
Note:The available ST UHF library project for Arm and the corresponding example project use Raspberry Pi 3B
hardware for development. For more details about project configuration, refer to the appropriate project solution
files.
UM2618 - Rev 4
page 3/24
2Software architecture
The ST UHF library follows a classic stacked middleware software design and consists of components that run on
a reader module and on a host system as the default use case.
The complete ST UHF library is ANSI-C and POSIX compliant, resulting in easy porting to several other operating
systems and platforms.
The ST UHF library currently supports the most common UHF standards. Extensions and more protocols will be
released in upcoming versions.
Working sample source code is available for Windows and Linux, to use different library modules.
UM2618
Software architecture
2.1
ST UHF library API
The exposed ST UHF library API allows the user to build RAIN applications on ST25RU3993 reader devices.
Three stacked layers represent the complete exposed ST UHF library API.
•Activity
•Session
•Device
In this arrangement abstraction and complexity increase starting from device moving up to activity. The purpose
of the device layer is to abstract the hardware specific functionalities, such as direct register access. The session
layer uses the device layer to implement entire protocols such as the EPC Gen2V2 standard or other UHF
standards and protocols. The activity layer uses the device and session layers to abstract functionalities for
automated inventory of tags running in the background.
Table 1. Main layers
LayerDescription
ActivityFunctionality like background inventory lookup via a build-in "Inventory Runner"
SessionImplementation of different standards or protocols like EPC Gen2V2
DeviceAbstraction of hardware specific functionalities like register access
2.2STUHFL EVAL API
On the device/reader module side the STUHFL EVAL API provides a basic software interface to ST25RU3993
low-level drivers. The ST UHF library builds on top of this low-level interface and derives its ST25RU3993
dependent functionalities. Applications where no host system is involved directly call the low-level STUHFL EVAL
API on reader/device side.
Note:Applications not using the ST UHF library stack may be directly attached to this interface.
2.3ST UHF library wrappers
On top of the ST UHF library host interface, multiple wrappers are available for fast prototyping.
•Java/C#/Python
•ST EVAL API
Java, C# and Python are state of the art programming languages and enable software developers to implement
fast and efficiently different kinds of UHF application. In addition to wrappers for different software development
languages it is also possible to implement other custom interface wrapper like ST EVAL API wrapper.
Note:Software wrappers for others languages can easily be implemented when these programming languages
support calling native C code.
UM2618 - Rev 4
page 4/24
UM2618
Not exposed layers
The STUHFL EVAL API wrapper (host side) fully emulates the STUHFL EVAL API on the device side. This allows
users to start developing firmware applications on host systems and finish their task by porting the firmware
to the device/reader side. The advantage of this approach is that the host side offers debuggers, advanced
code tracers and many other host system development features. These host tools speed-up and simplify code
development. When the firmware code development on the host side is completed, simply "copy and paste" the
firmware application code to the device/reader side. No additional source code modifications are required to run
the firmware on the MCU.
Note:The STUHFL EVAL API wrapper fully emulates the STUHFL EVAL API, exactly as available on the device side.
2.4Not exposed layers
Underneath the exposed ST UHF library layer, several other layers work on the host with their counterparts on the
device side. This layer stack is taking care of the data transfer between the host and the reader device.
•Dispatcher
•Protocol
•Bus
These layers follow a stack design and depend only on their direct neighbours. The main purpose of the
dispatcher layer is to bundle the ST UHF library API function calls in one single module and to forward it to
the protocol layer.
The protocol layer transfers the abstracted function calls into transferable data chunks and forwards these data
packets to the bus layer.
Finally, the bus layer sends the data chunks over a physical interface and receives them on the device/reader
module side. For the data transfer in the opposite direction from device/reader side to the host side, the protocol
and the dispatcher layers do their task inversely.
LayerDescription
Dispatcher Merge and divide from API layers
ProtocolEncodes and decodes data into TLV formatted data chunks ready for transfer between host and device
BusPlatform depended transfer layer handling data exchange
2.4.1Support and helper
In addition to the above mentioned not exposed layers the library implements support and helper layers, which
provide relevant functionalities and expose their interface to almost all other modules.
LayerDescription
TLVTag-Length-Value encoding and decoding support
LoggingLogging helper
Table 2. Not exposed layers
Table 3. Helper modules
UM2618 - Rev 4
page 5/24
Figure 2. ST UHFL library system architecture
STUHFL wrappers
UM2618
Not exposed layers
Host side
· STUHFL_F_Start(…)
· STUHFL_F_Stop(…)
· STUHFL_F_RegisterHandler(…)
· …
· STUHFL_F_Gen2Inventory(…)
· STUHFL_F_Gen2Select(…)
· STUHFL_F_Gen2Read(…)
· …
· STUHFL_F_GB29768Inventory(…)
· …
· STUHFL_F_Gen2Inventory(…)
· STUHFL_F_Gen2Select(…)
· STUHFL_F_gen2Read(…)
· …
· STUHFL_F_GBT29768Inventory(…)
· …
· STUHFL_F_Connect(…)
· STUHFL_F_SetParam(…)
· STUHFL_F_GetParam(…)
· STUHFL_F_Reboot(…)
· ...
STUHFL
EVA API
Java/C#/......
STUHFL API
Activity layer
Inventory runner
Session layer
Gen2V2GB/T 29768
Device layer
ST25RU3993
EVAL board
ST25RU3993
Dispatcher
Protocol layer
Bus layer
UART
.........
......
module
...
...
Support and helpers
Logging......
Device/reader module side
Bus layer
TLV
Protocol layer
Dispatcher
STUHFL EVAL API
Platform dependent
ST25RU3993 low level drivers
SPITIMERGPIO...
Platform dependent drivers
UM2618 - Rev 4
page 6/24
2.5Host side usage
The functionality exposed by the ST UHF library API enables the development of RAIN applications based on
ST25RU3993 reader IC devices or modules on host devices. Host systems running the OS Windows or Linux are
supported by default. As the whole library is ANSI-C and POSIX compatible, it also easily builds for other POSIX
compatible platform.
The following figure shows an example of host side usage.
Figure 3. ST UHF library usage overview
UHF application
Host
e.g. RPi
STUHFL
UM2618
Host side usage
Device/reader module
e.g. STM32L476 based EVAL board
ST25RU3993
device firmware
STUHFL EVAL API
Device drivers
ST25RU3993 drivers
SPI
ST25RU3993
IRQ
UM2618 - Rev 4
page 7/24
2.6Device side usage
The functionalities exposed by STUHFL EVAL API provide an abstract interface to the full UHF functionalities
provided by the ST25RU3993 reader IC, without the burden of manually handling low-level register access.
Therefore, this interface is device-independent and enables the implementation of any abstract UHF application.
The following figure shows an example of device side usage.
UM2618
Device side usage
Figure 4. ST UHF library EVAL API device side usage
UHF application
STUHFL EVAL API
Device drivers
Device/reader module
e.g. STM32L476 based EVAL board
ST25RU3993 module based firmware
ST25RU3993 drivers
SPI
ST25RU3993
IRQ
UM2618 - Rev 4
page 8/24
3Source code
The complete source code (including sample sources for Windows and Linux) is available for download from
www.st.com.
3.1Directory and file structure
The package comes as zip file, with the following directory structure.
MiddlewareThe ST UHF library projects for Windows and Linux as source code
Note:For correct operation the user must choose one of the appropriate firmware packages, delivered along with the
library.
The “STUHFL” folder is located inside the “middleware/clib” folder.
It contains the following folders:
•“doc”: contains a detailed API description as Windows chm file.
•“inc”: contains all relevant interface files
•“src”: contains all implementation files
Figure 6. STUHFL directory structure
UM2618 - Rev 4
page 9/24
Directory and file structure
The “inc” directory contains all relevant interface files and a subfolder containing platform specific files.
Figure 7. "inc" structure
UM2618
Table 5. API headers
FilenameDescriptionNote
stuhfl.h
stuhfl_al.hApplication moduleSTUHFL API
stuhfl_dl.hGeneric part of device moduleSTUHFL API
stuhfl_dl_ST25RU3993.h ST25RU3993 IC depending device module layer
stuhfl_err.hDefinition of error codesSTUHFL API
stuhfl_evalAPI.h
stuhfl_helpers.hHelper module
stuhfl_log.hLogging module definition
stuhfl_pl.hProtocol layer definition
stuhfl_sl.hSession layerSTUHFL API
Basis header file, containing main typedefs and
defines
STUHFL EVAL API definition. Used by STUHFL
enabled firmware implementation and as STUHFL
wrapper implementation
STUHFL API
Not exposed as STUHFL API, internal
usage
STUHFL wrapper - STUHFL EVAL API
Not exposed as STUHFL API, internal
usage
Not exposed as STUHFL API, internal
usage
Not exposed as STUHFL API, internal
usage
The “platform” directory contains all relevant files that are important when porting to other platforms.
UM2618 - Rev 4
Figure 8. "Platform" directory
page 10/24
UM2618
ST UHF library solution location
Table 6. Platform dependent headers
FilenameDescription
Stuhfl_bl_posix.hPOSIX compatible bus layer for UART communication
stuhfl_bl_win32.hUART communication implementation for Windows
stuhfl_platform.hImplementation of generic functionality for platform independency
stuhfl_dl_ST25RU3993.h ST25RU3993 IC depending device module layerNot exposed as STUHFL API, internal usage
3.2ST UHF library solution location
The solution to build a Win32 dynamic link library or Arm based shared object library is located at ./Middleware/
clib/STUHFL.sln.
Note:For software development based on STUHFL the STUHFL demonstration solution contains the STUHFL project
and a complete demonstration application. This allows the user to build and debug at the same time both for
Win32 and for Raspberry Pi platforms.
UM2618 - Rev 4
page 11/24
UM2618
Implementation of sample source code
3.2.1Build STUHFL for Windows (DLL only)
The user must execute the following steps:
1.Open the VS2017 solution .\Middleware\clib\STUHFL.sln
2.Right-click on the STUHFL project and click rebuild
Note:This generates a Win32 dynamic link library ready to use to communicate to ST25RU3993 reader IC based
demonstantion boards (Windows host systems only).
3.2.2Build STUHFL for Linux with Raspberry Pi 3B (shared object only)
The user must execute the following steps:
1.Open the VS2017 solution .\Middleware\clib\STUHFL.sln
2.Add the IP address of your Raspberry Pi in the Tools/Options/Cross platform options
3.In the STUHFL (Linux) project properties set this as your remote machine
4.Right-click on the STUHFL(Linux) project and click rebuild
Note:This generates a Linux complete shared object to communicate to ST25RU3993 reader IC based
demonstrantion boards (Linux host systems only).
3.3
Implementation of sample source code
3.3.1Build STUHFL-demo for Windows
The user must execute the following steps:
1.Open the VS2017 solution ./Applications/STUHFL_demo/STUHFL_demo.sln
2.Rebuild solution
3.Start debugging to debug the demonstration
Note:For further information about the available demonstration check the documentation of the STUHFL_demo
project.
3.3.2Build STUHFL-demo for Linux
The user must execute the following steps:
1.Open the VS2017 solution ./Applications/STUHFL_demo/STUHFL_demo_rpi.sln
2.Add the IP address of your Raspberry Pi in the Tools\Options\Cross platform options.
3.In the STUHFL and STUHFL demonstration project properties set this as your remote machine
4.Update the communication port location (default: /dev/ttyUSB0) where to ST25RU3993 EVAL board is
connected to Raspberry Pi.
5.See STUHFL_demo.c and adjust the COM_PORT define
6.Rebuild solution
7.Start debugging
Note:For further information about the available demonstrations check the documentation of the STUHFL_demo
project.
3.4ST UHF library portability
The ST UHF library is ANSI-C and POSIX compatible. To port the library to other platforms or operating systems
a simple cross-compilation or remote-compilation is sufficient. Exceptions are the low-level communication drivers
for the host to device and the reverse communication, always platform dependent. All platform dependent
components that need to be reworked before successful porting are located in ./Middleware/clib/STUHFL/src/
platform
Note:To port the ST UHF library to other platforms and/or operating system add the low-level communication drivers
for your platform to the ./Middleware/clib/STUHFL/src/platform folder before compilation.
UM2618 - Rev 4
page 12/24
4Software interface description
For detailed API description check the available documentation, which is part of the source code package and
is available in compiled HTML file format (chm). Only a short overview of the different API functionalities for the
different modules is given in the following sections.
Note:For detailed information, refer to the file “./Middleware/clib/STUHFL/ doc/STUHFL.chm”
UM2618
Software interface description
4.1
Device layer
Device layer exposed functionality.
4.1.1Connections
The table below gives an overview of the connectivity functions.
FunctionDescription
STUHFL_F_ConnectConnect to a device via STUHFL
STUHFL_F_DisconnectDisconnect from current connected device via STUHFL
STUHFL_F_GetCtxGet device context of current attached device
STUHFL_F_ResetReset current attached device
4.1.2Parmeter access
The table below gives an overview of the parameter access functions.
FunctionDescription
STUHFL_F_SetParamGeneric set parameter function to set value of configuration
STUHFL_F_GetParamGeneric get parameter function to get value of configuration
STUHFL_F_GetParamInfoGet parameter information
STUHFL_F_SetMultipleParamsSet list of multiple parameters
STUHFL_F_GetMultipleParamsGet list of multiple parameters
Table 7. STUHFL connection functionality
Table 8. STUHFL parameter access functionality
4.1.3Data exchange
The table below gives an overview of the data exchange functions.
STUHFL_F_SendCmdSend command to device
STUHFL_F_ReceiveCmdDataReceive command to device
STUHFL_F_ExecuteCmdSend and receive combination in one call
STUHFL_F_GetRawDataReceive raw data from device
UM2618 - Rev 4
Table 9. STUHFL data exchange functionality
FunctionDescription
page 13/24
4.1.4Generic maintenance
The table below gives an overview of the generic maintenance functions.
STUHFL_F_GetVersionGet device version information
STUHFL_F_GetInfoGet device info information
STUHFL_F_UpgradeFirmware upgrade
STUHFL_F_EnterBootloaderReboot and enter bootloader
STUHFL_F_RebootReboot FW
4.2Session layer
4.2.1Gen2V2 of STUHFL
The table below gives an overview of the gen2V2 functions.
UM2618
Session layer
Table 10. STUHFL maintenance functionality
FunctionDescription
FunctionDescription
STUHFL_F_Gen2_InventoryGen2 Inventory depending on the current inventory and gen2 configuration
STUHFL_F_Gen2_SelectGen2 Select command to select or filter Gen2 transponders
STUHFL_F_Gen2_ReadGen2 Read command to read from the Gen2 transponders
STUHFL_F_Gen2_WriteGen2 Write command to write data to Gen2 transponders
STUHFL_F_Gen2_LockGen2 Lock command to lock Gen2 transponders
STUHFL_F_Gen2_KillGen2 Kill command to kill Gen2 transponders.
STUHFL_F_Gen2_GenericCmdGeneric Gen2 bit exchange
STUHFL_F_Gen2_QueryMeasureRssiRSSI measurement during Gen2 Query command
4.2.2GB/T 29768 of STUHFL
The table below gives an overview of the GB/T 29768 functions.
FunctionDescription
STUHFL_F_Gb29768_Inventory GB/T 29768 Inventory depending on the current inventory and GB/T 29768 configuration
STUHFL_F_Gb29768_SortGB/T 29768 Sort command to select or filter GB/T 29768 transponders
STUHFL_F_Gb29768_ReadGB/T 29768 Read command to read from the GB/T 29768 transponders
STUHFL_F_Gb29768_WriteGB/T 29768 Write command to write data to GB/T 29768 transponders
STUHFL_F_Gb29768_LockGB/T 29768 Lock command to lock GB/T 29768 transponders
STUHFL_F_Gb29768_KillGB/T 29768 Kill command to kill GB/T 29768 transponders.
STUHFL_F_Gb29768_EraseGB/T 29768 Erase command to erase GB/T 29768 transponders.
Table 11. STUHFL Gen2V2 functionality
Table 12. STUHFL GB/T 29768 functionality
UM2618 - Rev 4
page 14/24
4.3Activity layer
4.3.1Actions
The table below gives an overview of the action functions.
Table 13. STUHFL action functionality
FunctionDescription
STUHFL_F_StartStart foreground or background action
STUHFL_F_StopStart action
4.4STUHFL EVAL API wrapper
4.4.1Generic
The table below gives an overview of the generic functions to access the evaluation board and retrieve basic
information
UM2618
Activity layer
FunctionDescription
ConnectConnect to ST25RU3993 based evaluation board
DisconnectDisconnect from a current connected board
Get_BoardVersionRead the board software and hardware information
Get_BoardInfoGet human readable software and hardware device information
RebootReboot evaluation board
EnterBootloaderShutdown FW and enter STM32 ROM bootloader of evaluation board
4.4.2Configuration
The table below gives an overview of the configuration functions.
Set_RegisterMultipleWrites multiple ST25RU3993 registers content at once.
STMicroelectronics NV and its subsidiaries (“ST”) reserve the right to make changes, corrections, enhancements, modifications, and improvements to ST
products and/or to this document at any time without notice. Purchasers should obtain the latest relevant information on ST products before placing orders. ST
products are sold pursuant to ST’s terms and conditions of sale in place at the time of order acknowledgement.
Purchasers are solely responsible for the choice, selection, and use of ST products and ST assumes no liability for application assistance or the design of
Purchasers’ products.
No license, express or implied, to any intellectual property right is granted by ST herein.
Resale of ST products with provisions different from the information set forth herein shall void any warranty granted by ST for such product.
ST and the ST logo are trademarks of ST. For additional information about ST trademarks, please refer to www.st.com/trademarks. All other product or service
names are the property of their respective owners.
Information in this document supersedes and replaces information previously supplied in any prior versions of this document.