Broke whole the libnfc :-)
use a new way to handle drivers use absolute include path instead of relative ones move some nfc_device_t members in a better place nfc_device_t now embeddeds driver data and chip data pointers (useful to be more generic) use more readable variables instead of strange coding convention move PRINT_HEX macro into nfc-internal.h silent warnings with more strict CFLAGS chips/pn53x: use the powerful C99 writing to construct PN53x commands chips/pn53x: remove almost all memcpy() chips/pn53x: WriteRegister, ReadRegister and SetParameters command wrappers are correctly named chips/pn53x: introduce chip state (SLEEP, NORMAL or EXECUTE) chips/pn53x: add SAMConfiguration command wrapper (need to be improved) chips/pn53x: remove almost all const arrays chips/pn53x: use human readable defines for commands instead of hex values chips/pn53x: in debug mode, the PN53x command is shown in human-readable string, awesome isn't it? ;-) drivers: split transceive() into send() and receive() to be able to handle more cases (differed replies, abort commands, etc) later drivers: use a const structure of functions instead of -dirty- callbacks array drivers/pn532_uart: major improvement of UART handling drivers/pn532_uart: check PN53x frames when received buses/uart: receive() is now based on expected bytes instead of calculated timeouts.. buses/uart: use a smart way to determine available ports on POSIX systems (tested on Linux and FreeBSD)
This commit is contained in:
parent
f1d909ae74
commit
5af845cdfc
20 changed files with 937 additions and 775 deletions
|
|
@ -1,7 +1,9 @@
|
|||
/*-
|
||||
* Public platform independent Near Field Communication (NFC) library
|
||||
*
|
||||
* Copyright (C) 2009, 2010, Roel Verdult, Romuald Conty
|
||||
* Copyright (C) 2009, Roel Verdult, Romuald Conty
|
||||
* Copyright (C) 2010, Roel Verdult, Romuald Conty, Romain Tartière
|
||||
* Copyright (C) 2011, Romuald Conty, Romain Tartière
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by the
|
||||
|
|
@ -27,11 +29,6 @@
|
|||
|
||||
# include <nfc/nfc-types.h>
|
||||
|
||||
# define PN53x_NORMAL_FRAME_MAX_LEN 255
|
||||
# define PN53x_NORMAL_FRAME_OVERHEAD 7
|
||||
# define PN53x_EXTENDED_FRAME_MAX_LEN 264
|
||||
# define PN53x_EXTENDED_FRAME_OVERHEAD 10
|
||||
|
||||
// Registers and symbols masks used to covers parts within a register
|
||||
# define REG_CIU_TX_MODE 0x6302
|
||||
# define SYMBOL_TX_CRC_ENABLE 0x80
|
||||
|
|
@ -98,6 +95,24 @@
|
|||
# define DEISERRFRAME 0x0300/* Error frame */
|
||||
# define DENOTSUP 0x0400/* Not supported */
|
||||
|
||||
typedef enum {
|
||||
PN531 = 0x01,
|
||||
PN532 = 0x02,
|
||||
PN533 = 0x04
|
||||
} pn53x_type;
|
||||
|
||||
typedef enum {
|
||||
SLEEP = 0x00, // Need to be wake up to process commands
|
||||
NORMAL = 0x01, // Ready to process command
|
||||
EXECUTE = 0x02, // Need to cancel the running command to process new one
|
||||
} pn53x_state;
|
||||
|
||||
struct pn53x_data {
|
||||
pn53x_type type;
|
||||
pn53x_state state;
|
||||
};
|
||||
|
||||
|
||||
/* PN53x specific types */
|
||||
/**
|
||||
* @enum pn53x_modulation_t
|
||||
|
|
@ -185,18 +200,17 @@ bool pn53x_check_ack_frame_callback (nfc_device_t * pnd, const byte_t * pbtRx
|
|||
const size_t szRxFrameLen);
|
||||
bool pn53x_check_error_frame_callback (nfc_device_t * pnd, const byte_t * pbtRxFrame,
|
||||
const size_t szRxFrameLen);
|
||||
bool pn53x_transceive (nfc_device_t * pnd, const byte_t * pbtTx, const size_t szTx, byte_t * pbtRx,
|
||||
size_t * pszRx);
|
||||
bool pn53x_get_reg (nfc_device_t * pnd, uint16_t ui16Reg, uint8_t * ui8Value);
|
||||
bool pn53x_set_reg (nfc_device_t * pnd, uint16_t ui16Reg, uint8_t ui8SymbolMask, uint8_t ui8Value);
|
||||
bool pn53x_set_parameter (nfc_device_t * pnd, const uint8_t ui8Value, const bool bEnable);
|
||||
bool pn53x_transceive (nfc_device_t * pnd, const byte_t * pbtTx, const size_t szTx, byte_t * pbtRx, size_t *pszRx, bool toto);
|
||||
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_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_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,
|
||||
nfc_chip_t nc, nfc_modulation_type_t nmt,
|
||||
pn53x_type chip_type, nfc_modulation_type_t nmt,
|
||||
nfc_target_info_t * pnti);
|
||||
bool pn53x_get_firmware_version (nfc_device_t * pnd, char abtFirmwareText[18]);
|
||||
bool pn53x_configure (nfc_device_t * pnd, const nfc_device_option_t ndo, const bool bEnable);
|
||||
|
|
@ -234,6 +248,7 @@ static const struct chip_callbacks pn53x_callbacks_list = {
|
|||
|
||||
// C wrappers for PN53x commands
|
||||
bool pn53x_SetParameters (nfc_device_t * pnd, const uint8_t ui8Value);
|
||||
bool pn53x_SAMConfiguration (nfc_device_t * pnd, const uint8_t ui8Mode);
|
||||
bool pn53x_InListPassiveTarget (nfc_device_t * pnd, const pn53x_modulation_t pmInitModulation,
|
||||
const byte_t szMaxTargets, const byte_t * pbtInitiatorData,
|
||||
const size_t szInitiatorDataLen, byte_t * pbtTargetsData, size_t * pszTargetsData);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue