ST AN3955 APPLICATION NOTE

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 List of terms and acronyms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
2.2 Notational conventions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
2.2.1 Binary number representation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
2.2.2 Hexadecimal number representation . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
2.2.3 Decimal number representation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
3 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
3.1 CR95HF overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
3.2 ISO/IEC 14443-3 overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
3.3 SRIX4K product overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
3.4 Library overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
4 CR95HF low level layer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
4.1 Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
4.2 Definition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
4.3 CR95HF layer functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
4.4 IDN function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
4.5 ECHO function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
4.6 ProtocolSelect function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
4.7 SendRecv function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
4.8 Idle function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
4.9 RdReg function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
4.10 BaudRate function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
4.11 SendEOF function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
4.12 FieldOff function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
4.13 HexCommandToStringCommand function . . . . . . . . . . . . . . . . . . . . . . . . 22
4.14 IsReaderResultCodeOk function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
4.15 IsReaderErrorCode function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
2/68 Doc ID 022017 Rev 1
AN3955 Contents
4.16 IsCommandExists function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
4.17 GetReaderErrorCode function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
4.18 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 ISO/IEC 14443-3 Type A command format . . . . . . . . . . . . . . . . . . . . . . 26
5.1.2 EOF and SOF . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
5.1.3 Parity bit management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
5.1.4 ISO/IEC 14443-3 Type A CRC16 management . . . . . . . . . . . . . . . . . . . 27
5.1.5 Functions of ISO/IEC 14443_A layer . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
5.1.6 CR95HF configuration function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
5.1.7 ISO/IEC 14443-3 Type A command function . . . . . . . . . . . . . . . . . . . . . 30
5.1.8 ISO/IEC 14443-3 Type A Split function . . . . . . . . . . . . . . . . . . . . . . . . . 33
5.1.9 ISO/IEC 14443-3 Type A Is function . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
5.1.10 ISO/IEC 14443-3 Type A GET functions . . . . . . . . . . . . . . . . . . . . . . . . 36
5.1.11 ISO/IEC 14443-3 Type A Advanced functions . . . . . . . . . . . . . . . . . . . . 37
5.2 ISO/IEC 14443-3 Type B layer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
5.2.1 ISO/IEC 14443-3 Type B command format . . . . . . . . . . . . . . . . . . . . . . 40
5.2.2 EOF and SOF . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
5.2.3 Data management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
5.2.4 ISO/IEC 14443-3 Type B CRC16 management . . . . . . . . . . . . . . . . . . . 40
5.2.5 Functions of ISO/IEC 14443-3 Type B layer . . . . . . . . . . . . . . . . . . . . . 40
5.2.6 CR95HF configuration function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
5.2.7 ISO/IEC 14443-3 Type B Set function . . . . . . . . . . . . . . . . . . . . . . . . . . 42
5.2.8 ISO/IEC 14443-3 Type B command function . . . . . . . . . . . . . . . . . . . . . 43
5.2.9 ISO/IEC 14443-3 Type B Split function . . . . . . . . . . . . . . . . . . . . . . . . . 45
5.2.10 ISO/IEC 14443-3 Type B Is function . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
6 SRIX4K library . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
6.1 SRIX4K command format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
6.1.1 SRIX4K CR16 management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
6.1.2 Functions of SRIX4K layer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
6.1.3 CR95HF configuration function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
6.1.4 SRIX4K command function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
6.1.5 SRIX4K Split functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
6.1.6 SRIX4K Is function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
Doc ID 022017 Rev 1 3/68
Contents AN3955
6.1.7 SRIX4K Advanced function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
7 Project example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
7.1 Hardware . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
7.2 Keil µvision
7.3 Project structure on Keil µvision
7.3.1 Standard peripheral drivers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
7.3.2 Drivers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
7.3.3 Libraries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
® . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
® . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61
7.4 Application functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
7.4.1 Application example flowchart . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
7.4.2 Detect an ISO/IEC 14443-3 Type A tag function . . . . . . . . . . . . . . . . . . 64
7.4.3 Detect an ISO/IEC 14443-3 Type B tag function . . . . . . . . . . . . . . . . . . 65
7.4.4 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. Typical application block diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
Figure 2. Interaction between typical user application and CR95HF library layers . . . . . . . . . . . . . . 12
Figure 3. Example of function flowchart . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
Figure 4. Select sequence algorithm flowchart . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
Figure 5. Example of project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61
Figure 6. Flowchart of application example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
Figure 7. Flowchart of User detects an ISO/IEC 14443-3 Type A tag . . . . . . . . . . . . . . . . . . . . . . . . 64
Figure 8. Flowchart of User detects an ISO/IEC 14443-3 Type B tag . . . . . . . . . . . . . . . . . . . . . . . . 65
Figure 9. SRIX tag detection flowchart . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66
Doc ID 022017 Rev 1 5/68
List of tables AN3955
List of tables
Table 1. Terms and acronyms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
Table 2. CR95HF layer functions based on CR95HF commands . . . . . . . . . . . . . . . . . . . . . . . . . . 14
Table 3. CR95HF layer additional functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
Table 4. CR95HF_IDN function description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
Table 5. CR95HF_Echo function description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
Table 6. CR95HF_ProtocolSelect function description. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
Table 7. CR95HF_ProtocolSelect ISO/IEC 14443-3 Type A protocol parameter. . . . . . . . . . . . . . . 17
Table 8. CR95HF_ProtocolSelect ISO14443-3 Type B protocol parameter. . . . . . . . . . . . . . . . . . . 17
Table 9. CR95HF_SendRecv function description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
Table 10. SendRecv command in ISO/IEC 14443-3 Type A case . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
Table 11. SendRecv command in ISO/IEC 14443-3 Type B case . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
Table 12. CR95HF success response value for ISO/IEC 14443-3 Type A. . . . . . . . . . . . . . . . . . . . . 19
Table 13. Specific success code for ACK or NAK contactless response . . . . . . . . . . . . . . . . . . . . . . 20
Table 14. CR95HF success response value for ISO/IEC 14443-3 Type B. . . . . . . . . . . . . . . . . . . . . 20
Table 15. CR95HF error response value for ISO/IEC 14443-3 Type A and B . . . . . . . . . . . . . . . . . . 20
Table 16. CR95HF_Idle function description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
Table 17. CR95HF_RdReg function description. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
Table 18. CR95HF_BaudRate function description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
Table 19. CR95HF_SendEOF function description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
Table 20. CR95HF_FieldOff function description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
Table 21. CR95HF_HexCommandToStringCommand function description. . . . . . . . . . . . . . . . . . . . 22
Table 22. CR95HF_IsReaderResultCodeOk function description . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
Table 23. CR95HF_IsReaderErrorCode function description. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
Table 24. CR95HF_IsCommandExists function description. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
Table 25. CR95HF_GetReaderErrorCode function description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
Table 26. ISO/IEC 14443-3 Type A commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
Table 27. Configuration of the CR95HF . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
Table 28. ISO/IEC 14443-3 Type A layer function description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
Table 29. ISO14443A_ProtocolSelect function description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
Table 30. ISO/IEC 14443-3 Type A Is function description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
Table 31. ISO/IEC 14443-3 Type A GET function description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
Table 32. ISO/IEC 14443-3 Type A Advanced function description . . . . . . . . . . . . . . . . . . . . . . . . . . 29
Table 33. ISO14443A_ProtocolSelect function description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
Table 34. ISO14443A_REQA function description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
Table 35. ISO14443A_WUPA function description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
Table 36. ISO14443A_HLTA function description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
Table 37. ISO14443A_AnticollisionLevel1 function description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
Table 38. ISO14443A_AnticollisionLevel2 function description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
Table 39. ISO14443A_AnticollisionLevel3 function description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
Table 40. ISO14443A_SelectLevel1 function description. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
Table 41. ISO14443A_SelectLevel2 functiond description. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
Table 42. ISO14443A_SelectLevel3 function description. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
Table 43. ISO14443A_Split ATQA function description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
Table 44. ISO14443A_IsCollisionDetected function description . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
Table 45. ISO14443A_IsCRCError function description. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
Table 46. ISO14443A_IsParityError function description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
Table 47. ISO14443A_Is14443_4Compatible function description . . . . . . . . . . . . . . . . . . . . . . . . . . 35
Table 48. ISO14443A_IsUIDComplete function description. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
6/68 Doc ID 022017 Rev 1
AN3955 List of tables
Table 49. ISO14443A_IsPresent function description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
Table 50. ISO14443A_IsCorrectBCC function description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
Table 51. ISO14443A_GetSignificantBit function description. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
Table 52. ISO14443A_GetFirstCollisionByte function description . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
Table 53. ISO14443A_GetFirstCollisionBit function description. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
Table 54. ISO14443A_SelectSequence function description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
Table 55. ISO14443A_GetUIDsize function description. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
Table 56. ISO14443A_GetUID function description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
Table 57. ISO/IEC14443-3 Type B configuration function description . . . . . . . . . . . . . . . . . . . . . . . . 40
Table 58. ISO14443B_SetParamByte function description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
Table 59. ISO/IEC 14443-3 Type B command functions description . . . . . . . . . . . . . . . . . . . . . . . . . 41
Table 60. ISO/IEC 14443-3 Type B Split functions description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
Table 61. ISO/IEC 14443-3 Type B Is function description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
Table 62. ISO14443B_ProtocolSelect function description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
Table 63. ISO14443B_SetParamByte function description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
Table 64. ISO14443B_REQB function description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
Table 65. ISO14443B_WUPB function description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
Table 66. ISO14443B_SlotMarker function description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
Table 67. ISO14443B_Attrib function description. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
Table 68. ISO14443B_HLTB function description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
Table 69. ISO14443B_SplitATQB function description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
Table 70. ISO14443B_SplitApplicationDataField function description . . . . . . . . . . . . . . . . . . . . . . . . 45
Table 71. ISO14443B_SplitProtocolInfoField function description . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
Table 72. ISO14443B_IsPresent function description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
Table 73. SRIX4K_ProtocolSelect function description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
Table 74. Commands included in the lib_SRIX4k.c file . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
Table 75. SRIX4K Split functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
Table 76. SRIX4K_Is functions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
Table 77. SRIX4K_Advanced functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
Table 78. SRIX4K_ProtocolSelect function description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
Table 79. SRIX4K_Initiate function description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
Table 80. SRIX4K_Pcall16 function description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
Table 81. SRIX4K_SlotMarker function description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
Table 82. SRIX4K_SelectChipID command description. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
Table 83. SRIX4K_Completion function description. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
Table 84. SRIX4K_ResetToInventory command description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
Table 85. SRIX4K_ReadSingleBlock function description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
Table 86. SRIX4K_WriteSingleBlock function description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
Table 87. SRIX4K_GetUID function description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
Table 88. SRIX4K_SplitInitiateResponse function description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
Table 89. SRIX4K_SplitPCall16Response function description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
Table 90. SRIX4K_SplitSlotMarkerResponse function description. . . . . . . . . . . . . . . . . . . . . . . . . . . 55
Table 91. SRIX4K_SplitSelectChipIDResponse function description. . . . . . . . . . . . . . . . . . . . . . . . . 55
Table 92. SRIX4K_SplitCompletionResponse function description . . . . . . . . . . . . . . . . . . . . . . . . . . 56
Table 93. SRIX4K_SplitReadSingleBlockResponse function description. . . . . . . . . . . . . . . . . . . . . . 56
Table 94. SRIX4K_SplitWritedBlockResponse function description. . . . . . . . . . . . . . . . . . . . . . . . . . 57
Table 95. SRIX4K_SplitGetUIDResponse function description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
Table 96. SRIX4K_IsPresent function description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
Table 97. SRIX4K_IsSRIX4KPresent function description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
Table 98. SRIX4K_GetUIDadvanced function description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
Table 99. SRIX4K_GetChipIDAndSelectIt function description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
Table 100. SRIX4K_Anticollision function description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
Doc ID 022017 Rev 1 7/68
List of tables AN3955
Table 101. Detection of an ISO/IEC 14443-3 Type A contactless tag . . . . . . . . . . . . . . . . . . . . . . . . . 64
Table 102. Detection of an SRIX tag function. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
Table 103. Document revision history . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
8/68 Doc ID 022017 Rev 1
AN3955 Acronyms and notational conventions

