Improve API for target emulation, nfc_target_mode_t does not exist anymore (this mode is computed from nfc_target_t)
This commit is contained in:
parent
1e52e1dc9f
commit
1f62e9e2f2
12 changed files with 163 additions and 108 deletions
|
|
@ -70,6 +70,8 @@ typedef struct {
|
|||
bool bPar;
|
||||
/** Should the PN53x chip handle frames encapsulation and chaining */
|
||||
bool bEasyFraming;
|
||||
/** Should the PN53x chip switch automatically in ISO14443-4 when ISO14443 */
|
||||
bool bAutoIso14443_4;
|
||||
/** 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. */
|
||||
|
|
@ -143,21 +145,51 @@ struct driver_callbacks {
|
|||
* @brief NFC device option
|
||||
*/
|
||||
typedef enum {
|
||||
/** Let the PN53X chip handle the CRC bytes. This means that the chip appends the CRC bytes to the frames that are transmitted. It will parse the last bytes from received frames as incoming CRC bytes. They will be verified against the used modulation and protocol. If an frame is expected with incorrect CRC bytes this option should be disabled. Example frames where this is useful are the ATQA and UID+BCC that are transmitted without CRC bytes during the anti-collision phase of the ISO14443-A protocol. */
|
||||
/** Let the PN53X chip handle the CRC bytes. This means that the chip appends
|
||||
* the CRC bytes to the frames that are transmitted. It will parse the last
|
||||
* bytes from received frames as incoming CRC bytes. They will be verified
|
||||
* against the used modulation and protocol. If an frame is expected with
|
||||
* incorrect CRC bytes this option should be disabled. Example frames where
|
||||
* this is useful are the ATQA and UID+BCC that are transmitted without CRC
|
||||
* bytes during the anti-collision phase of the ISO14443-A protocol. */
|
||||
NDO_HANDLE_CRC = 0x00,
|
||||
/** Parity bits in the network layer of ISO14443-A are by default generated and validated in the PN53X chip. This is a very convenient feature. On certain times though it is useful to get full control of the transmitted data. The proprietary MIFARE Classic protocol uses for example custom (encrypted) parity bits. For interoperability it is required to be completely compatible, including the arbitrary parity bits. When this option is disabled, the functions to communicating bits should be used. */
|
||||
/** Parity bits in the network layer of ISO14443-A are by default generated and
|
||||
* validated in the PN53X chip. This is a very convenient feature. On certain
|
||||
* times though it is useful to get full control of the transmitted data. The
|
||||
* proprietary MIFARE Classic protocol uses for example custom (encrypted)
|
||||
* parity bits. For interoperability it is required to be completely
|
||||
* compatible, including the arbitrary parity bits. When this option is
|
||||
* disabled, the functions to communicating bits should be used. */
|
||||
NDO_HANDLE_PARITY = 0x01,
|
||||
/** This option can be used to enable or disable the electronic field of the NFC device. */
|
||||
/** This option can be used to enable or disable the electronic field of the
|
||||
* NFC device. */
|
||||
NDO_ACTIVATE_FIELD = 0x10,
|
||||
/** The internal CRYPTO1 co-processor can be used to transmit messages encrypted. This option is automatically activated after a successful MIFARE Classic authentication. */
|
||||
/** The internal CRYPTO1 co-processor can be used to transmit messages
|
||||
* encrypted. This option is automatically activated after a successful MIFARE
|
||||
* Classic authentication. */
|
||||
NDO_ACTIVATE_CRYPTO1 = 0x11,
|
||||
/** The default configuration defines that the PN53X chip will try indefinitely to invite a tag in the field to respond. This could be desired when it is certain a tag will enter the field. On the other hand, when this is uncertain, it will block the application. This option could best be compared to the (NON)BLOCKING option used by (socket)network programming. */
|
||||
/** The default configuration defines that the PN53X chip will try indefinitely
|
||||
* to invite a tag in the field to respond. This could be desired when it is
|
||||
* certain a tag will enter the field. On the other hand, when this is
|
||||
* uncertain, it will block the application. This option could best be compared
|
||||
* to the (NON)BLOCKING option used by (socket)network programming. */
|
||||
NDO_INFINITE_SELECT = 0x20,
|
||||
/** If this option is enabled, frames that carry less than 4 bits are allowed. According to the standards these frames should normally be handles as invalid frames. */
|
||||
/** If this option is enabled, frames that carry less than 4 bits are allowed.
|
||||
* According to the standards these frames should normally be handles as
|
||||
* invalid frames. */
|
||||
NDO_ACCEPT_INVALID_FRAMES = 0x30,
|
||||
/** If the NFC device should only listen to frames, it could be useful to let it gather multiple frames in a sequence. They will be stored in the internal FIFO of the PN53X chip. This could be retrieved by using the receive data functions. Note that if the chip runs out of bytes (FIFO = 64 bytes long), it will overwrite the first received frames, so quick retrieving of the received data is desirable. */
|
||||
/** If the NFC device should only listen to frames, it could be useful to let
|
||||
* it gather multiple frames in a sequence. They will be stored in the internal
|
||||
* FIFO of the PN53X chip. This could be retrieved by using the receive data
|
||||
* functions. Note that if the chip runs out of bytes (FIFO = 64 bytes long),
|
||||
* it will overwrite the first received frames, so quick retrieving of the
|
||||
* received data is desirable. */
|
||||
NDO_ACCEPT_MULTIPLE_FRAMES = 0x31,
|
||||
/** This option can be used to enable or disable the auto-switching mode to ISO14443-4 is device is compliant */
|
||||
/** This option can be used to enable or disable the auto-switching mode to
|
||||
* ISO14443-4 is device is compliant.
|
||||
* In initiator mode, it means that NFC chip will send RATS automatically.
|
||||
* In target mode, with a NFC chip compiliant (ie. PN532), the chip will
|
||||
* emulate a 14443-4 PICC using hardware capability */
|
||||
NDO_AUTO_ISO14443_4 = 0x40,
|
||||
/** Use automatic frames encapsulation and chaining. */
|
||||
NDO_EASY_FRAMING = 0x41,
|
||||
|
|
@ -165,6 +197,16 @@ typedef enum {
|
|||
NDO_FORCE_ISO14443_A = 0x42,
|
||||
} nfc_device_option_t;
|
||||
|
||||
/**
|
||||
* @enum nfc_dep_mode_t
|
||||
* @brief NFC D.E.P. (Data Exchange Protocol) active/passive mode
|
||||
*/
|
||||
typedef enum {
|
||||
NDM_UNDEFINED = 0,
|
||||
NDM_PASSIVE,
|
||||
NDM_ACTIVE,
|
||||
} nfc_dep_mode_t;
|
||||
|
||||
/**
|
||||
* @struct nfc_dep_info_t
|
||||
* @brief NFC target information in D.E.P. (Data Exchange Protocol) see ISO/IEC 18092 (NFCIP-1)
|
||||
|
|
@ -185,17 +227,10 @@ typedef struct {
|
|||
/** General Bytes */
|
||||
byte_t abtGB[48];
|
||||
size_t szGB;
|
||||
/** DEP mode */
|
||||
nfc_dep_mode_t ndm;
|
||||
} nfc_dep_info_t;
|
||||
|
||||
/**
|
||||
* @enum nfc_dep_mode_t
|
||||
* @brief NFC D.E.P. (Data Exchange Protocol) active/passive mode
|
||||
*/
|
||||
typedef enum {
|
||||
NDM_PASSIVE,
|
||||
NDM_ACTIVE,
|
||||
} nfc_dep_mode_t;
|
||||
|
||||
/**
|
||||
* @struct nfc_iso14443a_info_t
|
||||
* @brief NFC ISO14443A tag (MIFARE) information
|
||||
|
|
@ -257,21 +292,6 @@ typedef union {
|
|||
nfc_dep_info_t ndi;
|
||||
} nfc_target_info_t;
|
||||
|
||||
/**
|
||||
* @enum nfc_target_mode_t
|
||||
* @brief NFC target type enumeration
|
||||
*/
|
||||
typedef enum {
|
||||
/** Configure the PN53x to accept all initiator mode */
|
||||
NTM_NORMAL = 0x00,
|
||||
/** Configure the PN53x to accept to be initialized only in passive mode */
|
||||
NTM_PASSIVE_ONLY = 0x01,
|
||||
/** Configure the PN53x to accept to be initialized only as DEP target */
|
||||
NTM_DEP_ONLY = 0x02,
|
||||
/** Configure the PN532 to accept to be initialized only as ISO/IEC14443-4 PICC */
|
||||
NTM_ISO14443_4_PICC_ONLY = 0x04
|
||||
} nfc_target_mode_t;
|
||||
|
||||
/**
|
||||
* @enum nfc_baud_rate_t
|
||||
* @brief NFC baud rate enumeration
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue