25 #ifndef __NFC_CHIPS_PN53X_H__
26 # define __NFC_CHIPS_PN53X_H__
30 # define PN53x_NORMAL_FRAME_MAX_LEN 255
31 # define PN53x_NORMAL_FRAME_OVERHEAD 7
32 # define PN53x_EXTENDED_FRAME_MAX_LEN 264
33 # define PN53x_EXTENDED_FRAME_OVERHEAD 10
36 # define REG_CIU_TX_MODE 0x6302
37 # define SYMBOL_TX_CRC_ENABLE 0x80
43 # define SYMBOL_TX_FRAMING 0x03
45 # define REG_CIU_RX_MODE 0x6303
46 # define SYMBOL_RX_CRC_ENABLE 0x80
47 # define SYMBOL_RX_NO_ERROR 0x08
48 # define SYMBOL_RX_MULTIPLE 0x04
50 # define SYMBOL_RX_FRAMING 0x03
52 # define REG_CIU_TX_AUTO 0x6305
53 # define SYMBOL_FORCE_100_ASK 0x40
54 # define SYMBOL_AUTO_WAKE_UP 0x20
55 # define SYMBOL_INITIAL_RF_ON 0x04
57 # define REG_CIU_MANUAL_RCV 0x630D
58 # define SYMBOL_PARITY_DISABLE 0x10
60 # define REG_CIU_STATUS2 0x6338
61 # define SYMBOL_MF_CRYPTO1_ON 0x08
63 # define REG_CIU_CONTROL 0x633C
64 # define SYMBOL_INITIATOR 0x10
65 # define SYMBOL_RX_LAST_BITS 0x07
67 # define REG_CIU_BIT_FRAMING 0x633D
68 # define SYMBOL_TX_LAST_BITS 0x07
71 #define SUPPORT_ISO14443A 0x01
72 #define SUPPORT_ISO14443B 0x02
73 #define SUPPORT_ISO18092 0x04
76 # define PARAM_NONE 0x00
77 # define PARAM_NAD_USED 0x01
78 # define PARAM_DID_USED 0x02
79 # define PARAM_AUTO_ATR_RES 0x04
80 # define PARAM_AUTO_RATS 0x10
81 # define PARAM_14443_4_PICC 0x20
82 # define PARAM_NFC_SECURE 0x20
83 # define PARAM_NO_AMBLE 0x40
86 # define RFCI_FIELD 0x01 // 1
87 # define RFCI_TIMING 0x02 // 3
88 # define RFCI_RETRY_DATA 0x04 // 1
89 # define RFCI_RETRY_SELECT 0x05 // 3
90 # define RFCI_ANALOG_TYPE_A_106 0x0A // 11
91 # define RFCI_ANALOG_TYPE_A_212_424 0x0B // 8
92 # define RFCI_ANALOG_TYPE_B 0x0C // 3
93 # define RFCI_ANALOG_TYPE_14443_4 0x0D // 9
96 # define DENACK 0x0100
97 # define DEACKMISMATCH 0x0200
98 # define DEISERRFRAME 0x0300
99 # define DENOTSUP 0x0400
184 bool pn53x_check_ack_frame_callback (
nfc_device_t * pnd,
const byte_t * pbtRxFrame,
185 const size_t szRxFrameLen);
186 bool pn53x_check_error_frame_callback (
nfc_device_t * pnd,
const byte_t * pbtRxFrame,
187 const size_t szRxFrameLen);
188 bool pn53x_transceive (
nfc_device_t * pnd,
const byte_t * pbtTx,
const size_t szTx, byte_t * pbtRx,
190 bool pn53x_get_reg (
nfc_device_t * pnd, uint16_t ui16Reg, uint8_t * ui8Value);
191 bool pn53x_set_reg (
nfc_device_t * pnd, uint16_t ui16Reg, uint8_t ui8SymbolMask, uint8_t ui8Value);
192 bool pn53x_set_parameter (
nfc_device_t * pnd,
const uint8_t ui8Value,
const bool bEnable);
193 bool pn53x_set_tx_bits (
nfc_device_t * pnd,
const uint8_t ui8Bits);
194 bool pn53x_wrap_frame (
const byte_t * pbtTx,
const size_t szTxBits,
const byte_t * pbtTxPar, byte_t * pbtFrame,
195 size_t * pszFrameBits);
196 bool pn53x_unwrap_frame (
const byte_t * pbtFrame,
const size_t szFrameBits, byte_t * pbtRx,
size_t * pszRxBits,
198 bool pn53x_decode_target_data (
const byte_t * pbtRawData,
size_t szRawData,
201 bool pn53x_get_firmware_version (
nfc_device_t * pnd,
char abtFirmwareText[18]);
205 bool pn53x_initiator_select_passive_target (
nfc_device_t * pnd,
207 const byte_t * pbtInitData,
const size_t szInitData,
211 const byte_t btPollNr,
const byte_t btPeriod,
213 bool pn53x_initiator_select_dep_target (
nfc_device_t * pnd,
217 bool pn53x_initiator_transceive_bits (
nfc_device_t * pnd,
const byte_t * pbtTx,
const size_t szTxBits,
218 const byte_t * pbtTxPar, byte_t * pbtRx,
size_t * pszRxBits,
220 bool pn53x_initiator_transceive_bytes (
nfc_device_t * pnd,
const byte_t * pbtTx,
const size_t szTx,
221 byte_t * pbtRx,
size_t * pszRx);
224 bool pn53x_target_receive_bits (
nfc_device_t * pnd, byte_t * pbtRx,
size_t * pszRxBits, byte_t * pbtRxPar);
225 bool pn53x_target_receive_bytes (
nfc_device_t * pnd, byte_t * pbtRx,
size_t * pszRx);
226 bool pn53x_target_send_bits (
nfc_device_t * pnd,
const byte_t * pbtTx,
const size_t szTxBits,
227 const byte_t * pbtTxPar);
228 bool pn53x_target_send_bytes (
nfc_device_t * pnd,
const byte_t * pbtTx,
const size_t szTx);
236 bool pn53x_SetParameters (
nfc_device_t * pnd,
const uint8_t ui8Value);
238 const byte_t szMaxTargets,
const byte_t * pbtInitiatorData,
239 const size_t szInitiatorDataLen, byte_t * pbtTargetsData,
size_t * pszTargetsData);
240 bool pn53x_InDeselect (
nfc_device_t * pnd,
const uint8_t ui8Target);
241 bool pn53x_InRelease (
nfc_device_t * pnd,
const uint8_t ui8Target);
243 const byte_t btPollNr,
const byte_t btPeriod,
nfc_target_t * pntTargets,
244 size_t * pszTargetFound);
247 const byte_t * pbtPassiveInitiatorData,
248 const byte_t * pbtNFCID3i,
249 const byte_t * pbtGB,
const size_t szGB,
252 const byte_t * pbtMifareParams,
253 const byte_t * pbtTkt,
size_t szTkt,
254 const byte_t * pbtFeliCaParams,
255 const byte_t * pbtNFCID3t,
const byte_t * pbtGB,
const size_t szGB,
256 byte_t * pbtRx,
size_t * pszRx, byte_t * pbtModeByte);
259 #endif // __NFC_CHIPS_PN53X_H__