2 Acronyms and notational conventions

2.1 List of terms and acronyms

Table 1. Terms and acronyms

Terms Definition
AFI Application Family Identifier
ATQA Answer to Request Type A
ATQB Answer to Request Type B
ATS Answ e r To Select
CRC Cyclic Redundancy Check
EOF End Of Frame
FWT Frame Waiting Time
HLTA Halt command Type A
HLTB Halt command Type B
IC Integrated Circuit
IEC International Electrotechnical Commission
ISO International Organization for Standardization
MCU Microcontroller Unit
NACK Negative Acknowledge
NFC Near Field Communication
RATS Request for Answer To Select
REQA Request command Type A
REQB Request command Type B
RF Radio Frequency
RFID Radio Frequency Identification
RFU Reserved for Future Use
SAK Select AcKnowledge
SOF Start Of Frame
SRI Short Range Interface
SRIX Short Range Interface with anti clone function
UID Unique Identifier
WUPA Wake-Up A command Type A
WUPB Wake-Up A command Type B
XOR eXclusif OR
Doc ID 022017 Rev 1 9/68
Acronyms and notational conventions AN3955

2.2 Notational conventions

The following conventions and notations apply in this document unless otherwise stated.

2.2.1 Binary number representation

Binary numbers are represented by strings of digits 0 and 1 shown with the Most Significant Bit (MSB) on the left, the Least Signifcant Bit (LSB) on the right, and “0b” added at the beginning.
For example: 0b11110101

