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

Header for cr95hf_command.c - constants for commands and parameters of communication. More...

#include "cr95hf_structure.h"
#include "cr95hf_driver.h"
#include "string.h"

Go to the source code of this file.

Defines

#define CR95HF_CMD_IDN   0x01
#define CR95HF_CMD_PROT_SEL   0x02
#define CR95HF_CMD_SEND_REC   0x04
#define CR95HF_CMD_IDLE   0x07
#define CR95HF_CMD_RDREG   0x08
#define CR95HF_CMD_WRT_REG   0x09
#define CR95HF_CMD_BAUDRATE   0x0A
#define CR95HF_CMD_ECHO   0x55
#define CR95HF_CMD_POLL_FIELD   0x03
#define CR95HF_CMD_LISTEN   0x05
#define CR95HF_CMD_SEND   0x06
#define CR95HF_CMD_SUB_FREQ_RES   0x0B
#define CR95HF_CMD_AC_FILTER   0x0D
#define CR95HF_CMD_RD_REG_DATALENGTH   0x03
#define CR95HF_CMD_BAUD_RATE_DATALENGTH   0x01
#define CR95HF_CMD_IDLE_DATALENGTH   0x0E
#define CR95HF_PARAMETERSLENGTH_FIELDOFF   0x01
#define CR95HF_PARAMETERSLENGTH_PROT_ISO15693   0x01
#define CR95HF_PARAMETERSLENGTH_PROT_ISO14443_BYTE0   0x01
#define CR95HF_PARAMETERSLENGTH_PROT_ISO14443_BYTE1   0x02
#define CR95HF_PARAMETERSLENGTH_PROT_ISO14443_BYTE2   0x03
#define CR95HF_PARAMETERSLENGTH_PROT_FELICA   0x02
#define CR95HF_PROT_SEL_FIELDOFF   0x00
#define CR95HF_PROT_SEL_ISO15693   0x01
#define CR95HF_PROT_SEL_ISO14443_A   0x02
#define CR95HF_PROT_SEL_ISO14443_B   0x03
#define CR95HF_PROT_SEL_FELICA   0x04
#define CR95HF_FIELDOFF_PARAMETER_BYTE   0x00
#define CR95HF_BIT7_6_RFU   0x00
#define CR95HF_BIT4_5_DATARATE_26KBITS   0x00
#define CR95HF_BIT4_5_DATARATE_52KBITS   0x10
#define CR95HF_BIT4_5_DATARATE_6KBITS   0x20
#define CR95HF_BIT4_5_DATARATE_RFU   0x30
#define CR95HF_BIT3_RESPECT312_DELAY   0x00
#define CR95HF_BIT3_WAIT_FOR_SOF   0x08
#define CR95HF_BIT2_MODULATION_100   0x00
#define CR95HF_BIT2_MODULATION_10   0x04
#define CR95HF_BIT1_SINGLE_CARRIER   0x00
#define CR95HF_BIT1_DUAL_CARRIERS   0x02
#define CR95HF_BIT0_APPEND_CRC   0x01
#define CR95HF_DATARATE_MASK   0x30
#define CR95HF_SHIFT_DATARATE_INFO_TO_PARAMETERS   0x04
#define CR95HF_SUCCESS_CODE   0x00
#define CR95HF_ERROR_CODE   0x01
#define CR95HF_INIT_ResponseReceiving   0xEC
#define CR95HF_IDN_SUCCESS_CODE   0x00
#define CR95HF_IDN_ROMCRC_CURSOR   0x02
#define CR95HF_PROTOCOL_SUCCESS_CODE   0x00
#define CR95HF_ERROR_INVALID_PROTOCOL   0x83
#define CR95HF_ERROR_INVALID_CMD_LENGTH   0x82
#define CR95HF_SENDRECV_SUCCESS_CODE   0x80
#define CR95HF_ERROR_4BYTE_FRAME   0x90
#define CR95HF_ERROR_COMMUNICATION   0x86
#define CR95HF_ERROR_NOTAG_OR_TIMEOUT   0x87
#define CR95HF_ERROR_INVALID_SOF   0x88
#define CR95HF_ERROR_BUFFER_OVERFLOW   0x89
#define CR95HF_ERROR_FRAMING   0x8A
#define CR95HF_EROR_EGT_TIMEOUT   0x8B
#define CR95HF_ERROR_INVALID_LENGTH_FELICA   0x8C
#define CR95HF_ERROR_CRC_FELICA   0x8D
#define CR95HF_ERROR_RECEPTION_LOST   0x8E
#define CR95HF_RD_REG_SUCCESS_CODE   0x00
#define CR95HF_RD_REG_ST_RESERVED   0x00
#define CR95HF_WAKE_UP_REGISTER_CURSOR   0x62
#define CR95HF_WAKE_UP_REGISTER_SIZE   0x01
#define CR95HF_ANALOG_CONFIG_REGISTER_CURSOR   0x69
#define CR95HF_ANALOG_CONFIG_REGISTER_SIZE   0x01
#define CR95HF_ANALOG_CONFIG_REGISTER_INDEX   0x68
#define CR95HF_ANALOG_CONFIG_INDEX   0x01
#define CR95HF_WR_REG_LENGTH_OF_CMD   0x04
#define CR95HF_WR_REG_FLAG_INCREMENT   0x01
#define CR95HF_SET_INDEX_LENGTH_OF_CMD   0x03
#define CR95HF_SET_INDEX_FLAG_INCREMENT   0x00
#define CR95HF_WAKE_UP_BECAUSE_TAG_DETECTION   0x02
#define CR95HF_WAKE_UP_BECAUSE_TIMEOUT   0x01
#define CR95HF_DEFAULT_BAUD_RATE   0x75
#define CR95HF_BAUD_RATE_FAILED_DEFAULT_VALUE_ON   0x10
#define CR95HF_BAUD_RATE_FAILED_PREVIOUS_VALUE_ON   0x20
#define CR95HF_ECHO_SUCCESS_CODE   0x55
#define CR95HF_BAUD_RATE_ERROR   0xBE
#define CR95HF_COMMUNICATION_WITH_MCU_FAILED   0xCE
#define CR95HF_INVALID_PROTOCOL   0xE0
#define CR95HF_PARAMETER_BYTE0   0x00
#define CR95HF_PARAMETER_BYTE1   0xE0
#define CR95HF_PARAMETER_BYTE2   0xE0
#define CR95HF_DATARATE_26KBITS   0x00
#define CR95HF_DATARATE_52KBITS   0x01
#define CR95HF_DATARATE_6KBITS   0x02
#define CR95HF_DATARATE_RFU   0x03
#define CR95HF_RESPECT312_DELAY   0x00
#define CR95HF_WAIT_FOR_SOF   0x01
#define CR95HF_MODULATION_100   0x00
#define CR95HF_MODULATION_10   0x01
#define CR95HF_SINGLE_CARRIER   0x00
#define CR95HF_DUAL_CARRIERS   0x01
#define CR95HF_CMD_IDLE_SUCCESS_CODE   0x00
#define CR95HF_IDLE_LEAVE_CTRL_L   0x18
#define CR95HF_IDLE_LEAVE_CTRL_H   0x00
#define CR95HF_IDLE_OSC_START   0x60
#define CR95HF_IDLE_DAC_START   0x60
#define CR95HF_IDLE_SWING_CNT   0x3F
#define CR95HF_IDLE_CRTRL_L_INIT_DAC_CMP_IDX   0x80
#define CR95HF_IDLE_CRTRL_L_DAC_ENABLE   0x40
#define CR95HF_IDLE_CRTRL_L_LFO_ENABLE   0x20
#define CR95HF_IDLE_CRTRL_L_HFO_ENABLE   0x10
#define CR95HF_IDLE_CRTRL_L_VDDA_ENABLE   0x08
#define CR95HF_IDLE_CRTRL_L_HIBERNATE_ENABLE   0x04
#define CR95HF_IDLE_CRTRL_L_IDLE_MODE_ENABLE   0x02
#define CR95HF_IDLE_CRTRL_L_SLEEP_MODE_ENABLE   0x01
#define CR95HF_IDLE_CRTRL_H_GTM_STOP   0x40
#define CR95HF_IDLE_CRTRL_H_CLK_SRC_HFO   0x00
#define CR95HF_IDLE_CRTRL_H_CLK_SRC_CLK_REC   0x02
#define CR95HF_IDLE_CRTRL_H_CARD_CLAMP_ENABLE   0x01
#define CR95HF_IDLE_CRTRL_H_CARD_RX_CHAIN_ENABLE   0x08
#define CR95HF_IDLE_CRTRL_H_READER_RX_CHAIN_ENABLE   0x04
#define CR95HF_IDLE_CRTRL_H_F_DET_ENABLE   0x02
#define CR95HF_IDLE_CRTRL_H_IRef_ENABLE   0x01
#define CR95HF_IDLE_MASK_WAKE_UP_FLAGS   0x0F
#define CR95HF_IDLE_WUFLAGS_BIT0_TIMER   0x01
#define CR95HF_IDLE_WUFLAGS_BIT1_TAG_DETECTED   0x02
#define CR95HF_IDLE_WUFLAGS_BIT2_RFU   0x00
#define CR95HF_IDLE_WUFLAGS_BIT3_EXTERNAL_INTERRUPT_IRQ_IN   0x08
#define CR95HF_IDLE_WUFLAGS_BIT4_EXTERNAL_INTERRUPT_NSS   0x10
#define CR95HF_IDLE_WUFLAGS_BIT5_RFU   0x00
#define CR95HF_IDLE_WUFLAGS_BIT6_RFU   0x00
#define CR95HF_IDLE_WUFLAGS_BIT7_RFU   0x00
#define CR95HF_IDLE_WUFLAGS_BIT_RESET   0x00
#define CR95HF_DETECTOR_CALIBRATION_EnterCtrl_L   0xA2
#define CR95HF_DETECTOR_CALIBRATION_EnterCtrl_H   0x00
#define CR95HF_DETECTOR_CALIBRATION_WUCtrl_L   0xF8
#define CR95HF_DETECTOR_CALIBRATION_WUCtrl_H   0x01
#define CR95HF_DETECTOR_CALIBRATION_LeaveCtrl_L   0x18
#define CR95HF_DETECTOR_CALIBRATION_LeaveCtrl_H   0x00
#define CR95HF_DETECTOR_CALIBRATION_WUPeriod   0x01
#define CR95HF_DETECTOR_CALIBRATION_Max_Sleep   0x01
#define CR95HF_DETECTOR_CALIBRATION_REF_0   0x3F
#define CR95HF_DETECTOR_CALIBRATION_LOOP_CNT_INIT   0x01
#define CR95HF_DETECTOR_CALIBRATION_LOOP_CNT_END   0x06
#define CR95HF_DETECTOR_CALIBRATION_DACDATA_H_MIN   0x00
#define CR95HF_DETECTOR_CALIBRATION_DACDATA_H_MAX   0x3F
#define CR95HF_DETECTOR_CALIBRATION_DACDATA_L   0x00
#define CR95HF_NUMBER_OF_WAITING_PERIOD   0x01
#define CR95HF_ERROR   0xEE
#define CR95HF_POLL_FIELD_CMD_FLAG_SET   0x01
#define CR95HF_POLL_FIELD_CMD_FLAG_RESET   0x00
#define CR95HF_POLL_FIELD_CMD_SUCCESS_CODE   0x00
#define CR95HF_POLL_FIELD_CMD_DATALENGTH   0x01
#define CR95HF_LISTEN_CMD_SUCCESS_CODE   0x00
#define CR95HF_LISTEN_CMD_COMMUNICATION_SUCCESS_CODE   0x80
#define CR95HF_LISTEN_ERROR_NOFIELD   0x8F
#define CR95HF_SEND_CMD_SUCCESS_CODE   0x00
#define CR95HF_SEND_CMD_RESPONSE_DATALENGTH   0x00
#define CR95HF_WRITE_REG_CMD_SUCCESS_CODE   0x00
#define CR95HF_SUB_FREQ_RES_CMD_SUCCESS_CODE   0x00
#define CR95HF_SUB_FREQ_RES_CMD_RESPONSE_DATALENGTH   0x01
#define CR95HF_ACFILTER_CMD_SUCCESS_CODE   0x00
#define CR95HF_ACFILTER_ATQA_LENGTH   0x02
#define CR95HF_ACFILTER_UID_PART_LENGTH   0x04
#define CR95HF_ACFILTER_LENGTH_7   0x07
#define CR95HF_ACFILTER_LENGTH_11   0x0B

