nfc_device struct is not exposed as public API anymore (partial commit)
- split libnfc's errors and chip's errors - fix nfc_property enum
This commit is contained in:
parent
98355d36a7
commit
9bdc20353c
11 changed files with 329 additions and 314 deletions
|
|
@ -127,8 +127,8 @@ typedef enum {
|
|||
} pn53x_operating_mode;
|
||||
|
||||
struct pn53x_io {
|
||||
bool (*send)(nfc_device *pnd, const uint8_t *pbtData, const size_t szData, int timeout);
|
||||
int (*receive)(nfc_device *pnd, uint8_t *pbtData, const size_t szDataLen, int timeout);
|
||||
bool (*send)(struct nfc_device *pnd, const uint8_t *pbtData, const size_t szData, int timeout);
|
||||
int (*receive)(struct nfc_device *pnd, uint8_t *pbtData, const size_t szDataLen, int timeout);
|
||||
};
|
||||
|
||||
/* defines */
|
||||
|
|
@ -146,6 +146,8 @@ struct pn53x_data {
|
|||
nfc_target *current_target;
|
||||
/** PN53x I/O functions stored in struct */
|
||||
const struct pn53x_io *io;
|
||||
/** Last status byte returned by PN53x */
|
||||
uint8_t last_status_byte;
|
||||
/** Register cache for REG_CIU_BIT_FRAMING, SYMBOL_TX_LAST_BITS: The last TX bits setting, we need to reset this if it does not apply anymore */
|
||||
uint8_t ui8TxBits;
|
||||
/** Register cache for SetParameters function. */
|
||||
|
|
@ -261,11 +263,11 @@ typedef enum {
|
|||
extern const uint8_t pn53x_ack_frame[6];
|
||||
extern const uint8_t pn53x_nack_frame[6];
|
||||
|
||||
bool pn53x_init(nfc_device *pnd);
|
||||
bool pn53x_transceive (nfc_device *pnd, const uint8_t *pbtTx, const size_t szTx, uint8_t *pbtRx, size_t *pszRx, int timeout);
|
||||
bool pn53x_init(struct nfc_device *pnd);
|
||||
bool pn53x_transceive (struct nfc_device *pnd, const uint8_t *pbtTx, const size_t szTx, uint8_t *pbtRx, size_t *pszRx, int timeout);
|
||||
|
||||
bool pn53x_set_parameters (nfc_device *pnd, const uint8_t ui8Value, const bool bEnable);
|
||||
bool pn53x_set_tx_bits (nfc_device *pnd, const uint8_t ui8Bits);
|
||||
bool pn53x_set_parameters (struct nfc_device *pnd, const uint8_t ui8Value, const bool bEnable);
|
||||
bool pn53x_set_tx_bits (struct nfc_device *pnd, const uint8_t ui8Bits);
|
||||
bool pn53x_wrap_frame (const uint8_t *pbtTx, const size_t szTxBits, const uint8_t *pbtTxPar, uint8_t *pbtFrame,
|
||||
size_t *pszFrameBits);
|
||||
bool pn53x_unwrap_frame (const uint8_t *pbtFrame, const size_t szFrameBits, uint8_t *pbtRx, size_t *pszRxBits,
|
||||
|
|
@ -273,74 +275,74 @@ bool pn53x_unwrap_frame (const uint8_t *pbtFrame, const size_t szFrameBits, u
|
|||
bool pn53x_decode_target_data (const uint8_t *pbtRawData, size_t szRawData,
|
||||
pn53x_type chip_type, nfc_modulation_type nmt,
|
||||
nfc_target_info *pnti);
|
||||
bool pn53x_read_register (nfc_device *pnd, uint16_t ui16Reg, uint8_t *ui8Value);
|
||||
bool pn53x_write_register (nfc_device *pnd, uint16_t ui16Reg, uint8_t ui8SymbolMask, uint8_t ui8Value);
|
||||
bool pn53x_get_firmware_version (nfc_device *pnd, char abtFirmwareText[22]);
|
||||
int pn53x_set_property_int (nfc_device *pnd, const nfc_property property, const int value);
|
||||
int pn53x_set_property_bool (nfc_device *pnd, const nfc_property property, const bool bEnable);
|
||||
bool pn53x_read_register (struct nfc_device *pnd, uint16_t ui16Reg, uint8_t *ui8Value);
|
||||
bool pn53x_write_register (struct nfc_device *pnd, uint16_t ui16Reg, uint8_t ui8SymbolMask, uint8_t ui8Value);
|
||||
bool pn53x_get_firmware_version (struct nfc_device *pnd, char abtFirmwareText[22]);
|
||||
int pn53x_set_property_int (struct nfc_device *pnd, const nfc_property property, const int value);
|
||||
int pn53x_set_property_bool (struct nfc_device *pnd, const nfc_property property, const bool bEnable);
|
||||
|
||||
bool pn53x_check_communication (nfc_device *pnd);
|
||||
bool pn53x_idle (nfc_device *pnd);
|
||||
bool pn53x_check_communication (struct nfc_device *pnd);
|
||||
bool pn53x_idle (struct nfc_device *pnd);
|
||||
|
||||
// NFC device as Initiator functions
|
||||
int pn53x_initiator_init (nfc_device *pnd);
|
||||
bool pn53x_initiator_select_passive_target (nfc_device *pnd,
|
||||
int pn53x_initiator_init (struct nfc_device *pnd);
|
||||
bool pn53x_initiator_select_passive_target (struct nfc_device *pnd,
|
||||
const nfc_modulation nm,
|
||||
const uint8_t *pbtInitData, const size_t szInitData,
|
||||
nfc_target *pnt);
|
||||
bool pn53x_initiator_poll_target (nfc_device *pnd,
|
||||
bool pn53x_initiator_poll_target (struct nfc_device *pnd,
|
||||
const nfc_modulation *pnmModulations, const size_t szModulations,
|
||||
const uint8_t uiPollNr, const uint8_t uiPeriod,
|
||||
nfc_target *pnt);
|
||||
bool pn53x_initiator_select_dep_target (nfc_device *pnd,
|
||||
bool pn53x_initiator_select_dep_target (struct nfc_device *pnd,
|
||||
const nfc_dep_mode ndm, const nfc_baud_rate nbr,
|
||||
const nfc_dep_info *pndiInitiator,
|
||||
nfc_target *pnt,
|
||||
const int timeout);
|
||||
bool pn53x_initiator_transceive_bits (nfc_device *pnd, const uint8_t *pbtTx, const size_t szTxBits,
|
||||
bool pn53x_initiator_transceive_bits (struct nfc_device *pnd, const uint8_t *pbtTx, const size_t szTxBits,
|
||||
const uint8_t *pbtTxPar, uint8_t *pbtRx, size_t *pszRxBits,
|
||||
uint8_t *pbtRxPar);
|
||||
bool pn53x_initiator_transceive_bytes (nfc_device *pnd, const uint8_t *pbtTx, const size_t szTx,
|
||||
bool pn53x_initiator_transceive_bytes (struct nfc_device *pnd, const uint8_t *pbtTx, const size_t szTx,
|
||||
uint8_t *pbtRx, size_t *pszRx, int timeout);
|
||||
bool pn53x_initiator_transceive_bits_timed (nfc_device *pnd, const uint8_t *pbtTx, const size_t szTxBits,
|
||||
bool pn53x_initiator_transceive_bits_timed (struct nfc_device *pnd, const uint8_t *pbtTx, const size_t szTxBits,
|
||||
const uint8_t *pbtTxPar, uint8_t *pbtRx, size_t *pszRxBits,
|
||||
uint8_t *pbtRxPar, uint32_t *cycles);
|
||||
bool pn53x_initiator_transceive_bytes_timed (nfc_device *pnd, const uint8_t *pbtTx, const size_t szTx,
|
||||
bool pn53x_initiator_transceive_bytes_timed (struct nfc_device *pnd, const uint8_t *pbtTx, const size_t szTx,
|
||||
uint8_t *pbtRx, size_t *pszRx, uint32_t *cycles);
|
||||
bool pn53x_initiator_deselect_target (nfc_device *pnd);
|
||||
bool pn53x_initiator_deselect_target (struct nfc_device *pnd);
|
||||
|
||||
// NFC device as Target functions
|
||||
bool pn53x_target_init (nfc_device *pnd, nfc_target *pnt, uint8_t *pbtRx, size_t *pszRx);
|
||||
bool pn53x_target_receive_bits (nfc_device *pnd, uint8_t *pbtRx, size_t *pszRxBits, uint8_t *pbtRxPar);
|
||||
bool pn53x_target_receive_bytes (nfc_device *pnd, uint8_t *pbtRx, size_t *pszRx, int timeout);
|
||||
bool pn53x_target_send_bits (nfc_device *pnd, const uint8_t *pbtTx, const size_t szTxBits, const uint8_t *pbtTxPar);
|
||||
bool pn53x_target_send_bytes (nfc_device *pnd, const uint8_t *pbtTx, const size_t szTx, int timeout);
|
||||
bool pn53x_target_init (struct nfc_device *pnd, nfc_target *pnt, uint8_t *pbtRx, size_t *pszRx);
|
||||
bool pn53x_target_receive_bits (struct nfc_device *pnd, uint8_t *pbtRx, size_t *pszRxBits, uint8_t *pbtRxPar);
|
||||
bool pn53x_target_receive_bytes (struct nfc_device *pnd, uint8_t *pbtRx, size_t *pszRx, int timeout);
|
||||
bool pn53x_target_send_bits (struct nfc_device *pnd, const uint8_t *pbtTx, const size_t szTxBits, const uint8_t *pbtTxPar);
|
||||
bool pn53x_target_send_bytes (struct nfc_device *pnd, const uint8_t *pbtTx, const size_t szTx, int timeout);
|
||||
|
||||
// Error handling functions
|
||||
const char *pn53x_strerror (const nfc_device *pnd);
|
||||
const char *pn53x_strerror (const struct nfc_device *pnd);
|
||||
|
||||
// C wrappers for PN53x commands
|
||||
bool pn53x_SetParameters (nfc_device *pnd, const uint8_t ui8Value);
|
||||
bool pn53x_SAMConfiguration (nfc_device *pnd, const pn532_sam_mode mode, int timeout);
|
||||
bool pn53x_PowerDown (nfc_device *pnd);
|
||||
bool pn53x_InListPassiveTarget (nfc_device *pnd, const pn53x_modulation pmInitModulation,
|
||||
bool pn53x_SetParameters (struct nfc_device *pnd, const uint8_t ui8Value);
|
||||
bool pn53x_SAMConfiguration (struct nfc_device *pnd, const pn532_sam_mode mode, int timeout);
|
||||
bool pn53x_PowerDown (struct nfc_device *pnd);
|
||||
bool pn53x_InListPassiveTarget (struct nfc_device *pnd, const pn53x_modulation pmInitModulation,
|
||||
const uint8_t szMaxTargets, const uint8_t *pbtInitiatorData,
|
||||
const size_t szInitiatorDataLen, uint8_t *pbtTargetsData, size_t *pszTargetsData,
|
||||
int timeout);
|
||||
bool pn53x_InDeselect (nfc_device *pnd, const uint8_t ui8Target);
|
||||
bool pn53x_InRelease (nfc_device *pnd, const uint8_t ui8Target);
|
||||
bool pn53x_InAutoPoll (nfc_device *pnd, const pn53x_target_type *ppttTargetTypes, const size_t szTargetTypes,
|
||||
bool pn53x_InDeselect (struct nfc_device *pnd, const uint8_t ui8Target);
|
||||
bool pn53x_InRelease (struct nfc_device *pnd, const uint8_t ui8Target);
|
||||
bool pn53x_InAutoPoll (struct nfc_device *pnd, const pn53x_target_type *ppttTargetTypes, const size_t szTargetTypes,
|
||||
const uint8_t btPollNr, const uint8_t btPeriod, nfc_target *pntTargets,
|
||||
size_t *pszTargetFound,
|
||||
const int timeout);
|
||||
bool pn53x_InJumpForDEP (nfc_device *pnd,
|
||||
bool pn53x_InJumpForDEP (struct nfc_device *pnd,
|
||||
const nfc_dep_mode ndm, const nfc_baud_rate nbr,
|
||||
const uint8_t *pbtPassiveInitiatorData,
|
||||
const uint8_t *pbtNFCID3i,
|
||||
const uint8_t *pbtGB, const size_t szGB,
|
||||
nfc_target *pnt,
|
||||
const int timeout);
|
||||
bool pn53x_TgInitAsTarget (nfc_device *pnd, pn53x_target_mode ptm,
|
||||
bool pn53x_TgInitAsTarget (struct nfc_device *pnd, pn53x_target_mode ptm,
|
||||
const uint8_t *pbtMifareParams,
|
||||
const uint8_t *pbtTkt, size_t szTkt,
|
||||
const uint8_t *pbtFeliCaParams,
|
||||
|
|
@ -348,17 +350,17 @@ bool pn53x_TgInitAsTarget (nfc_device *pnd, pn53x_target_mode ptm,
|
|||
uint8_t *pbtRx, size_t *pszRx, uint8_t *pbtModeByte);
|
||||
|
||||
// RFConfiguration
|
||||
bool pn53x_RFConfiguration__RF_field (nfc_device *pnd, bool bEnable);
|
||||
bool pn53x_RFConfiguration__Various_timings (nfc_device *pnd, const uint8_t fATR_RES_Timeout, const uint8_t fRetryTimeout);
|
||||
bool pn53x_RFConfiguration__MaxRtyCOM (nfc_device *pnd, const uint8_t MaxRtyCOM);
|
||||
bool pn53x_RFConfiguration__MaxRetries (nfc_device *pnd, const uint8_t MxRtyATR, const uint8_t MxRtyPSL, const uint8_t MxRtyPassiveActivation);
|
||||
bool pn53x_RFConfiguration__RF_field (struct nfc_device *pnd, bool bEnable);
|
||||
bool pn53x_RFConfiguration__Various_timings (struct nfc_device *pnd, const uint8_t fATR_RES_Timeout, const uint8_t fRetryTimeout);
|
||||
bool pn53x_RFConfiguration__MaxRtyCOM (struct nfc_device *pnd, const uint8_t MaxRtyCOM);
|
||||
bool pn53x_RFConfiguration__MaxRetries (struct nfc_device *pnd, const uint8_t MxRtyATR, const uint8_t MxRtyPSL, const uint8_t MxRtyPassiveActivation);
|
||||
|
||||
// Misc
|
||||
bool pn53x_check_ack_frame (nfc_device *pnd, const uint8_t *pbtRxFrame, const size_t szRxFrameLen);
|
||||
bool pn53x_check_error_frame (nfc_device *pnd, const uint8_t *pbtRxFrame, const size_t szRxFrameLen);
|
||||
bool pn53x_check_ack_frame (struct nfc_device *pnd, const uint8_t *pbtRxFrame, const size_t szRxFrameLen);
|
||||
bool pn53x_check_error_frame (struct nfc_device *pnd, const uint8_t *pbtRxFrame, const size_t szRxFrameLen);
|
||||
bool pn53x_build_frame (uint8_t *pbtFrame, size_t *pszFrame, const uint8_t *pbtData, const size_t szData);
|
||||
|
||||
void pn53x_data_new (nfc_device *pnd, const struct pn53x_io *io);
|
||||
void pn53x_data_free (nfc_device *pnd);
|
||||
void pn53x_data_new (struct nfc_device *pnd, const struct pn53x_io *io);
|
||||
void pn53x_data_free (struct nfc_device *pnd);
|
||||
|
||||
#endif // __NFC_CHIPS_PN53X_H__
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue