Massive code clean up: (Fixes Issue 161)
- Remove typedef from internal structs - Remove _t suffix from types - Fix tests using connstrings
This commit is contained in:
parent
55daa29a7c
commit
c718fafee7
47 changed files with 546 additions and 533 deletions
|
|
@ -127,8 +127,8 @@ typedef enum {
|
|||
} pn53x_operating_mode;
|
||||
|
||||
struct pn53x_io {
|
||||
bool (*send)(nfc_device_t * pnd, const byte_t * pbtData, const size_t szData, struct timeval *timeout);
|
||||
int (*receive)(nfc_device_t * pnd, byte_t * pbtData, const size_t szDataLen, struct timeval *timeout);
|
||||
bool (*send)(nfc_device * pnd, const byte_t * pbtData, const size_t szData, struct timeval *timeout);
|
||||
int (*receive)(nfc_device * pnd, byte_t * pbtData, const size_t szDataLen, struct timeval *timeout);
|
||||
};
|
||||
|
||||
/* defines */
|
||||
|
|
@ -143,7 +143,7 @@ struct pn53x_data {
|
|||
/** Current operating mode */
|
||||
pn53x_operating_mode operating_mode;
|
||||
/** Current emulated target */
|
||||
nfc_target_t* current_target;
|
||||
nfc_target* current_target;
|
||||
/** PN53x I/O functions stored in struct */
|
||||
const struct pn53x_io * io;
|
||||
/** 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 */
|
||||
|
|
@ -165,7 +165,7 @@ struct pn53x_data {
|
|||
#define CHIP_DATA(pnd) ((struct pn53x_data*)(pnd->chip_data))
|
||||
|
||||
/**
|
||||
* @enum pn53x_modulation_t
|
||||
* @enum pn53x_modulation
|
||||
* @brief NFC modulation
|
||||
*/
|
||||
typedef enum {
|
||||
|
|
@ -187,10 +187,10 @@ typedef enum {
|
|||
PM_ISO14443B_424 = 0x07,
|
||||
/** ISO14443-B http://en.wikipedia.org/wiki/ISO/IEC_14443 (Not supported by PN531 nor PN532) */
|
||||
PM_ISO14443B_847 = 0x08,
|
||||
} pn53x_modulation_t;
|
||||
} pn53x_modulation;
|
||||
|
||||
/**
|
||||
* @enum pn53x_target_type_t
|
||||
* @enum pn53x_target_type
|
||||
* @brief NFC target type enumeration
|
||||
*/
|
||||
typedef enum {
|
||||
|
|
@ -228,7 +228,7 @@ typedef enum {
|
|||
PTT_DEP_ACTIVE_212 = 0x81,
|
||||
/** DEP active 424 kbps */
|
||||
PTT_DEP_ACTIVE_424 = 0x82,
|
||||
} pn53x_target_type_t;
|
||||
} pn53x_target_type;
|
||||
|
||||
typedef enum {
|
||||
PSM_NORMAL = 0x01,
|
||||
|
|
@ -238,7 +238,7 @@ typedef enum {
|
|||
} pn532_sam_mode;
|
||||
|
||||
/**
|
||||
* @enum pn53x_target_mode_t
|
||||
* @enum pn53x_target_mode
|
||||
* @brief PN53x target mode enumeration
|
||||
*/
|
||||
typedef enum {
|
||||
|
|
@ -250,86 +250,86 @@ typedef enum {
|
|||
PTM_DEP_ONLY = 0x02,
|
||||
/** Configure the PN532 to accept to be initialized only as ISO/IEC14443-4 PICC */
|
||||
PTM_ISO14443_4_PICC_ONLY = 0x04
|
||||
} pn53x_target_mode_t;
|
||||
} pn53x_target_mode;
|
||||
|
||||
extern const byte_t pn53x_ack_frame[6];
|
||||
extern const byte_t pn53x_nack_frame[6];
|
||||
|
||||
bool pn53x_init(nfc_device_t * pnd);
|
||||
bool pn53x_transceive (nfc_device_t * pnd, const byte_t * pbtTx, const size_t szTx, byte_t * pbtRx, size_t *pszRx, struct timeval *timeout);
|
||||
bool pn53x_init(nfc_device * pnd);
|
||||
bool pn53x_transceive (nfc_device * pnd, const byte_t * pbtTx, const size_t szTx, byte_t * pbtRx, size_t *pszRx, struct timeval *timeout);
|
||||
|
||||
bool pn53x_set_parameters (nfc_device_t * pnd, const uint8_t ui8Value, const bool bEnable);
|
||||
bool pn53x_set_tx_bits (nfc_device_t * pnd, const uint8_t ui8Bits);
|
||||
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_wrap_frame (const byte_t * pbtTx, const size_t szTxBits, const byte_t * pbtTxPar, byte_t * pbtFrame,
|
||||
size_t * pszFrameBits);
|
||||
bool pn53x_unwrap_frame (const byte_t * pbtFrame, const size_t szFrameBits, byte_t * pbtRx, size_t * pszRxBits,
|
||||
byte_t * pbtRxPar);
|
||||
bool pn53x_decode_target_data (const byte_t * pbtRawData, size_t szRawData,
|
||||
pn53x_type chip_type, nfc_modulation_type_t nmt,
|
||||
nfc_target_info_t * pnti);
|
||||
bool pn53x_read_register (nfc_device_t * pnd, uint16_t ui16Reg, uint8_t * ui8Value);
|
||||
bool pn53x_write_register (nfc_device_t * pnd, uint16_t ui16Reg, uint8_t ui8SymbolMask, uint8_t ui8Value);
|
||||
bool pn53x_get_firmware_version (nfc_device_t * pnd, char abtFirmwareText[22]);
|
||||
bool pn53x_configure (nfc_device_t * pnd, const nfc_device_option_t ndo, const bool bEnable);
|
||||
bool pn53x_check_communication (nfc_device_t *pnd);
|
||||
bool pn53x_idle (nfc_device_t * pnd);
|
||||
pn53x_type chip_type, nfc_modulationype 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]);
|
||||
bool pn53x_configure (nfc_device * pnd, const nfc_device_option ndo, const bool bEnable);
|
||||
bool pn53x_check_communication (nfc_device *pnd);
|
||||
bool pn53x_idle (nfc_device * pnd);
|
||||
|
||||
// NFC device as Initiator functions
|
||||
bool pn53x_initiator_init (nfc_device_t * pnd);
|
||||
bool pn53x_initiator_select_passive_target (nfc_device_t * pnd,
|
||||
const nfc_modulation_t nm,
|
||||
bool pn53x_initiator_init (nfc_device * pnd);
|
||||
bool pn53x_initiator_select_passive_target (nfc_device * pnd,
|
||||
const nfc_modulation nm,
|
||||
const byte_t * pbtInitData, const size_t szInitData,
|
||||
nfc_target_t * pnt);
|
||||
bool pn53x_initiator_poll_target (nfc_device_t * pnd,
|
||||
const nfc_modulation_t * pnmModulations, const size_t szModulations,
|
||||
nfc_target * pnt);
|
||||
bool pn53x_initiator_poll_target (nfc_device * pnd,
|
||||
const nfc_modulation * pnmModulations, const size_t szModulations,
|
||||
const uint8_t uiPollNr, const uint8_t uiPeriod,
|
||||
nfc_target_t * pnt);
|
||||
bool pn53x_initiator_select_dep_target (nfc_device_t * pnd,
|
||||
const nfc_dep_mode_t ndm, const nfc_baud_rate_t nbr,
|
||||
const nfc_dep_info_t * pndiInitiator,
|
||||
nfc_target_t * pnt);
|
||||
bool pn53x_initiator_transceive_bits (nfc_device_t * pnd, const byte_t * pbtTx, const size_t szTxBits,
|
||||
nfc_target * pnt);
|
||||
bool pn53x_initiator_select_dep_target (nfc_device * pnd,
|
||||
const nfc_dep_mode ndm, const nfc_baud_rate nbr,
|
||||
const nfc_dep_info * pndiInitiator,
|
||||
nfc_target * pnt);
|
||||
bool pn53x_initiator_transceive_bits (nfc_device * pnd, const byte_t * pbtTx, const size_t szTxBits,
|
||||
const byte_t * pbtTxPar, byte_t * pbtRx, size_t * pszRxBits,
|
||||
byte_t * pbtRxPar);
|
||||
bool pn53x_initiator_transceive_bytes (nfc_device_t * pnd, const byte_t * pbtTx, const size_t szTx,
|
||||
bool pn53x_initiator_transceive_bytes (nfc_device * pnd, const byte_t * pbtTx, const size_t szTx,
|
||||
byte_t * pbtRx, size_t * pszRx, struct timeval *timeout);
|
||||
bool pn53x_initiator_transceive_bits_timed (nfc_device_t * pnd, const byte_t * pbtTx, const size_t szTxBits,
|
||||
bool pn53x_initiator_transceive_bits_timed (nfc_device * pnd, const byte_t * pbtTx, const size_t szTxBits,
|
||||
const byte_t * pbtTxPar, byte_t * pbtRx, size_t * pszRxBits,
|
||||
byte_t * pbtRxPar, uint32_t * cycles);
|
||||
bool pn53x_initiator_transceive_bytes_timed (nfc_device_t * pnd, const byte_t * pbtTx, const size_t szTx,
|
||||
bool pn53x_initiator_transceive_bytes_timed (nfc_device * pnd, const byte_t * pbtTx, const size_t szTx,
|
||||
byte_t * pbtRx, size_t * pszRx, uint32_t * cycles);
|
||||
bool pn53x_initiator_deselect_target (nfc_device_t * pnd);
|
||||
bool pn53x_initiator_deselect_target (nfc_device * pnd);
|
||||
|
||||
// NFC device as Target functions
|
||||
bool pn53x_target_init (nfc_device_t * pnd, nfc_target_t * pnt, byte_t * pbtRx, size_t * pszRx);
|
||||
bool pn53x_target_receive_bits (nfc_device_t * pnd, byte_t * pbtRx, size_t * pszRxBits, byte_t * pbtRxPar);
|
||||
bool pn53x_target_receive_bytes (nfc_device_t * pnd, byte_t * pbtRx, size_t * pszRx, struct timeval *timeout);
|
||||
bool pn53x_target_send_bits (nfc_device_t * pnd, const byte_t * pbtTx, const size_t szTxBits, const byte_t * pbtTxPar);
|
||||
bool pn53x_target_send_bytes (nfc_device_t * pnd, const byte_t * pbtTx, const size_t szTx, struct timeval *timeout);
|
||||
bool pn53x_target_init (nfc_device * pnd, nfc_target * pnt, byte_t * pbtRx, size_t * pszRx);
|
||||
bool pn53x_target_receive_bits (nfc_device * pnd, byte_t * pbtRx, size_t * pszRxBits, byte_t * pbtRxPar);
|
||||
bool pn53x_target_receive_bytes (nfc_device * pnd, byte_t * pbtRx, size_t * pszRx, struct timeval *timeout);
|
||||
bool pn53x_target_send_bits (nfc_device * pnd, const byte_t * pbtTx, const size_t szTxBits, const byte_t * pbtTxPar);
|
||||
bool pn53x_target_send_bytes (nfc_device * pnd, const byte_t * pbtTx, const size_t szTx, struct timeval *timeout);
|
||||
|
||||
// Error handling functions
|
||||
const char *pn53x_strerror (const nfc_device_t * pnd);
|
||||
const char *pn53x_strerror (const nfc_device * pnd);
|
||||
|
||||
// C wrappers for PN53x commands
|
||||
bool pn53x_SetParameters (nfc_device_t * pnd, const uint8_t ui8Value);
|
||||
bool pn53x_SAMConfiguration (nfc_device_t * pnd, const pn532_sam_mode mode, struct timeval *timeout);
|
||||
bool pn53x_PowerDown (nfc_device_t * pnd);
|
||||
bool pn53x_InListPassiveTarget (nfc_device_t * pnd, const pn53x_modulation_t pmInitModulation,
|
||||
bool pn53x_SetParameters (nfc_device * pnd, const uint8_t ui8Value);
|
||||
bool pn53x_SAMConfiguration (nfc_device * pnd, const pn532_sam_mode mode, struct timeval *timeout);
|
||||
bool pn53x_PowerDown (nfc_device * pnd);
|
||||
bool pn53x_InListPassiveTarget (nfc_device * pnd, const pn53x_modulation pmInitModulation,
|
||||
const byte_t szMaxTargets, const byte_t * pbtInitiatorData,
|
||||
const size_t szInitiatorDataLen, byte_t * pbtTargetsData, size_t * pszTargetsData,
|
||||
struct timeval *timeout);
|
||||
bool pn53x_InDeselect (nfc_device_t * pnd, const uint8_t ui8Target);
|
||||
bool pn53x_InRelease (nfc_device_t * pnd, const uint8_t ui8Target);
|
||||
bool pn53x_InAutoPoll (nfc_device_t * pnd, const pn53x_target_type_t * ppttTargetTypes, const size_t szTargetTypes,
|
||||
const byte_t btPollNr, const byte_t btPeriod, nfc_target_t * pntTargets,
|
||||
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,
|
||||
const byte_t btPollNr, const byte_t btPeriod, nfc_target * pntTargets,
|
||||
size_t * pszTargetFound);
|
||||
bool pn53x_InJumpForDEP (nfc_device_t * pnd,
|
||||
const nfc_dep_mode_t ndm, const nfc_baud_rate_t nbr,
|
||||
bool pn53x_InJumpForDEP (nfc_device * pnd,
|
||||
const nfc_dep_mode ndm, const nfc_baud_rate nbr,
|
||||
const byte_t * pbtPassiveInitiatorData,
|
||||
const byte_t * pbtNFCID3i,
|
||||
const byte_t * pbtGB, const size_t szGB,
|
||||
nfc_target_t * pnt);
|
||||
bool pn53x_TgInitAsTarget (nfc_device_t * pnd, pn53x_target_mode_t ptm,
|
||||
nfc_target * pnt);
|
||||
bool pn53x_TgInitAsTarget (nfc_device * pnd, pn53x_target_mode ptm,
|
||||
const byte_t * pbtMifareParams,
|
||||
const byte_t * pbtTkt, size_t szTkt,
|
||||
const byte_t * pbtFeliCaParams,
|
||||
|
|
@ -337,17 +337,17 @@ bool pn53x_TgInitAsTarget (nfc_device_t * pnd, pn53x_target_mode_t ptm,
|
|||
byte_t * pbtRx, size_t * pszRx, byte_t * pbtModeByte);
|
||||
|
||||
// RFConfiguration
|
||||
bool pn53x_RFConfiguration__RF_field (nfc_device_t * pnd, bool bEnable);
|
||||
bool pn53x_RFConfiguration__Various_timings (nfc_device_t * pnd, const uint8_t fATR_RES_Timeout, const uint8_t fRetryTimeout);
|
||||
bool pn53x_RFConfiguration__MaxRtyCOM (nfc_device_t * pnd, const uint8_t MaxRtyCOM);
|
||||
bool pn53x_RFConfiguration__MaxRetries (nfc_device_t * pnd, const uint8_t MxRtyATR, const uint8_t MxRtyPSL, const uint8_t MxRtyPassiveActivation);
|
||||
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);
|
||||
|
||||
// Misc
|
||||
bool pn53x_check_ack_frame (nfc_device_t * pnd, const byte_t * pbtRxFrame, const size_t szRxFrameLen);
|
||||
bool pn53x_check_error_frame (nfc_device_t * pnd, const byte_t * pbtRxFrame, const size_t szRxFrameLen);
|
||||
bool pn53x_check_ack_frame (nfc_device * pnd, const byte_t * pbtRxFrame, const size_t szRxFrameLen);
|
||||
bool pn53x_check_error_frame (nfc_device * pnd, const byte_t * pbtRxFrame, const size_t szRxFrameLen);
|
||||
bool pn53x_build_frame (byte_t * pbtFrame, size_t * pszFrame, const byte_t * pbtData, const size_t szData);
|
||||
|
||||
void pn53x_data_new (nfc_device_t * pnd, const struct pn53x_io* io);
|
||||
void pn53x_data_free (nfc_device_t * pnd);
|
||||
void pn53x_data_new (nfc_device * pnd, const struct pn53x_io* io);
|
||||
void pn53x_data_free (nfc_device * pnd);
|
||||
|
||||
#endif // __NFC_CHIPS_PN53X_H__
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue