libnfc 1.3.9
|
00001 /*- 00002 * Public platform independent Near Field Communication (NFC) library 00003 * 00004 * Copyright (C) 2009, 2010, Roel Verdult, Romuald Conty 00005 * 00006 * This program is free software: you can redistribute it and/or modify it 00007 * under the terms of the GNU Lesser General Public License as published by the 00008 * Free Software Foundation, either version 3 of the License, or (at your 00009 * option) any later version. 00010 * 00011 * This program is distributed in the hope that it will be useful, but WITHOUT 00012 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 00013 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 00014 * more details. 00015 * 00016 * You should have received a copy of the GNU Lesser General Public License 00017 * along with this program. If not, see <http://www.gnu.org/licenses/> 00018 */ 00019 00025 #ifndef __NFC_CHIPS_PN53X_H__ 00026 # define __NFC_CHIPS_PN53X_H__ 00027 00028 # include <nfc/nfc-types.h> 00029 00030 # define MAX_FRAME_LEN 264 00031 00032 // Registers and symbols masks used to covers parts within a register 00033 # define REG_CIU_TX_MODE 0x6302 00034 # define SYMBOL_TX_CRC_ENABLE 0x80 00035 # define REG_CIU_RX_MODE 0x6303 00036 # define SYMBOL_RX_CRC_ENABLE 0x80 00037 # define SYMBOL_RX_NO_ERROR 0x08 00038 # define SYMBOL_RX_MULTIPLE 0x04 00039 # define REG_CIU_TX_AUTO 0x6305 00040 # define SYMBOL_FORCE_100_ASK 0x40 00041 # define SYMBOL_AUTO_WAKE_UP 0x20 00042 # define SYMBOL_INITIAL_RF_ON 0x04 00043 # define REG_CIU_MANUAL_RCV 0x630D 00044 # define SYMBOL_PARITY_DISABLE 0x10 00045 # define REG_CIU_STATUS2 0x6338 00046 # define SYMBOL_MF_CRYPTO1_ON 0x08 00047 # define REG_CIU_CONTROL 0x633C 00048 # define SYMBOL_INITIATOR 0x10 00049 # define SYMBOL_RX_LAST_BITS 0x07 00050 # define REG_CIU_BIT_FRAMING 0x633D 00051 # define SYMBOL_TX_LAST_BITS 0x07 00052 00053 # define SYMBOL_PARAM_fAutomaticRATS 0x10 00054 # define SYMBOL_PARAM_fAutomaticATR_RES 0x04 00055 00056 // Internal parameters flags 00057 # define PARAM_NONE 0x00 00058 # define PARAM_NAD_USED 0x01 00059 # define PARAM_DID_USED 0x02 00060 # define PARAM_AUTO_ATR_RES 0x04 00061 # define PARAM_AUTO_RATS 0x10 00062 # define PARAM_14443_4_PICC 0x20 00063 # define PARAM_NO_AMBLE 0x40 00064 00065 // Radio Field Configure Items // Configuration Data length 00066 # define RFCI_FIELD 0x01 // 1 00067 # define RFCI_TIMING 0x02 // 3 00068 # define RFCI_RETRY_DATA 0x04 // 1 00069 # define RFCI_RETRY_SELECT 0x05 // 3 00070 # define RFCI_ANALOG_TYPE_A_106 0x0A // 11 00071 # define RFCI_ANALOG_TYPE_A_212_424 0x0B // 8 00072 # define RFCI_ANALOG_TYPE_B 0x0C // 3 00073 # define RFCI_ANALOG_TYPE_14443_4 0x0D // 9 00074 00075 /* PN53x specific device-level errors */ 00076 # define DENACK 0x0100/* NACK */ 00077 # define DEACKMISMATCH 0x0200/* Unexpected data */ 00078 # define DEISERRFRAME 0x0300/* Error frame */ 00079 # define DENOTSUP 0x0400/* Not supported */ 00080 00081 bool pn53x_transceive_check_ack_frame_callback (nfc_device_t * pnd, const byte_t * pbtRxFrame, 00082 const size_t szRxFrameLen); 00083 bool pn53x_transceive_check_error_frame_callback (nfc_device_t * pnd, const byte_t * pbtRxFrame, 00084 const size_t szRxFrameLen); 00085 bool pn53x_transceive (nfc_device_t * pnd, const byte_t * pbtTx, const size_t szTxLen, byte_t * pbtRx, 00086 size_t * pszRxLen); 00087 bool pn53x_get_reg (nfc_device_t * pnd, uint16_t ui16Reg, uint8_t * ui8Value); 00088 bool pn53x_set_reg (nfc_device_t * pnd, uint16_t ui16Reg, uint8_t ui8SybmolMask, uint8_t ui8Value); 00089 bool pn53x_set_parameters (nfc_device_t * pnd, uint8_t ui8Value); 00090 bool pn53x_set_tx_bits (nfc_device_t * pnd, uint8_t ui8Bits); 00091 bool pn53x_wrap_frame (const byte_t * pbtTx, const size_t szTxBits, const byte_t * pbtTxPar, byte_t * pbtFrame, 00092 size_t * pszFrameBits); 00093 bool pn53x_unwrap_frame (const byte_t * pbtFrame, const size_t szFrameBits, byte_t * pbtRx, size_t * pszRxBits, 00094 byte_t * pbtRxPar); 00095 bool pn53x_decode_target_data (const byte_t * pbtRawData, size_t szDataLen, nfc_chip_t nc, nfc_target_type_t ntt, 00096 nfc_target_info_t * pnti); 00097 00098 bool pn53x_InListPassiveTarget (nfc_device_t * pnd, const nfc_modulation_t nmInitModulation, 00099 const byte_t szMaxTargets, const byte_t * pbtInitiatorData, 00100 const size_t szInitiatorDataLen, byte_t * pbtTargetsData, size_t * pszTargetsData); 00101 bool pn53x_InDeselect (nfc_device_t * pnd, const uint8_t ui8Target); 00102 bool pn53x_InRelease (nfc_device_t * pnd, const uint8_t ui8Target); 00103 bool pn53x_InAutoPoll (nfc_device_t * pnd, const nfc_target_type_t * pnttTargetTypes, const size_t szTargetTypes, 00104 const byte_t btPollNr, const byte_t btPeriod, nfc_target_t * pntTargets, 00105 size_t * pszTargetFound); 00106 00107 bool pn53x_get_firmware_version (nfc_device_t * pnd); 00108 bool pn53x_configure (nfc_device_t * pnd, const nfc_device_option_t ndo, const bool bEnable); 00109 bool pn53x_initiator_select_dep_target (nfc_device_t * pnd, const nfc_modulation_t nmInitModulation, 00110 const byte_t * pbtPidData, const size_t szPidDataLen, 00111 const byte_t * pbtNFCID3i, const size_t szNFCID3iDataLen, 00112 const byte_t * pbtGbData, const size_t szGbDataLen, 00113 nfc_target_info_t * pnti); 00114 bool pn53x_initiator_transceive_bits (nfc_device_t * pnd, const byte_t * pbtTx, const size_t szTxBits, 00115 const byte_t * pbtTxPar, byte_t * pbtRx, size_t * pszRxBits, 00116 byte_t * pbtRxPar); 00117 bool pn53x_initiator_transceive_bytes (nfc_device_t * pnd, const byte_t * pbtTx, const size_t szTxLen, 00118 byte_t * pbtRx, size_t * pszRxLen); 00119 00120 bool pn53x_target_init (nfc_device_t * pnd, byte_t * pbtRx, size_t * pszRxBits); 00121 bool pn53x_target_receive_bits (nfc_device_t * pnd, byte_t * pbtRx, size_t * pszRxBits, byte_t * pbtRxPar); 00122 bool pn53x_target_receive_bytes (nfc_device_t * pnd, byte_t * pbtRx, size_t * pszRxLen); 00123 bool pn53x_target_send_bits (nfc_device_t * pnd, const byte_t * pbtTx, const size_t szTxBits, 00124 const byte_t * pbtTxPar); 00125 bool pn53x_target_send_bytes (nfc_device_t * pnd, const byte_t * pbtTx, const size_t szTxLen); 00126 00127 const char *pn53x_strerror (const nfc_device_t * pnd); 00128 00129 static const struct chip_callbacks pn53x_callbacks_list = { 00130 pn53x_strerror 00131 }; 00132 00133 #endif // __NFC_CHIPS_PN53X_H__