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
CR95HF low level layer AN3955

4.11 SendEOF function

This function emits an RF pulse (EOF). Ta b le 19 describes the CR95HF_SendEOF function.

Table 19. CR95HF_SendEOF function description

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

4.12 FieldOff function

This function switches off the RF field. Ta bl e 2 0 describes the CR95HF_FieldOff function.

Table 20. CR95HF_FieldOff function description

Prototype
Input parameter None
Output parameter None
result = int8_t CR95HF_FieldOff(void);
Return parameter CR95HF_SUCCESS_CODE: Function is successful.

4.13 HexCommandToStringCommand function

This function returns the command ASCII code. Ta bl e 2 1 describes the CR95HF_HexCommandToStringCommand function.

Table 21. CR95HF_HexCommandToStringCommand function description

result = int8_t CR95HF_HexCommandToStringCommand
Prototype
Input parameter CmdCode: Command code (one byte)
Output parameter
Return parameter CR95HF_SUCCESS_CODE: Function is successful.
(uint8_t CmdCode, uint8_t *StringCommand, uint8_t *CmdNameNbByte);
StringCommand: Command string (ASCII format) CmdNameNbByte: Number of bytes in the command code
22/68 Doc ID 022017 Rev 1
AN3955 CR95HF low level layer

4.14 IsReaderResultCodeOk function

This function returns CR95HF_SUCCESS_CODE if the CR95HF command has succeeded.
Ta bl e 2 2 describes the CR95HF_IsReaderResultCodeOk function.

Table 22. CR95HF_IsReaderResultCodeOk function description

result = int8_t
Prototype
CR95HF_IsReaderResultCodeOk (uint8_t CmdCode,uc8 *ReaderReply);
Input parameter
Output parameter None
Return parameter
CmdCode: Command code (one byte) ReaderReply: Pointer to CR95HF response
CR95HF_NOREPLY_CODE: No CR95HF response CR95HF_SUCCESS_CODE: Function is successful. CR95HF_ERROR_CODE: Function failed. CR95HF does
not return a correct code.

4.15 IsReaderErrorCode function

This function returns CR95HF_SUCCESS_CODE value if the CR95HF command has returned an error code. Tabl e 2 3 describes the CR95HF_IsReaderErrorCode function.

Table 23. CR95HF_IsReaderErrorCode function description

Prototype
Input parameter
Output parameter None
Return parameter
result = int8_t CR95HF_IsReaderErrorCode (uint8_t CmdCode,uint8_t *ReaderReply);
CmdCode: Command code (one byte) ReaderReply: Pointer to CR95HF response
CR95HF_NOREPLY_CODE: No CR95HF response CR95HF_SUCCESS_CODE: Function is successful. CR95HF_ERROR_CODE:
Function failed. CR95HF does not return an error code.

4.16 IsCommandExists function

This function returns CR95HF_SUCCESS_CODE if the CmdCode value exists. Ta bl e 2 4 describes the CR95HF_IsCommandExists function.

Table 24. CR95HF_IsCommandExists function description

Prototype
Input parameter CmdCode: Command code (one byte)
Output parameter None
Return parameter
result = int8_t CR95HF_IsCommandExists(uint8_t CmdCode);
CR95HF_SUCCESS_CODE: Function is successful. CR95HF_ERRORCODE_COMMANDUNKNOWN: The command code is unknown.
Doc ID 022017 Rev 1 23/68
CR95HF low level layer AN3955

4.17 GetReaderErrorCode function

This function returns a description of the error contained in the ReaderReply parameter.
Ta bl e 2 5 describes the CR95HF_GetReaderErrorCode function.

Table 25. CR95HF_GetReaderErrorCode function description

Prototype
result = int8_t CR95HF_GetReaderErrorCode (uc8 CmdCode,uc8 *ReaderReply,char *ErrorDescription);
Input parameter
Output parameter ErrorDescription: Pointer to ASCII string
Return parameter
CmdCode: Command code (one byte) ReaderReply: Pointer to CR95HF response
CR95HF_SUCCESS_CODE: Function is successful. ERRORCODE_GENERIC: Function failed. CR95HF does not return an error
code.
24/68 Doc ID 022017 Rev 1
AN3955 CR95HF low level layer
AI18875
Start
Echo
Echo
response?
Select
protocol
Selected?
SendRecv
Another
protocol?
No
Error code
Yes
No
Yes
Yes

4.18 Application example: protocol selection and communication

To communicate with a contactless tag, the application must select the RF protocol by sending a ProtocolSelect command. Then, the application can use SendRecv commands to send data to a contactless tag.
The user can select another protocol or change RF parameters (e.g. choose another datarate) at any time by issuing again a ProtocolSelect command. Figure 3 shows an example of function flowchart.

Figure 3. Example of function flowchart

Doc ID 022017 Rev 1 25/68
ISO/IEC 14443-3 layers AN3955

5 ISO/IEC 14443-3 layers

For a brief description of ISO/IEC 14443-3 layers, refer to Section 3.2: ISO/IEC 14443-3
overview.
The ISO/IEC 14443-3 layers include two layers:
the ISO/IEC 14443-3 Type A layer
the ISO/IEC 14443-3 Type B layer

5.1 ISO/IEC 14443-3 Type A layer

The ISO/IEC 14443-3 Type A layer is composed of:
the lib_iso14443A.c source file
the lib_iso14443A.h include file

5.1.1 ISO/IEC 14443-3 Type A command format

The ISO/IEC 14443-3 Type A specification defines two command framings: a short frame and a standard frame.
Short frame:
SOF Data CRC EOF
with: SOF: Start Of Frame Data: 7 bits EOF: End Of Frame
Standard frame:
SOF Command
code
with: SOF: Start Of Frame Command code: 1 byte Parity: 1 bit Data: 1 byte EOF: End Of Frame

5.1.2 EOF and SOF

Parity Data Parity Data Parity ... EOF
The EOF and SOF are managed by the CR95HF.
26/68 Doc ID 022017 Rev 1
AN3955 ISO/IEC 14443-3 layers

5.1.3 Parity bit management

The parity bit of a standard frame is managed by the CR95HF.

5.1.4 ISO/IEC 14443-3 Type A CRC16 management

The ISO/IEC 14443-3 Type A specification defines a two-byte CRC. It is appended to some RF commands to check the data transmission between CR95HF and a contactless tag.
th
The 5 is set to 1, the CR95HF appends the CRC to RF commands.
Ta bl e 2 6 lists the ISO/IEC 14443-3 Type A commands and notifies if a CRC is required. The
functions of ISO/IEC 14443-3 Type A layer listed in Tab l e 26 manage the transmission flag and the CRC.
Table 26. ISO/IEC 14443-3 Type A commands
bit of the transmission flag of SendRecv command controls the CRC. When this bit
ISO/IEC 14443-3
Type A command
REQA No 04 02 26 07
WUPA No 04 02 52 07
HLTA Yes 04 03 50 00 28
Anticollision No 04 02 93 20 08
Select Yes
CRC
SendRecv
example
04 02 93 70
88...28
Comments ISO/IEC 14443_A function
Command on 7 bits without CRC
Command on 7 bits without CRC
The last byte has 8 bits with CRC
The last byte has 8 bits without CRC
The last byte has 8 bits with CRC
ISO14443A_REQA
ISO14443A_WUPA
ISO14443A_HLTA
ISO14443A_AntiCollisionLevelX
ISO14443A_SelectLevelX
If the user application does not use the previous functions, it has to manage the CRC by using bit 5 of the transmission flag.
Doc ID 022017 Rev 1 27/68
ISO/IEC 14443-3 layers AN3955

5.1.5 Functions of ISO/IEC 14443_A layer

The lib_iso14443A.c file includes all the commands defined in the ISO/IEC 14443-3 Type A specifications.
Ta bl e 2 7 lists the command to configure the CR95HF in order to communicate with an
ISO/IEC 14443-3 Type A tag.
Table 27. Configuration of the CR95HF
Function Description
ISO14443A_ProtocolSelect
Configures CR95HF to communicate with an ISO/IEC 14443 Type A contactless tag.
Ta bl e 2 8 lists the functions of this layer which emit an ISO/IEC 14443-3 Type A command.
Table 28. ISO/IEC 14443-3 Type A layer function description
Function Description
ISO14443A_REQA Sends a REQA command to a contactless tag.
ISO14443A_WUPA Sends a WUPA command to a contactless tag.
ISO14443A_HLTA Sends an HLTA command to a contactless tag.
ISO14443A_AntiCollisionLevel1
ISO14443A_AntiCollisionLevel2
ISO14443A_AntiCollisionLevel3
ISO14443A_SelectLevel1 Sends a select command (Level 1) to a contactless tag.
ISO14443A_SelectLevel2 Sends a select command (Level 2) to a contactless tag.
ISO14443A_SelectLevel3 Sends a select command (Level 3) to a contactless tag.
Sends an anti-collision command (Level 1) to a contactless tag.
Sends an anti-collision command (Level 2) to a contactless tag.
Sends an anti-collision command (Level 3) to a contactless tag.
A CR95HF response includes different information fields extracted by the following functions. Ta bl e 29 describes the ISO14443A_ProtocolSelect function.
Table 29. ISO14443A_ProtocolSelect function description
Function Description
ISO14443A_ProtocolSelect
28/68 Doc ID 022017 Rev 1
Configures CR95HF to communicate with an ISO/IEC 14443 Type A contactless tag.
AN3955 ISO/IEC 14443-3 layers
The Is functions return RESULTOK if the function is successful, otherwise the Is functions return ERRORCODE_GENERIC. Ta bl e 3 0 lists the Is functions.
Table 30. ISO/IEC 14443-3 Type A Is function description
Function Description
ISO14443A_IsCollisionDetected
ISO14443A_IsCRCError
ISO14443A_IsParityError
ISO14443A_IsCorrectBCC Checks if BCC byte matches the data.
ISO14443A_IS14443_4Compatible
ISO14443A_ISUIDComplete Checks if the UID is completed.
ISO14443A_IsPresent Checks if a 14443-3 Type A tag is present in the RF field.
Checks if the collision bit of the CR95HF control byte is set (collision detected).
Checks if the CRC bit of the CR95HF control byte is set (CRC error detected).
Checks if the Parity bit of the CR95HF control byte is set (parity error detected).
Checks if the contacless tag is compliant with ISO/IEC 14443_4 specification.
The GET functions return an information field. Tabl e 3 1 describes the GET functions.
Table 31. ISO/IEC 14443-3 Type A GET function description
Function Description
ISO14443A_GetSignificantBit
ISO14443A_GetFirstCollisionByte
Returns the number of significant bit of the byte. This information is extracted from control bytes of CR95HF.
Returns the index of the first byte where the collision is detected. This information is extracted from control bytes of CR95HF.
Returns the index of the first bit where the collision is
ISO14443A_GetFirstCollisionBit
detected. This information is extracted from control bytes of CR95HF.
The advanced functions use the select sequence of one tag to manage a specific sequence.
Ta bl e 3 2 describes the advanced functions.
Table 32. ISO/IEC 14443-3 Type A Advanced function description
Function Description
ISO14443A_SelectSequence
ISO14443A_GetUIDsize
ISO14443A_GetUID Returns UID of a contacless tag.
Doc ID 022017 Rev 1 29/68
Runs a select sequence as defined in ISO/IEC 14443-3 specification.
Returns UID size (information extracted from ATQA contactless tag response).
ISO/IEC 14443-3 layers AN3955

5.1.6 CR95HF configuration function

The CR95HF configuration function sends a ProtocolSelect command to CR95HF device in order to select the ISO/IEC 14443-3 Type A protocol. The transmission and reception data rates are integrated in the command. This command turns on the RF field.
Ta bl e 3 3 describes the ISO14443A_ProtocolSelect function.
Table 33. ISO14443A_ProtocolSelect function description
Prototype
int8_t ISO14443A_ProtocolSelect (uc8TXDataRate, uc8 RxDataRate, uint8_t*pResponse);
Input parameter
Output parameter pResponse: Pointer to the CR95HF response
Return parameter
TxDataRate: Transmission data rate (2 bits) RxDataRate: Reception data rate (2 bits)
RESULTOK: The ISO/IEC 14443-3 Type A protocol is selected. ISO14443A_ERRORCODE_PARAMETER: One parameter is incorrect. CR95HF_ERROR_CODE: Function failed. The ISO/IEC 14443-3 Type A
protocol is not selected.

5.1.7 ISO/IEC 14443-3 Type A command function

These functions send a basic RF command to a contactless tag and check the CR95HF response.
The ISO14443A_REQA function sends a REQA command to a contactless tag. Ta bl e 3 4 describes the ISO14443A_REQA function.
Table 34. ISO14443A_REQA function description
Prototype
Input parameter None Output parameter pResponse: Pointer to the CR95HF response
Return parameter
ISO14443A_REQA (uint8_t *pResponse);
RESULTOK: The REQA command is successfully emitted to a contactless tag.
CR95HF_ERROR_CODE: Function failed. The CR95HF returns an error code.
The ISO14443A_WUPA function sends a WUPA command to a contactless tag. Tabl e 3 5 describes the ISO14443A_WUPA function.
Table 35. ISO14443A_WUPA function description
Prototype
Input parameter None Output parameter pResponse: Pointer to the CR95HF response
Return parameter
30/68 Doc ID 022017 Rev 1
int8_t ISO14443A_WUPA (uint8_t *pResponse);
RESULTOK: The WUPA command is successfully emitted to a contactless tag.
CR95HF_ERROR_CODE: Function failed. The CR95HF returns an error code.
AN3955 ISO/IEC 14443-3 layers
The ISO14443A_HLTA function sends an HLTA command to a contactless tag. Tab l e 36 describes the ISO14443A_HLTA function.
Table 36. ISO14443A_HLTA function description
Prototype
Input parameter None Output parameter pResponse: Pointer to the CR95HF response
Return parameter
int8_t ISO14443A_HLTA (uint8_t *pResponse);
RESULTOK: The HLTA command is successfully emitted to a contactless tag. CR95HF_ERROR_CODE: Function failed. The CR95HF returns an error
code
The ISO14443A_AnticollisionLevel1 function sends an anticollision (level 1) command to a contactless tag.
Ta bl e 3 7 describes the ISO14443A_AnticollisionLevel1 function.
Table 37. ISO14443A_AnticollisionLevel1 function description
Prototype
Input parameter None
int8_t ISO14443A_AnticollisionLevel1 (uint8_t *pResponse);
Output parameter pResponse: Pointer to the CR95HF response
RESULTOK: The anticollision (level 1) command is successfully emitted to a
Return parameter
contactless tag. CR95HF_ERROR_CODE: Function failed. The CR95HF returns an error
code.
The ISO14443A_AnticollisionLevel2 function sends an anticollision (level 2) command to a contactless tag.
Ta bl e 3 8 describes the ISO14443A_AnticollisionLevel2 function.
Table 38. ISO14443A_AnticollisionLevel2 function description
Prototype
Input parameter None Output parameter pResponse: Pointer to the CR95HF response
Return parameter
int8_t ISO14443A_AnticollisionLevel2 (uint8_t *pResponse);
RESULTOK: The anticollision (level 2) command is successfully emitted to a contactless tag.
CR95HF_ERROR_CODE: Function failed. The CR95HF returns an error code.
Doc ID 022017 Rev 1 31/68
ISO/IEC 14443-3 layers AN3955
The ISO14443A_AnticollisionLevel3 function sends an anticollision (level 3) command to a contactless tag.
Ta bl e 3 9 describes the ISO14443A_AnticollisionLevel3 function.
Table 39. ISO14443A_AnticollisionLevel3 function description
Prototype
Input parameter None Output parameter pResponse: Pointer to the CR95HF response
Return parameter
int8_t ISO14443A_AnticollisionLevel3 (uint8_t *pResponse);
RESULTOK: The anticollision (level 3) command is successfully emitted to a contactless tag.
CR95HF_ERROR_CODE: Function failed. The CR95HF returns an error code.
The ISO14443A_SelectLevel1 function sends a Select (level 1) command to a contactless tag. Ta b le 4 0 describes the ISO14443A_SelectLevel1 function.
Table 40. ISO14443A_SelectLevel1 function description
Prototype
int8_t ISO14443A_SelectLevel1 (uc8 NbByteUIDin, uc8*UIDin, uint8_t*pResponse);
Input parameter
Output parameter pResponse: Pointer to the CR95HF response
Return parameter
NbByteUIDin: Number of bytes of UID in parameter UIDin: Pointer of contacless tag UID
RESULTOK: The Select (level 1) command is successfully emitted to a
contactless tag.
ISO14443A_ERRORCODE_PARAMETER: NbByteUIDin is incorrect. CR95HF_ERROR_CODE: Function failed. The CR95HF returns an error
code.
The ISO14443A_SelectLevel2 function sends a Select (level 2) command to a contactless tag. Ta b le 4 1 describes the ISO14443A_SelectLevel2 function.
Table 41. ISO14443A_SelectLevel2 functiond description
Prototype
Input parameter
Output parameter pResponse: Pointer to the CR95HF response
Return parameter
int8_t ISO14443A_SelectLevel2 (uc8 NbByteUIDin, uc8*UIDin, uint8_t*pResponse);
NbByteUIDin: Number of bytes of UIDin parameter UIDin: Pointer of contacless tag UID
RESULTOK: The Select (level 2) command is successfully emitted to a
contactless tag.
ISO14443A_ERRORCODE_PARAMETER: NbByteUIDin is incorrect. CR95HF_ERROR_CODE: Function failed. The CR95HF returns an error
code.
32/68 Doc ID 022017 Rev 1
AN3955 ISO/IEC 14443-3 layers
The ISO14443A_SelectLevel3 function sends a Select (level 3) command to a contactless tag. Ta b le 4 2 describes the ISO14443A_SelectLevel3 function.
Table 42. ISO14443A_SelectLevel3 function description
Prototype
int8_t ISO14443A_SelectLevel3 (uc8 NbByteUIDin, uc8*UIDin, uint8_t*pResponse);
Input parameter
Output parameter pResponse: Pointer to the CR95HF response
Return parameter
NbByteUIDin: Number of bytes of the UIDin parameter UIDin: Pointer of a contacless tag UID
RESULTOK: The Select (level 3)command is successfully emitted to
contactless tag.
ISO14443A_ERRORCODE_PARAMETER: NbByteUIDin is incorrect. CR95HF_ERROR_CODE: Function failed. The CR95HF returns an error
code.
The ISO14443A_SelectSequence function described in Section 5.1.11: ISO/IEC 14443-
3 Type A Advanced functions carries out a whole sequence using the Select and
Anticollision commands. For more information, refer to Section 5.1.5: Functions of ISO/IEC 14443_A layer.

5.1.8 ISO/IEC 14443-3 Type A Split function

The ISO14443A_SplitATQA function splits the ATQA contactless tag response. Ta b le 4 3 describes the ISO14443A_SplitATQA function.
Table 43. ISO14443A_Split ATQA function description
int8_t ISO14443A_SplitATQA (uint8_t
Prototype
*ReaderResponse, uint8_t*ProprietaryCoding, uint8_t*UIDsizeframe, uint8_t*BitFrameAnticol, uint8_t*CR95HFControlByteIndex);
Input parameter ReaderResponse: Pointer of the CR95HF response
ProprietaryCoding: Proprietary coding (4 bits) UIDsizeframe: UID size bit frame (2 bits): 0 for single UID size, 1 for double
Output parameter
Return parameter
UID size, 2 for triple UID size
BitFrameAnticol: Bit frame anti-collision (5 bits) CR95HFControlByteIndex: Index on control byte of CR95HF response (3
bytes)
RESULTOK: Function is successful. CR95HF_ERROR_CODE: Function failed. The CR95HF returns an error
code.
Doc ID 022017 Rev 1 33/68
ISO/IEC 14443-3 layers AN3955

5.1.9 ISO/IEC 14443-3 Type A Is function

The Is functions return RESULTOK if the function is successful, otherwise the Is functions return ERRORCODE_GENERIC.
The Is functions return RESULTOK if the bit collision is detected. The
ISO14443A_IsCollisionDetected function returns RESULTOK if the bit CollisionDetected of the CR95HF control byte is set.
Ta bl e 4 4 describes the ISO14443A_IsCollisionDetected function.
Table 44. ISO14443A_IsCollisionDetected function description
Prototype
Input parameter CR95HFControlByteIndex: Pointer to the CR95HF control byte (3 bytes)
Output parameter None
Return parameter
1. Three control bytes are appended by CR95HF to contactless tag response. Refer to Table 12: CR95HF
success response value for ISO/IEC 14443-3 Type A.
The ISO14443A_IsCRCError function returns RESULTOK if the bit CRC Error of CR95HF control bytes is set. Otherwise, the ISO14443A_IsCRCError function returns
ERRORCODE_GENERIC. Ta bl e 4 5 describes the ISO14443_IsCRCError function.
int8_t ISO14443A_IsCollisionDetected(uc8*CR95HFContr olByteIndex);
(1)
.
RESULTOK: CollisionDetected bit is set. ERRORCODE_GENERIC: CollisionDetected bit is reset.
Table 45. ISO14443A_IsCRCError function description
Prototype
Input parameter CR95HFControlByteIndex: Pointer of the CR95HF control bytes (3 bytes)
Output parameter None
Return parameter
1. Three control bytes are appended by CR95HF to contactless tag response. Refer to Table 12: CR95HF
success response value for ISO/IEC 14443-3 Type A.
int8_t ISO14443A_IsCRCError(uc8*CR95HFControlByteI ndex);
(1)
RESULTOK: CRC Error bit is set. ERRORCODE_GENERIC: CRC Error bit is reset.
The ISO14443A_IsParityError function returns RESULTOK if the bit Parity Error of CR95HF control bytes is set. Otherwise, the ISO14443A_IsParityError function returns ERRORCODE_GENERIC. Ta ble 46 describes the ISO14443A_IsParityError function.
Table 46. ISO14443A_IsParityError function description
Prototype
Input parameter CR95HFControlByteIndex: Pointer on CR95HF control bytes (3 bytes)
Output parameter None
Return parameter
int8_t ISO14443A_IsParityError(uc8*CR95HFControlByte Index);
(1)
.
RESULTOK: Parity Error bit is set. ERRORCODE_GENERIC: Parity Error bit is reset.
.
1. Three control bytes are appended by CR95HF to contactless tag response. Refer to Table 12: CR95HF
success response value for ISO/IEC 14443-3 Type A.
34/68 Doc ID 022017 Rev 1
AN3955 ISO/IEC 14443-3 layers
The ISO14443A_Is14443_4Compatible function returns RESULTOK if the bit Contactless Tag is compliant with ISO/IEC 14443_4. Otherwise, the ISO14443A_Is14443_4Compatible function returns ERRORCODE_GENERIC. Ta bl e 4 7 describes the ISO14443A_Is14443_4Compatible function.
Table 47. ISO14443A_Is14443_4Compatible function description
Prototype
Input parameter SAKbyte: Contactless tag response to the Select command
Output parameter None
Return parameter
int8_t ISO14443A_Is14443_4Compatible(uc8 SAKbyte);
RESULTOK: The contactless tag is compatible with ISO/IEC 14443_4. ERRORCODE_GENERIC: The contactless tag is not compatible with the
ISO/IEC 14443_4.
The ISO14443A_IsUIDComplete function returns RESULTOK if the UID is complete. Otherwise, the ISO14443A_IsUIDComplete function returns ERRORCODE_GENERIC.
Ta bl e 4 8 describes the ISO14443A_IsUIDComplete function.
Table 48. ISO14443A_IsUIDComplete function description
Prototype
Input parameter SAKbyte: Contactless tag response to select command
Output parameter None
Return parameter
int8_t ISO14443A_IsUIDComplete(uc8 SAKbyte);
RESULTOK: UID is complete. The anti-collision loop is over. ERRORCODE_GENERIC: UID is not complete.
The ISO14443A_IsPresent function returns RESULTOK if a 14443 Type A contactless tag is present into RF field. Otherwise, the ISO14443A_IsPresent function returns ERRORCODE_GENERIC. Ta bl e 4 9 describes the ISO14443A_IsPresent function.
Table 49. ISO14443A_IsPresent function description
Prototype
Input parameter None
Output parameter None
Return parameter
int8_tISO14443A_IsPresent (void);
RESULTOK: An ISO/IEC 14443 Type A contactless tag is present. ERRORCODE_GENERIC: No ISO/IEC 14443 Type A contactless tag
available
Doc ID 022017 Rev 1 35/68
ISO/IEC 14443-3 layers AN3955
The ISO14443_IsCorrectBCC function returns RESULTOK if the XOR of Data is equal to BCC. Otherwise, the ISO14443_IsCorrectBCC function returns ERRORCODE_GENERIC.
Ta bl e 5 0 describes the ISO14443A_IsCorrectBCC function.
Table 50. ISO14443A_IsCorrectBCC function description
Prototype
Input parameter
Output parameter None
int8_t ISO14443A_IsCorrectBCC (uint8_t NbByte, uint8_t*Data, uint8_t BCC);
NbByte: Number of bytes of Data Data: Data to check (without BCC byte) BCC: BCC byte of contactless tag response
Return parameter
RESULTOK: BCC byte is equal to the XOR of Data. ERRORCODE_GENERIC: BCC byte is different to XOR of Data.

5.1.10 ISO/IEC 14443-3 Type A GET functions

The ISO14443A_GetSignificantBit function returns the number of significant bits of the first byte. This information is extracted from the control bytes of the CR95HF response.
Ta bl e 5 1 describes the ISO14443A_GetSignificantBit function.
Table 51. ISO14443A_GetSignificantBit function description
Prototype
Input parameter
Output parameter None
Return parameter Number of significant bit of the first byte
1. Three control bytes are appended by CR95HF to contactless tag response. Refer to Table 12: CR95HF
success response value for ISO/IEC 14443-3 Type A.
The ISO14443A_GetFirtsCollisionByte function returns the index of the first byte where the collision is detected. This information is extracted from the control bytes of CR95HF. Ta bl e 5 2 describes the ISO14443A_GetFirstCollisionByte function.
int8_t ISO14443A_GetSignificantBit (uc8*CR95HF ControlByteIndex);
CR95HFControlByteIndex: Pointer of the CR95HF control bytes (3
(1)
bytes)
.
Table 52. ISO14443A_GetFirstCollisionByte function description
Prototype
Input parameter
Output parameter None
Return parameter Index of the first byte where the collision is detected.
1. Three control bytes are appended by CR95HF to contactless tag response. Refer to Table 12: CR95HF
success response value for ISO/IEC 14443-3 Type A.
36/68 Doc ID 022017 Rev 1
int8_t ISO14443A_GetFirstCollisionByte (uc8*CR95HF ControlByteIndex);
CR95HFControlByteIndex: Pointer of the CR95HF control bytes (3
(1)
bytes)
.
AN3955 ISO/IEC 14443-3 layers
The ISO14443A_GetFirstCollisionBit function returns the index of the first bit where the collision is detected. This information is extracted from control byte of CR95HF. Tabl e 5 3 describes the ISO14443A_GetFirstCollisionBit function.
Table 53. ISO14443A_GetFirstCollisionBit function description
Prototype
int8_t ISO14443A_GetFirstCollisionBit (uc8*CR95HF ControlByteIndex);
Input parameter
Output parameter None
Return parameter Index of the first bit where the collision is detected.
1. Three control bytes are appended by CR95HF to contactless tag response. Refer to Table 12: CR95HF
success response value for ISO/IEC 14443-3 Type A.
CR95HFControlByteIndex: Pointer of the CR95HF control bytes (3
(1)
bytes)
.

