This application note explains how to develop a Visual Basic or C/C++ application code to
drive STMicroelectronics STARTKIT-M24LR-A starter kit from a host computer. The
STARTKIT-M24LR-A is a ISO 15693 reader designed to operate with the M24LRXX dual
interface EEPROM. It is connected to the host USB port and can be used either as a I
reader connected to the transponders through an I
using the integrated RF antenna.
Figure 1.STARTKIT-M24LR-A
2
C bus cable or as an RF reader when
2
C
Reference documents
●M24LRXX datasheet
●“M24LRXX tool kit user guide” (UM0853)
●“Configuring your ISO 15693 reader to support the M24LRXX” application note
The M24LRXX is a dual interface EEPROM which can be accessed either through an I2C
serial bus or a contactless interface using the ISO 15693 RFID protocol.
To easily control the M24LRXX RF and I
the STARTKIT-M24LR-A.
Refer to the product datasheet and to application note AN3163 “Configuring your ISO 15693
reader to support the M24LRXX” for more in-depth information on the M24LRXX and for
explanations on the RF and I
http://www.st.com.
Application note AN3227 helps software engineers using and including the software
delivered with the STARTKIT-M24LR-A in their own application. Some examples are offered
showing how to send an RF request in Visual Basic and C/C++. These examples also show
how to manage the I
2
C protocol.
1.2 STARTKIT-M24LR-A
2
C communication protocols. Both documents are available on
2
C channels, ST offers several tools among which is
The STARTKIT-M24LR-A reader is connected to the host-computer USB port. It manages
RF ISO 15693 commands (High-level Inventory and Transparent commands) and I
2
C
commands between the reader and M24LRXX-based transponders (see Figure 2:
STARTKIT-M24LR-A application schematics).
Figure 2.STARTKIT-M24LR-A application schematics
6/38Doc ID 17575 Rev 2
AN3227Description
●RF ISO 15693 commands
RF ISO 15693 commands are sent by the host computer to the transponders via the
reader RF interface. Two types of commands are available:
–High-level Inventory command (see Section 4.2: RF ISO 15693 High-level
Inventory command)
The host sends an already formatted Inventory request to the transponders via the
reader RF interface. This command launches an anticollision sequence to identify
all the transponders present in the RF field and sends back the UID information to
the host. Due to reader limitations, a maximum of two transponders can be
detected by an Inventory request.
–Transparent commands (see Section 4.3: RF ISO 15693 Transparent commands).
The host can also send RF Transparent commands to transponders via the reader
RF interface. The Transparent commands send single or multiple frames
compliant with the ISO 15693 protocol. Refer to the M24LRXX datasheet for a
detailed description of the available Dual interface EEPROM command.
The transponders answers are sent back to the computer.
2
●I
C commands (see Section 4.4: I2C commands).
2
I
C commands are sent by the host computer to the M24LRXX via the reader I2C bus.
The following sections explain how to detect the STARTKIT-M24LR-A reader and open the
communication prior to sending RF or I
then describe in details how to send RF commands to transponders and manage I
2
C commands to the M24LRXX transponders. They
2
C
communication.
Doc ID 17575 Rev 27/38
Installation requirementsAN3227
2 Installation requirements
Communication with the STARTKIT-M24LR-A is based on the HID USB class. To be able to
communicate with the reader, the HIDdll.dll file must be installed in your computer. This is
mandatory for sending any RF or I
Depending on whether you use Visual Basic or C/C++, other .bas or .h files must be used
for correct function declaration. These installations are outlined below.
2.1 HIDdll.dll installation
The HIDdll.dll contains all the functions allowing to drive the STARTKIT-M24LR-A.
Copy the HIDdll.dll which is delivery with the AN3227.zip available at
http://www.st.com/dualeeprom to the Windows system folder of your computer
(C:/Windows/System32). If you have installed the M24LRxx_Application_Software, then the
HIDdll.dll file is already present in your Windows system folder.
2.2 Visual Basic project requirements
2
C request using the STARTKIT-M24LR-A.
To create a Visual Basic project, the HIDdll.bas header file must be inserted in your source
code. It references all the STARTKIT-M24LR-A functions declared in the HIDdll.dll.
Insert the HIDdll.bas into your Visual Basic project. HIDdll.bas makes the link between
HIDdll.dll and the source code. HIDdll.bas contains all the functions declarations and
descriptions for whichever communication mode you choose: RF ISO 15693 or I
HIDdll.bas can be found in theAN3227.zipavailable at http://www.st.com/dualeeprom.
Below is an example of the command needing to be declared in your Visual Basic header
file, when operating in RF ISO15693 mode or I
Public Declare Function API_USBAll Lib "HIDdll.DLL" (ByVal
commHandle As Long, ByVal cmdSize As Long, ByRef cmd As Byte, ByRef
returnlen As Byte, ByRef pBuffer As Byte) As Long
2.3 C/C++ project requirements
To create a C/C++ project, the HIDdll.h header file and the HIDdll.lib library, are required.
HIDdll.h and HIDdll.lib files allow linking your source code to the HIDdll.dll file. HIDdll.h can
be found in the source code exampleAN3227.zip available at
http://www.st.com/dualeeprom.
In the source code, declare the header files as follows:
#include "HIDdll.h"
2
C mode:
2
C mode.
Below is an example of the command needing to be declared in your C/C++ header file,
when operating in RF ISO15693 mode or I
To send an I2C or an RF command to the STARTKIT-M24LR-A reader, the computer must
first detect the reader. Once it is detected, a handleis randomly assigned to the reader.
This section presents all the available functions for performing reader detection. Visual
Basic and C/C++ source code examples are also provided.
3.1 Reader detection functions
The following functions are included in the HIDdll.dll file and must be called to be able to use
the reader:
●API_USBGetConnectedDeviceNum
This function detects any connected STARTKIT-M24LR-A reader, and sends back the
number of readers connected to the USB ports of your computer.
●API_USBOpenWithNum
This function returns the handle of the STARTKIT-M24LR-A identified by the index
number. This reader must have been previously detected by the
API_USBGetConnectedDeviceNum function.
●API_USBCloseComm
This function closes USB communication for the STARTKIT-M24LR-A identified by its
handle.
Below is an example of reader detection Visual Basic code:
Public Function Detect_STARTKIT_M24LR_A() As Boolean
Dim lngNbStartKit As Long
Dim lngStatus As Long
Dim i As Long
Dim deviceIndex As Integer
Dim numInputBuffersInt As Integer
Dim strDataMsg As String
‘STARTKIT-M24LR-A
Dim lngReqDataLen As Long
Dim abytReqData (0 To 63) As Byte
Dim abytAnswerDataLen (0 To 63) As Byte
Dim abytAnswerData (0 To 63) As Byte
Dim strRequestData As String
Dim strAnswerData As String
'RETURN THE NUMBER OF STARTKIT-M24LR-A DEVICES CONNECTED
lngNbStartKit = API_USBGetConnectedDeviceNum()
'ONE STARTKIT-M24LR-A CONNECTED
If (lngNbStartKit > 0) Then
deviceIndex = 0
numInputBuffersInt = 64
'------> OPEN CONNECTION WITH STARTKIT-M24LR-A
‘------> GET USB HANDLE (hcomm_public)
lngStatus = API_USBOpenWithNum(hcomm_public, _
deviceIndex, _
numInputBuffersInt)
'------> GET FIRMWARE VERSION OF STARTKIT-M24LR-A
strReqData = "86"
lngReqDataLen = Len(strReqData) / 2 'lenght of request
'format request as Array of bytes for API_USBALL use
For i = 0 To lngReqDataLen - 1
abytReqData (i) = CByte("&h" & Mid(strReqData, _
(i * 2) + 1, 2))
Next i
lngStatus = API_USBAll(hcomm_public, _
lngReqDataLen,
Doc ID 17575 Rev 211/38
STARTKIT-M24LR-A detectionAN3227
abytReqData(0), _
abytAnswerDataLen(0),
abytAnswerData(0))
'Analyse STARTKIT-M24LR-A answer
For i = 1 To abytSTARTKITanswerSize(0)
strAnswerData = strAnswerData & _
Chr(abytSTARTKITanswer(i - 1))
Next i
'DISPLAY STARTKIT-M24LR-A ANSWER = GET INFO
txtDetectResult.Text = strAnswerData
Else
'No STARTKIT-M24LR-A CONNECTED
End If
End Function
‘STARTKIT-M24LR-A KIT CLOSE USB COMMUNICATION
Private Sub Form_terminate()
Dim booAnswer As Boolean
Dim lngCloseComm As Long
booAnswer = API_USBCloseComm(hcomm_public)
End Sub
3.3 C/C++ source code example
Below is an example of reader detection C/C++ code:
int detect_STARTKIT_M24LR_A ()
{
int iNbStartKit;
int deviceIndex;
unsigned short numInputBuffersInt;
int istatus;
int entry3;
/* RETURN THE NUMBER OF STARTKIT-M24LR-A DEVICES CONNECTED */
iNbStartKit = API_USBGetConnectedDeviceNum();
/* ONE STARTKIT-M24LR-A CONNECTED */
if (iNbStartKit > 0)
{
deviceIndex = 0;
numInputBuffersInt = 64;
/* ------> OPEN CONNECTION AND GET USB HANDLE */
istatus = API_USBOpenWithNum(&hcomm_public,
deviceIndex,
numInputBuffersInt);
if (istatus == 0)
{
/* USB connection OK */
/* hcomm_public is handle for STARTKIT-M24LR-A functions */
return 1;
12/38Doc ID 17575 Rev 2
Loading...
+ 26 hidden pages
You need points to download manuals.
1 point = 1 manual.
You can buy points or you can get point for every manual you upload.