2.2.2 Hexadecimal number representation

Hexadecimal numbers are represented by using the numbers 0 to 9, the characters A - F, and a “0x” added at the beginning. The Most Significant Byte (MSB) is shown on the left and the Least Significant Byte (LSB) on the right.
For example: 0xF5

2.2.3 Decimal number representation

Decimal numbers are represented as is, without any trailing character. For example: 245
10/68 Doc ID 022017 Rev 1
AN3955 Overview
AI18873a
ISO15693 RF
MCU
CR95HF
Contactless tag
CR95HF
library
14443 type A
Or
14443 type B
13,56 MHz RF commands

3 Overview

3.1 CR95HF overview

The CR95HF is a Radio Frenquency (RF) transceiver Integrated Circuit (IC) for 13.56 MHz contactless tags, which includes ISO/IEC 14443, ISO/IEC 15693 and ISO/IEC 18092 protocols. It manages the RF communication with Radio Frequency Identification (RFID) or Near Field Communication (NFC) tags. It includes trame coding, RF modulation and contactless tag response decoding.
The CR95HF is a slave device and must be controlled by a host (Microcontroller Unit). This library is an interface between user application function and standard peripheral driver.
The library was written in compliance with ANSI C standards.
Figure 1 describes a typical application block diagram.

Figure 1. Typical application block diagram

