AN3955
Application note
CR95HF library for ISO/IEC 14443-3 and SRIX contactless tag ICs
1
Introduction
This document describes the ISO/IEC 14443-3 libraries used by a microcontroller to drive
the CR95HF 13.56 MHz multiprotocol contactless transceiver using an SPI or UART
interface in order to perform wireless communications with ISO/IEC 14443 Type A or B
contactless tag.
The library was developed to speed up the development of applications using the CR95HF.
The CR95HF library is composed of three layers:
■
■
■
CR95HF low level layer
Standard ISO/IEC 14443-3 protocol layer (type A and type B)
SRIX4K product specific layer
The library code has been developed in ANSI C language, and validated on an STM32
evaluation board.
1.1
Reference documents
■
■
■
CR95HF datasheet
ISO/IEC 14443-3 specification
SRIX4K datasheet
September 2011
Doc ID 022017 Rev 1
1/68
www.st.com
Contents
AN3955
Contents
1
Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.1
Reference documents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
2
Acronyms and notational conventions . . . . . . . . . . . . . . . . . . . . . . . . . . 9
2.1
2.2
List of terms and acronyms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
Notational conventions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
2.2.1
2.2.2
2.2.3
Binary number representation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
Hexadecimal number representation . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
Decimal number representation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
3
Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
3.1
3.2
3.3
3.4
CR95HF overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
ISO/IEC 14443-3 overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
SRIX4K product overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
Library overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
4
CR95HF low level layer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
4.1
4.2
4.3
4.4
4.5
4.6
4.7
4.8
4.9
4.10
4.11
4.12
4.13
4.14
4.15
Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
Definition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
CR95HF layer functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
IDN function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
ECHO function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
ProtocolSelect function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
SendRecv function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
Idle function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
RdReg function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
BaudRate function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
SendEOF function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
FieldOff function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
HexCommandToStringCommand function . . . . . . . . . . . . . . . . . . . . . . . . 22
IsReaderResultCodeOk function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
IsReaderErrorCode function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
2/68
Doc ID 022017 Rev 1
AN3955
Contents
4.16
4.17
4.18
IsCommandExists function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
GetReaderErrorCode function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
Application example: protocol selection and communication . . . . . . . . . . 25
5
ISO/IEC 14443-3 layers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
5.1
ISO/IEC 14443-3 Type A layer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
5.1.1
5.1.2
5.1.3
5.1.4
5.1.5
5.1.6
5.1.7
5.1.8
5.1.9
5.1.10
5.1.11
ISO/IEC 14443-3 Type A command format . . . . . . . . . . . . . . . . . . . . . . 26
EOF and SOF . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
Parity bit management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
ISO/IEC 14443-3 Type A CRC16 management . . . . . . . . . . . . . . . . . . . 27
Functions of ISO/IEC 14443_A layer . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
CR95HF configuration function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
ISO/IEC 14443-3 Type A command function . . . . . . . . . . . . . . . . . . . . . 30
ISO/IEC 14443-3 Type A Split function . . . . . . . . . . . . . . . . . . . . . . . . . 33
ISO/IEC 14443-3 Type A Is function . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
ISO/IEC 14443-3 Type A GET functions . . . . . . . . . . . . . . . . . . . . . . . . 36
ISO/IEC 14443-3 Type A Advanced functions . . . . . . . . . . . . . . . . . . . . 37
5.2
ISO/IEC 14443-3 Type B layer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
5.2.1
5.2.2
5.2.3
5.2.4
5.2.5
5.2.6
5.2.7
5.2.8
5.2.9
5.2.10
ISO/IEC 14443-3 Type B command format . . . . . . . . . . . . . . . . . . . . . . 40
EOF and SOF . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
Data management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
ISO/IEC 14443-3 Type B CRC16 management . . . . . . . . . . . . . . . . . . . 40
Functions of ISO/IEC 14443-3 Type B layer . . . . . . . . . . . . . . . . . . . . . 40
CR95HF configuration function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
ISO/IEC 14443-3 Type B Set function . . . . . . . . . . . . . . . . . . . . . . . . . . 42
ISO/IEC 14443-3 Type B command function . . . . . . . . . . . . . . . . . . . . . 43
ISO/IEC 14443-3 Type B Split function . . . . . . . . . . . . . . . . . . . . . . . . . 45
ISO/IEC 14443-3 Type B Is function . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
6
SRIX4K library . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
6.1
SRIX4K command format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
6.1.1
6.1.2
6.1.3
6.1.4
6.1.5
6.1.6
SRIX4K CR16 management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
Functions of SRIX4K layer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
CR95HF configuration function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
SRIX4K command function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
SRIX4K Split functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
SRIX4K Is function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
Doc ID 022017 Rev 1
3/68
Contents
6.1.7
AN3955
SRIX4K Advanced function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
7
Project example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
7.1
7.2
7.3
Hardware . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
Keil µvision
®
7.3.1
7.3.2
7.3.3
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
Project structure on Keil µvision
® . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61
Standard peripheral drivers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
Drivers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
Libraries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
7.4
Application functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
7.4.1
7.4.2
7.4.3
7.4.4
Application example flowchart . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
Detect an ISO/IEC 14443-3 Type A tag function . . . . . . . . . . . . . . . . . . 64
Detect an ISO/IEC 14443-3 Type B tag function . . . . . . . . . . . . . . . . . . 65
Detect an SRIX tag function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
8
Revision history . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
4/68
Doc ID 022017 Rev 1
AN3955
List of figures
List of figures
Figure 1.
Figure 2.
Figure 3.
Figure 4.
Figure 5.
Figure 6.
Figure 7.
Figure 8.
Figure 9.
Typical application block diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
Interaction between typical user application and CR95HF library layers . . . . . . . . . . . . . . 12
Example of function flowchart . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
Select sequence algorithm flowchart . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
Example of project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61
Flowchart of application example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
Flowchart of User detects an ISO/IEC 14443-3 Type A tag . . . . . . . . . . . . . . . . . . . . . . . . 64
Flowchart of User detects an ISO/IEC 14443-3 Type B tag . . . . . . . . . . . . . . . . . . . . . . . . 65
SRIX tag detection flowchart . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66
Doc ID 022017 Rev 1
5/68