April 2011 Doc ID 018637 Rev 1 1/73
AN3375
Application note
CR95HF library for ISO15693
and Dual Interface EEPROM products
Introduction
This document describes the CR95HF library which allows a microcontroller to drive the
CR95HF 13.56 MHz multiprotocol contactless transceiver using an SPI or UART interface in
order to perform ISO15693 wireless communications with Dual Interface EEPROM devices.
The library was developed to speed up the development of applications using the CR95HF
in conjunction with a contactless tag based on an M24LRXX dual interface EEPROM.
The CR95HF library is split into three layers:
■ Low level CR95HF layer
■ Standard ISO15693 protocol layer
■ Dual Interface EEPROM specific layer
The library code has been developed in ANSI C language, and validated on an STM32
microcontroller.
Reference documents
■ CR95HF datasheet
■ ISO/IEC FCD 15693-3
■ M24LRXX datasheets
Figure 1. Typical application block diagram
!)
)3/2&
)3/2&
-#5
#2(&
#ONTACTLESSTAG
#2(&
LIBRARY
$UAL)#
-,2882
PRODUCTS
)3/2&
-EMORY
PRODUCTS
www.st.com
Contents AN3375
2/73 Doc ID 018637 Rev 1
Contents
1 CR95HF description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
1.1 CR95HF overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
1.2 Library overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
2 CR95HF low level layer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
2.1 Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
2.2 Low layer overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
2.3 CR95HF layer functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
2.3.1 IDN function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
2.3.2 Echo function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
2.3.3 ProtocolSelect function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
2.3.4 SendRecv function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
2.3.5 Idle function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
2.3.6 RdReg function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
2.3.7 BaudRate function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
2.3.8 SendEOF function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
2.3.9 FieldOff function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
2.3.10 HexCommandToStringCommand function . . . . . . . . . . . . . . . . . . . . . . . 17
2.3.11 IsReaderResultCodeOk function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
2.3.12 IsReaderErrorCode function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
2.3.13 IsCommandExists function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
2.3.14 GetReaderErrorCode function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
2.3.15 Application example: protocol selection and communication . . . . . . . . . 20
3 ISO15693 library (intermediate layer) . . . . . . . . . . . . . . . . . . . . . . . . . . 21
3.1 ISO15693 command format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
3.1.1 EOF and SOF . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
3.1.2 CRC management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
3.1.3 Request flag management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
3.1.4 Command code and data management . . . . . . . . . . . . . . . . . . . . . . . . 22
3.2 ISO15693 functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
3.3 CRC management functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
3.3.1 ISO15693_CRC16 function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
3.3.2 ISO15693_IsCorrectCRC16Residue function . . . . . . . . . . . . . . . . . . . . 25
AN3375 Contents
Doc ID 018637 Rev 1 3/73
3.4 ISO15693 command functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
3.4.1 ISO15693_CreateRequestFlag function . . . . . . . . . . . . . . . . . . . . . . . . 26
3.4.2 ISO15693_Inventory function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
3.4.3 ISO15693_InventoryOneSlot function . . . . . . . . . . . . . . . . . . . . . . . . . . 27
3.4.4 ISO15693_Inventory16Slots function . . . . . . . . . . . . . . . . . . . . . . . . . . 28
3.4.5 ISO15693_ReadSingleBlock function . . . . . . . . . . . . . . . . . . . . . . . . . . 28
3.4.6 ISO15693_WriteSingleBlock function . . . . . . . . . . . . . . . . . . . . . . . . . . 29
3.4.7 ISO15693_LockSingleBlock function . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
3.4.8 ISO15693_ReadMultipleBlocks function . . . . . . . . . . . . . . . . . . . . . . . . 30
3.4.9 ISO15693_Select function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
3.4.10 ISO15693_ResetToReady function . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
3.4.11 ISO15693_WriteAFI function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
3.4.12 ISO15693_LockAFI function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
3.4.13 ISO15693_WriteDSFID function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
3.4.14 ISO15693_LockDSFID function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
3.4.15 ISO15693_GetMultipleBlockSecutityStatus function . . . . . . . . . . . . . . . 33
3.4.16 ISO15693_StayQuiet function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
3.4.17 ISO15693_GetSystemInfo function . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
3.4.18 ISO15693_SendEOF function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
3.5 Advanced functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
3.5.1 ISO15693_SelectProtocol function . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
3.5.2 ISO15693_GetUID function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
3.5.3 ISO15693_GetDSFID function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
3.5.4 ISO15693_GetAFI function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
3.5.5 ISO15693_GetMemSizeInfo function . . . . . . . . . . . . . . . . . . . . . . . . . . 37
3.5.6 ISO15693_GetIcRef function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
3.5.7 ISO15693_IsPresent function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
3.5.8 ISO15693_IsCollisionDetected function . . . . . . . . . . . . . . . . . . . . . . . . 38
3.5.9 ISO15693_IsATagInTheField function . . . . . . . . . . . . . . . . . . . . . . . . . . 39
3.5.10 ISO15693_IsTagErrorCode function . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
3.6 Extract flag from request flags functions . . . . . . . . . . . . . . . . . . . . . . . . . 39
3.6.1 ISO15693_GetSubCarrierFlag function . . . . . . . . . . . . . . . . . . . . . . . . . 40
3.6.2 ISO15693_GetDataRateFlag function . . . . . . . . . . . . . . . . . . . . . . . . . . 40
3.6.3 ISO15693_GetInventoryFlag function . . . . . . . . . . . . . . . . . . . . . . . . . . 41
3.6.4 ISO15693_IsInventoryFlag function . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
3.6.5 ISO15693_GetProtocolExtensionFlag function . . . . . . . . . . . . . . . . . . . 41
3.6.6 ISO15693_GetSelectOrAFIFlag function . . . . . . . . . . . . . . . . . . . . . . . . 42
Contents AN3375
4/73 Doc ID 018637 Rev 1
3.6.7 ISO15693_GetAddressOrNbSlotsFlag function . . . . . . . . . . . . . . . . . . 42
3.6.8 ISO15693_IsAddressOrNbSlotsFlag function . . . . . . . . . . . . . . . . . . . . 42
3.6.9 ISO15693_GetOptionFlag function . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
3.6.10 ISO15693_GetRFUFlag function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
3.7 Get flag from response flag byte function . . . . . . . . . . . . . . . . . . . . . . . . . 43
3.7.1 ISO15693_GetErrorFlag function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
3.8 Get flag from information flag byte functions . . . . . . . . . . . . . . . . . . . . . . 44
3.8.1 ISO15693_GetDSFIDFlag function . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
3.8.2 ISO15693_GetAFIFlag function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
3.8.3 ISO15693_GetMemorySizeFlag function . . . . . . . . . . . . . . . . . . . . . . . 45
3.8.4 ISO15693_GetICReferenceFlag function . . . . . . . . . . . . . . . . . . . . . . . 45
3.9 Split contactless tag response functions . . . . . . . . . . . . . . . . . . . . . . . . . 46
3.9.1 ISO15693_SplitInventoryResponse function . . . . . . . . . . . . . . . . . . . . . 46
3.9.2 ISO15693_SplitGetSystemInfoResponse function . . . . . . . . . . . . . . . . 47
3.9.3 ISO15693_SplitMemorySizeInfo function . . . . . . . . . . . . . . . . . . . . . . . 47
3.9.4 ISO15693_SplitReadSingleBlockResponse function . . . . . . . . . . . . . . . 48
3.9.5 ISO15693_SplitReadMultipleBlockResponse function . . . . . . . . . . . . . 49
3.9.6 ISO15693_SplitWriteSingleBlockResponse function . . . . . . . . . . . . . . . 50
3.9.7 ISO15693_SplitWriteMultipleBlockResponse function . . . . . . . . . . . . . 50
3.9.8 ISO15693_SplitWriteAFIResponse function . . . . . . . . . . . . . . . . . . . . . 51
3.9.9 ISO15693_SplitWriteDSFIDResponse function . . . . . . . . . . . . . . . . . . . 51
3.9.10 ISO15693_SplitLockBlockResponse function . . . . . . . . . . . . . . . . . . . . 52
3.9.11 ISO15693_SplitLockAFIResponse function . . . . . . . . . . . . . . . . . . . . . . 52
3.9.12 ISO15693_SplitLockDSFIDResponse function . . . . . . . . . . . . . . . . . . . 53
3.9.13 ISO15693_SplitSelectResponse function . . . . . . . . . . . . . . . . . . . . . . . 53
3.9.14 ISO15693_SplitResetToReadyResponse function . . . . . . . . . . . . . . . . 54
3.9.15 ISO15693_SplitGetMultipleBlockSecutityResponse function . . . . . . . . 54
4 M24LRXX-R Layer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
4.1 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
4.1.1 CRC management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
4.1.2 Request flag management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
4.1.3 Request flags and CR95HF_ProtocolSelect functions . . . . . . . . . . . . . 55
4.1.4 Extension flag . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
4.2 M24LRXX-R layer commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
4.3 M24LRXX-R global functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
AN3375 Contents
Doc ID 018637 Rev 1 5/73
4.3.1 M24LRXX_ReadSingleBlock function . . . . . . . . . . . . . . . . . . . . . . . . . . 59
4.3.2 M24LRXX_WriteSingleBlock function . . . . . . . . . . . . . . . . . . . . . . . . . . 59
4.3.3 M24LRXX_ReadMultipleBlocks function . . . . . . . . . . . . . . . . . . . . . . . . 60
4.3.4 M24LRXX_GetMultipleBlockSecutityStatus function . . . . . . . . . . . . . . . 60
4.4 M24LRXX-R specific functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61
4.4.1 M24LRXX_WriteSectorPassword function . . . . . . . . . . . . . . . . . . . . . . 61
4.4.2 M24LRXX_LockSectorPassword function . . . . . . . . . . . . . . . . . . . . . . . 61
4.4.3 M24LRXX_PresentSectorPassword function . . . . . . . . . . . . . . . . . . . . . 62
4.4.4 M24LRXX_FastReadSingleBlock function . . . . . . . . . . . . . . . . . . . . . . . 62
4.4.5 M24LRXX_FastReadMultipleBlock function . . . . . . . . . . . . . . . . . . . . . 63
4.4.6 M24LRXX_FastInventoryInitiated function . . . . . . . . . . . . . . . . . . . . . . . 63
4.4.7 M24LRXX_FastInitiate function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64
4.4.8 M24LRXX_InventoryInitiated function . . . . . . . . . . . . . . . . . . . . . . . . . . 64
4.4.9 M24LRXX_Initiate function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
4.4.10 M24LRXX_GetMemSizeInfo function . . . . . . . . . . . . . . . . . . . . . . . . . . 65
4.4.11 M24LRXX_GetIcRef function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66
4.4.12 M24LRXX_IsAM24LR64 function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66
4.5 M24LRXX-R flags functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
4.5.1 M24LRXX_SplitGetSystemInfoResponse function . . . . . . . . . . . . . . . . 67
5 Project example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68
5.1 Project description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68
5.1.1 Hardware . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68
5.1.2 Keil µvision . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68
5.1.3 Project structure on Keil µvision . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68
5.2 Application functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70
5.3 Typical inventory flowchart . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71
5.4 Revision history . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72