For more details concerning the CR95HF, please refer to CR95HF datasheet.

3.2 ISO/IEC 14443-3 overview

The ISO/IEC 14443-3 is a standard, which specifies two different RF protocols (Type A and Type B). It describes low-level functions allowing to handle one ore more contactless tags. As an example, the ISO/IEC 14443-3 commands can be used to read the Unique Identifier (UID) or to perform anti-collision.
The higher level commands to read or write the user memory of contactless tags are not described in ISO/IEC 14443-3 specifications. These commands are defined in the contactless datasheet. For instance, the SRIX4K datasheet defines Read, Write and other specific commands.
For more information about Read, Write or other commands, refer to the SRIX4K datasheet. Since the frames coding specified by ISO/IEC 14443 Type A differ from Type B, the CR95HF
cannot communicate with an ISO/IEC 14443 Type A and an ISO/IEC 14443 Type B contactless tag at the same time.
Doc ID 022017 Rev 1 11/68
Overview AN3955
MS19951V1
User functions
(user application specific)
Standard peripheral driver
(MCU specific layer)
CR95HF library
CR95HF library layer
(integrates the commands defined in CR95HF datasheet)
Protocol layer (embeds commands defined in the ISO/IEC 14443-3 specification)
ISO14443_3 type A library layer ISO14443_3 type B library layer
Product layer (embeds commands defined in the product datasheet)
SRiX4K layer

3.3 SRIX4K product overview

The SRIX4K is an STMicroelectronics contactless tag powered by an RF field. It contains a 4-kbit EEPROM memory that can be accessed by using RF commands.
For more information about low-level commands to handle a tag and an upper level to read, write or lock memory, refer to the SRIX4K datasheeet.
SRIX4K is compliant with ISO/IEC 14443-3 Type B frame format specification.