Functions

u8 CR95HF_IDN (CR95HF_ResponseReceiving *Response)
 This function sends an IDN command.
u8 CR95HF_ProtocolSelect (const u8 Protocol, const u8 ParametersLength, const u8 *Parameters, CR95HF_Protocol_Config *Protocol_Settings)
 This function sends a protocol select command.
u8 CR95HF_SendRecv (CR95HF_ResponseReceiving *Response, const CR95HF_CommandSending *Command)
u8 CR95HF_Idle (const u8 WakeUpFlags, const u8 EnterCtrlL, const u8 EnterCtrlH, const u8 WUCtrlL, const u8 WUCtrlH, const u8 LeaveCtrlL, const u8 LeaveCtrlH, const u8 WUPeriod, const u8 OscStart, const u8 DacStart, const u8 DacDataL, const u8 DacDataH, const u8 SwingsCnt, const u8 MaxSleep, CR95HF_Idle_Config *Idle_Config)
 This function sends an idle command using the parameters provided.
u8 CR95HF_Rd_Wake_up_Reg (CR95HF_ResponseReceiving *Response, CR95HF_Idle_Config *Idle_Config)
 This function reads the wake up register of the CR95HF to determine what caused the awakening of the CR95HF after an Idle command.
u8 CR95HF_Rd_Analog_Register_Config_B (CR95HF_ResponseReceiving *Response)
 This function reads the RCB register of the CR95HF to check the analog configuration Register containing the modulation depth and reader chain gain. Note that a CR95HF_Set_Analog_Register_Config_B_Index command must be issued before reading the register.
