STM8L libraries for CR95HF 1.0
Defines | Functions
ISO15693/inc/iso15693_command.h File Reference

Header for the iso15693_command.c file. More...

#include "iso15693_structure.h"
#include "cr95hf_command.h"

Go to the source code of this file.

Defines

#define ISO15693_CMD_INVENTORY   0x01
#define ISO15693_CMD_STAY_QUIET   0x02
#define ISO15693_CMD_READ_SINGLE_BLOCK   0x20
#define ISO15693_CMD_WRITE_SINGLE_BLOCK   0x21
#define ISO15693_CMD_LOCK_BLOCK   0x22
#define ISO15693_CMD_READ_MULTIPLE_BLOCKS   0x23
#define ISO15693_CMD_WRITE_MULTIPLE_BLOCKS   0x24
#define ISO15693_CMD_SELECT   0x25
#define ISO15693_CMD_RESET_TO_READY   0x26
#define ISO15693_CMD_WRITE_AFI   0x27
#define ISO15693_CMD_LOCK_AFI   0x28
#define ISO15693_CMD_WRITE_DSFID   0x29
#define ISO15693_CMD_LOCK_DSFID   0x2A
#define ISO15693_CMD_GET_SYSTEM_INFO   0x2B
#define ISO15693_CMD_GET_MULTIPLE_BLOCKS_STATUS   0x2C
#define ISO15693_ICREF_SHIFT   0x02
#define ISO15693_ICREF_CURSOR_IN_UID   0x05
#define ISO15693_UID_CURSOR_CR95HF_RESPONSE_DATA   0x02
#define ISO15693_INVENTORY_16_SLOTS_COUNTER   0x0F
#define ISO15693_DEFAULT_BLOCK_SIZE   0x04
#define ISO15693_DEFAULT_BLOCK_PLUS_STATUS_SIZE   0x05
#define ISO15693_MAX_SIZE_BLOCK_WRITE_CMD   0x1F
#define ISO15693_MAX_SIZE_BLOCK_READ_CMD   0x1F
#define ISO15693_UID_SIZE_BITS   0x40
#define ISO15693_MANUFACTURER_CURSOR   0x06
#define ISO15693_ERROR_CODE_CURSOR   0x01
#define ISO15693_INFORMATION_FLAG_CURSOR   0x01
#define ISO15693_MEMSIZE_3BYTES_BLOCK_SIZE_CURSOR   0x02
#define ISO15693_MEMSIZE_2BYTES_BLOCK_SIZE_CURSOR   0x01
#define ISO15693_LENGTH_PARAMETERS_READ_RESPONSE   0x04
#define ISO15693_LENGTH_FIX_PARAMETERS_GET_SYS_INFO_RESPONSE   0x0D
#define ISO15693_READ_MULITPLE_BLOCK_SIZE_ISO15693_MAX_SIZE_BLOCK_READ_CMD   (SIZE_1KBITS_BYTES+ISO15693_LENGTH_PARAMETERS_READ_RESPONSE+ISO15693_MAX_SIZE_BLOCK_READ_CMD+1)
#define ISO15693_ERROR_FRAME_SIZE   0x05
#define ISO15693_STMICROELECTRONICS_MANUFACTURER_CODE   0x02
#define ISO15693_CRC_MASK   0x02
#define ISO15693_COLLISION_DETECTION_MASK   0x01
#define ISO15693_REQUEST_FLAGS_BITS_SELECT_ADDRESS_MASK   0x30
#define ISO15693_SUCCESS_CODE   0x00
#define ISO15693_ERROR_PARAMETERS_REQUEST_FLAGS   0x02
#define ISO15693_ERROR_CODE   0x01
#define ISO15693_BLOCK_SIZE_ERROR   0x00
#define ISO15693_ERROR_CRC   0xCC
#define ISO15693_ERROR_COLLISION_DETECTED   0xCD
#define ISO15693_ERROR_COLLISION_CRC   0xCF
#define ISO15693_PRELOADCRC16   0xFFFF
#define ISO15693_POLYCRC16   0x8408
#define ISO15693_MASKCRC16   0x0001
#define ISO15693_RESIDUECRC16   0xF0B8
#define ISO15693_RESULTOKCRC16   0x00
#define ISO15693_ERRORCODE_GENERICCRC16   0x01
#define ISO15693_FLAG_TEST_BIT3   0x04
#define ISO15693_AFI_TEST_BIT5   0x10
#define ISO15693_BIT1_SINGLE_SUBCARRIER   0x00
#define ISO15693_BIT1_DUAL_SUBCARRIERS   0x01
#define ISO15693_BIT2_LOW_DATARATE   0x00
#define ISO15693_BIT2_HIGH_DATARATE   0x02
#define ISO15693_BIT3_INVENTORY_FLAG_RESET   0x00
#define ISO15693_BIT3_INVENTORY_FLAG_SET   0x04
#define ISO15693_BIT4_NO_PROTOCOL_EXTENSION   0x00
#define ISO15693_BIT4_PROTOCOL_EXTENSION   0x08
#define ISO15693_BIT3RESET_BIT5_REQUEST_TAG_NOT_SELECTED   0x00
#define ISO15693_BIT3RESET_BIT5_REQUEST_TAG_SELECTED   0x10
#define ISO15693_BIT3RESET_BIT6_REQUEST_NOT_ADDRESSED   0x00
#define ISO15693_BIT3RESET_BIT6_REQUEST_ADDRESSED   0x20
#define ISO15693_BIT3RESET_BIT7_OPTIONFLAG_RESET   0x00
#define ISO15693_BIT3RESET_BIT7_OPTIONFLAG_SET   0x40
#define ISO15693_BIT3RESET_BIT8_RFU   0x00
#define ISO15693_BIT3SET_BIT5_AFI_NOT_PRESENT   0x00
#define ISO15693_BIT3SET_BIT5_AFI_PRESENT   0x10
#define ISO15693_BIT3SET_BIT6_16_SLOTS   0x00
#define ISO15693_BIT3SET_BIT6_1_SLOT   0x20
#define ISO15693_BIT3SET_BIT7_OPTIONFLAG_RESET   0x00
#define ISO15693_BIT3SET_BIT7_OPTIONFLAG_SET   0x40
#define ISO15693_BIT3SET_BIT8_RFU   0x00
#define ISO15693_BIT8_RFU_SET_MASK   0x80
#define ISO15693_SINGLE_SUBCARRIER   0x00
#define ISO15693_DUAL_SUBCARRIERS   0x01
#define ISO15693_LOW_DATARATE   0x00
#define ISO15693_HIGH_DATARATE   0x02
#define ISO15693_INVENTORY_FLAG_RESET   0x00
#define ISO15693_INVENTORY_FLAG_SET   0x04
#define ISO15693_NO_PROTOCOL_EXTENSION   0x00
#define ISO15693_PROTOCOL_EXTENSION   0x08
#define ISO15693_SELECT_FLAG_RESET   0x00
#define ISO15693_SELECT_FLAG_SET   0x10
#define ISO15693_ADDRESS_FLAG_RESET   0x00
#define ISO15693_ADDRESS_FLAG_SET   0x20
#define ISO15693_AFI_NOT_PRESENT   0x00
#define ISO15693_AFI_PRESENT   0x01
#define ISO15693_16_SLOTS   0x00
#define ISO15693_1_SLOT   0x01
#define ISO15693_OPTION_FLAG_SET   0x40
#define ISO15693_OPTION_FLAG_RESET   0x00
#define ISO15693_BIT8_RFU_RESET   0x00
#define ISO15693_BIT8_RFU_SET   0x80
#define ISO15693_ERROR_INVALID_FLAG   0xFF
#define ISO15693_RESPONSE_FLAGS_ERRORFLAG_MASK   0x01
#define ISO15693_INFORMATION_FLAGS_DSFID_MASK   0x01
#define ISO15693_INFORMATION_FLAGS_AFI_MASK   0x02
#define ISO15693_INFORMATION_FLAGS_MEMSIZE_MASK   0x04
#define ISO15693_INFORMATION_FLAGS_ICREF_MASK   0x08
#define ISO15693_UID_MSB   0xE0

Functions

u8 Scan15693Tag (void)
u8 ISO15693_Inventory (ISO15693_Tag *MyTag, const u8 Request_flags, const u8 Tag_AFI, const u8 MaskLength, const u8 *Mask, u8 *Inventory_16_slots_Nb_UID_Retrieved)
 This function sends, through the CR95HF, to a contactless tag, an inventory command and fills the Tag structure if some contactless tag answers. Note that if there are 16 slots it's recommend to set the CR95HF into WAIT302µs parameter with the protocol select command. Indeed, if the CR95HF is in Wait SOF mode it will waits up to 20ms before returning that there is no tag in the field whereas by waiting ionly 302 µs it allows to the application to know more rapidly that there is no tag and to send an EOF to switch to the next slot.
u8 ISO15693_Stay_Quiet (const u8 Request_flags, const u8 *Tag_UID)
 This function sends, through the CR95HF, a stay quiet command to a unique contactless tag designated by its UID.
u8 ISO15693_Read_Single_Block (ISO15693_Tag *MyTag, const u8 Request_flags, const u8 *Tag_UID, const u8 Block_number)
 This function sends, through the CR95HF, a read single block command to the contactless tag in the field or to an unique contactless tag designated by its UID.
u8 ISO15693_Write_Single_Block (ISO15693_Tag *MyTag, const u8 Request_flags, const u8 *Tag_UID, const u8 Block_number, const u8 Block_Length, const u8 *Data)
 This function sends, through the CR95HF, a write single block command to the contactless tag in the field or to an unique contactless tag designated by its UID.