3.4 Library overview

The library described in this application note is composed of three layers:
A low-level layer supporting the commands described in the CR95HF datasheet. This
level is fully supported by the CR95HF library.
An intermediate layer based on the ISO/IEC 14443-3 protocol. This layer is divided in
two files, one for Type A and another for Type B.
An upper layer supporting the commands described in the SRIX4K datasheet.
The library can be downloaded from STMicroelectronics internet site at http://www.st.com.
Figure 2 shows an example of application architecture and describes the interaction
between a typical user application and the CR95HF library layers.

Figure 2. Interaction between typical user application and CR95HF library layers

12/68 Doc ID 022017 Rev 1
AN3955 CR95HF low level layer

4 CR95HF low level layer

For a brief description of CR95HF, refer to Section 3.1: CR95HF overview. This layer is composed of:
the lib_CR95HF.c source file
the lib_CR95HF.h include file

4.1 Types

The CR95HF library functions use the following ANSI C compliant types:
typedef unsigned char uint8_t;
typedef signed char int8_t;
typedef const uint8_t uc8;
typedef signed short int int16_t;

4.2 Definition

The layer supports all the commands defined in the CR95HF datasheet. Each CR95HF command corresponds to a specific function. As an example, the function calling the ECHO command is int8_t CR95HF_Echo (uint8_t *pResponse).
Additional functions are described in Table 3: CR95HF layer additional functions. Application developers can use the functions described in Table 2: CR95HF layer functions
based on CR95HF commands to create their own higher level functions.
For more details about commands, refer to the CR95HF datasheet.
Doc ID 022017 Rev 1 13/68
CR95HF low level layer AN3955

4.3 CR95HF layer functions

The tables below introduce the functions available in the CR95HF layer.
.

Table 2. CR95HF layer functions based on CR95HF commands

Function name Brief description
Sends an IDN command to CR95HF device. It returns its version
CR95HF_IDN
CR95HF_Echo
CR95HF_ProtocolSelect
CR95HF_SendRecv
CR95HF_Idle
CR95HF_RdReg
CR95HF_BaudRate
number. For more details about CR95HF_IDN function, refer to
Section 4.4: IDN function.
Sends an Echo command to CR95HF device which returns an Echo response. The Echo function checks if communications can be started between the MCU and the CR95HF. For more details about CR95HF_Echo function, refer to Section 4.5: ECHO function.
Sends a ProtocolSelect command to CR95HF device. It selects the RF communication protocol, configures RF parameters and switches the RF field on. For more details about CR95HF_ProtocolSelect function, refer to Section 4.6: ProtocolSelect function.
Sends a SendRecv command. The parameter sent to the command is the frame which is coded according to the protocol previously selected by issuing a ProtocolSelect command. For more details about CR95HF_SendRecv function, refer to Section 4.7: SendRecv
function.
Sends an Idle command to the CR95HF device to switch it into low consumption mode. For more details about CR95HF_Idle function, refer to Section 4.8: Idle function.
Sends a ReadRegister command to the CR95HF device to read the CR95HF internal register. For more details about CR95HF_RdReg function, refer to Section 4.9: RdReg function.
Sends a Baudrate command to the CR95HF device. It changes the CR95HF UART baudrate. For more details about CR95HF_BaudRatefunction, refer to Section 4.10: BaudRate
function.
14/68 Doc ID 022017 Rev 1
AN3955 CR95HF low level layer
.

Table 3. CR95HF layer additional functions

Function name Brief description
Sends an RF pulse (EOF). For more details about
CR95HF_SendEOF
CR95HF_FieldOff
CR95HF_HexCommandToStringCommand
CR95HF_GetReaderErrorCode
CR95HF_IsReaderResultCodeOk
CR95HF_IsReaderErrorCode
CR95HF_IsCommandExists
CR95HF_SendEOF function, refer to Section 4.11:
SendEOF function.
Switches off the RF field. For more details about CR95HF_FieldOff function, refer to Section 4.12:
FieldOff function.
Translates hexadecimal command code to command name. It returns the ASCII code of the command. For more details about CR95HF_HexCommandToStringCommand function, refer to Section 4.13: HexCommandToStringCommand
function.
Translates hexadecimal error code to error code description. It returns a description of the error contained in the ReaderReply parameter. For more details about CR95HF_GetReaderErrorCode, refer to Section 4.17: GetReaderErrorCode function.
Checks if returned code is a successful code. It returns CR95HF_SUCCESS_CODE if the CR95HF command is successful. For more details about CR95HF_IsReaderResultCodeOk function, refer to
Section 4.14: IsReaderResultCodeOk function.
Checks if returned code is an error code. It returns CR95HF_SUCCESS_CODE value if the CR95HF command has returned an error code. For more details about CR95HF_IsReaderErrorCode function, refer to Section 4.15: IsReaderErrorCode function.
Checks if command is available. It returns CR95HF_SUCCESS_CODE if the CmdCode value exists. For more details about CR95HF_IsCommandExists function, refer to
Section 4.16: IsCommandExists function.
Doc ID 022017 Rev 1 15/68
CR95HF low level layer AN3955

4.4 IDN function

The CR95HF_IDN function sends an IDN command to the CR95HF device.

Table 4. CR95HF_IDN function description

Prototype
Input parameter None Output parameter pResponse: Pointer to CR95HF response Return parameter CR95HF_SUCCESS_CODE: Function is successful.
result = int8_t CR95HF_IDN (uint8_t *pResponse)

4.5 ECHO function

The CR95HF_Echo function sends an ECHO command to the CR95HF device.

Table 5. CR95HF_Echo function description

Prototype
Input parameter None Output parameter pResponse: Pointer to CR95HF response
result = int8_t CR95HF_Echo (uint8_t *pResponse)
Return parameter CR95HF_SUCCESS_CODE: Function is successful.

4.6 ProtocolSelect function

The CR95HF_ProtocolSelect function sends a ProtocolSelect command to the CR95HF device.
To set up communications with a contactless tag, the ProtocolSelect command must be sent to the CR95HF before the SendRecv commands.

Table 6. CR95HF_ProtocolSelect function description

Prototype
Input parameter
Output parameter pResponse: Pointer to CR95HF response
Return parameter
1. ISO/IEC 15693, ISO/IEC 18092, ISO/IEC 14443-3 Type A or Type B RF protocols.
result = int8_t CR95HF_ProtocolSelect(uc8 Length,uc8 Protocol,uc8 *Data,uint8_t *pResponse)
Length: Number of data bytes Protocol: Type of protocol Data input: Pointer to data
CR95HF_ERRORCODE_PARAMETER: Function failed CR95HF_SUCCESS_CODE: Function is successful. CR95HF_ERRORCODE_PARAMETERLENGTH: Parameter length is
incorrect.
(1)
The Data input parameter depends on the selected protocol. This application note applies to ISO/IEC 14443-3 Type A and ISO/IEC 14443-3 Type B products.
16/68 Doc ID 022017 Rev 1
AN3955 CR95HF low level layer
Ta bl e 7 describes the ProtocolSelect command in ISO/IEC 14443-3 Type A case.

Table 7. CR95HF_ProtocolSelect ISO/IEC 14443-3 Type A protocol parameter

Parameter name Byte Bit Value Example
Command Code
Length
Protocol
Parameter
1. Optional. If not specify default FWT~86 µs
2. PP <= 0x0E and 0x01 <= MM <= 0xFE
0 7:0 0x02 0x02020200
1 7:0 0x02
2 7:0
3 7:6
5:4
3:0
5:4 7:0
0x02
protocol
Transmission data rate
Reception data rate
RFU
FWT= (256*16/fc)*(2*PP)*(MM+1) where “PP” represents byte 4 and “MM” byte 5.
: ISO/IEC 14443-3 Type A
ISO/IEC 14443-3 Type A with reception and transmission data rates at 106 kbps
(1) (2)
Ta bl e 8 describes the ProtocolSelect command in ISO/IEC 14443-3 Type B case.

Table 8. CR95HF_ProtocolSelect ISO14443-3 Type B protocol parameter