u8 CR95HF_Set_Analog_Register_Config_B_Index (void)
 This command is used to set the address index before reading the analog configuration register.
u8 CR95HF_Wr_Analog_Register_Config_B_Reg (u8 Analog_Configuration_Register)
 This command is used to overwrite the Analog Configuration Register.
u8 CR95HF_Baud_Rate (const u8 New_Baud_Rate)
 This function changes the baud rate communication between MCU and CR95HF. If the command fails last.
u8 CR95HF_Echo (void)
 this function sends an ECHO command
u8 CR95HF_FieldOff (CR95HF_Protocol_Config *Protocol_Settings)
 This function swithes the RF Field Off using the protocol select comand.
u8 CR95HF_SendEOF (CR95HF_ResponseReceiving *Response)
 This function sends an End Of Frame. This can be used for instance in ISO15693 inventory command or write command. Right after the EOF the tag could answer a command (Write or Inventory), so the response is received and written into the structure provided.
u8 CR95HF_Modify_Baud_Rate (const u8 New_Baud_Rate)
 This function is a procedure to change Baud_Rate in UART communication. The function calls the Baud_Rate function and changes the MCU internal baud rate. In case of failure the function tries to recover the communication by returning into the previous baud rate or into the default baud rate.
u8 CR95HF_IsReaderResultOK (CR95HF_ResponseReceiving *Response, const u8 Code_OK)
 This function checks if the CR95HF has answered a success code.
u8 CR95HF_ISO15693_ComputeParameterByte_ProtocolSelect (u8 Bit7_6, u8 Bit5_4, u8 Bit3, u8 Bit2, u8 Bit1)
 This function computes the parameter byte for iso15693 protocol Select command, bit0 is forced to 1 to append CRC.
u8 CR95HF_Is_IRQin_Interrupt_Wake_up_Condition (const u8 WUFlags)
 This function is related to the idle mode. Its first goal is to determine whether an interrupt on IRQ_in is a wakeup condition (For instance if the CR95HF is in idle Mode, this function could also be called to determine which way to use to wake up the CR95HF).It can also be called once the CR95HF has woken up to determine if the CR95HF woke up because of timeout.Note that for the first case the WuFlags issued for the Idle command sould be given as input parameter (available in the CR95HF_Idle_Config structure) and for the second the case afther having issued CR95HF_Rd_Wake_up_Reg the last_reason_of_wakeup field of the CR95HF_Idle_Config structure may be used as input parameter.
u8 CR95HF_Is_NSS_Interrupt_Wake_up_Condition (const u8 WUFlags)
 This function is related to the idle mode. Its first goal is to determine whether an interrupt on NSS is a wakeup condition (For instance if the CR95HF is in idle Mode, this function could also be called to determine which way to use to wake up the CR95HF).It can also be called once the CR95HF has woken up to determine if the CR95HF woke up because of timeout.Note that for the first case the WuFlags issued for the Idle command sould be given as input parameter (available in the CR95HF_Idle_Config structure) and for the second the case afther having issued CR95HF_Rd_Wake_up_Reg the last_reason_of_wakeup field of the CR95HF_Idle_Config structure may be used as input parameter.
u8 CR95HF_Is_Tag_Detected_Wake_up_Condition (const u8 WUFlags)
 This function is related to the idle mode. Its first goal is to determine whether a tag detection is a wakeup condition (For instance if the CR95HF is in idle Mode, this function could also be called to determine which way to use to wake up the CR95HF).It can also be called once the CR95HF has woken up to determine if the CR95HF woke up because of timeout.Note that for the first case the WuFlags issued for the Idle command sould be given as input parameter (available in the CR95HF_Idle_Config structure) and for the second the case afther having issued CR95HF_Rd_Wake_up_Reg the last_reason_of_wakeup field of the CR95HF_Idle_Config structure may be used as input parameter.
u8 CR95HF_Is_Timeout_Wake_up_Condition (const u8 WUFlags)
 This function is related to the idle mode. Its goal is to determine whether the internal timer is a wakeup condition (For instance if the CR95HF is in idle Mode, this fucntion could be called to determine which way to use to wake up the CR95HF).It can also be called once the CR95HF has woken up to determine if the CR95HF woke up because of timeout.Note that for the first case the WuFlags issued for the Idle command sould be given as input parameter (available in the CR95HF_Idle_Config structure) and for the second the case afther having issued CR95HF_Rd_Wake_up_Reg the last_reason_of_wakeup field of the CR95HF_Idle_Config structure may be used as input parameter.
u8 CR95HF_Idle_Detector_Calibration (CR95HF_Protocol_Config *Protocol_Settings, CR95HF_Idle_Config *Idle_Config)
 The purpose of this function is to perform the detector calibration according to the Application Note :
u8 CR95HF_Tagdet (const u8 DacDataL, const u8 DacDataH)
 The purpose of this function is to perform the detector calibration according to the Application Note : AN3433 Tag Detection Calibration Process.
u8 CR95HF_Wait_Wake_up_from_Idle (CR95HF_ResponseReceiving *CR95HF_Response_Idle, CR95HF_Idle_Config *Idle_Config, u8 Number_of_DELAY_BEFORE_TIMEOUT_250MS)
 The purpose of this function is to wait for CR95HF exiting the idle mode and retrieve what caused the wake-up. The method proposed is to wait for the CR95HF answer and then to send several echo command in order to resume communication and clear the fifo stack. Note that this function waits for CR95HF wakes up on its own (internal timer, tag detection), after this function the CR95HF_Wake_up_CR95HF fucntion may be called to wake up the CR95HF with NNS or IRQ_in interrupt.
u8 CR95HF_Wake_up_CR95HF (CR95HF_Idle_Config *Idle_Config)
 The purpose of this function is to avoid getting stuck when the CR95HF exists idle mode. The method proposed is to send several echo command in order to resume communication and clear the fifo stack.
void CR95HF_SendCommand (CR95HF_CommandSending *Cmd)
 This function sends a command to the cr95hf.
CR95HF_ResponseReceiving CR95HF_ReceiveAnswer (void)
 this function receives and returns the response to a command previously sent to the cr95hf
void CR95HF_Wait_Receive_Answer (CR95HF_ResponseReceiving *Response)
 This function waits and receive the answer frrom the CR95HF.
void CR95HF_Init_ResponseReceiving (CR95HF_ResponseReceiving *Response)
 this function initialize the response structure to erase previous data from any other command this allows to be sure that resp_code is not issued by random data
void CR95HF_Add_Data_ToCommand (CR95HF_CommandSending *Cmd, u8 *Cptr_ToIncrement, u8 DataLength, u8 *Data)
 This function add an array of data into the command's data and increments the counter of data.

Detailed Description

Header for cr95hf_command.c - constants for commands and parameters of communication.

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

Define Documentation

#define CR95HF_CMD_IDN   0x01

< COMMANDS CODE

#define CR95HF_CMD_RD_REG_DATALENGTH   0x03

< COMMANDS DATALENTH

 All Data Structures Files Functions Variables Defines