5.1.11 ISO/IEC 14443-3 Type A Advanced functions

The ISO14443A_SelectSequence function runs a select sequence. For more information, refer to the ISO/IEC 14443-3 documentation. Tabl e 5 4 describes the ISO14443A_SelectSequence function.
Table 54. ISO14443A_SelectSequence function description
Prototype
Input parameter None
Output parameter
Return parameter
int8_t ISO14443A_SelectSequence(uint_t*SAKByte);
SAKByte: The last SAK byte received from a contactless tag during select sequence.
RESULTOK: Function is successful. The Select sequence is completed. ERRORCODE_GENERIC: Function failed. An error occured during a select
sequence.
For more information about the ISO14443A_SelectSequence function, refer to Ta bl e 3 2:
ISO/IEC 14443-3 Type A Advanced function description.
Doc ID 022017 Rev 1 37/68
ISO/IEC 14443-3 layers AN3955
MS19952V1
Start
END
Configures
CR95HF
emits REQA
Command
Emits Anticollision level1
command
Emits Select level 1
command
Emits Anticollision level 2
command
Emits Select level 2
command
Tag
response ?
No
Yes
Is UID
completed ?
Yes
No
Emits Anticollision level 3
command
Emits Select level 3
command
Is UID
completed ?
ISO14443A_ProtocolSelect
ISO14443A_REQA
ISO14443A_AntiCollisionLevel1
ISO14443A_SelectLevel1
ISO14443A_AntiCollisionLevel2
ISO14443A_SelectLevel2
ISO14443A_IsUIDComplete
ISO14443A_AntiCollisionLevel3
ISO14443A_SelectLevel3
ISO14443A_IsUIDComplete
Yes
No
The following flowchart illustrates the select sequence algorithm.
Figure 4. Select sequence algorithm flowchart
38/68 Doc ID 022017 Rev 1
AN3955 ISO/IEC 14443-3 layers
The ISO14443A_GetUIDsize function returns the UID size of a contactless tag. Tab l e 55 describes the ISO14443A_GetUIDsize function.
Table 55. ISO14443A_GetUIDsize function description
Prototype
Input parameter None Output parameter UIDsize: 2-bit value: 0 for single, 1 for double, 2 for triple and 3 for RFU.
Return parameter
int8_t ISO14443A_GetUIDsize(uint8_t*UIDsize);
RESULTOK: Function is successful. ERRORCODE_GENERIC: Function failed.
The ISO14443A_GetUID function returns the UID of a contactless tag. Ta bl e 5 6 describes the ISO14443A_GetUID function.
Table 56. ISO14443A_GetUID function description
Prototype
Input parameter None
Output parameter
int8_t ISO14443A_GetUID(uint8_t*SAKByte,uint8_t*Nb UIDByte, uint8_t*UIDout);
SAKByte: The last SAK byte received from a contactless tag during a
Select sequence.
NbUIDByte: Number of bytes of UID UIDout: The last SAK byte received from a contactless tag during a select
sequence.
Return parameter
RESULTOK: Function is successful. The select sequence is completed. ERRORCODE_GENERIC: Function failed. An error occured during the
select sequence. ISO14443A_ERRORCODE_BCC: A BCC byte is incorrect. The received
data from a contactless tag is corrupted.
Doc ID 022017 Rev 1 39/68
ISO/IEC 14443-3 layers AN3955

5.2 ISO/IEC 14443-3 Type B layer

The ISO/IEC 14443-3 Type B layer is composed of:
the lib_iso14443B.c source file
the lib_iso14443B.h include file

5.2.1 ISO/IEC 14443-3 Type B command format

The ISO/IEC 14443-3 Type B specification defines the following command frame:
SOF Data CRC EOF
with: SOF: Start of Frame Data: 1 byte or more CRC: 2 bytes EOF: End of Frame

5.2.2 EOF and SOF

The EOF and SOF are managed by CR95HF.

5.2.3 Data management

The command code and data must be managed by the user application.

5.2.4 ISO/IEC 14443-3 Type B CRC16 management

The ISO/IEC 14443-3 Type B specification defines a two-byte CRC. It is appended to RF commands to check the data transmission between CR95HF and a contactless tag.
The bit number 0 of a parameter byte of ProtocolSelect command controls the CRC. When this bit is set to 1, the CR95HF appends the CRC to all RF commands.
The ProtocolSelect command sets this bit, thus the CR95HF manages the CRC.

5.2.5 Functions of ISO/IEC 14443-3 Type B layer

Ta bl e 5 7 describes the function to configure the CR95HF to communicate with an ISO/IEC
14443 Type B contactless tag.
Table 57. ISO/IEC14443-3 Type B configuration function description
Function Description
ISO14443B_ProtocolSelect
Configures CR95HF to communicate with an ISO/IEC 14443 Type B contactless tag.
40/68 Doc ID 022017 Rev 1
AN3955 ISO/IEC 14443-3 layers
Ta bl e 5 8 describes the ISO14443B_SetParamByte function.
Table 58. ISO14443B_SetParamByte function description
ISO14443B_SetParamByte Returns the PARAM byte.
Ta bl e 5 9 lists the functions of this layer which emit an ISO/IEC 14443-3 Type B command.
Table 59. ISO/IEC 14443-3 Type B command functions description
ISO14443B_REQB Sends an REQB command to a contactless tag.
ISO14443B_WUPB Sends a WUPB command to a contactless tag.
ISO14443B_SlotMarker Sends a SlotMarker command to a contactless tag.
ISO14443B_Attrib Sends an Attrib command to a contactless tag.
ISO14443B_HLTB Sends an HLTB command to a contactless tag.
Ta bl e 6 0 lists the Split functions. A CR95HF response can include different information
fields extracted by the following functions.
Table 60. ISO/IEC 14443-3 Type B Split functions description
ISO14443B_SplitATQB Splits an ATQB contactless tag response.
ISO14443B_SplitApplicationDataField Splits an ApplicationData field.
ISO14443B_SplitProtocolInfoField Splits a ProtocolInfo field.
Ta bl e 6 1 lists the Is function. This function returns RESULTOK if the function is successful.
Otherwise, the Is function returns ERRORCODE_GENERIC.
Table 61. ISO/IEC 14443-3 Type B Is function description
ISO14443B_IsPresent Checks if a 14443-3 Type B tag is present in the RF field.
Doc ID 022017 Rev 1 41/68
ISO/IEC 14443-3 layers AN3955

5.2.6 CR95HF configuration function

The CR95HF configuration function sends a ProtocolSelect command to the CR95HF device to select the ISO/IEC 14443-3 Type B protocol. The transmission and reception data rates are integrated in the command. This command turns on the RF field.
Ta bl e 6 2 describes the ISO14443B_ProtocolSelect function.
Table 62. ISO14443B_ProtocolSelect function description
Prototype
int8_t ISO14443B_ProtocolSelect (uc8TxDataRate, uc8 RxDataRate, uint8_t*pResponse);
Input parameter
Output parameter pResponse: Pointer to the CR95HF response
Return parameter
TxDataRate: Transmission data rate (2 bits) RxDataRate: Reception data rate (2 bits)
RESULTOK: Function is successful.The ISO14443-4 Type B protocol is
selected.
ISO14443B_ERRORCODE_PARAMETER: One parameter is incorrect. CR95HF_ERROR_CODE: Function failed. The ISO 14443_4 Type B
protocol is not selected.
Note: The Bit 0 (Append CRC) is automatically set inside this function enabling the CR95HF to
manage the CRC of the RF command.
For more information, refer to Section 5.2.4: ISO/IEC 14443-3 Type B CRC16 management.

5.2.7 ISO/IEC 14443-3 Type B Set function

The ISO14443B_SetParamByte function returns PARAM byte, which is the result of the concatenation of the input parameters. A PARAM byte is an input parameter of REQB and WUPB commands.
Ta bl e 6 3 describes the ISO14443B_SetParamByte function.
Table 63. ISO14443B_SetParamByte function description
Prototype
int8_t ISO14443B_SetParamByte(uc8ExtendedBit, uc8 REQBWUPBbit, uc8NumberOfSlots);
ExtendedBit: Indicates the PCD capability to support an extended ATQB
Input parameter
Output parameter None Return parameter PARAM: PARAM byte
42/68 Doc ID 022017 Rev 1
response.
REQBWUPBbit: This bit defines either REQB (0) or WUPB (1). NumberOfSlots: Number of slots
AN3955 ISO/IEC 14443-3 layers