Parameter name Byte Bit Value Example
Command Code
Length
Protocol
0 7:0 0x02 0x02020301
1 7:0 0x02
2 7:0
3 7:6
0x03
Transmission data rate
: ISO/IEC 14443-3 Type B protocol
ISO/IEC 14443-3 Type B with reception and transmission data rates at 106 kbps
Reception data rate
5:4
RFU
3:0
Append CRC
Parameter
5:4 7:0
1. Optional. If not specify default FWT~300µs.
2. PP <= 0x0E and 0x01 <= MM <= 0xFE
0
1: CR95HF appends CRC 0: CR95HF does not append CRC
FWT= (256*16/fc)*(2*PP)*(MM+1) where “PP” represents byte 4 and “MM” byte 5.
Doc ID 022017 Rev 1 17/68
(1) (2)
The CR95HF manages the CRC.
CR95HF low level layer AN3955

4.7 SendRecv function

The CR95HF_SendRecv function sends a SendRecv command. The CR95HF encodes the frame, transmits it at 13.56 MHz, and decodes the contactless tag response.
The contactless tag response is then sent back in the pResponse parameter.

Table 9. CR95HF_SendRecv function description

Prototype
result = int8_t CR95HF_SendRecv (uc8 Length,uc8 *Parameters,uint8_t *pResponse)
Input parameter
Output parameter pResponse : Pointer to CR95HF response
Return parameter
Length: Number of bytes in Parameters input Parameters input: Pointer to data
CR95HF_ERRORCODE_PARAMETER: Function failed CR95HF_SUCCESS_CODE: Function is successful. CR95HF_ERRORCODE_PARAMETERLENGTH: Parameter
length is incorrect.
The Parameters input depends on the selected protocol. This application note applies to ISO/IEC 14443-3 Type A and ISO/IEC 14443-3 Type B products.
Ta bl e 1 0 describes the SendRecv command in ISO/IEC 14443-3 Type A case.

Table 10. SendRecv command in ISO/IEC 14443-3 Type A case

Parameter name Byte Bit Value Comments Example
Command Code
Length
Data
0 7:0 0x04
1 7:0 0xXX
2:X 7:0 0xXX
X+1 7
-RFU
6 0b0
Number of Data bytes and transmission flag
Data
Split frame
-
REQA command:
0x04022607 26:
Data (REQA
command code)
07:
number of significant bits (REQA is coded on 7 bits)
with
1: CR95HF
5
appends CRC
Transmission flag
0: CR95HF does not append CRC
4 0b0
3:0
18/68 Doc ID 022017 Rev 1
0xX
Append CRC
RFU
Number of significant bits
AN3955 CR95HF low level layer
Ta bl e 1 1 describes the SendRecv command in ISO/IEC 14443-3 Type B case.

Table 11. SendRecv command in ISO/IEC 14443-3 Type B case

Parameter name Byte Bit Value Comments Example
Command Code
Length
Data
0 7:0 0x04
1 7:0 0xXX
2:X 7:0 0xXX
Length of entire data
Data
-
REQB command:
0x040305000
For more information, refer to CR95HF datasheet.Ta ble 12 describes the CR95HF success response value for ISO/IEC 14443-3 Type A.

Table 12. CR95HF success response value for ISO/IEC 14443-3 Type A

Parameter
name
Result Code
Length
Data
Byte Bit Value Comments Example
0 7:0 0x04
1 7:0 0xXX
2:X 7:0 0xXX
X+1 7
1: CR95HF has detected a collision
0: No collision detected
60
Success code
Number of bytes of Data + control bytes
Contactless tag response
Collision between two contactless tag responses
RFU
0X80054400280000
where:
80: success 05: Number of bytes 4400: ATQA 28: CRC error
Number of significant bits: 8
00 00: No collision
detected
(1)
&
1: CRC error
5
0: No CRC error
1: Parity error
4
Control bytes
0: No Parity error
3:0
X+2 7:0 0xXX
X+3 7:4 0b000
3:0 0bXXXX
1. CRC error bit is set but there is no CRC on ATQA response. So this bit is not significant.
2. Since the ISO/IEC 14443-3 Type A is a bit-oriented protocol, CR95HF can receive a non integer amount of bytes.
3. To calculate the point of collision between two contactless tag responses, the user application must refer to the control bytes. The byte where the collision is detected is indicated by Control Byte X+2 (Index of first byte), and the specific bit in the byte where the collision is detected is indicated by Control Byte X+3 (Index of first bit). Both indices start from 0 and the bit index can be 8, meaning that the collision affected parity. This information is only valid if the Collision Dectected bit (Bit 7 of control Byte X+1) is set.
CRC error on contactless response
Parity error on contactless response
Number of significant bits in the first byte
Index of the first byte where the collision is detected
RFU
Index of the first bit where the collision is detected
(2)
(3)
Doc ID 022017 Rev 1 19/68
CR95HF low level layer AN3955
CR95HF returns a specific correct code for ACK or NAK contactless response, coded on 4 bits, as described in Tabl e 1 3.

