astyle --formatted --mode=c --indent=spaces=2 --indent-switches --indent-preprocessor --keep-one-line-blocks --max-instatement-indent=60
This commit is contained in:
parent
26569c2202
commit
a2cd236441
45 changed files with 1096 additions and 1082 deletions
|
|
@ -133,13 +133,13 @@ typedef enum {
|
|||
#else
|
||||
# define PNCMD( X, Y ) { X , Y, #X }
|
||||
# define PNCMD_TRACE( X ) do { \
|
||||
for (size_t i=0; i<(sizeof(pn53x_commands)/sizeof(pn53x_command)); i++) { \
|
||||
if ( X == pn53x_commands[i].ui8Code ) { \
|
||||
log_put( LOG_CATEGORY, NFC_PRIORITY_TRACE, "%s", pn53x_commands[i].abtCommandText ); \
|
||||
break; \
|
||||
} \
|
||||
} \
|
||||
} while(0)
|
||||
for (size_t i=0; i<(sizeof(pn53x_commands)/sizeof(pn53x_command)); i++) { \
|
||||
if ( X == pn53x_commands[i].ui8Code ) { \
|
||||
log_put( LOG_CATEGORY, NFC_PRIORITY_TRACE, "%s", pn53x_commands[i].abtCommandText ); \
|
||||
break; \
|
||||
} \
|
||||
} \
|
||||
} while(0)
|
||||
#endif
|
||||
|
||||
static const pn53x_command pn53x_commands[] = {
|
||||
|
|
@ -214,16 +214,16 @@ typedef struct {
|
|||
|
||||
#ifndef LOGGING
|
||||
# define PNREG_TRACE( X ) do { \
|
||||
} while(0)
|
||||
} while(0)
|
||||
#else
|
||||
# define PNREG_TRACE( X ) do { \
|
||||
for (size_t i=0; i<(sizeof(pn53x_registers)/sizeof(pn53x_register)); i++) { \
|
||||
if ( X == pn53x_registers[i].ui16Address ) { \
|
||||
log_put( LOG_CATEGORY, NFC_PRIORITY_TRACE, "%s (%s)", pn53x_registers[i].abtRegisterText, pn53x_registers[i].abtRegisterDescription ); \
|
||||
break; \
|
||||
} \
|
||||
} \
|
||||
} while(0)
|
||||
for (size_t i=0; i<(sizeof(pn53x_registers)/sizeof(pn53x_register)); i++) { \
|
||||
if ( X == pn53x_registers[i].ui16Address ) { \
|
||||
log_put( LOG_CATEGORY, NFC_PRIORITY_TRACE, "%s (%s)", pn53x_registers[i].abtRegisterText, pn53x_registers[i].abtRegisterDescription ); \
|
||||
break; \
|
||||
} \
|
||||
} \
|
||||
} while(0)
|
||||
#endif
|
||||
|
||||
// Register addresses
|
||||
|
|
|
|||
|
|
@ -271,9 +271,9 @@ pn53x_transceive (struct nfc_device *pnd, const uint8_t *pbtTx, const size_t szT
|
|||
res = NFC_ECHIP;
|
||||
break;
|
||||
};
|
||||
/*
|
||||
{ EMFAUTH, "Mifare Authentication Error" },
|
||||
*/
|
||||
/*
|
||||
{ EMFAUTH, "Mifare Authentication Error" },
|
||||
*/
|
||||
|
||||
if (res < 0) {
|
||||
pnd->last_error = res;
|
||||
|
|
@ -551,7 +551,7 @@ pn53x_decode_target_data (const uint8_t *pbtRawData, size_t szRawData, pn53x_typ
|
|||
pbtRawData += 2;
|
||||
memcpy (pnti->nji.btId, pbtRawData, 4);
|
||||
break;
|
||||
// Should not happend...
|
||||
// Should not happend...
|
||||
case NMT_DEP:
|
||||
return NFC_ECHIP;
|
||||
break;
|
||||
|
|
@ -763,16 +763,16 @@ pn53x_set_property_int (struct nfc_device *pnd, const nfc_property property, con
|
|||
switch (property) {
|
||||
case NP_TIMEOUT_COMMAND:
|
||||
CHIP_DATA (pnd)->timeout_command = value;
|
||||
break;
|
||||
break;
|
||||
case NP_TIMEOUT_ATR:
|
||||
CHIP_DATA (pnd)->timeout_atr = value;
|
||||
return pn53x_RFConfiguration__Various_timings (pnd, pn53x_int_to_timeout(CHIP_DATA (pnd)->timeout_atr), pn53x_int_to_timeout(CHIP_DATA (pnd)->timeout_communication));
|
||||
break;
|
||||
break;
|
||||
case NP_TIMEOUT_COM:
|
||||
CHIP_DATA (pnd)->timeout_communication = value;
|
||||
return pn53x_RFConfiguration__Various_timings (pnd, pn53x_int_to_timeout(CHIP_DATA (pnd)->timeout_atr), pn53x_int_to_timeout(CHIP_DATA (pnd)->timeout_communication));
|
||||
break;
|
||||
// Following properties are invalid (not integer)
|
||||
// Following properties are invalid (not integer)
|
||||
case NP_HANDLE_CRC:
|
||||
case NP_HANDLE_PARITY:
|
||||
case NP_ACTIVATE_FIELD:
|
||||
|
|
@ -847,10 +847,10 @@ pn53x_set_property_bool (struct nfc_device *pnd, const nfc_property property, co
|
|||
// timings could be tweak better than this, and maybe we can tweak timings
|
||||
// to "gain" a sort-of hardware polling (ie. like PN532 does)
|
||||
if (pn53x_RFConfiguration__MaxRetries (pnd,
|
||||
(bEnable) ? 0xff : 0x00, // MxRtyATR, default: active = 0xff, passive = 0x02
|
||||
(bEnable) ? 0xff : 0x01, // MxRtyPSL, default: 0x01
|
||||
(bEnable) ? 0xff : 0x02 // MxRtyPassiveActivation, default: 0xff (0x00 leads to problems with PN531)
|
||||
) == 0)
|
||||
(bEnable) ? 0xff : 0x00, // MxRtyATR, default: active = 0xff, passive = 0x02
|
||||
(bEnable) ? 0xff : 0x01, // MxRtyPSL, default: 0x01
|
||||
(bEnable) ? 0xff : 0x02 // MxRtyPassiveActivation, default: 0xff (0x00 leads to problems with PN531)
|
||||
) == 0)
|
||||
return NFC_SUCCESS;
|
||||
}
|
||||
break;
|
||||
|
|
@ -913,7 +913,7 @@ pn53x_set_property_bool (struct nfc_device *pnd, const nfc_property property, co
|
|||
}
|
||||
return pn53x_write_register (pnd, PN53X_REG_CIU_RxMode, SYMBOL_RX_SPEED, 0x00);
|
||||
break;
|
||||
// Following properties are invalid (not boolean)
|
||||
// Following properties are invalid (not boolean)
|
||||
case NP_TIMEOUT_COMMAND:
|
||||
case NP_TIMEOUT_ATR:
|
||||
case NP_TIMEOUT_COM:
|
||||
|
|
@ -941,7 +941,7 @@ pn53x_idle (struct nfc_device *pnd)
|
|||
return res;
|
||||
}
|
||||
}
|
||||
break;
|
||||
break;
|
||||
case INITIATOR:
|
||||
// Deselect all active communications
|
||||
if ((res = pn53x_InDeselect (pnd, 0)) < 0) {
|
||||
|
|
@ -962,9 +962,9 @@ pn53x_idle (struct nfc_device *pnd)
|
|||
return res;
|
||||
}
|
||||
}
|
||||
break;
|
||||
break;
|
||||
case IDLE: // Nothing to do.
|
||||
break;
|
||||
break;
|
||||
};
|
||||
CHIP_DATA (pnd)->operating_mode = IDLE;
|
||||
return NFC_SUCCESS;
|
||||
|
|
@ -1004,10 +1004,10 @@ pn53x_initiator_init (struct nfc_device *pnd)
|
|||
|
||||
static int
|
||||
pn53x_initiator_select_passive_target_ext (struct nfc_device *pnd,
|
||||
const nfc_modulation nm,
|
||||
const uint8_t *pbtInitData, const size_t szInitData,
|
||||
nfc_target *pnt,
|
||||
int timeout)
|
||||
const nfc_modulation nm,
|
||||
const uint8_t *pbtInitData, const size_t szInitData,
|
||||
nfc_target *pnt,
|
||||
int timeout)
|
||||
{
|
||||
uint8_t abtTargetsData[PN53x_EXTENDED_FRAME__DATA_MAX_LEN];
|
||||
size_t szTargetsData = sizeof (abtTargetsData);
|
||||
|
|
@ -1118,9 +1118,9 @@ pn53x_initiator_select_passive_target (struct nfc_device *pnd,
|
|||
|
||||
int
|
||||
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)
|
||||
const nfc_modulation *pnmModulations, const size_t szModulations,
|
||||
const uint8_t uiPollNr, const uint8_t uiPeriod,
|
||||
nfc_target *pnt)
|
||||
{
|
||||
int res = 0;
|
||||
|
||||
|
|
@ -1155,7 +1155,7 @@ pn53x_initiator_poll_target (struct nfc_device *pnd,
|
|||
break;
|
||||
default:
|
||||
return NFC_ECHIP;
|
||||
break;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
pn53x_set_property_bool (pnd, NP_INFINITE_SELECT, true);
|
||||
|
|
@ -1186,10 +1186,10 @@ pn53x_initiator_poll_target (struct nfc_device *pnd,
|
|||
|
||||
int
|
||||
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)
|
||||
const nfc_dep_mode ndm, const nfc_baud_rate nbr,
|
||||
const nfc_dep_info *pndiInitiator,
|
||||
nfc_target *pnt,
|
||||
const int timeout)
|
||||
{
|
||||
const uint8_t abtPassiveInitiatorData[] = { 0x00, 0xff, 0xff, 0x00, 0x0f }; // Only for 212/424 kpbs: First 4 bytes shall be set like this according to NFCIP-1, last byte is TSN (Time Slot Number)
|
||||
const uint8_t * pbtPassiveInitiatorData = NULL;
|
||||
|
|
@ -1323,8 +1323,8 @@ pn53x_initiator_transceive_bytes (struct nfc_device *pnd, const uint8_t *pbtTx,
|
|||
// We have to give the amount of bytes + (the two command bytes 0xD4, 0x42)
|
||||
uint8_t abtRx[PN53x_EXTENDED_FRAME__DATA_MAX_LEN];
|
||||
if ((res = pn53x_transceive (pnd, abtCmd, szTx + szExtraTxLen, abtRx, sizeof(abtRx), timeout)) < 0) {
|
||||
pnd->last_error = res;
|
||||
return pnd->last_error;
|
||||
pnd->last_error = res;
|
||||
return pnd->last_error;
|
||||
}
|
||||
const size_t szRxLen = (size_t)res - 1;
|
||||
if (pbtRx != NULL) {
|
||||
|
|
@ -1347,9 +1347,9 @@ static void __pn53x_init_timer(struct nfc_device *pnd, const uint32_t max_cycles
|
|||
// prescaler = 2 => precision: ~369ns timer saturates at ~25ms
|
||||
// prescaler = 10 => precision: ~1.5us timer saturates at ~100ms
|
||||
if (max_cycles > 0xFFFF) {
|
||||
CHIP_DATA (pnd)->timer_prescaler = ((max_cycles/0xFFFF)-1)/2;
|
||||
CHIP_DATA (pnd)->timer_prescaler = ((max_cycles/0xFFFF)-1)/2;
|
||||
} else {
|
||||
CHIP_DATA (pnd)->timer_prescaler = 0;
|
||||
CHIP_DATA (pnd)->timer_prescaler = 0;
|
||||
}
|
||||
uint16_t reloadval = 0xFFFF;
|
||||
// Initialize timer
|
||||
|
|
@ -1404,9 +1404,9 @@ static uint32_t __pn53x_get_timer(struct nfc_device *pnd, const uint8_t last_cmd
|
|||
}
|
||||
// Correction depending on last parity bit sent
|
||||
parity = (last_cmd_byte >> 7) ^ ((last_cmd_byte >> 6) & 1) ^
|
||||
((last_cmd_byte >> 5) & 1) ^ ((last_cmd_byte >> 4) & 1) ^
|
||||
((last_cmd_byte >> 3) & 1) ^ ((last_cmd_byte >> 2) & 1) ^
|
||||
((last_cmd_byte >> 1) & 1) ^ (last_cmd_byte & 1);
|
||||
((last_cmd_byte >> 5) & 1) ^ ((last_cmd_byte >> 4) & 1) ^
|
||||
((last_cmd_byte >> 3) & 1) ^ ((last_cmd_byte >> 2) & 1) ^
|
||||
((last_cmd_byte >> 1) & 1) ^ (last_cmd_byte & 1);
|
||||
parity = parity ? 0:1;
|
||||
// When sent ...YY (cmd ends with logical 1, so when last parity bit is 1):
|
||||
if (parity) {
|
||||
|
|
@ -1676,17 +1676,17 @@ pn53x_target_init (struct nfc_device *pnd, nfc_target *pnt, uint8_t *pbtRx, cons
|
|||
pn53x_set_parameters (pnd, PARAM_14443_4_PICC, false);
|
||||
}
|
||||
}
|
||||
break;
|
||||
break;
|
||||
case NMT_FELICA:
|
||||
ptm = PTM_PASSIVE_ONLY;
|
||||
break;
|
||||
break;
|
||||
case NMT_DEP:
|
||||
pn53x_set_parameters (pnd, PARAM_AUTO_ATR_RES, true);
|
||||
ptm = PTM_DEP_ONLY;
|
||||
if (pnt->nti.ndi.ndm == NDM_PASSIVE) {
|
||||
ptm |= PTM_PASSIVE_ONLY; // We add passive mode restriction
|
||||
}
|
||||
break;
|
||||
break;
|
||||
case NMT_ISO14443B:
|
||||
case NMT_ISO14443BI:
|
||||
case NMT_ISO14443B2SR:
|
||||
|
|
@ -1694,7 +1694,7 @@ pn53x_target_init (struct nfc_device *pnd, nfc_target *pnt, uint8_t *pbtRx, cons
|
|||
case NMT_JEWEL:
|
||||
pnd->last_error = NFC_EDEVNOTSUPP;
|
||||
return pnd->last_error;
|
||||
break;
|
||||
break;
|
||||
}
|
||||
|
||||
// Let the PN53X be activated by the RF level detector from power down mode
|
||||
|
|
@ -1741,7 +1741,7 @@ pn53x_target_init (struct nfc_device *pnd, nfc_target *pnt, uint8_t *pbtRx, cons
|
|||
// Set SystemCode
|
||||
memcpy(abtFeliCaParams+16, pnt->nti.nfi.abtSysCode, 2);
|
||||
pbtFeliCaParams = abtFeliCaParams;
|
||||
break;
|
||||
break;
|
||||
|
||||
case NMT_DEP:
|
||||
// Set NFCID3
|
||||
|
|
@ -1788,7 +1788,7 @@ pn53x_target_init (struct nfc_device *pnd, nfc_target *pnt, uint8_t *pbtRx, cons
|
|||
abtFeliCaParams[17] = 0xab;
|
||||
|
||||
pbtFeliCaParams = abtFeliCaParams;
|
||||
break;
|
||||
break;
|
||||
case NMT_ISO14443B:
|
||||
case NMT_ISO14443BI:
|
||||
case NMT_ISO14443B2SR:
|
||||
|
|
@ -1796,7 +1796,7 @@ pn53x_target_init (struct nfc_device *pnd, nfc_target *pnt, uint8_t *pbtRx, cons
|
|||
case NMT_JEWEL:
|
||||
pnd->last_error = NFC_EDEVNOTSUPP;
|
||||
return pnd->last_error;
|
||||
break;
|
||||
break;
|
||||
}
|
||||
|
||||
bool targetActivated = false;
|
||||
|
|
@ -1820,13 +1820,13 @@ pn53x_target_init (struct nfc_device *pnd, nfc_target *pnt, uint8_t *pbtRx, cons
|
|||
switch(btActivatedMode & 0x70) { // Baud rate
|
||||
case 0x00: // 106kbps
|
||||
nm.nbr = NBR_106;
|
||||
break;
|
||||
break;
|
||||
case 0x10: // 212kbps
|
||||
nm.nbr = NBR_212;
|
||||
break;
|
||||
break;
|
||||
case 0x20: // 424kbps
|
||||
nm.nbr = NBR_424;
|
||||
break;
|
||||
break;
|
||||
};
|
||||
|
||||
if (btActivatedMode & 0x04) { // D.E.P.
|
||||
|
|
@ -1865,8 +1865,8 @@ pn53x_target_init (struct nfc_device *pnd, nfc_target *pnt, uint8_t *pbtRx, cons
|
|||
memcpy (CHIP_DATA (pnd)->current_target, pnt, sizeof(nfc_target));
|
||||
|
||||
if (ptm & PTM_ISO14443_4_PICC_ONLY) {
|
||||
// When PN532 is in PICC target mode, it automatically reply to RATS so
|
||||
// we don't need to forward this command
|
||||
// When PN532 is in PICC target mode, it automatically reply to RATS so
|
||||
// we don't need to forward this command
|
||||
szRx = 0;
|
||||
}
|
||||
}
|
||||
|
|
@ -1943,7 +1943,7 @@ pn53x_target_receive_bytes (struct nfc_device *pnd, uint8_t *pbtRx, const size_t
|
|||
return pnd->last_error;
|
||||
}
|
||||
}
|
||||
// NO BREAK
|
||||
// NO BREAK
|
||||
case NMT_JEWEL:
|
||||
case NMT_ISO14443B:
|
||||
case NMT_ISO14443BI:
|
||||
|
|
@ -2048,7 +2048,7 @@ pn53x_target_send_bytes (struct nfc_device *pnd, const uint8_t *pbtTx, const siz
|
|||
return pnd->last_error;
|
||||
}
|
||||
}
|
||||
// NO BREAK
|
||||
// NO BREAK
|
||||
case NMT_JEWEL:
|
||||
case NMT_ISO14443B:
|
||||
case NMT_ISO14443BI:
|
||||
|
|
@ -2367,7 +2367,7 @@ pn53x_InAutoPoll (struct nfc_device *pnd,
|
|||
uint8_t abtRx[PN53x_EXTENDED_FRAME__DATA_MAX_LEN];
|
||||
size_t szRx = sizeof(abtRx);
|
||||
int res = pn53x_transceive (pnd, abtCmd, szTxInAutoPoll, abtRx, szRx, timeout);
|
||||
szRx = (size_t) res;
|
||||
szRx = (size_t) res;
|
||||
if (res < 0) {
|
||||
return res;
|
||||
} else if (szRx > 0) {
|
||||
|
|
@ -2428,18 +2428,18 @@ pn53x_InJumpForDEP (struct nfc_device *pnd,
|
|||
switch (nbr) {
|
||||
case NBR_106:
|
||||
abtCmd[2] = 0x00; // baud rate is 106 kbps
|
||||
break;
|
||||
break;
|
||||
case NBR_212:
|
||||
abtCmd[2] = 0x01; // baud rate is 212 kbps
|
||||
break;
|
||||
break;
|
||||
case NBR_424:
|
||||
abtCmd[2] = 0x02; // baud rate is 424 kbps
|
||||
break;
|
||||
break;
|
||||
case NBR_847:
|
||||
case NBR_UNDEFINED:
|
||||
pnd->last_error = NFC_EINVARG;
|
||||
return pnd->last_error;
|
||||
break;
|
||||
break;
|
||||
}
|
||||
|
||||
if (pbtPassiveInitiatorData && (ndm == NDM_PASSIVE)) { /* can't have passive initiator data when using active mode */
|
||||
|
|
@ -2448,18 +2448,18 @@ pn53x_InJumpForDEP (struct nfc_device *pnd,
|
|||
abtCmd[3] |= 0x01;
|
||||
memcpy (abtCmd + offset, pbtPassiveInitiatorData, 4);
|
||||
offset += 4;
|
||||
break;
|
||||
break;
|
||||
case NBR_212:
|
||||
case NBR_424:
|
||||
abtCmd[3] |= 0x01;
|
||||
memcpy (abtCmd + offset, pbtPassiveInitiatorData, 5);
|
||||
offset += 5;
|
||||
break;
|
||||
break;
|
||||
case NBR_847:
|
||||
case NBR_UNDEFINED:
|
||||
pnd->last_error = NFC_EINVARG;
|
||||
return pnd->last_error;
|
||||
break;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -2677,54 +2677,54 @@ pn53x_nm_to_pm(const nfc_modulation nm)
|
|||
switch(nm.nmt) {
|
||||
case NMT_ISO14443A:
|
||||
return PM_ISO14443A_106;
|
||||
break;
|
||||
break;
|
||||
|
||||
case NMT_ISO14443B:
|
||||
switch(nm.nbr) {
|
||||
case NBR_106:
|
||||
return PM_ISO14443B_106;
|
||||
break;
|
||||
break;
|
||||
case NBR_212:
|
||||
return PM_ISO14443B_212;
|
||||
break;
|
||||
break;
|
||||
case NBR_424:
|
||||
return PM_ISO14443B_424;
|
||||
break;
|
||||
break;
|
||||
case NBR_847:
|
||||
return PM_ISO14443B_847;
|
||||
break;
|
||||
break;
|
||||
case NBR_UNDEFINED:
|
||||
// Nothing to do...
|
||||
break;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
break;
|
||||
|
||||
case NMT_JEWEL:
|
||||
return PM_JEWEL_106;
|
||||
break;
|
||||
break;
|
||||
|
||||
case NMT_FELICA:
|
||||
switch(nm.nbr) {
|
||||
case NBR_212:
|
||||
return PM_FELICA_212;
|
||||
break;
|
||||
break;
|
||||
case NBR_424:
|
||||
return PM_FELICA_424;
|
||||
break;
|
||||
break;
|
||||
case NBR_106:
|
||||
case NBR_847:
|
||||
case NBR_UNDEFINED:
|
||||
// Nothing to do...
|
||||
break;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
break;
|
||||
|
||||
case NMT_ISO14443BI:
|
||||
case NMT_ISO14443B2SR:
|
||||
case NMT_ISO14443B2CT:
|
||||
case NMT_DEP:
|
||||
// Nothing to do...
|
||||
break;
|
||||
break;
|
||||
}
|
||||
return PM_UNDEFINED;
|
||||
}
|
||||
|
|
@ -2738,44 +2738,44 @@ pn53x_ptt_to_nm( const pn53x_target_type ptt )
|
|||
case PTT_GENERIC_PASSIVE_424:
|
||||
case PTT_UNDEFINED:
|
||||
// XXX This should not happend, how handle it cleanly ?
|
||||
break;
|
||||
break;
|
||||
|
||||
case PTT_MIFARE:
|
||||
case PTT_ISO14443_4A_106:
|
||||
return (const nfc_modulation){ .nmt = NMT_ISO14443A, .nbr = NBR_106 };
|
||||
break;
|
||||
return (const nfc_modulation) { .nmt = NMT_ISO14443A, .nbr = NBR_106 };
|
||||
break;
|
||||
|
||||
case PTT_ISO14443_4B_106:
|
||||
case PTT_ISO14443_4B_TCL_106:
|
||||
return (const nfc_modulation){ .nmt = NMT_ISO14443B, .nbr = NBR_106 };
|
||||
break;
|
||||
return (const nfc_modulation) { .nmt = NMT_ISO14443B, .nbr = NBR_106 };
|
||||
break;
|
||||
|
||||
case PTT_JEWEL_106:
|
||||
return (const nfc_modulation){ .nmt = NMT_JEWEL, .nbr = NBR_106 };
|
||||
break;
|
||||
return (const nfc_modulation) { .nmt = NMT_JEWEL, .nbr = NBR_106 };
|
||||
break;
|
||||
|
||||
case PTT_FELICA_212:
|
||||
return (const nfc_modulation){ .nmt = NMT_FELICA, .nbr = NBR_212 };
|
||||
break;
|
||||
return (const nfc_modulation) { .nmt = NMT_FELICA, .nbr = NBR_212 };
|
||||
break;
|
||||
case PTT_FELICA_424:
|
||||
return (const nfc_modulation){ .nmt = NMT_FELICA, .nbr = NBR_424 };
|
||||
break;
|
||||
return (const nfc_modulation) { .nmt = NMT_FELICA, .nbr = NBR_424 };
|
||||
break;
|
||||
|
||||
case PTT_DEP_PASSIVE_106:
|
||||
case PTT_DEP_ACTIVE_106:
|
||||
return (const nfc_modulation){ .nmt = NMT_DEP, .nbr = NBR_106 };
|
||||
break;
|
||||
return (const nfc_modulation) { .nmt = NMT_DEP, .nbr = NBR_106 };
|
||||
break;
|
||||
case PTT_DEP_PASSIVE_212:
|
||||
case PTT_DEP_ACTIVE_212:
|
||||
return (const nfc_modulation){ .nmt = NMT_DEP, .nbr = NBR_212 };
|
||||
break;
|
||||
return (const nfc_modulation) { .nmt = NMT_DEP, .nbr = NBR_212 };
|
||||
break;
|
||||
case PTT_DEP_PASSIVE_424:
|
||||
case PTT_DEP_ACTIVE_424:
|
||||
return (const nfc_modulation){ .nmt = NMT_DEP, .nbr = NBR_424 };
|
||||
break;
|
||||
return (const nfc_modulation) { .nmt = NMT_DEP, .nbr = NBR_424 };
|
||||
break;
|
||||
}
|
||||
// We should never be here, this line silent compilation warning
|
||||
return (const nfc_modulation){ .nmt = NMT_ISO14443A, .nbr = NBR_106 };
|
||||
return (const nfc_modulation) { .nmt = NMT_ISO14443A, .nbr = NBR_106 };
|
||||
}
|
||||
|
||||
pn53x_target_type
|
||||
|
|
@ -2785,48 +2785,48 @@ pn53x_nm_to_ptt(const nfc_modulation nm)
|
|||
case NMT_ISO14443A:
|
||||
return PTT_MIFARE;
|
||||
// return PTT_ISO14443_4A_106;
|
||||
break;
|
||||
break;
|
||||
|
||||
case NMT_ISO14443B:
|
||||
switch(nm.nbr) {
|
||||
case NBR_106:
|
||||
return PTT_ISO14443_4B_106;
|
||||
break;
|
||||
break;
|
||||
case NBR_UNDEFINED:
|
||||
case NBR_212:
|
||||
case NBR_424:
|
||||
case NBR_847:
|
||||
// Nothing to do...
|
||||
break;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
break;
|
||||
|
||||
case NMT_JEWEL:
|
||||
return PTT_JEWEL_106;
|
||||
break;
|
||||
break;
|
||||
|
||||
case NMT_FELICA:
|
||||
switch(nm.nbr) {
|
||||
case NBR_212:
|
||||
return PTT_FELICA_212;
|
||||
break;
|
||||
break;
|
||||
case NBR_424:
|
||||
return PTT_FELICA_424;
|
||||
break;
|
||||
break;
|
||||
case NBR_UNDEFINED:
|
||||
case NBR_106:
|
||||
case NBR_847:
|
||||
// Nothing to do...
|
||||
break;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
break;
|
||||
|
||||
case NMT_ISO14443BI:
|
||||
case NMT_ISO14443B2SR:
|
||||
case NMT_ISO14443B2CT:
|
||||
case NMT_DEP:
|
||||
// Nothing to do...
|
||||
break;
|
||||
break;
|
||||
}
|
||||
return PTT_UNDEFINED;
|
||||
}
|
||||
|
|
@ -2837,10 +2837,10 @@ pn53x_get_supported_modulation(nfc_device *pnd, const nfc_mode mode, const nfc_m
|
|||
switch (mode) {
|
||||
case N_TARGET:
|
||||
*supported_mt = CHIP_DATA(pnd)->supported_modulation_as_target;
|
||||
break;
|
||||
break;
|
||||
case N_INITIATOR:
|
||||
*supported_mt = CHIP_DATA(pnd)->supported_modulation_as_initiator;
|
||||
break;
|
||||
break;
|
||||
default:
|
||||
return NFC_EINVARG;
|
||||
}
|
||||
|
|
@ -2853,10 +2853,10 @@ pn53x_get_supported_baud_rate (nfc_device *pnd, const nfc_modulation_type nmt, c
|
|||
switch (nmt) {
|
||||
case NMT_FELICA:
|
||||
*supported_br = (nfc_baud_rate*)pn53x_felica_supported_baud_rates;
|
||||
break;
|
||||
break;
|
||||
case NMT_ISO14443A:
|
||||
*supported_br = (nfc_baud_rate*)pn53x_iso14443a_supported_baud_rates;
|
||||
break;
|
||||
break;
|
||||
case NMT_ISO14443B:
|
||||
case NMT_ISO14443BI:
|
||||
case NMT_ISO14443B2SR:
|
||||
|
|
@ -2871,10 +2871,10 @@ pn53x_get_supported_baud_rate (nfc_device *pnd, const nfc_modulation_type nmt, c
|
|||
break;
|
||||
case NMT_JEWEL:
|
||||
*supported_br = (nfc_baud_rate*)pn53x_jewel_supported_baud_rates;
|
||||
break;
|
||||
break;
|
||||
case NMT_DEP:
|
||||
*supported_br = (nfc_baud_rate*)pn53x_dep_supported_baud_rates;
|
||||
break;
|
||||
break;
|
||||
default:
|
||||
return NFC_EINVARG;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -155,41 +155,41 @@ struct pn53x_io {
|
|||
* @brief PN53x data structure
|
||||
*/
|
||||
struct pn53x_data {
|
||||
/** Chip type (PN531, PN532 or PN533) */
|
||||
/** Chip type (PN531, PN532 or PN533) */
|
||||
pn53x_type type;
|
||||
/** Chip firmware text */
|
||||
/** Chip firmware text */
|
||||
char firmware_text[22];
|
||||
/** Current power mode */
|
||||
/** Current power mode */
|
||||
pn53x_power_mode power_mode;
|
||||
/** Current operating mode */
|
||||
/** Current operating mode */
|
||||
pn53x_operating_mode operating_mode;
|
||||
/** Current emulated target */
|
||||
/** Current emulated target */
|
||||
nfc_target *current_target;
|
||||
/** PN53x I/O functions stored in struct */
|
||||
/** PN53x I/O functions stored in struct */
|
||||
const struct pn53x_io *io;
|
||||
/** Last status byte returned by PN53x */
|
||||
/** 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 */
|
||||
/** 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. */
|
||||
/** Register cache for SetParameters function. */
|
||||
uint8_t ui8Parameters;
|
||||
/** Last sent command */
|
||||
/** Last sent command */
|
||||
uint8_t last_command;
|
||||
/** Interframe timer correction */
|
||||
/** Interframe timer correction */
|
||||
int16_t timer_correction;
|
||||
/** Timer prescaler */
|
||||
/** Timer prescaler */
|
||||
uint16_t timer_prescaler;
|
||||
/** WriteBack cache */
|
||||
/** WriteBack cache */
|
||||
uint8_t wb_data[PN53X_CACHE_REGISTER_SIZE];
|
||||
uint8_t wb_mask[PN53X_CACHE_REGISTER_SIZE];
|
||||
bool wb_trigged;
|
||||
/** Command timeout */
|
||||
/** Command timeout */
|
||||
int timeout_command;
|
||||
/** ATR timeout */
|
||||
/** ATR timeout */
|
||||
int timeout_atr;
|
||||
/** Communication timeout */
|
||||
/** Communication timeout */
|
||||
int timeout_communication;
|
||||
/** Supported modulation type */
|
||||
/** Supported modulation type */
|
||||
nfc_modulation_type *supported_modulation_as_initiator;
|
||||
nfc_modulation_type *supported_modulation_as_target;
|
||||
};
|
||||
|
|
@ -203,21 +203,21 @@ struct pn53x_data {
|
|||
typedef enum {
|
||||
/** Undefined modulation */
|
||||
PM_UNDEFINED = -1,
|
||||
/** ISO14443-A (NXP MIFARE) http://en.wikipedia.org/wiki/MIFARE */
|
||||
/** ISO14443-A (NXP MIFARE) http://en.wikipedia.org/wiki/MIFARE */
|
||||
PM_ISO14443A_106 = 0x00,
|
||||
/** JIS X 6319-4 (Sony Felica) http://en.wikipedia.org/wiki/FeliCa */
|
||||
/** JIS X 6319-4 (Sony Felica) http://en.wikipedia.org/wiki/FeliCa */
|
||||
PM_FELICA_212 = 0x01,
|
||||
/** JIS X 6319-4 (Sony Felica) http://en.wikipedia.org/wiki/FeliCa */
|
||||
/** JIS X 6319-4 (Sony Felica) http://en.wikipedia.org/wiki/FeliCa */
|
||||
PM_FELICA_424 = 0x02,
|
||||
/** ISO14443-B http://en.wikipedia.org/wiki/ISO/IEC_14443 (Not supported by PN531) */
|
||||
/** ISO14443-B http://en.wikipedia.org/wiki/ISO/IEC_14443 (Not supported by PN531) */
|
||||
PM_ISO14443B_106 = 0x03,
|
||||
/** Jewel Topaz (Innovision Research & Development) (Not supported by PN531) */
|
||||
/** Jewel Topaz (Innovision Research & Development) (Not supported by PN531) */
|
||||
PM_JEWEL_106 = 0x04,
|
||||
/** ISO14443-B http://en.wikipedia.org/wiki/ISO/IEC_14443 (Not supported by PN531 nor PN532) */
|
||||
/** ISO14443-B http://en.wikipedia.org/wiki/ISO/IEC_14443 (Not supported by PN531 nor PN532) */
|
||||
PM_ISO14443B_212 = 0x06,
|
||||
/** ISO14443-B http://en.wikipedia.org/wiki/ISO/IEC_14443 (Not supported by PN531 nor PN532) */
|
||||
/** ISO14443-B http://en.wikipedia.org/wiki/ISO/IEC_14443 (Not supported by PN531 nor PN532) */
|
||||
PM_ISO14443B_424 = 0x07,
|
||||
/** ISO14443-B http://en.wikipedia.org/wiki/ISO/IEC_14443 (Not supported by PN531 nor PN532) */
|
||||
/** ISO14443-B http://en.wikipedia.org/wiki/ISO/IEC_14443 (Not supported by PN531 nor PN532) */
|
||||
PM_ISO14443B_847 = 0x08,
|
||||
} pn53x_modulation;
|
||||
|
||||
|
|
@ -299,8 +299,8 @@ int pn53x_set_tx_bits (struct nfc_device *pnd, const uint8_t ui8Bits);
|
|||
int pn53x_wrap_frame (const uint8_t *pbtTx, const size_t szTxBits, const uint8_t *pbtTxPar, uint8_t *pbtFrame);
|
||||
int pn53x_unwrap_frame (const uint8_t *pbtFrame, const size_t szFrameBits, uint8_t *pbtRx, uint8_t *pbtRxPar);
|
||||
int pn53x_decode_target_data (const uint8_t *pbtRawData, size_t szRawData,
|
||||
pn53x_type chip_type, nfc_modulation_type nmt,
|
||||
nfc_target_info *pnti);
|
||||
pn53x_type chip_type, nfc_modulation_type nmt,
|
||||
nfc_target_info *pnti);
|
||||
int pn53x_read_register (struct nfc_device *pnd, uint16_t ui16Reg, uint8_t *ui8Value);
|
||||
int pn53x_write_register (struct nfc_device *pnd, uint16_t ui16Reg, uint8_t ui8SymbolMask, uint8_t ui8Value);
|
||||
int pn53x_decode_firmware_version (struct nfc_device *pnd);
|
||||
|
|
@ -313,26 +313,26 @@ int pn53x_idle (struct nfc_device *pnd);
|
|||
// NFC device as Initiator functions
|
||||
int pn53x_initiator_init (struct nfc_device *pnd);
|
||||
int pn53x_initiator_select_passive_target (struct nfc_device *pnd,
|
||||
const nfc_modulation nm,
|
||||
const uint8_t *pbtInitData, const size_t szInitData,
|
||||
nfc_target *pnt);
|
||||
const nfc_modulation nm,
|
||||
const uint8_t *pbtInitData, const size_t szInitData,
|
||||
nfc_target *pnt);
|
||||
int 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);
|
||||
const nfc_modulation *pnmModulations, const size_t szModulations,
|
||||
const uint8_t uiPollNr, const uint8_t uiPeriod,
|
||||
nfc_target *pnt);
|
||||
int 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);
|
||||
const nfc_dep_mode ndm, const nfc_baud_rate nbr,
|
||||
const nfc_dep_info *pndiInitiator,
|
||||
nfc_target *pnt,
|
||||
const int timeout);
|
||||
int pn53x_initiator_transceive_bits (struct nfc_device *pnd, const uint8_t *pbtTx, const size_t szTxBits,
|
||||
const uint8_t *pbtTxPar, uint8_t *pbtRx, uint8_t *pbtRxPar);
|
||||
const uint8_t *pbtTxPar, uint8_t *pbtRx, uint8_t *pbtRxPar);
|
||||
int pn53x_initiator_transceive_bytes (struct nfc_device *pnd, const uint8_t *pbtTx, const size_t szTx,
|
||||
uint8_t *pbtRx, const size_t szRx, int timeout);
|
||||
uint8_t *pbtRx, const size_t szRx, int timeout);
|
||||
int pn53x_initiator_transceive_bits_timed (struct nfc_device *pnd, const uint8_t *pbtTx, const size_t szTxBits,
|
||||
const uint8_t *pbtTxPar, uint8_t *pbtRx, uint8_t *pbtRxPar, uint32_t *cycles);
|
||||
const uint8_t *pbtTxPar, uint8_t *pbtRx, uint8_t *pbtRxPar, uint32_t *cycles);
|
||||
int pn53x_initiator_transceive_bytes_timed (struct nfc_device *pnd, const uint8_t *pbtTx, const size_t szTx,
|
||||
uint8_t *pbtRx, uint32_t *cycles);
|
||||
uint8_t *pbtRx, uint32_t *cycles);
|
||||
int pn53x_initiator_deselect_target (struct nfc_device *pnd);
|
||||
int pn53x_initiator_target_is_present (struct nfc_device *pnd, const nfc_target nt);
|
||||
|
||||
|
|
@ -351,27 +351,27 @@ int pn53x_SetParameters (struct nfc_device *pnd, const uint8_t ui8Value);
|
|||
int pn53x_SAMConfiguration (struct nfc_device *pnd, const pn532_sam_mode mode, int timeout);
|
||||
int pn53x_PowerDown (struct nfc_device *pnd);
|
||||
int 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);
|
||||
const uint8_t szMaxTargets, const uint8_t *pbtInitiatorData,
|
||||
const size_t szInitiatorDataLen, uint8_t *pbtTargetsData, size_t *pszTargetsData,
|
||||
int timeout);
|
||||
int pn53x_InDeselect (struct nfc_device *pnd, const uint8_t ui8Target);
|
||||
int pn53x_InRelease (struct nfc_device *pnd, const uint8_t ui8Target);
|
||||
int 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,
|
||||
const int timeout);
|
||||
const uint8_t btPollNr, const uint8_t btPeriod, nfc_target *pntTargets,
|
||||
const int timeout);
|
||||
int 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);
|
||||
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);
|
||||
int 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,
|
||||
const uint8_t *pbtNFCID3t, const uint8_t *pbtGB, const size_t szGB,
|
||||
uint8_t *pbtRx, const size_t szRxLen, uint8_t *pbtModeByte, int timeout);
|
||||
const uint8_t *pbtMifareParams,
|
||||
const uint8_t *pbtTkt, size_t szTkt,
|
||||
const uint8_t *pbtFeliCaParams,
|
||||
const uint8_t *pbtNFCID3t, const uint8_t *pbtGB, const size_t szGB,
|
||||
uint8_t *pbtRx, const size_t szRxLen, uint8_t *pbtModeByte, int timeout);
|
||||
|
||||
// RFConfiguration
|
||||
int pn53x_RFConfiguration__RF_field (struct nfc_device *pnd, bool bEnable);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue