This application note explains how to develop an application using either Visual Basic or
C/C++ language to drive the DEMO-CR95HF-A demonstration board from a host computer.
The DEMO-CR95HF-A is a demonstration kit which allows to evaluate the performance of
STMicroelectronics CR95HF 13.56 MHz multiprotocol contactless transceiver. It includes a
ready-to-use board to interface with the CR95HF host PC demonstration software through a
USB interface.
The DEMO-CR95HF-A board is powered through the USB port and no external power
supply is required. It is made up of a CR95HF contactless transceiver, a 48 x 34 mm 13.56
MHz inductive etched antenna and its associated tuning components. The CR95HF
communicates with the STM32F103CB 32-bit core MCU via the SPI bus.
A dynamic link library (DLL) file is used by the host computer to manage several functions
and communicate with the STM32 MCU and the CR95HF IC. It is included in the
demo-cr95hf-a_dev_appli.zip version 2 (Visual Basic 6 and C/C++ source code examples)
which can be downloaded from http://www.st.com.
AN3954
Application note
Developing your own Visual Basic or C/C++ application
on a DEMO-CR95HF-A demonstration board
An executable with a simple user interface is also available for both Visual Basic and C/C++
projects.
Figure 1.DEMO-CR95HF-A evaluation board
For more information, refer to the following documents available on www.st.com:
■ CR95HF: 13.56-MHz multi-protocol contactless transceiver IC with SPI and UART serial
access datasheet
■ DEMO-CR95HF-A: Demonstration kit for the CR95HF 13.56 MHz transceiver IC data
The DEMO-CR95HF-A is connected to the host computer through its USB port. No
particular USB driver is needed. The HID USB driver (already included in all Windows
operating systems) is used for communication.
Through the USB port of your computer, you can drive the board, communicate with the
STM32 MCU, manage the CR95HF IC and send requests to a RF tag.
Figure 2.Typical application block diagram
1.2 Using the DLL system file
A DLL file (CR95HF.dll) is provided in order to drive the DEMO-CR95HF-A board from your
computer.
Copy this file to the system folder of your computer (C:/Windows/system32/).
This DLL contains several functions to enable communication with the board.
Using this DLL, the host computer is able to manage several functions and communicate
with the STM32 MCU and the CR95HF IC.
1.2.1 Overview of DLL functions
The CR95HFDll_GetDLLrev function reads the revision number of the DLL file. If the DLL
file is not correctly installed in the system folder of the host computer, this function returns
an error message (see Figure 3).
The CR95HFDLL_USBconnect function is required to connect the DEMO-CR95HF-A board
to the host computer and communicate with it. It is available from DLL revision 0.5 and
upper. The computer first checks if a DEMO-CR95HF-A is connected to the USB port. If so,
it assigns a USB handle to the board (see Figure 3).
The CR95HFDLL_USBhandlecheck function can be used to verify if the DEMO-CR95HF-A
is connected to the USB port of your computer. It is available from DLL revision 0.6 and
upper. This function sends a request to the DEMO-CR95HF-A and waits for an
acknowledge. An error code is sent if the communication with the board has been lost. In
Doc ID 022016 Rev 23/42
Getting startedAN3954
-36
)3/2&
-#5
#2(&
#ONTACTLESS
TAG
#2(&
LIBRARY
2&
$%-/#2(&!
53"
(/34
#/-054%2
53"
REVISION
#2$LLDLL
-36
)3/2&
-#5
#2(&
#ONTACTLESS
TAG
#2(&
LIBRARY
2&
$%-/#2(&!
53"
(/34
#/-054%2
53"
#2$LLDLL
this case, the CR95HFDLL_USBconnect can be used to reconnect the DEMO-CR95HF-A
to the host computer.
Figure 3.Typical application block diagram
A set of functions are available to drive the STM32 MCU (see Figure 4):
●CR95HFDll_Echo: verifies that the DEMO-CR95HF-A board is connected to the USB
port of the computer.
●CR95HFDLL_getMCUrev: reads the firmware revision of the STM32 MCU.
●CR95HFDLL_getInterfacePinState: verifies the communication path between the
STM32 MCU and the CR95HF IC (either SPI or UART).
Figure 4.Typical application block diagram
Other functions can be used to send instructions to the CR95HF IC (see Figure 5):
●CR95HFDll_Idn: gets the IDN of the CR95HF IC.
●CR95HFDll_Select: configures the required RF protocol for the CR95HF IC (IS0
15693, ISO 14443B …) and starts the RF field on the antenna.
●CR95HFDll_STCmd: sends commands to the CR95HF IC (refer to datasheet for a list
of possible commands).
●CR95HFDll_FieldOff: stops the RF field of the CR95HF IC.
●CR95HFDll_ResetSPI: resets the SPI interface of the CR95HF IC.
●CR95HFDll_SendIRQPulse: sends an interruption pulse on the IRQ pin of the CR95HF
IC to wake it up. This interrupt function can be used when the communication between
the STM32 MCU and the DEMO-CR95HF-A is performed in SPI mode.
●CR95HFDll_SendNSSPulse: sends an interrupt pulse to the NSS pin of the CR95HF
IC to wake it up. This interrupt function can be used when the communication between
the STM32 MCU and the DEMO-CR95HF-A is performed in UART mode.
●CR95HFDll_Polling_Reading: launches a polling sequence and reads the CR95HF
answer buffer to retrieve the answer when it is not available in the FIFO answer buffer
(e.g. after an IDLE command)
4/42Doc ID 022016 Rev 2
AN3954Getting started
-36
)3/2&
-#5
#2(&
#ONTACTLESS
TAG
#2(&
LIBRARY
2&
$%-/#2(&!
53"
(/34
#/-054%2
53"
#2$LLDLL
Figure 5.Typical application block diagram
Finally, the CR95HFDll_SendReceive function sends an RF frame to any tag present in the
RF field and receives its answer according to the RF protocol previously defined using the
Select command (see Figure 6).
Figure 6.Typical application block diagram
(/34
#/-054%2
#2$LLDLL
53"
53"
#2(&
LIBRARY
-#5
$%-/#2(&!
#2(&
)3/2&
2&
#ONTACTLESS
TAG
-36
Doc ID 022016 Rev 25/42
Function descriptionsAN3954
2 Function descriptions
This section describes the various functions required to evaluate the DEMO-CR95HF-A
demonstration board.
2.1 Functions to check DLL installation and USB connection
2.1.1 CR95HFDll_GetDLLrev
This function detects if the CR95HF.dll file has been installed in the system folder of the host
PC system, reads its header and sends back its revision number.
This is used by software to ensure that the DLL is correctly installed and that it is up to date.
If no DLL file is found, it returns an error message.
Visual Basic language
Declaration: Public Declare Function CR95HFDll_GetDLLrev Lib
"CR95HF.dll" (ByVal mystring As String) As Long
Prototype: Dim lngStatus As Long
Dim strAnswer As String * 256
lngStatus = CR95HFDll_GetDLLrev(strAnswer)
Input parameter:None
Output parameter:strAnswer: Revision of the DLL installed on your PC system.
Answer example: "0.4"
Returned value: lngStatus: 0
Source code example
Private Sub cmdGetDllRev_Click()
Dim strAnswer As String * 256
Dim lngStatus As Long
lngStatus = CR95HFDll_GetDLLrev(strAnswer)
If (lngStatus = 0) Then
txtDllRev.Text = strAnswer
Else
txtDllRev.Text = "Error = no Dll found"
End If
End Sub
printf("DEMO-CR95HF-A is connected and ready to be used\n\n\r");
else
printf("Error : DEMO-CR95HF-A not ready to be used\n\n\r");
printf("\n\n\n\n");
printf("\npress any key to continue");
printf("\n");
scanf("%s", &entry3);
return iresult;
}
2.1.3 CR95HFDLL_USBhandlecheck
This function can be used to verify if the DEMO-CR95HF-A is correctly connected to the
USB port of the computer and if the USB Handle attribué by the CR95HFDLL_USBconnect
is always valid.
Visual Basic language
Declaration:Public Declare Function CR95HFDLL_USBhandlecheck Lib
"CR95HF.dll" () As Long
Prototype:Dim lngStatus as long
lngStatus = CR95HFDLL_USBhandlecheck()
Input parameter: None
Output parameter:None
Returned value:lngStatus:
0: the USB handle is valid
1: the USB handle is invalid and the DEMO-CR95HF-A board
not connected
Source code example
Private Sub cmdUSBhandlecheck_Click()
Dim lngStatus As Long
txtUSBhandlecheckAnswer.Text = ""
lngStatus = CR95HFDLL_USBhandlecheck()
If (lngStatus = 0) Then
txtUSBhandlecheckAnswer.Text = "DEMO-CR95HF-A connected"
ElseIf (lngStatus = 5) Then
txtUSBhandlecheckAnswer.Text = "DEMO-CR95HF-A not connected (use
CR95HFDLL_USBconnect to connect it)"
End If
End Sub
Doc ID 022016 Rev 29/42
Function descriptionsAN3954
C/C++ language
Declaration: __declspec(dllexport) int __stdcall
CR95HFDLL_USBhandcheck(void);
Prototype:int iresult;
iresult= CR95HFDLL_USBhandcheck();
Input parameter:None
Output parameter:None
Return value:iresult:
0: the USB handle is valid
1: the USB handle is invalid and the DEMO-CR95HF-A board
not connected
Source code example
int DEMO_CR95HF_A_USBhandlecheck (void)
{
int iresult;
char entry3;
printf("\n\n\n\n");
iresult= CR95HFDLL_USBhandlecheck ();
printf("\nCR95HFDll_USBhandlecheck function:\n");
printf("\n --> request : CR95HFDll_USBhandlecheck()");
printf("\n <-- answer : ");
if (iresult == 0)
printf("DEMO-CR95HF-A is well connected\n\n\r");
else
printf("Error : DEMO-CR95HF-A not connected (use
CR95HFDLL_USBConnect)\n\n\r");
printf("\n\n\n\n");
printf("\npress any key to continue");
printf("\n");
scanf("%s", &entry3);
return iresult;
}
10/42Doc ID 022016 Rev 2
AN3954Function descriptions
2.2 Functions to communicate with the STM32 MCU
2.2.1 CR95HFDll_Echo
This function sends a USB request to the STM32 MCU that executes an Echo request on
the CR95HF. The STM32 MCU sends back the answer of the CR95HF, if possible, or
returns an error code ‘1’ if there is no answer.
Note:The Echo request uses the EchoCode command to perform a serial interface echo. For
more information, refer to the CR95HF transceiver datasheet.
Visual Basic language
Declaration:Public Declare Function CR95HFDll_Echo Lib "CR95HF.dll"
(ByVal mystring As String) As Long
Prototype:Dim lngStatus as long
Dim strAnswer As String * 256
lngStatus = CR95HFDll_Echo(strAnswer)
Input parameter: None
Output parameter:strAnswer: The CR95HF IC answer to the Echo request is “5500” if
there is no error.
Answer example: “5500”
Returned value:lngStatus:
0: No error
5: DEMO-CR95HF-A board not connected
Source code example
Private Sub cmdEcho_Click()
Dim strAnswer As String * 256
Dim lngStatus As Long
lngStatus = CR95HFDll_Echo(strAnswer)
If (lngStatus = 0) Then
txtEchoAnswer.Text = strAnswer
Else
txtEchoAnswer.Text = "No communication with DEMO-CR95HF-A board"
End If
End Sub
Doc ID 022016 Rev 211/42
Function descriptionsAN3954
C/C++ language
Declaration:__declspec(dllimport) int __stdcall CR95HFDll_Echo(char
printf("%s = Error : no communication with MCU\n\n\r",
strAnswer);
printf("\n\n\n\n");
printf("\npress any key to continue");
printf("\n");
scanf("%s", &entry3);
return iresult;
}
2.2.3 CR95HFDLL_getInterfacePinState
This function verifies the communication path between the STM32 MCU and the CR95HF
IC (either SPI or UART).
The STM32 MCU checks which communication configuration is selected on the DEMOCR95HF-A board. Two solder bridges are available to select the SPI or UART configuration.
By defeat, the board is delivered in the SPI configuration.
Visual Basic language
Declaration:Public Declare Function CR95HFDLL_getMCUrev Lib
"CR95HF.dll" (ByVal mystring As String) As Long
Prototype:status = CR95HFDLL_getMCUrev(strAnswer)
Input parameter:None
Output parameter:strAnswer: Interface Pin state.
Answer example: “00010X”
14/42Doc ID 022016 Rev 2
AN3954Function descriptions
Where:
00: Status byte (see Appendix A for error codes)
01: Size of answer (in bytes)
0X: Communication mode
With X:
0: Communication in UART mode
1: Communication in SPI Mode
Returned value:lngStatus:
0: No error
5: DEMO-CR95HF-A board not connected
Source code example
Private Sub cmdGetInterfacePinState_Click()
Dim strAnswer As String * 256
Dim lngStatus As Long
If (lngStatus = 0) Then
txtGetInterfacePinStateAnswer.Text = strAnswer
If (Mid(strAnswer, 6, 1) = "0") Then
chkInterfacePinState(0).Value = vbChecked
chkInterfacePinState(1).Value = vbUnchecked
ElseIf (Mid(strAnswer, 6, 1) = "1") Then
chkInterfacePinState(0).Value = vbUnchecked
chkInterfacePinState(1).Value = vbChecked
Else
DoEvents
'error
End If
Else
txtGetInterfacePinStateAnswer.Text = "No answer from the DEMOCR95HF-A board"
End If
printf("%s = Get Interface Pin State successfully\n\n\r",
strAnswer);
if (strAnswer[5] == '0')
printf("\n %c = communication in UART
mode",strAnswer[3]);
else
printf("\n %c = communication in SPI
mode",strAnswer[3]);
}
else
printf("\n %s = No answer from DEMO-CR95HF-A\n\n\r",
strAnswer);
printf("\n\n\n\n");
printf("\npress any key to continue");
printf("\n");
scanf("%s", &entry3);
return iresult;
}
16/42Doc ID 022016 Rev 2
AN3954Function descriptions
2.3 Functions to communicate with the CR95HF IC
2.3.1 CR95HFDll_Idn
This function sends a USB request to the STM32 MCU that requests the IDN of the
CR95HF IC. The STM32 MCU send back the answer of the CR95HF containing the IDN
value (ASCII codes), if possible, or returns an error code ‘1’ if there is no answer.
Note:The IDN command requests brief information about the CR95HF and its firmware version.
For more information, refer to the CR95HF transceiver datasheet.
Visual Basic language
Declaration:Public Declare Function CR95HFDll_Idn Lib "CR95HF.dll"
(ByVal mystring As String) As Long
Prototype:Dim strAnswer As String * 256
Dim lngStatus As Long
status = CR95HFDll_Idn(strAnswer)
Input parameter:None
Output parameter:strAnswer: IDN of the CR95HF IC (if no error)
printf("%s = Error : no Idn returned\n\n\r", strAnswer);
printf("\n\n\n\n");
printf("\npress any key to continue");
printf("\n");
scanf("%s", &entry3);
return iresult;
}
18/42Doc ID 022016 Rev 2
AN3954Function descriptions
2.3.2 CR95HFDll_Select
This function sends a USB request to the STM32 MCU that prepares the CR95HF for
communication by executing a Select request containing the selected RF parameters to the
the CR95HF IC. The STM32 MCU sends back the answer of the CR95HF, if possible, or
returns an error code ‘1’ if there is no answer. In addition to selecting the correct RF
communication parameters, this function activates the RF field. This is necessary at the
start of communications if the RF field was previously switched off.
The parameters of this function indicate the selected RF communication protocol
(ISO 15693, ISO 14443A, ISO 14443B, FELICA) as defined in the CR95HF datasheet.
Note:The Select request uses the Protocol Select command to select the RF communication
protocol and specify certain protocol-related parameters. For more information, refer to the
CR95HF transceiver datasheet.
Visual Basic language
Declaration:Public Declare Function CR95HFDll_Select Lib
"CR95HF.dll" (ByVal mycmdstring As String, ByVal
mystring As String) As Long
Prototype:Dim lngStatus As Long
Dim strConfiguration As String
Dim strSelectMsg As String * 256
lngStatus = CR95HFDll_Select(strConfiguration,
strSelectMsg)
Input parameter:strConfiguration: Selected RF communication protocol and certain
protocol-related parameters. (This configuration is used for
SendReceive requests.)
ISO15693 HighDataRate 10% One subcarrier = “010D”:
Where:
“01” is the ISO 15693 configuration
“0D” are the parameters
ISO14443A = "0200":
Where:
“02” is the ISO 14443A configuration
“00” are the parameters
ISO14443B = "0301":
Where:
“03” is the ISO 14443B configuration
“01” are the parameters
Output parameter:strSelectMsg: The DEMO-CR95HF-A sends back an answer if the
CR95HF is configured correctly and the RF field is on.
Answer example: “0000”
Where:
“00” is the status byte (see Appendix A for error codes)
“00” is the size of the answer
Doc ID 022016 Rev 219/42
Function descriptionsAN3954
Returned value:lngStatus:
0: No error
5: DEMO-CR95HF-A board not connected
2: Empty argument error
3: Command parmeter error
Source code example
'Private Sub cmdSelect_ISO15693_protocol_Click()
Dim strAnswer As String * 256
Dim lngStatus As Long
lngStatus = CR95HFDll_Select("010D", strAnswer)
If (lngStatus = 0) Then
txtISO15693_SelectAnswer.Text = strAnswer
Else
txtISO15693_SelectAnswer.Text = " Select protocol ISO15693 not
executed"
End If
End Sub
Private Sub cmdSelect_ISO14443B_protocol_Click()
Dim strAnswer As String * 256
Dim lngStatus As Long
lngStatus = CR95HFDll_Select("0301", strAnswer)
If (lngStatus = 0) Then
txtISO14443B_SelectAnswer.Text = strAnswer
Else
txtISO14443B_SelectAnswer.Text = "Select protocol ISO14443B not
executed"
End If
printf("\n\n\n\n");
printf("\npress any key to continue");
printf("\n");
scanf("%s", &entry3);
return iresult;
}
2.3.3 CR95HFDll_STCmd
This function is used to send any request to the CR95HF IC. The STM32 MCU receives the
frame contained in the request and sends it directly to the CR95HF IC. The STM32 MCU
sends back the answer from the CR95HF IC to the PC through the USB port. The frame has
to be formatted according to the CR95HF datasheet.
This function can be defined as a “Transparent Mode” command.
The CR95HF formatted frame has to be send through this CR95HFDll_STCmd function
preceded by “01” data as the header byte.
Visual Basic language
Declaration:Public Declare Function CR95HFDll_STCmd Lib "CR95HF.dll"
(ByVal mycmdstring As String, ByVal mystring As String)
As Long
Prototype:Dim lngStatus As Long
Dim strMCUrequest As String
Dim strCR95HFanswer As String * 256
printf("\n\n\n\n");
printf("\npress any key to continue");
printf("\n");
scanf("%s", &entry3);
return iresult;
}
printf("%s = Idle answer\n\n\r", strAnswer);
printf("%s = No answer from CR95HF IC\n\n\r", strAnswer);
Doc ID 022016 Rev 227/42
Function descriptionsAN3954
2.3.4 CR95HFDll_FieldOff
This function sends a USB request to the STM32 MCU to switch off the CR95HF RF Field.
The STM32 MCU sends back the answer of the CR95HF, if possible, or returns an error
code ‘1’ if there is no answer.
Note:To perform this RF Field Off command, the STM32 MCU sends a Protocol Select command
with parameters ‘0000’. For more information, refer to the CR95HF transceiver datasheet.
Visual Basic language
Declaration:Public Declare Function CR95HFDll_FieldOff Lib
"CR95HF.dll" (ByVal mystring As String) As Long
Prototype:Dim lngStatus As Long
Dim strAnswer As String * 256
status = CR95HFDll_FieldOff(strAnswer)
Input parameter:None
Output parameter:strAnswer: The DEMO-CR95HF-A sends back an answer and the
RF Field is switched off.
Answer example: “0000”
Where:
“00” is the status byte (see Appendix A for error codes)
“00” is the size of the answer
Returned value:lngStatus:
0: No error
5: DEMO-CR95HF-A board not connected
Source code example
Private Sub cmdFieldOff_Click()
Dim strAnswer As String * 256
Dim lngStatus As Long
lngStatus = CR95HFDll_FieldOff(strAnswer)
If (lngStatus = 0) Then
txtFieldOffAnswer.Text = strAnswer
Else
txtFieldOffAnswer.Text = "Field Off request not executed"
End If
printf("%s = No answer from DEMO-CR95HF-A\n\n\r", strAnswer);
printf("\n\n\n\n");
printf("\npress any key to continue");
printf("\n");
scanf("%s", &entry3);
return iresult;
}
2.3.6 CR95HFDll_SendIRQPulse
This function must be used when the DEMO-CR95HF-A is configured in SPI mode
(communication between the STM32 MCU and the CR95HF IC). The interrupt pulse is sent
to the CR95HF IRQ pin.
Visual Basic language
Declaration:Public Declare Function CR95HFDll_SendIRQPulse Lib
"CR95HF.dll" (ByVal mystring As String) As Long
Prototype:Dim lngStatus As Long
Dim strAnswer As String * 256
lngStatus = CR95HFDll_SendIRQPulse(strAnswer)
Input parameter:None
Output parameter:strAnswer: The DEMO-CR95HF-A sends back an answer if the IRQ
pulse was correctly sent.
Answer example: “0000”
Where:
“00” is the status byte (see Appendix A for error codes)
“00” is the size of the answer
Returned value:lngStatus:
0: No error
5: DEMO-CR95HF-A board not connected
Source code example
Private Sub cmdSendIRQPulse_Click()
Dim strAnswer As String * 256
Dim lngStatus As Long
lngStatus = CR95HFDll_SendIRQPulse(strAnswer)
If (lngStatus = 0) Then
Doc ID 022016 Rev 231/42
Function descriptionsAN3954
txtSendIRQPulseAnswer.Text = strAnswer
Else
txtSendIRQPulseAnswer.Text = "No answer from the DEMO-CR95HF-A
board"
End If
printf("%s = No answer from DEMO-CR95HF-A\n\n\r", strAnswer);
printf("\n\n\n\n");
printf("\npress any key to continue");
printf("\n");
scanf("%s", &entry3);
return iresult;
}
32/42Doc ID 022016 Rev 2
AN3954Function descriptions
2.3.7 CR95HFDll_Polling_Reading
This function polls the CR95HF SPI communication wires. When the CR95HF is ready, it
sends back the data stored in its FIFO answer buffer.
This function can be used after an IDLE command to make sure that the answer buffer has
been emptied and avoid receiving an erroneous answer on the next request.
Visual Basic language
Declaration: Public Declare Function CR95HFDll_Polling_Reading Lib
"CR95HF.dll" (ByVal mystring As String) As Long
Prototype: Dim strAnswer As String * 256
Dim lngStatus As Long
lngStatus = CR95HFDll_Polling_Reading(strAnswer)
Input parameter: None
Output parameter: CR95HF answer stored in FIFO answer buffer
Return value: lngStatus:
0: No error
5: DEMO-CR95HF-A board not connected
Source code example
Private Sub cmdPollingReading_Click()
Dim strAnswer As String * 256
Dim lngStatus As Long
lngStatus = CR95HFDll_Polling_Reading(strAnswer)
If (lngStatus = 0) Then
txtPollingReadingAnswer.Text = strAnswer
Else
txtPollingReadingAnswer.Text = "No answer from the
Output parameter:CR95HF answer stored in FIFO answer buffer
Return value: iresult:
0: No error
5: DEMO-CR95HF-A board not connected
Source code example
int Set_Polling_Reading_config (void)
{
Doc ID 022016 Rev 233/42
Function descriptionsAN3954
int iresult;
char strAnswer[50]="";
char entry3;
printf("\n\n\n\n");
iresult = CR95HFDll_Polling_Reading(strAnswer);
printf("\nSend IRQ Pulse using CR95HFDll_Polling_Readin
function:\n");
printf("\n --> request : CR95HFDll_Polling_Reading(strAnswer)");
printf("\n <-- answer : ");
if (iresult == 0)
printf("%s = Set Polling Reading successfully\n\n\r", strAnswer);
else
printf("%s = No answer from DEMO-CR95HF-A\n\n\r", strAnswer);
printf("\n\n\n\n");
printf("\npress any key to continue");
printf("\n");
scanf("%s", &entry3);
return iresult;
}
2.3.8 CR95HFDll_SendNSSPulse
This function sends an interrupt to wake up the CR95HF IC. It can be used when the
DEMO-CR95HF-A is configured in UART mode (communication between the STM32 MCU
and the CR95HF IC). The interrupt pulse is sent to the CR95HF NSS pin.
Visual Basic language
Declaration:Public Declare Function CR95HFDll_SendNSSPulse Lib
"CR95HF.dll" (ByVal mystring As String) As Long
Prototype:Dim strAnswer As String * 256
Dim lngStatus As Long
lngStatus = CR95HFDll_SendNSSPulse(strAnswer)
Input parameter:None
Output parameter:strAnswer. The DEMO-CR95HF-A sends back an answer if the
NSS pulse was correctly sent.
Example of answer: “0000”
where
“00” is the status byte (see Appendix A for error codes)
“00” is the size of the answer
Return value:lngStatus:
0: No error
5: DEMO-CR95HF-A board not connected
Source code example
Private Sub cmdSendNSSPulse_Click()
Dim strAnswer As String * 256
Dim lngStatus As Long
lngStatus = CR95HFDll_SendNSSPulse(strAnswer)
If (lngStatus = 0) Then
txtNSSpulseAnswer.Text = strAnswer
Else
txtNSSpulseAnswer.Text = "No answer from the DEMO-CR95HF-A board"
End If
End Sub
Output parameter:strAnswer: The DEMO-CR95HF-Asends back an answer
if the NSS pulse was correctly sent.
Example of answer: “0000”
where
“00” is the status byte (see Appendix A for error codes)
“00” is the size of the answer
Return value: iresult:
0: No error
5: DEMO-CR95HF-A board not connected
Source code example
int Send_NSS_Pulse (void)
{
int iresult;
char strAnswer[50]="";
char entry3;
printf("\n\n\n\n");
iresult = CR95HFDll_SendNSSPulse(strAnswer);
printf("\nSend IRQ Pulse using CR95HFDll_SendNSSPulse function:\n");
printf("\n --> request : CR95HFDll_SendNSSPulse(strAnswer)");
printf("\n <-- answer : ");
if (iresult == 0)
printf("%s = No answer from DEMO-CR95HF-A\n\n\r", strAnswer);
printf("\n\n\n\n");
printf("\npress any key to continue");
printf("\n");
scanf("%s", &entry3);
return iresult;
}
Doc ID 022016 Rev 235/42
Function descriptionsAN3954
2.4 Functions to communicate with a RF tag
2.4.1 CR95HFDll_SendReceive
This function sends a USB request to the STM32 MCU that executes a SendRecv command
with data to the CR95HF IC. The STM32 MCU sends back the answer of the CR95HF, if
possible, or returns an error code ‘1’ if there is no answer.
Note:The request uses the SendRecv command to send data using previously selected protocol
and to receive the tag response. For more information, refer to the CR95HF transceiver
datasheet.
Visual Basic language
Declaration:Public Declare Function CR95HFDll_SendReceive Lib
"CR95HF.dll" (ByVal mycmdstring As String, ByVal
mystring As String) As Long
Prototype:Dim lngStatus As Long
Dim strCR95HFrequest As String
Dim strTagResponse As String * 256
lngStatus = CR95HFDll_SendReceive(strCR95HFrequest,
strTagResponse )
Input parameter:strCR95HFrequest: The RF Request to be sent by the CR95HF IC to
the Tag (with previously selected ISO format).
ISO 15693 Inventory example: “260100”
Where:
“260100” is the ISO 15693 Inventory command.
ISO 14443B Initiate example: "0600"
Where:
“0600” is the ISO 14443B Initiate command.
Output parameter:strTagResponse: The Tag answer if the CR95HF has received an
answer from the Tag in the field; otherwise, an error code (see
Appendix A).
ISO 15693 Inventory example:
“800D00FF5AB914F6414C02E0385D00”
Where:
“80” is the status byte (see Appendix A for error codes)
“0D” is the length of entire data field
“00FF5AB914F6414C02E0” data received from the tag
“385D” is the original received CRC value
“00” is the protocol error status
ISO 14443B Initiate example: “80046C125900”
Where:
“80” is the status byte (see annexe 2 for error codes)
“04” is the length of entire data field
“6C” is the data received from the tag
36/42Doc ID 022016 Rev 2
AN3954Function descriptions
“1259” is the original received CRC value
“00” is the protocol error status
Returned value:lngStatus:
0: No error
5: DEMO-CR95HF-A board not connected
4: Communication error
Source code example
Private Sub cmdSendReceive_ISO15693_Inventory_Click()
Dim strTagResponse As String * 256
Dim lngStatus As Long
Input parameter:strCR95HFrequest: The RF Request to be sent by the CR95HF IC to
the Tag (with previously selected ISO format).
ISO 15693 Inventory example: “260100”
Where:
“260100” is the ISO 15693 Inventory command.
Doc ID 022016 Rev 237/42
Function descriptionsAN3954
ISO 14443B Initiate example: "0600"
Where:
“0600” is the ISO 14443B Initiate command.
Output parameter:strTagResponse: The Tag answer if the CR95HF has received an
answer from the Tag in the field; otherwise, an error code (see
Appendix A).
ISO 15693 Inventory example:
“800D00FF5AB914F6414C02E0385D00”
Where:
“80” is the status byte (see Appendix A for error codes)
“0D” is the length of entire data field
“00FF5AB914F6414C02E0” data received from the tag
“385D” is the original received CRC value
“00” is the protocol error status
ISO 14443B Initiate example: “80046C125900”
Where:
“80” is the status byte (see annexe 2 for error codes)
“04” is the length of entire data field
“6C” is the data received from the tag
“1259” is the original received CRC value
“00” is the protocol error status
Returned value:iresult:
0: No error
5: DEMO-CR95HF-A board not connected
4: Communication error
Source code example
int Send_ISO15693_Inventory (void)
{
int iresult;
char strRequest[50]="";
char strTagAnswer[50]="";
char entry3;
Updated returned value in Visual basic and C/C++ for Section 2.2.1:
CR95HFDll_Echo.
Doc ID 022016 Rev 241/42
AN3954
Please Read Carefully:
Information in this document is provided solely in connection with ST products. STMicroelectronics NV and its subsidiaries (“ST”) reserve the
right to make changes, corrections, modifications or improvements, to this document, and the products and services described herein at any
time, without notice.
All ST products are sold pursuant to ST’s terms and conditions of sale.
Purchasers are solely responsible for the choice, selection and use of the ST products and services described herein, and ST assumes no
liability whatsoever relating to the choice, selection or use of the ST products and services described herein.
No license, express or implied, by estoppel or otherwise, to any intellectual property rights is granted under this document. If any part of this
document refers to any third party products or services it shall not be deemed a license grant by ST for the use of such third party products
or services, or any intellectual property contained therein or considered as a warranty covering the use in any manner whatsoever of such
third party products or services or any intellectual property contained therein.
UNLESS OTHERWISE SET FORTH IN ST’S TERMS AND CONDITIONS OF SALE ST DISCLAIMS ANY EXPRESS OR IMPLIED
WARRANTY WITH RESPECT TO THE USE AND/OR SALE OF ST PRODUCTS INCLUDING WITHOUT LIMITATION IMPLIED
WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE (AND THEIR EQUIVALENTS UNDER THE LAWS
OF ANY JURISDICTION), OR INFRINGEMENT OF ANY PATENT, COPYRIGHT OR OTHER INTELLECTUAL PROPERTY RIGHT.
UNLESS EXPRESSLY APPROVED IN WRITING BY TWO AUTHORIZED ST REPRESENTATIVES, ST PRODUCTS ARE NOT
RECOMMENDED, AUTHORIZED OR WARRANTED FOR USE IN MILITARY, AIR CRAFT, SPACE, LIFE SAVING, OR LIFE SUSTAINING
APPLICATIONS, NOR IN PRODUCTS OR SYSTEMS WHERE FAILURE OR MALFUNCTION MAY RESULT IN PERSONAL INJURY,
DEATH, OR SEVERE PROPERTY OR ENVIRONMENTAL DAMAGE. ST PRODUCTS WHICH ARE NOT SPECIFIED AS "AUTOMOTIVE
GRADE" MAY ONLY BE USED IN AUTOMOTIVE APPLICATIONS AT USER’S OWN RISK.
Resale of ST products with provisions different from the statements and/or technical features set forth in this document shall immediately void
any warranty granted by ST for the ST product or service described herein and shall not create or extend in any manner whatsoever, any
liability of ST.
ST and the ST logo are trademarks or registered trademarks of ST in various countries.
Information in this document supersedes and replaces all information previously supplied.
The ST logo is a registered trademark of STMicroelectronics. All other names are the property of their respective owners.