Table 13. Specific success code for ACK or NAK contactless response

Parameter name Byte Bit Value Comments
Result Code
Length
0 7:0 0x90
1 7:0 0x04
Success code
Number of valid bits: 4
2:X 7:0 0x01: NAK
Data
0x05: NAK
Contactless tag response
0x0A: ACK
Ta bl e 1 4 describes the CR95HF success response value for ISO/IEC 14443-3 Type B.

Table 14. CR95HF success response value for ISO/IEC 14443-3 Type B

Parameter
name
Result Code
Length
Data
Byte Bit Value Comments Example
0 7:0 0x80
1 7:0 0xXX
2:X 7:0 0xXX
X+1 7:2 0b0000
Success code
Number of bytes of Data + control bytes
Contactless tag response
RFU
0x800F50AA0B000500 000000B371716A2100
where:
80: Success 0F: Number of byte 50AA0B000500000000 B371716A21:
ATQB
00: CRC Ok
Control bytes
1 1: CRC error
0: no CRC error
CRC error or contactless response
0
-RFU
For more information, refer to CR95HF datasheet.
If CR95HF_SendRecv function fails, the CR95HF returns an error code in the pResponse parameter (see Ta bl e 1 5 ). As an example, if no contactless tag is present in the RF field, the CR95HF response is 0x8700.

Table 15. CR95HF error response value for ISO/IEC 14443-3 Type A and B

Parameter name Byte Bit Value Example
Result code
Length
0 7:0 0x08
1 7:0 0x00
For more information about CR95HF error code, refer to CR95HF datasheet.
20/68 Doc ID 022017 Rev 1
0x8700
tag in the field
: no contactless
AN3955 CR95HF low level layer

4.8 Idle function

This function sends an Idle command to the CR95HF to switch the CR95HF device into low consumption mode. Ta b le 1 6 describes the CR95HF_Idle function.
Table 16.
Prototype
Input parameter
Output parameter pResponse : Pointer to the CR95HF response
Return parameter
CR95HF_Idle function description
result = int8_t CR95HF_Idle(uc8 Length,uc8 *Data,uint8_t *pResponse);
Length: Number of data bytes Data: Pointer to data
CR95HF_ERRORCODE_PARAMETER: Function failed CR95HF_SUCCESS_CODE: Function is successful. CR95HF_ERRORCODE_PARAMETERLENGTH:
Parameter length is incorrect.

4.9 RdReg function

This function sends an RdReg command to the CR95HF in order to read the CR95HF internal register. Ta ble 17 describes the CR95HF_RdReg function.

Table 17. CR95HF_RdReg function description

result = int8_t CR95HF_RdReg(uc8
Prototype
Input parameter
Output parameter pResponse : Pointer to CR95HF response Return parameter CR95HF_SUCCESS_CODE: Function is successful.
Length,uc8 Address,uc8 RegCount,uc8 Flags,uint8_t *pResponse);
Length : Number of bytes (Address+RegCount+Flags) Address: Register address RegCount: Number of bytes to read Flags: ST reserved (must be 0x00)

4.10 BaudRate function

This function sends a BaudRate command to the CR95HF. It allows configuring the UART baudrate. Ta bl e 1 8 describes the CR95HF_BaudRate function.

Table 18. CR95HF_BaudRate function description

Prototype
Input parameter BaudRate: New baud rate = 13.56/(2*BaudRate+2) Mbps Output parameter pResponse : Pointer to the CR95HF response Return parameter CR95HF_SUCCESS_CODE: Function is successful.
For more information about this command, please refer to CR95HF datasheet.
result = int8_t CR95HF_BaudRate (uc8 BaudRate,uint8_t *pResponse);
Doc ID 022017 Rev 1 21/68
Loading...
+ 47 hidden pages