u8 ISO15693_Lock_Block (ISO15693_Tag *MyTag, const u8 Request_flags, const u8 *Tag_UID, const u8 Block_number)
 This function sends, through the CR95HF, a lock block command to the contactless tag in the field or to an unique contactless tag designated by its UID.
u8 ISO15693_Read_Multiple_Block (ISO15693_Tag *MyTag, const u8 Request_flags, const u8 *Tag_UID, const u8 First_Block_number, const u8 Number_of_Blocks)
 This function sends, through the CR95HF, a read multiple block command to the contactless tag in the field or to an unique contactless tag designated by its UID. Note that data received are stored into the internal EEPROM of the MCU.
u8 ISO15693_Select (ISO15693_Tag *MyTag, const u8 Request_flags, const u8 *Tag_UID)
 This function sends, through the CR95HF, a select command to the unique contactless tag designated by its UID.
u8 ISO15693_Reset_to_Ready (ISO15693_Tag *MyTag, const u8 Request_flags, const u8 *Tag_UID)
 This function sends, through the CR95HF, a reset to ready state command to a contactless tag . This command could be used in two different case:
u8 ISO15693_Write_AFI (ISO15693_Tag *MyTag, const u8 Request_flags, const u8 *Tag_UID, const u8 Tag_AFI)
 This function sends, through the CR95HF, a write AFI command to the contacless tag in the field or to an unique contactless tag designated by its UID.
u8 ISO15693_Lock_AFI (ISO15693_Tag *MyTag, const u8 Request_flags, const u8 *Tag_UID)
 This function sends, through the CR95HF, a Lock AFI command to the contacless tag in the field or to an unique contactless tag designated by its UID.
u8 ISO15693_Write_DSFID (ISO15693_Tag *MyTag, const u8 Request_flags, const u8 *Tag_UID, const u8 Tag_DSFID)
 This function sends, through the CR95HF, a write DSFID command to the contacless tag in the field or to an unique contactless tag designated by its UID.
u8 ISO15693_Lock_DSFID (ISO15693_Tag *MyTag, const u8 Request_flags, const u8 *Tag_UID)
 This function sends, through the CR95HF, a Lock DSFID command to the contacless tag in the field or to an unique contactless tag designated by its UID.
u8 ISO15693_Get_System_Info (ISO15693_Tag *MyTag, const u8 Request_flags, const u8 *Tag_UID)
 This function sends, through the CR95HF, an get System Information commandto the contacless tag in the field or to an unique contactless tag designated by its UID.
