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.1Reference 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® . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . 60

 

7.3

Project structure on Keil µvision® . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . 61

7.3.1 Standard peripheral drivers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62 7.3.2 Drivers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62 7.3.3 Libraries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62

 

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.1List 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

 

Answer 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.2Notational conventions

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

2.2.1Binary 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.2Hexadecimal 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.3Decimal number representation

Decimal numbers are represented as is, without any trailing character.

For example: 245

10/68

Doc ID 022017 Rev 1

AN3955

Overview

 

 

3 Overview

3.1CR95HF 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

 

 

 

 

 

 

 

Contactless tag

 

 

 

CR95HF

 

 

14443 type A

library

 

 

 

 

 

 

 

 

 

 

CR95HF

13,56 MHz RF commands

Or

MCU

 

 

 

 

 

14443 type B

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

AI18873a

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

3.2ISO/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

ST AN3955 APPLICATION NOTE

Overview

AN3955

 

 

3.3SRIX4K 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.4Library 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

User functions (user application specific)

Product layer (embeds commands defined in the product datasheet)

SRiX4K layer

Protocol layer (embeds commands defined in the ISO/IEC 14443-3 specification)

ISO14443_3 type A library layer

 

ISO14443_3 type B library layer

 

 

 

CR95HF library layer

(integrates the commands defined in CR95HF datasheet)

CR95HF library

Standard peripheral driver (MCU specific layer)

MS19951V1

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.1Types

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.2Definition

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.3CR95HF layer functions

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

.

CR95HF layer functions based on CR95HF commands

Table 2.

Function name

Brief description

 

 

 

 

 

Sends an IDN command to CR95HF device. It returns its version

CR95HF_IDN

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

CR95HF_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

CR95HF_ProtocolSelect

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

CR95HF_SendRecv

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

CR95HF_Idle

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_RdReg

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_BaudRate

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

 

 

 

 

.

CR95HF layer additional functions

 

Table 3.

 

 

Function name

Brief description

 

 

 

 

 

 

 

Sends an RF pulse (EOF). For more details about

 

CR95HF_SendEOF

CR95HF_SendEOF function, refer to Section 4.11:

 

 

 

SendEOF function.

 

 

 

 

 

 

 

Switches off the RF field. For more details about

 

CR95HF_FieldOff

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

 

CR95HF_HexCommandToStringCommand

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

 

CR95HF_GetReaderErrorCode

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

 

CR95HF_IsReaderResultCodeOk

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

 

CR95HF_IsReaderErrorCode

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

 

CR95HF_IsCommandExists

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.4IDN function

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

Table 4.

CR95HF_IDN function description

Prototype

 

result = int8_t CR95HF_IDN (uint8_t *pResponse)

 

 

Input parameter

None

 

 

Output parameter

pResponse: Pointer to CR95HF response

 

 

Return parameter

CR95HF_SUCCESS_CODE: Function is successful.

 

 

 

4.5ECHO function

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

Table 5.

CR95HF_Echo function description

Prototype

 

result = int8_t CR95HF_Echo (uint8_t *pResponse)

 

 

Input parameter

None

 

 

Output parameter

pResponse: Pointer to CR95HF response

 

 

Return parameter

CR95HF_SUCCESS_CODE: Function is successful.

 

 

 

4.6ProtocolSelect 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

 

result = int8_t CR95HF_ProtocolSelect(uc8

 

Length,uc8 Protocol,uc8 *Data,uint8_t *pResponse)

 

 

 

 

 

 

 

Length: Number of data bytes

Input parameter

Protocol: Type of protocol(1)

 

 

Data input: Pointer to data

 

 

Output parameter

pResponse: Pointer to CR95HF response

 

 

 

 

 

CR95HF_ERRORCODE_PARAMETER: Function failed

Return parameter

CR95HF_SUCCESS_CODE: Function is successful.

CR95HF_ERRORCODE_PARAMETERLENGTH: Parameter length is

 

 

 

 

incorrect.

 

 

 

1. ISO/IEC 15693, ISO/IEC 18092, ISO/IEC 14443-3 Type A or Type B RF protocols.

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

 

 

Table 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

0

7:0

0x02

0x02020200

 

 

 

 

 

ISO/IEC 14443-3 Type

Length

 

1

7:0

0x02

 

A with reception and

 

 

 

 

 

Protocol

 

2

7:0

0x02: ISO/IEC 14443-3 Type A

transmission data

 

 

 

protocol

rates at 106 kbps

 

 

 

 

 

 

 

 

 

 

 

 

3

7:6

Transmission data rate

 

 

 

 

 

 

 

 

 

 

5:4

Reception data rate

 

 

 

 

 

 

 

Parameter

 

 

3:0

RFU

 

 

 

 

 

 

 

 

5:4

7:0

FWT= (256*16/fc)*(2*PP)*(MM+1)(1) (2)

 

 

 

 

 

where “PP” represents byte 4 and “MM”

 

 

 

 

 

byte 5.

 

 

 

 

 

 

 

1.Optional. If not specify default FWT~86 µs

2.PP <= 0x0E and 0x01 <= MM <= 0xFE

Table 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

0

7:0

0x02

0x02020301

 

 

 

 

 

ISO/IEC 14443-3 Type

Length

 

1

7:0

0x02

 

B with reception and

 

 

 

 

 

Protocol

 

2

7:0

0x03: ISO/IEC 14443-3 Type B protocol

transmission data

 

 

 

 

 

rates at 106 kbps

 

 

3

7:6

Transmission data rate

 

 

 

 

 

 

 

 

 

 

 

 

5:4

Reception data rate

 

 

 

 

 

 

 

 

 

 

3:0

RFU

The CR95HF

 

 

 

 

 

 

 

 

 

Append CRC

Parameter

 

 

0

manages the CRC.

 

 

 

1: CR95HF appends CRC

 

 

 

 

 

 

 

 

 

 

0: CR95HF does not append CRC

 

 

 

 

 

 

 

 

 

5:4

7:0

FWT= (256*16/fc)*(2*PP)*(MM+1)(1) (2)

 

 

 

 

 

where “PP” represents byte 4 and “MM”

 

 

 

 

 

byte 5.

 

 

 

 

 

 

 

1.Optional. If not specify default FWT~300µs.

2.PP <= 0x0E and 0x01 <= MM <= 0xFE

Doc ID 022017 Rev 1

17/68

CR95HF low level layer

AN3955

 

 

4.7SendRecv 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

Length: Number of bytes in Parameters input

Parameters input: Pointer to data

 

 

 

 

Output parameter

pResponse : Pointer to CR95HF response

 

 

 

 

 

CR95HF_ERRORCODE_PARAMETER: Function failed

Return parameter

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.

Table 10 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

0

7:0

0x04

-

REQA command:

 

 

 

 

 

0x04022607 with

 

1

7:0

0xXX

Number of Data

Length

 

 

 

bytes and

26: Data (REQA

 

 

 

command code)

 

 

 

 

transmission flag

 

 

 

 

 

07: number

Data

2:X

7:0

0xXX

Data

of significant bits

 

 

 

 

 

 

 

 

 

 

(REQA is coded on 7

 

X+1

7

-

RFU

 

bits)

 

 

 

 

 

 

 

6

0b0

Split frame

 

 

 

 

 

 

 

 

 

 

 

5

1: CR95HF

 

 

 

 

 

appends CRC

 

 

Transmission flag

 

 

0: CR95HF

Append CRC

 

 

 

does not

 

 

 

 

 

 

 

 

 

 

append CRC

 

 

 

 

 

 

 

 

 

 

4

0b0

RFU

 

 

 

 

 

 

 

 

 

3:0

0xX

Number of

 

 

 

 

significant bits

 

 

 

 

 

 

 

 

 

 

 

 

18/68

Doc ID 022017 Rev 1

AN3955

CR95HF low level layer

 

 

Table 11 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

0

7:0

0x04

-

REQB command:

 

 

 

 

 

0x040305000

Length

1

7:0

0xXX

Length of entire

 

 

 

 

data

 

 

 

 

 

 

 

 

 

 

 

 

Data

2:X

7:0

0xXX

Data

 

 

 

 

 

 

 

For more information, refer to CR95HF datasheet.Table 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

Byte Bit

Value

Comments

Example

name

 

 

 

 

Result

0

7:0

0x04

Success code

0X80054400280000

Code

 

 

 

where:

 

 

 

 

 

 

 

 

 

80: success

Length

1

7:0

0xXX

Number of bytes of Data

 

 

 

+ control bytes

05: Number of bytes

 

 

 

 

 

 

 

 

 

4400: ATQA

Data

2:X

7:0

0xXX

Contactless tag response

 

 

 

 

 

28: CRC error(1) &

 

 

 

1: CR95HF has

 

 

X+1

7

Collision between two

Number of significant

 

 

 

detected a collision

contactless tag

bits: 8

 

 

 

0: No collision detected

responses

00 00: No collision

 

 

 

 

 

detected

 

 

6

0

RFU

 

 

 

 

 

 

 

 

 

 

 

5

1: CRC error

CRC error on contactless

 

 

 

 

0: No CRC error

response

 

 

 

 

 

 

 

 

 

4

1: Parity error

Parity error on

 

Control

 

 

0: No Parity error

contactless response

 

bytes

 

 

 

 

 

 

3:0

 

Number of significant bits

 

 

 

 

 

 

 

 

 

in the first byte(2)

 

 

X+2

7:0

0xXX

Index of the first byte

 

 

 

 

 

where the collision is

 

 

 

 

 

detected(3)

 

 

X+3

7:4

0b000

RFU

 

 

 

 

 

 

 

 

 

3:0

0bXXXX

Index of the first bit where

 

 

 

 

 

the collision is detected

 

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.

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 Table 13.

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

Parameter name

Byte

Bit

Value

Comments

 

 

 

 

 

Result Code

0

7:0

0x90

Success code

 

 

 

 

 

Length

1

7:0

0x04

Number of valid bits: 4

 

 

 

 

 

 

2:X

7:0

0x01: NAK

 

Data

 

 

0x05: NAK

Contactless tag response

 

 

 

0x0A: ACK

 

 

 

 

 

 

Table 14 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

Byte Bit

Value

Comments

Example

name

 

 

 

 

Result Code 0

7:0

0x80

Success code

0x800F50AA0B000500

 

 

 

 

 

000000B371716A2100

Length

1

7:0

0xXX

Number of bytes of

where:

 

 

 

Data + control bytes

 

 

 

 

 

80: Success

 

2:X

7:0

0xXX

Contactless tag

Data

0F: Number of byte

 

 

 

response

50AA0B000500000000

 

 

 

 

 

 

 

 

 

 

X+1

7:2

0b0000

RFU

B371716A21: ATQB

 

00: CRC Ok

 

 

 

 

 

Control

 

1

1: CRC error

CRC error or

 

 

 

 

0: no CRC error

contactless

 

bytes

 

 

 

 

 

 

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 Table 15). 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

0

7:0

0x08

0x8700: no contactless

 

 

 

 

Length

1

7:0

0x00

tag in the field

 

 

 

 

 

 

For more information about CR95HF error code, refer to CR95HF datasheet.

20/68

Doc ID 022017 Rev 1

AN3955

CR95HF low level layer

 

 

4.8Idle function

This function sends an Idle command to the CR95HF to switch the CR95HF device into low consumption mode. Table 16 describes the CR95HF_Idle function.

Table 16. CR95HF_Idle function description

Prototype

result = int8_t CR95HF_Idle(uc8

Length,uc8 *Data,uint8_t *pResponse);

 

 

 

Input parameter

Length: Number of data bytes

Data: Pointer to data

 

 

 

Output parameter

pResponse : Pointer to the CR95HF response

 

 

 

CR95HF_ERRORCODE_PARAMETER: Function failed

Return parameter

CR95HF_SUCCESS_CODE: Function is successful.

CR95HF_ERRORCODE_PARAMETERLENGTH:

 

 

Parameter length is incorrect.

 

 

4.9RdReg function

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

Table 17. CR95HF_RdReg function description

 

result = int8_t CR95HF_RdReg(uc8

Prototype

Length,uc8 Address,uc8 RegCount,uc8

 

Flags,uint8_t *pResponse);

 

 

 

Length : Number of bytes (Address+RegCount+Flags)

Input parameter

Address: Register address

RegCount: Number of bytes to read

 

 

Flags: ST reserved (must be 0x00)

 

 

Output parameter

pResponse : Pointer to CR95HF response

 

 

Return parameter

CR95HF_SUCCESS_CODE: Function is successful.

 

 

4.10BaudRate function

This function sends a BaudRate command to the CR95HF. It allows configuring the UART baudrate. Table 18 describes the CR95HF_BaudRate function.

Table 18. CR95HF_BaudRate function description

Prototype

result = int8_t CR95HF_BaudRate (uc8

BaudRate,uint8_t *pResponse);

 

 

 

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.

Doc ID 022017 Rev 1

21/68

Loading...
+ 47 hidden pages