nfc-anticol now works even after running another program that change the modulation (Fixes Issue 111) (Thanks to Phil for help).

This commit is contained in:
Romuald Conty 2010-09-23 16:03:05 +00:00
parent 868919107a
commit ccfd24a682
4 changed files with 37 additions and 2 deletions

View file

@ -167,6 +167,11 @@ main (int argc, char *argv[])
nfc_perror (pnd, "nfc_configure");
exit (EXIT_FAILURE);
}
// Force 14443-A mode
if (!nfc_configure (pnd, NDO_FORCE_ISO14443_A, true)) {
nfc_perror (pnd, "nfc_configure");
exit (EXIT_FAILURE);
}
// Enable field so more power consuming cards can power themselves up
if (!nfc_configure (pnd, NDO_ACTIVATE_FIELD, true)) {

View file

@ -162,6 +162,8 @@ typedef enum {
NDO_AUTO_ISO14443_4 = 0x40,
/** Use automatic frames encapsulation and chaining. */
NDO_EASY_FRAMING = 0x41,
/** Force the chip to switch in ISO14443-A */
NDO_FORCE_ISO14443_A = 0x42,
} nfc_device_option_t;
////////////////////////////////////////////////////////////////////

View file

@ -708,12 +708,26 @@ pn53x_configure (nfc_device_t * pnd, const nfc_device_option_t ndo, const bool b
case NDO_AUTO_ISO14443_4:
// TODO: PN53x parameters could not be read, so we have to buffered current value in order to prevent from configuration overwrite
// ATM, buffered current value is not needed due to a single usage of these parameters
btValue =
(bEnable) ? (SYMBOL_PARAM_fAutomaticRATS | SYMBOL_PARAM_fAutomaticATR_RES) : SYMBOL_PARAM_fAutomaticATR_RES;
btValue = (bEnable) ? (SYMBOL_PARAM_fAutomaticRATS | SYMBOL_PARAM_fAutomaticATR_RES) : SYMBOL_PARAM_fAutomaticATR_RES;
if (!pn53x_set_parameters (pnd, btValue))
return false;
return true;
break;
case NDO_FORCE_ISO14443_A:
if(!bEnable) {
// Nothing to do
return true;
}
// Force pn53x to be in ISO1444-A mode
if (!pn53x_set_reg (pnd, REG_CIU_TX_MODE, SYMBOL_TX_FRAMING, 0x00)) {
return false;
}
if (!pn53x_set_reg (pnd, REG_CIU_RX_MODE, SYMBOL_RX_FRAMING, 0x00)) {
return false;
}
return true;
break;
}
// When we reach this, the configuration is completed and succesful

View file

@ -32,21 +32,35 @@
// Registers and symbols masks used to covers parts within a register
# define REG_CIU_TX_MODE 0x6302
# define SYMBOL_TX_CRC_ENABLE 0x80
// TX_FRAMING bits explanation:
// 00 : ISO/IEC 14443A/MIFARE and Passive Communication mode 106 kbit/s
// 01 : Active Communication mode
// 10 : FeliCa and Passive Communication mode at 212 kbit/s and 424 kbit/s
// 11 : ISO/IEC 14443B
# define SYMBOL_TX_FRAMING 0x03
# define REG_CIU_RX_MODE 0x6303
# define SYMBOL_RX_CRC_ENABLE 0x80
# define SYMBOL_RX_NO_ERROR 0x08
# define SYMBOL_RX_MULTIPLE 0x04
// RX_FRAMING follow same scheme than TX_FRAMING
# define SYMBOL_RX_FRAMING 0x03
# define REG_CIU_TX_AUTO 0x6305
# define SYMBOL_FORCE_100_ASK 0x40
# define SYMBOL_AUTO_WAKE_UP 0x20
# define SYMBOL_INITIAL_RF_ON 0x04
# define REG_CIU_MANUAL_RCV 0x630D
# define SYMBOL_PARITY_DISABLE 0x10
# define REG_CIU_STATUS2 0x6338
# define SYMBOL_MF_CRYPTO1_ON 0x08
# define REG_CIU_CONTROL 0x633C
# define SYMBOL_INITIATOR 0x10
# define SYMBOL_RX_LAST_BITS 0x07
# define REG_CIU_BIT_FRAMING 0x633D
# define SYMBOL_TX_LAST_BITS 0x07