u8 ISO15693_Get_Multiple_Blocks_Security_Status (ISO15693_Tag *MyTag, const u8 Request_flags, const u8 *Tag_UID, const u8 First_Block_number, const u8 Number_of_Blocks)
 This function sends, through the CR95HF, a get multiple blocks security status command to the contactless tag in the field or to an unique contactless tag designated by its UID. note that data are stored into the eeprom.
u8 ISO15693_Custom_Commands (ISO15693_Tag *MyTag, u8 Request_flags, u8 Custom, u8 IC_Mfg_Code, u8 Parameters_Length, u8 *parameters)
void ISO15693_Add_Request_Flags_Command_code_to_command (CR95HF_CommandSending *Cmd, u8 *Cptr_ToIncrement, const u8 Request_flags, const u8 Command_Code)
 This function add the UID into the command's data and increments the counter of data if the command is addressed.
void ISO15693_Add_Mask_to_command (CR95HF_CommandSending *Cmd, u8 *Cptr_ToIncrement, const u8 MaskLength, const u8 *Mask)
 This function add the Mask into the command's data and increments the counter of data.
void ISO15693_Add_UID_to_command (CR95HF_CommandSending *Cmd, u8 *Cptr_ToIncrement, const u8 *Tag_UID, const u8 Request_flags)
u8 ISO15693_Is_ResponseFlags_noError_Detected (const u8 ISO15693_Response_flags)
 This function checks if the response flag is set or not. If set the contactless tag encountered an error while performing the command.
u8 ISO15693_Is_Request_Flags_ok (const u8 Request_flags, const u8 ISO15693_cmd_code)
 This function performs several checks to verify that the request flag is not wrong. This is not a garantee that the request flags is right (depends on the contactless tag and on some commands' particularities).
u8 ISO15693_Is_Collision_Flag_Set (CR95HF_ResponseReceiving *Response)
 This function checks if the check collision flag added by the CR95HF is set or not. If it is, that means that the CRC95HF has detected an collision between two contactless tag answers.
u8 ISO15693_Is_CRC_Flag_Set (CR95HF_ResponseReceiving *Response)
 This function checks if the check CRC flag added by the CR95HF is set or not. If it is, that means that the CRC95HF has detected an error during the reception.
u8 ISO15693_Is_CorrectCRC16_Check (CR95HF_ResponseReceiving *Response)
 This function checks the check CRC flag and the residue of the received command. If there is any problem: mismatch or error, the function returns error value.
u8 ISO15693_Is_TagConstructor_STM (const ISO15693_Tag *MyTag)
 This function returns TRUE_CODE if the contactless tag has been manufactured by STMicroelectronics, the UID of the contactless tag must be known.
u8 ISO15693_Is_Memory_programming_function (const u8 ISO15693_cmd_code)
 This function returns if the contactless tag performs a memory programming by processing the command. ( write, lock)
u8 ISO15693_Is_DSFID_Present_Infoflag (const u8 Information_flags)
 This function returns if the DSFID is present within the contactless tag answer to a get system info command.
u8 ISO15693_Is_AFI_Present_Infoflag (const u8 Information_flags)
 This function returns if the AFI is present within the contactless tag answer to a get system info command.
u8 ISO15693_Is_MemSize_Present_Infoflag (const u8 Information_flags)
 This function returns if the Memsize is present within the contactless tag answer to a get system info command.
u8 ISO15693_Is_ICRef_Present_Infoflag (const u8 Information_flags)
 This function returns if the ICREF is present within the contactless tag answer to a get system info command.
u8 ISO15693_Get_Subcarrier_Flag (const u8 Request_flags)
 This function returns the subcarrier flag determining if the contactless tag's response is made with one or two subcarriers.
u8 ISO15693_Get_DataRate_Flag (const u8 Request_flags)
 This function returns the datarate flag determining if the contactless tag's response is made in high or low datarate.
u8 ISO15693_Get_Inventory_Flag (const u8 Request_flags)
 This function returns the inventory flag to determine if the ccontactless should run the anticollision sequence (inventory command).
u8 ISO15693_Get_ProtocolExtension_Flag (const u8 Request_flags)
 This function returns the protocol extension flag.
u8 ISO15693_Get_Select_Flag (const u8 Request_flags)
 This function returns the select flag to determine if the command is destineted to the contactless tag in selected mode. Note that a check is made to ensure that the inventory flag is reset.
u8 ISO15693_Get_Address_Flag (const u8 Request_flags)
 This function returns the address flag to determine if the command is addressed to the contactless tag designted by its UID. Note that a check is made to ensure that the inventory flag is reset.
u8 ISO15693_Get_AFI_Flag (const u8 Request_flags)
 This function returns the AFI flag to determine if the AFI is present within the command (inventory). Note that a check is made to ensure that the inventory flag is set.
u8 ISO15693_Get_Slots_Flag (const u8 Request_flags)
 This function returns the number of slots flag (1 or 16) that the contactless tag has to answer an inventory command. Note that a check is made to ensure that the inventory flag is set.
u8 ISO15693_Get_Option_Flag (const u8 Request_flags)
 This function returns the option flag. Note: this function assumes that the option flag has the same meaning whatever the inventory flag value.
u8 ISO15693_Get_RFU_Flag (const u8 Request_flags)
 This function returns RFU flag. The function may need to be tailored when RFU will be defined. Note: this function assumes the RFU flag is the same whatever the inventory flag.
u8 ISO15693_Get_SubCarrier_parameter_CR95HF (const CR95HF_Protocol_Config *Protocol_Settings)
 This function returns if the protocol in use is set with dual Subcarrier or single subcarrier.
u8 ISO15693_Get_Modulation_parameter_CR95HF (const CR95HF_Protocol_Config *Protocol_Settings)
 this function returns if the protocol in use is set with 10 percent modulation or 100 percent modultaion
u8 ISO15693_Get_Delay_parameter_CR95HF (const CR95HF_Protocol_Config *Protocol_Settings)
 this function returns if the protocol in use is set with wait Start of frame or respect 312 micro seconds delay for response slots
u8 ISO15693_Get_DataRate_parameter_CR95HF (const CR95HF_Protocol_Config *Protocol_Settings)
 this function returns if the protocol in use is set with wait Start of frame or respect 312 micro seconds delay for response slots
u8 ISO15693_Get_NumberofByte_MemSize_using_ICREF (const u8 ICRef)
 This functions returns the number of byte used to describe the memory size of the contactless tag (STMicroelectronics manufactured tag)
u8 ISO15693_Get_Size_of_Block_using_ICRef (const u8 ICRef)
 This functions returns the size of a block using the UID of the Tag ( STMicroelectronics' manufactured contactless tag).
u8 ISO15693_Get_Size_of_Block_using_MemSize (const ISO15693_Tag *MyTag)
 This functions returns the size of a block using the MemSize field of the tag structure a get system info command should have been performed before calling this function.
u16 ISO15693_Get_MemSize_kbits (const u8 *MemSize, const u8 Number_of_bytes_MemSize)
 This function returns the memory size of the contactless tag in a whole number of kilo bits .Note that the size max handled will be 256kbits.
u32 ISO15693_Get_MemSize_bits (const u8 *MemSize, const u8 Number_of_bytes_MemSize)
u8 ISO15693_Get_UID_from_EEPROM (u8 *UID_Tag, u8 UID_number)
 This function retrieves the UID stored into the EEPROM by the inventory 16 slots commands.
int16_t ISO15693_CRC16 (const u8 *DataIn, const u8 NbByte)
 This function computes the CRC16 as defined by CRC ISO/IEC 13239.
u8 ISO15693_IsCorrectCRC16Residue (const u8 *DataIn, const u8 Length)
 this function computes the CRC16 residue as defined by CRC ISO/IEC 13239
int16_t ISO15693_CRC16_EEPROM (const u8 NbByte)
 This function computes the CRC16 as defined by CRC ISO/IEC 13239 using data stored into the internal EEPROM of the MCU.
u8 ISO15693_IsCorrectCRC16Residue_EEPROM (const u8 Length)
 This function computes the CRC16 residue as defined by CRC ISO/IEC 13239 using data stored into the internal EEPROM of the MCU.
u8 ISO156693_Check_Data_Received_Start_Process (ISO15693_Tag *MyTag, const CR95HF_ResponseReceiving *Response, u8 *Cursor_in_response_data)
 This function checks if the data are sound (CRC ok) and filled in basic data common for all response : copy the whole data, write response_flag and data_length into the structure.
void ISO15693_Fill_in_Tag_Structure_ErrorFlag_set (ISO15693_Tag *MyTag, CR95HF_ResponseReceiving *Response)
 The purpose of the function is to fill the contactless Tag structure when the errorFlag is set in the contactless tag response.
u8 ISO15693_Read_Answer_Format_Response_Flags (ISO15693_Tag *MyTag, CR95HF_ResponseReceiving *Response, const u8 Status_cr95hf)
 The purpose of the function is to read the response of the contactless tag when the response expected is only response flags, if error flag is set the function calls the ISO15693_Fill_in_Tag_Structure_ErrorFlag_set function.
u8 ISO15693_Send_Receive_Inventory_cmd (ISO15693_Tag *MyTag, CR95HF_ResponseReceiving *Response, CR95HF_CommandSending *Cmd, u8 Request_flags, u8 *status_cr95hf, u8 *Inventory_16_slots_Nb_UID_Retrieved)
 This function sends a inventory command for conctactless tag.The function checks the type of inventory : 1 or 16 slots and calls the right fucntion to send the command and to manage answers received.
u8 ISO15693_Send_Receive_Single_Block_Memory_Programming_cmd (CR95HF_ResponseReceiving *Response, CR95HF_CommandSending *Cmd, const u8 Request_flags)
 This function sends to the contactless tag through the CR95HF a Single block (read, write, lock) memory programming command and receive the answer. As the contactless tag takes longer to perform that kind of the command, depending on the option flag and on the protocol parameters set the function handles the command sending and the contactless tag answer reception.
u8 ISO15693_Receive_Multiple_Blocks_cmd (CR95HF_ResponseReceiving *Response)
 This function receives, trough the CR95HF, the response of the contactless tag to a readMultiple block command (read). Note that data received from the contactless tag are stored into the internal eeprom of the MCU. (the whole contactless tag frame.
u8 ISO156693_Fill_in_TagStructure_Inventory_cmd (ISO15693_Tag *MyTag, CR95HF_ResponseReceiving *Response, u8 CR95HF_command_status)
 The purpose of this function is to split the response to an inventory command into different identifiable fields gathered within the structure.
u8 ISO156693_Fill_in_TagStructure_Read_Single_Block_cmd (ISO15693_Tag *MyTag, CR95HF_ResponseReceiving *Response, const u8 CR95HF_command_status, const u8 Request_flags)
 the purpose of this function is to split the response to a read single block command into different identifiable fields gathered within the structure
u8 ISO156693_Fill_in_TagStructure_Read_Multiple_Blocks_cmd (ISO15693_Tag *MyTag, CR95HF_ResponseReceiving *Response, const u8 CR95HF_command_status, const u8 Number_of_Blocks)
 The purpose of this function is to split the response to a read mutliple blocks into different identifiable fields gathered within the structure.
u8 ISO156693_Fill_in_TagStructure_Get_Multiple_Block_Status_cmd (ISO15693_Tag *MyTag, CR95HF_ResponseReceiving *Response, const u8 CR95HF_command_status, const u8 Number_of_Blocks)
 The purpose of this function is to split the response to a get multiple block security status command into different identifiable fields gathered within the structure.
void ISO15693_Retrieve_UID (ISO15693_Tag *MyTag, CR95HF_ResponseReceiving *Response, u8 *Cursor_in_response_data)
 The function fills the contactless Tag structure with the UID (Inventory and Get system info command).
void ISO15693_Retrieve_ICRef (ISO15693_Tag *MyTag)
 The function fills the contactless Tag structure with the ICRef using the UID (Get system info command). Only available for contactless tag manufactured by STMicroelectronics.

Detailed Description

Header for the iso15693_command.c file.

Author:
STMicroelectronics - MMY Application Team
Version:
V1.0
Date:

THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.

© COPYRIGHT 2011 STMicroelectronics

logo.bmp
 All Data Structures Files Functions Variables Defines