5.2.8 ISO/IEC 14443-3 Type B command function

These functions send an ISO/IEC 14443-3 Type B RF command to a contactless tag and check the CR95HF response.
The ISO14443B_REQB function sends an REQB command to a contactless tag. Ta bl e 6 4 describes the ISO14443B_REQB function if an REQB command is sent.
Table 64. ISO14443B_REQB function description
Prototype
Input parameter
Output parameter pResponse: Pointer to the CR95HF response
Return parameter
The ISO14443B_WUPB function sends a WUPB command to a contactless tag. Ta bl e 6 5 describes the ISO14443B_WUPB function if a WUPB command is sent.
int8_t ISO14443B_REQB(uc8 AFIin,uc8 Param, uint8_t *pResponse);
AFIin: An AFI byte (Application Family Identifier) represents the type of targeted application.
Param: PARAM byte
RESULTOK: Function is successful. The REQB command is successfully
transmitted to a contactless tag. CR95HF_ERROR_CODE: Function failed. The CR95HF returns an errror
code.
Table 65. ISO14443B_WUPB function description
Prototype
Input parameter
Output parameter pResponse: Pointer to the CR95HF response
Return parameter
int8_t ISO14443B_WUPB(uc8 AFIin,uc8 Param, uint8_t *pResponse);
AFIin: AFIbyte (Application Family identifier) represents the type of targeted application.
Param: PARAM byte
RESULTOK: Function is successful. The WUPB command is
successfully emitted to a contactless tag. CR95HF_ERROR_CODE: Function failed. The CR95HF returns an errror
code.
The ISO14443B_SlotMarker function sends a SlotMarker command to a contactless tag.
Ta bl e 6 6 describes the ISO14443B_SlotMarker function.
Table 66. ISO14443B_SlotMarker function description
Prototype
Input parameter SlotNumber: Slot number value (4 bits) between 1 and 15 Output parameter pResponse: Pointer to the CR95HF response
Return parameter
int8_t ISO14443B_SlotMarker(uc8 SlotNumber, uint8_t *pResponse);
RESULTOK: Function is successful. The command is successfully emitted to a contactless tag.
CR95HF_ERROR_CODE: Function failed. The CR95HF returns an errror code.
Doc ID 022017 Rev 1 43/68
ISO/IEC 14443-3 layers AN3955
The ISO14443B_Attrib function sends an Attrib command to a contactless tag. Tab l e 67 describes the ISO14443B_Attrib function.
Table 67. ISO14443B_Attrib function description
int8_t ISO14443B_Attrib(uc8 *Identifier, uc8
Prototype
*Parameters, uc8 NbByteHigherlayerData, uc8*HigherLayerData, uint8_t *pResponse);
Identifier: Pointer to the identifier parameter (4 bytes). It is the value of the PUPI sent by contactless tag in the ATQB.
Parameters input: Pointer on Parameters parameter (4 bytes)
Input parameter
Output parameter pResponse: Pointer to the CR95HF response
Return parameter
NbByteHigherlayerData: Number of bytes of HigherLayesDataparameter
HigherLayersData: Pointer on Parameters parameter (NBByteHigherlayerDatabytes (optional))
RESULTOK: Function is successful. The command is successfully emitted to contactless tag.
CR95HF_ERROR_CODE: Function failed. The CR95HF returns an errror code.
The ISO14443B_HLTB function sends an HLTB command to a contactless tag. Ta bl e 6 8 describes the ISO14443B_HLTB function.
Table 68. ISO14443B_HLTB function description
Prototype
Input parameter
Output parameter pResponse: Pointer to the CR95HF response
Return parameter
int8_t ISO14443B_HLTB(uc8 *Identifier, uc8 *Identifier, uint8_t *pResponse);
Identifier: Pointer on identifier parameter (4 bytes). It is the value of the
PUPI sent by a contactless tag in the ATQB contactless tag.
RESULTOK: Function is successful. The HLTB command was successfully transmitted to a contactless tag.
CR95HF_ERROR_CODE: Function failed. The CR95HF returns an errror code.
44/68 Doc ID 022017 Rev 1
AN3955 ISO/IEC 14443-3 layers

5.2.9 ISO/IEC 14443-3 Type B Split function

The ISO14443B_SplitATQB function splits the ATQB contactless tag response. Ta bl e 6 9 describes the ISO14443B_SplitATQB contactless response.
Table 69. ISO14443B_SplitATQB function description
int8_t ISO14443B_SplitATQB
Prototype
Input parameter ReaderResponse: Pointer on CR95HF response
Output parameter
Return parameter
(uint8_t*ReaderResponse, uint8_t*PUOIindex, uint8_t*ApplicationDataindex, uint8_t*ProtocolInfoindex);
PUPIindex: Index of PUPI field (4bytes) ApplicationDataindex: Index of ApplicatioData field (4bytes) ProtocolInfoindex: Index of Protocol field (3 or 4 bytes
depending on Extended ATQB supported bit.) Refer to Table 64:
ISO14443B_REQB function description.
RESULTOK: Function is successful. CR95HF_ERROR_CODE: Function failed. The CR95HF returns
an error code.
The ISO14443B_SplitApplicationDataField function splits the ApplicationData field. The application data field is a part of ATQB response. Ta bl e 7 0 describes the ISO14443B_SplitApplicationDataField function.
Table 70. ISO14443B_SplitApplicationDataField function description
int8_t ISO14443B_SplitApplicationDataField(
Prototype
uc8_t*ApplicationDataField, uint8_t*AFlout, uint8_t*CRC_BAIDoutIndex, uint8_t*ProtocolInfoindex);
Input parameter
Output parameter
Return parameter
ApplicationDataField: Application Data field (part of ATQB response, 4 bytes)
AFlout: AFI byte CRC_BAIDoutIndex: Index of CRC field (2 bytes) NumberOfApplication: Number of application byte
RESULTOK: Function is successful. CR95HF_ERROR_CODE: Function failed. The CR95HF returns
an error code.
Doc ID 022017 Rev 1 45/68
ISO/IEC 14443-3 layers AN3955
The ISO14443B_SplitProtocolInfoField function splits the ProtocolInfo field. The ProtocolInfo field is a part of ATQB response. Tabl e 7 1 describes the ISO14443B_SplitProtocolInfoField function.
Table 71. ISO14443B_SplitProtocolInfoField
function description
int8_t ISO14443B_SplitProtocolInfoField(uc8*Pr otocolInfoField,
Prototype
uint8_t*BitRateCapability,uint8_t*MaxFrameSize ,uint8*ProtocolType, uint8_t*FWIbits, uint8_t*ADCbits, uint8_t*FObits, uint8_t*SFGIbits, uint8_t*RFUbits);
Input parameter ProtocolInfoField: Protocol info field (part of ATQB response, 4bytes)
BitRateCapability: Bite rate supported by the contactless tag (8 bit) MaxFrameSize: Max frame size (4bit) ProtocolType: (4 bit) b1=1 compliant with 14443_4 b1=0 not
compliant with 14443_4. b2&b3 minimum TR2 coding b4: RFU
FWIbits: Frame waiting time integer (4 bit) ADCbits: Application data coding (2bit).
0b00: application is proprietary 0b01: application is coded (refer to ISO/IEC 14443-3, RFU
Output parameter
Return parameter
specification) FObits: Frame option (2bit) 0b1X: NAD suported x1b 0bX1: CID supported SFGIbits: SFGI bits (4 bit). Optional, depending on Extended ATQB
supported bit. Refer to Table 64: ISO14443B_REQB function
description.
RFUbits: RFU bits (4bit). Optional, depending on Extended ATQB supported bit. Refer to Table 64: ISO14443B_REQB function
description.
RESULTOK: Function is successful. CR95HF_ERROR_CODE: Function failed. The CR95HF returns an
error code.
46/68 Doc ID 022017 Rev 1
AN3955 ISO/IEC 14443-3 layers

5.2.10 ISO/IEC 14443-3 Type B Is function

The ISO14443B_IsPresent function returns RESULTOK if an ISO/IEC 14443-3 Type B is present into the RF field. Otherwise, it returns ERRORCODE_GENERIC. Tabl e 7 2 describes the ISO14443B_IsPresent function.
Table 72. ISO14443B_IsPresent function description
Prototype
Input parameter None
Output parameter None
Return parameter
For more information about Is function, refer to Table 61: ISO/IEC 14443-3 Type B Is
function description.
int8_t ISO14443B_IsPresent (void);
RESULTOK: A 14443-3 Type B contactless tag is present. ERRORCODE_GENERIC: No 14443-3 Type B contactless tag
available
Doc ID 022017 Rev 1 47/68
SRIX4K library AN3955

6 SRIX4K library

For a brief description of SRIX4K library, refer to Section 3.3: SRIX4K product overview. The SRIX4K library is composed of:
the lib_SRX4K.c source file
the lib_SRX4K.h include file
This library is valid for all SRIX series.

6.1 SRIX4K command format

The SRIX4K is compliant with the frame format specified in Section 5.2.1: ISO/IEC 14443-3
Type B command format.

6.1.1 SRIX4K CR16 management

The ISO/IEC 14443-3 Type B specification defines a two-byte CRC. It is appended to RF commands to check the data transmission between CR95HF and a contactless tag.
The CRC is managed by the first bit of parameter byte of ProtocolSelect (CR95HF layer) command. If it is set, the CR95HF appends the CRC to RF commands.
The SRIX4K_ProtocolSelect function sets this function, so the CR95HF manages the CRC.

6.1.2 Functions of SRIX4K layer

The SRIX4K_ProtocolSelect function permits to configure the CR95HF to communicate with an SRI contactless tag.
Ta bl e 7 3describes the SRIX4K_ProtocolSelect function.
Table 73. SRIX4K_ProtocolSelect function description
SRIX4K_ProtocolSelect
Ta bl e 7 4 lists the functions of this layer which emit a command described in SRIX4K
datasheet.
Table 74. Commands included in the lib_SRIX4k.c file
Function Description
SRIX4K_Initiate Sends an Initiate command to a contactless tag. SRIX4K_Pcall16 Sends an Pcall16 command to a contactless tag. SRIX4K_SlotMarker Sends a SlotMarker command to a contactless tag. SRIX4K_SelectChipID Sends a SelectChipID command to a contactless tag. SRIX4K_Completion Sends a Completion command to a contactless tag. SRIX4K_ResetToInventory Sends a ResetToInventory command to a contactless tag. SRIX4K_ReadSingleBlock Sends a ReadSingleBlock command to a contactless tag. SRIX4K_WriteSingleBlock Sends a WriteSingleBlock command to a contactless tag. SRIX4K_GetUID Sends a GetUID command to a contactless tag.
Configures CR95HF to communicate with an SRI contactless tag.
For more information, refer to the SRIX4K datasheet.
48/68 Doc ID 022017 Rev 1
AN3955 SRIX4K library
A CR95HF response can include different information fields extracted by the Split functions. Ta bl e 75 lists the Split functions.
Table 75. SRIX4K Split functions
Function Description
SRIX4K_SplitInitiateResponse Splits Initiate response of contactless tag.
SRIX4K_SplitPCall16Response Splits PCall16 response of contactless tag.
SRIX4K_SplitSlotMarkerResponse Splits SlotMarker response of contactless tag.
SRIX4K_SplitSelectChipIDResponse Splits SelectChipID response of contactless tag.
SRIX4K_SplitCompletionResponse Splits Completion response of contactless tag.
SRIX4K_SplitReadBlockResponse Splits ReadSingleBlock response of contactless tag.
SRIX4K_SplitWriteBlockResponse Splits WriteSingleBlock response of contactless tag.
SRIX4K_SplitGetUIDResponse Splits GetUID response of contactless tag.
The Is functions return RESULTOK if the function is successful, otherwise they return ERRORCODE_GENERIC. Ta bl e 7 6 lists the SRXI4K_Is functions.
Table 76. SRIX4K_Is functions
Function Description
SRIX4K_IsPresent Checks if an SR tag is in the RF field.
SRIX4K_IsSRIX4KPresent Checks if an SRIX4K contactless tag is in the RF field.
The Advanced functions use the previously function to manage a specific sequence.
Ta bl e 7 7 lists the SRIX4K_Advanced function.
Table 77. SRIX4K_Advanced functions
Function Description
SRIX4K_GetUIDadvanced Returns UID field of a contactless tag.
SRIX4K_GetChipIDAndSelectIt
SRIX4K_Anticollision
Returns a ChipID of a contactless tag and sends a SelectChipID command.
Runs an anti-collision sequence. For more information, refer to the SRIX4K datasheet.
Doc ID 022017 Rev 1 49/68
SRIX4K library AN3955

6.1.3 CR95HF configuration function

The SRIX4K_ProtocolSelect function sends a ProtocolSelect command to the CR95HF device to select the ISO/IEC 14443-3 Type B protocol. The transmission and reception data rates are integrated in the command. Tabl e 7 8 describes the SRIX4K_ProtocolSelect function.
Table 78. SRIX4K_ProtocolSelect function description
Prototype
int8_t SRIX4K_ProtocolSelect(uc8TxDataRate ,uint8_tRxDataRate,uint8_t*pResponse);
Input parameter
Output parameter pResponse: Pointer to the CR95HF response
Return parameter
TxDataRate: Transmission data rate (2bits) RxDataRate: Reception data rate (2bits)
RESULTOK: The ISO/IEC 14443_4 Type B protocol is selected. SRIX4K_ERRORCODE_PARAMETER: One parameter is
incorrect. CR95HF_ERROR_CODE: Function failed. The ISO/IEC
14443_4 Type B protocol is not selected.
Note: The Bit 0 (Append CRC) is automatically set inside this function enabling the CR95HF to
manage the CRC of the RF command.
For more information, refer to Section 5.2.4: ISO/IEC 14443-3 Type B CRC16 management.

6.1.4 SRIX4K command function

These functions send a RF command defined in SRIX4 datasheet to a contactless tag and check the CR95HF response.
The SRIX4K_Initiate function sends an Initiate command to a contactless tag. Tabl e 7 9 describes the SRIX4K_Initiate function.
Table 79. SRIX4K_Initiate function description
Prototype
int8_t SRIX4K_Initiate(uint8_t*pResponse);
Input parameter None Output parameter pResponse: Pointer to the CR95HF response
RESULTOK: Function is successful. The command is
Return parameter
50/68 Doc ID 022017 Rev 1
successfully emitted to a contactless tag. CR95HF_ERROR_CODE: Function failed. The CR95HF
returns an error code.
AN3955 SRIX4K library
The SRIX4K_Pcall16 function sends a Pcall16 command to a contactless tag. Ta bl e 8 0 describes the SRIX4K_Pcall16 function.
Table 80. SRIX4K_Pcall16 function description
Prototype
Input parameter None Output parameter pResponse: Pointer to the CR95HF response
Return parameter
int8_t SRIX4K_Pcall16(uint8_t*pResponse);
RESULTOK: Function is successful. The command is successfully emitted to a contactless tag.
CR95HF_ERROR_CODE: Function failed. The CR95HF returns an error code.
The SRIX4K_SlotMarker function sends a SlotMarker command to a contactless tag.
Ta bl e 8 1 describes the SRIX4K_SlotMarker function.
Table 81. SRIX4K_SlotMarker function description
Prototype
Input parameter SlotNumber: Slot number value (4bits) between 1 and 15 Output parameter pResponse: Pointer to the CR95HF response
Return parameter
int8_t SRIX4K_SlotMarker(uc8 SlotNumber, uint8_t*pResponse);
RESULTOK: Function is successful. The command is successfully emitted to contactless tag.
CR95HF_ERROR_CODE: Function failed. The CR95HF returns an error code.
The SRIX4K_SelectChipID function sends a SelectChipID command to a contactless tag. Ta ble 82 describes the SRIX4K_SelectChipID function.
Table 82. SRIX4K_SelectChipID command description
Prototype
Input parameter ChipID: Chip ID of a contactless tag Output parameter pResponse: Pointer to CR95HF response
Return parameter
int8_t SRIX4K_SelectChipID(uc8 ChipID, uint8_t*pResponse);
RESULTOK: Function is successful. The command is successfully emitted to a contactless tag.
CR95HF_ERROR_CODE: Function failed. The CR95HF returns an error code.
Doc ID 022017 Rev 1 51/68
SRIX4K library AN3955
The SRIX4K_Completion function sends a Completion command to a contactless tag.
Ta bl e 8 3 describes the SRIX4K_Completion function.
Table 83. SRIX4K_Completion function description
Prototype
Input parameter None Output parameter pResponse: Pointer to the CR95HF response
Return parameter
int8_t SRIX4K_Completion(uint8_t*pResponse);
RESULTOK: Function is successful. The command is successfully emitted to a contactless tag.
CR95HF_ERROR_CODE: Function failed. The CR95HF returns an error code.
The SRIX4K_ResetToInventory function sends a ResetToInventory command to a contactless tag. Ta b le 8 4 describes the SRIX4K_ResetToInventory function.
Table 84. SRIX4K_ResetToInventory command description
Prototype
Input parameter None Output parameter pResponse: Pointer to the CR95HF response
Return parameter
int8_t SRIX4K_ResetToInventory(uint8_t*pResponse);
RESULTOK: Function is successful. The command has been successfully emitted to contactless a tag.
CR95HF_ERROR_CODE: Function failed. The CR95HF returns an error code.
The SRIX4K_ReadSingleBlock function sends a ReadSingleBlock command to a contactless tag. Ta b le 8 5 describes the SRIX4K_ReadSingleBlock function.
Table 85. SRIX4K_ReadSingleBlock function description
Prototype
Input parameter BlockAddress: Block address to read into contactless tag memory. Output parameter pResponse: Pointer to CR95HF response
Return parameter
int8_t SRIX4K_ReadSingleBlock(uc8 BlockAddress, uint8_t*pResponse);
RESULTOK: Function is successful. The command is successfully emitted to a contactless tag.
CR95HF_ERROR_CODE: Function failed. The CR95HF returns an error code.
52/68 Doc ID 022017 Rev 1
AN3955 SRIX4K library
The SRIX4K_WriteSingleBlock function sends a WriteSingleBlock command to a contactless tag. Ta b le 8 6 describes the SRIX4K_WriteSingleBlock function.
Table 86. SRIX4K_WriteSingleBlock function description
int8_t SRIX4K_WriteSingleBlock(uc8
Prototype
BlockAddress,uc8*DataToWrite, uint8_t*pResponse);
BlockAddress (1 byte): Block address to read in contactless
Input parameter
Output parameter pResponse: Pointer to the CR95HF response
Return parameter
tag memory. DataToWrite (4 bytes): Pointer to Data to write in contactless
tag memory.
RESULTOK: Function is successful. The command is successfully emitted to a contactless tag.
CR95HF_ERROR_CODE: Function failed. The CR95HF returns an error code.
The SRIX4K_GetUID function sends a GetUID command to a contactless tag.
Ta bl e 8 7 describes the SRIX4K_GetUID function.
Table 87. SRIX4K_GetUID function description
Prototype
Input parameter None Output parameter pResponse: Pointer to the CR95HF response
Return parameter
int8_t SRIX4K_GetUID( uint8_t*pResponse);
RESULTOK: Function is successful.The command is successfully emitted to a contactless tag.
CR95HF_ERROR_CODE: Function failed. The CR95HF returns an error code.
Doc ID 022017 Rev 1 53/68
SRIX4K library AN3955

6.1.5 SRIX4K Split functions

The SRIX4K_SplitInitiateResponse function splits the Initiate contactless tag response. Ta bl e 8 8 describes the SRIX4K_SplitInitiateResponse function.
Table 88. SRIX4K_SplitInitiateResponse function description
int8_t SRIX4K_SplitInitiateResponse(uc8
Prototype
*ReaderResponse, uc8 Length, uint8_t*ChipID);
Input parameter
Output parameter ChipID: Chip ID of a contactless tag
Return parameter
ReaderResponse: Pointer on CR95HF response Length: Number of byte of Reader response
RESULTOK: Function is successful. CR95HF_ERROR_CODE: Function failed. The CR95HF
returns an error code. SRIX4K_ERRORCODE_CRCRESIDUE: CRC16 residue is
incorrect.
The SRIX4K_SplitPCall16Response function splits the PCall16 contactless tag response. Ta bl e 8 9 describes the SRIX4K_SplitPCall16Response function.
Table 89. SRIX4K_SplitPCall16Response function description
int8_t SRIX4K_SplitPCall16Response(uc8*
Prototype
ReaderResponse, uc8 Length, uint8_t*ChipID);
Input parameter
Output parameter ChipID: Chip ID of a contactless tag
Return parameter
ReaderResponse: Pointer to the CR95HF response Length: Number of byte of Reader response
RESULTOK: Function is successful. CR95HF_ERROR_CODE: Function failed.The CR95HF
returns an error code. SRIX4K_ERRORCODE_CRCRESIDUE: CRC16 residue is
incorrect.
54/68 Doc ID 022017 Rev 1
AN3955 SRIX4K library
The SRIX4K_SplitSlotMarkerResponse function splits the SlotMarker contactless tag response. Ta bl e 9 0 describes the SRIX4K_SplitSlotMarkerResponse function.
Table 90. SRIX4K_SplitSlotMarkerResponse function description
int8_t SRIX4K_SplitSlotMarkerResponse(u
Prototype
c8*ReaderResponse, uc8 Length, uint8_t*ChipID);
Input parameter
ReaderResponse: Pointer to the CR95HF response Length: Number of byte of Reader response
Output parameter ChipID: Chip ID of a contactless tag
RESULTOK: Function is successful. Contactless tag
response validated.
Return parameter
CR95HF_ERROR_CODE: Function failed. The CR95HF returns an error code.
SRIX4K_ERRORCODE_CRCRESIDUE: CRC16 residue is incorrect.
The SRIX4K_SplitSelectChipIDResponse function splits the SelectChipID contactless tag response.
Ta bl e 9 1 describes the SRIX4K_SplitSelectChipIDResponse function.
Table 91. SRIX4K_SplitSelectChipIDResponse function description
int8_t SRIX4K_SplitSelectChipIDResponse
Prototype
(uc8*ReaderResponse, uc8 Length, uint8_t*ChipID);
Input parameter
Output parameter ChipID: Chip ID of a contactless tag
Return parameter
ReaderResponse: Pointer to the CR95HF response Length: Number of byte of Reader response
RESULTOK: Function is successful. Contactless tag
response is validated. CR95HF_ERROR_CODE: Function failed. The CR95HF
returns an error code. SRIX4K_ERRORCODE_CRCRESIDUE: CRC16 residue is
incorrect.
Doc ID 022017 Rev 1 55/68
SRIX4K library AN3955
The SRIX4K_SplitCompletionResponse function splits the Completion contactless tag response. Ta bl e 9 2 describes the SRIX4K_SplitCompletionResponse function.
Table 92. SRIX4K_SplitCompletionResponse function description
int8_t SRIX4K_SplitCompletionResponse(u
Prototype
c8*ReaderResponse, uc8 Length, uint8_t*ChipID);
Input parameter
ReaderResponse: Pointer to the CR95HF response Length: Number of byte of Reader response
Output parameter ChipID: Chip ID of a contactless tag
RESULTOK: Function is successful. Contactless tag
response is validated.
Return parameter
CR95HF_ERROR_CODE: Function failed. The CR95HF returns an error code.
SRIX4K_ERRORCODE_CRCRESIDUE: CRC16 residue is incorrect.
The SRIX4K_SplitReadBockResponse function splits the ReadSingleBlock contactless tag response. Ta bl e 9 4 describes the SRIX4K_SplitReadBockResponse function.
Table 93. SRIX4K_SplitReadSingleBlockResponse function description
int8_t SRIX4K_SplitReadBlockResponse(uc
Prototype
8*ReaderResponse, uc8 Length, uint8_t*DataReadIndex);
Input parameter
Output parameter
Return parameter
ReaderResponse: Pointer on CR95HF response Length: Number of byte of Reader response
DataReadIndex: Index on ReaderResponse of data read
into a contactless tag. RESULTOK: Function is successful. Contactless tag
response is validated. CR95HF_ERROR_CODE: Function failed. The CR95HF
returns an error code. SRIX4K_ERRORCODE_CRCRESIDUE: CRC16 residue is
incorrect.
56/68 Doc ID 022017 Rev 1
AN3955 SRIX4K library
The SRIX4K_SplitWriteBlockResponse function splits the WriteSingleBlock contactless tag response. Ta b le 9 4 describes the SRIX4K_SplitWriteBlockResponse function.
Table 94. SRIX4K_SplitWritedBlockResponse function description
int8_t SRIX4K_SplitWriteBlockResponse(u
Prototype
c8*ReaderResponse, uc8 Length, uint8_t*ChipID);
Input parameter
ReaderResponse: Pointer to the CR95HF response Length: Number of byte of Reader response
Output parameter ChipID: Chip ID of a contactless tag
RESULTOK: Function is successful. Contactless tag
response validated.
Return parameter
CR95HF_ERROR_CODE: Function failed. The CR95HF returns an error code.
SRIX4K_ERRORCODE_CRCRESIDUE: CRC16 residue is incorrect.
The SRIX4K_SplitGetUIDResponse function splits the GetUID contactless tag response. Ta bl e 9 5 describes the SRIX4K_SplitGetUIDResponse function.
Table 95. SRIX4K_SplitGetUIDResponse function description
int8_t SRIX4K_SplitGetUIDResponse(uc8*R
Prototype
eaderResponse, uc8Length,uint8_t*UIDindex);
Input parameter
Output parameter ChipID: Chip ID of a contactless tag
Return parameter
ReaderResponse: Pointer to the CR95HF response Length: Number of byte of Reader response
RESULTOK: Function is successful. Contactless tag
response validated CR95HF_ERROR_CODE: Function failed. The CR95HF
returns an error code. SRIX4K_ERRORCODE_CRCRESIDUE: CRC16 residue is
incorrect.
Doc ID 022017 Rev 1 57/68
SRIX4K library AN3955

6.1.6 SRIX4K Is function

The SRIX4K_IsPresent function returns RESULTOK if an SRI contactless tag is present into the RF field. Otherwise, the SRIX4K_IsPresent function returns ERRORCODE_GENERIC. Ta bl e 9 6 describes the SRIX4K_IsPresent function.
Table 96. SRIX4K_IsPresent function description
Prototype
Input parameter None
Output parameter None
Return parameter
For more information about SRIX4K_Is function, refer to Table 76: SRIX4K_Is functions. The SRIX4K_IsSRIX4KPresent function returns RESULTOK if an SRIX4K contactless tag
is present into RF field. Otherwise, the SRIX4K_IsSRIX4KPresent function returns ERRORCODE_GENERIC. Ta bl e 9 7 describes the SRIX4K_IsSRIX4KPresent function.
Table 97. SRIX4K_IsSRIX4KPresent function description
Prototype
SRIX4K_IsPresent(void);
RESULTOK: Function is successful. An SRI contactless tag is present.
ERRORCODE_GENERIC: Function failed. No SRI contactless tag available.
int8_t SRIX4K_IsSRIX4KPresent(void);
Input parameter None
Output parameter None
RESULTOK: Function is successful. An SRIX4K contactless
Return parameter
tag is present. ERRORCODE_GENERIC: Function failed. No SRIX4K
contactless tag available.
58/68 Doc ID 022017 Rev 1
AN3955 SRIX4K library

6.1.7 SRIX4K Advanced function

The SRIX4K_GetUIDadvanced function returns UID field of a contactless tag. Tab l e 98 describes the SRIX4K_GetUIDadvanced function.
Table 98. SRIX4K_GetUIDadvanced function description
Prototype
Input parameter None Output parameter UIDfield: Pointer to the UID field of a contactless tag
Return parameter
The SRIX4k_GetChipIDAndSelectIt function returns a ChipId of a contactless tag and sends a SelectChipId command.
Ta bl e 9 9 describes the SRIX4k_GetChipIDAndSelectIt function.
Table 99. SRIX4K_GetChipIDAndSelectIt function description
Prototype
int8_t SRIX4K_GetUIDadvanced(uint8_t*UID field);
RESULTOK: Function is successful. Contactless tag response validated.
ERRORCODE_GENERIC: Function failed. CR95HF returns an error code.
int8_t SRIX4K_GetChipIDAndSelectIt(uint8 _t*ChipID);
Input parameter None Output parameter ChipID: Chip ID of a contactless tag
RESULTOK: Function is successful. Contactless tag
Return parameter
response validated. ERRORCODE_GENERIC: Function failed. CR95HF returns
an error code.
The SRIX4K_Anticollision function runs an anti-collision sequence. Ta b le 1 0 0 describes the SRIX4K_Anticollision function.
Table 100. SRIX4K_Anticollision function description
Prototype
Input parameter None
Output parameter
Return parameter
int8_t SRIX4K_Anticollision(uint8_t*NbT agInventoried, uint8_t*ChipIdArray);
NbTagInventoried: Number of tags inventoried in RF field *ChipIdArray: Pointer to the ChipId of the tag inventoried
(the length of a ChipId is one byte).
RESULTOK: Function is successful. ERRORCODE_GENERIC: Function failed. A parameter
value is incorrect or CR95HF returns an error code.
Doc ID 022017 Rev 1 59/68
Project example AN3955

7 Project example

This section provides an example of project. In this example, the application handles ISO/IEC 14443-3 Type A and Type B contactless tags. The results are displayed on the LCD screen.

7.1 Hardware

The project runs on an STM3210B-EVAL evaluation board.
7.2 Keil µvision
Keil µvision® is a full-featured development environment. It includes a C compiler for STM32 microcontroller family. Keil µvision http://www.keil.com.
An evaluation version is available free of charge for projects which do not exceed 32 Kbytes.
®
®
software is available from the internet Keil site at
60/68 Doc ID 022017 Rev 1
AN3955 Project example
7.3 Project structure on Keil µvision
Figure 5 shows an example of project.

Figure 5. Example of project

®
Doc ID 022017 Rev 1 61/68
Project example AN3955

7.3.1 Standard peripheral drivers

The Keil µvision® project was built from the MCD standard peripheral library (StdPeriph_Driver). It can be downloaded from the STMicroelectronics internet site at http://www.st.com.
It is used to drive all the peripherals used by your application.

7.3.2 Drivers

Some complementary drivers were developped for this application. They are grouped together in the User Drivers directory:
drv_UART: driver on UART serial interface for the communication to CR95HF. The
MCU can communicate with CR95HF using either UART or SPI serial interface.
drv_SPI: driver on SPI serial interface for the communication with CR95HF
drv_lcd: driver of LCD of STM3210B-EVAL board
drv_LED: driver of LED of STM3210B-EVAL board
drv_CR95HF: driver of CR95HF. This driver groups functions linked to MCU hardware.
(the function to configure the GPIO of the MCU).

7.3.3 Libraries

The libraries used in this project are:
CR95HF library
ISO/IEC 14443_A library
ISO/IEC 14443_B library
SRIX4K library
The libraries are independent of the hardware and can be reused on a different board. Furthermore, the lib-fonts.c library defines the test fonts for LCD drivers.

7.4 Application functions

The application is intended to handle three kinds of contactless tag:
ISO/IEC 14443-3 Type A contactless tag (function User_Get14443ATag())
ISO/IEC 14443-3 Type B contactless tag (function User_Get14443ATag())
SRIx contactless tag (function USer_Get14443SRTag())
The end of the infinite loop turns off the RF field (function CR95HF_FieldOff()).
62/68 Doc ID 022017 Rev 1
AN3955 Project example
MS19954V1
Start
Configure MCU
Catch a 14443-3
type A tag
Catch a 14443-3
type B tag
Catch a SRIX tag
Field Off
Wait 1s

7.4.1 Application example flowchart

Figure 6 shows a flowchart of an application example.
Figure 6. Flowchart of application example
Doc ID 022017 Rev 1 63/68
Project example AN3955
MS19955V1
Start
END
Select 14443-3 type A protocol
Send A REQA
command
Select a tag
Get UID
Tag
response ?
No
Yes
Tag selected ?
Yes
No

7.4.2 Detect an ISO/IEC 14443-3 Type A tag function

The ISO14443A_IsPresent function is used to detect an ISO/IEC 14443-3 Type A contactless tag.
The following table describes how the ISO14443A_IsPresent function detects an ISO/IEC 14443-3 Type A contactless tag.
Table 101. Detection of an ISO/IEC 14443-3 Type A contactless tag
Step Action
The ISO14443A_IsPresent function configures the CR95HF to communicate with
1
an ISO/IEC 14443-3 Type A contactless tag.
If a tag has been detected, it selects the tag by using the Advanced function
2
ISO14443A_SelectSequence.
3 It gets the UID. The user function is an Advanced function ISO14443A_GetUID.
Figure 7 described how to detect an ISO/IEC 14443-3 Type A tag.
The name of the used function is User_Get14443Atag (main.c).
Figure 7. Flowchart of User detects an ISO/IEC 14443-3 Type A tag
64/68 Doc ID 022017 Rev 1
AN3955 Project example
MS19956V1
Start
END
Select 14443-3 type B protocol
Send A REQB
command

7.4.3 Detect an ISO/IEC 14443-3 Type B tag function

The ISO14443B_IsPresent function is used in order to detect an ISO/IEC 14443-3 Type B contactless tag. This function configures CR95HF to communicate with an ISO/IEC 14443-3 Type B contactless tag and sends an REQB command.
If a tag response is detected, the ISO14443B_IsPresent function returns RESULTOK.
Figure 8 describes how to detect an ISO/IEC 14443-3 Type B tag.
Figure 8. Flowchart of User detects an ISO/IEC 14443-3 Type B tag

7.4.4 Detect an SRIX tag function

The SRIX4K_IsPresent function is used in order to detect an SRIX contactless tag. This function configures CR95HF in order to communicate with an ISO/IEC 14443-3 Type B contactless tag and sends an Initiate command.
The following table describes how the SRIX4K_IsPresent function detects an SRIX tag.
Table 102. Detection of an SRIX tag function
Step Action
The SRIX4K_IsPresent function
1
ISO/IEC 14443-3 Type B contactless tag and sends an Initiate command.
2 If a tag has been detected, it returns RESULTOK.
3 It gets the UID by using the Advanced function SRIX4K_GetUIDadvanced.
configures the CR95HF to communicate with an
Doc ID 022017 Rev 1 65/68
Project example AN3955
MS19957V1
Start
END
Select 14443-3 type B protocol
Send an Initiate
command
Get UID
Tag
response ?
No
Yes
Figure 9 describes how to detect an ISO/IEC 14443-3 Type B tag.
The name of the used function is User_Get14443SRTag (main.c).
Figure 9. SRIX tag detection flowchart
66/68 Doc ID 022017 Rev 1
AN3955 Revision history

8 Revision history

Table 103. Document revision history

Date Revision Changes
20-Sep-2011 1 Initial release.
Doc ID 022017 Rev 1 67/68
AN3955
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.
© 2011 STMicroelectronics - All rights reserved
STMicroelectronics group of companies
Australia - Belgium - Brazil - Canada - China - Czech Republic - Finland - France - Germany - Hong Kong - India - Israel - Italy - Japan -
Malaysia - Malta - Morocco - Philippines - Singapore - Spain - Sweden - Switzerland - United Kingdom - United States of America
www.st.com
68/68 Doc ID 022017 Rev 1
Loading...