pn53x initiator set registers for ISO14443B-2 ST SRx
Modification to set PN53X_REG_CIU_TxAuto, PN53X_REG_CIU_CWGsP & PN53X_REG_CIU_ModGsP registers values before init. Avoids a dummy scan in B mode before
This commit is contained in:
parent
3df7f25f11
commit
5b9ae7ee51
3 changed files with 32 additions and 33 deletions
|
@ -50,7 +50,7 @@
|
||||||
*
|
*
|
||||||
* Tested with
|
* Tested with
|
||||||
* - ST25TB512-AC - (BE/Brussels/STIB ; AliExpress ones)
|
* - ST25TB512-AC - (BE/Brussels/STIB ; AliExpress ones)
|
||||||
* - ST25TB512-AT - (FR/Lille/Ilevia ; FR/Reims/Citura)
|
* - ST25TB512-AT - (FR/Lille/Ilevia ; FR/Reims/Citura ; FR/Dijon/Divia ; FR/Strasbourg/CTS)
|
||||||
* - SRT512 - legacy - (FR/Bordeaux/TBM)
|
* - SRT512 - legacy - (FR/Bordeaux/TBM)
|
||||||
* - SRI512 - legacy - (anonymous vending machine)
|
* - SRI512 - legacy - (anonymous vending machine)
|
||||||
*/
|
*/
|
||||||
|
@ -94,7 +94,7 @@ int main(int argc, char *argv[])
|
||||||
nfc_context *context = NULL;
|
nfc_context *context = NULL;
|
||||||
nfc_device *pnd = NULL;
|
nfc_device *pnd = NULL;
|
||||||
nfc_target nt = {0};
|
nfc_target nt = {0};
|
||||||
nfc_modulation nm = {NMT_ISO14443B, NBR_106};
|
nfc_modulation nm = {NMT_ISO14443B2SR, NBR_106};
|
||||||
const st_data * stcurrent;
|
const st_data * stcurrent;
|
||||||
int opt, res;
|
int opt, res;
|
||||||
bool bIsBlock = false, bIsRead = false, bIsWrite = false, bIsBadCli = false;
|
bool bIsBlock = false, bIsRead = false, bIsWrite = false, bIsBadCli = false;
|
||||||
|
@ -205,45 +205,35 @@ int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
printf("Reader : %s - via %s\n ...wait for card...\n", nfc_device_get_name(pnd), nfc_device_get_connstring(pnd));
|
printf("Reader : %s - via %s\n ...wait for card...\n", nfc_device_get_name(pnd), nfc_device_get_connstring(pnd));
|
||||||
|
|
||||||
res = nfc_initiator_list_passive_targets(pnd, nm, &nt, 1);
|
if (nfc_initiator_select_passive_target(pnd, nm, NULL, 0, &nt) > 0)
|
||||||
if(res == 0) // we don't really wanted a NMT_ISO14443B
|
|
||||||
{
|
{
|
||||||
nm.nmt = NMT_ISO14443B2SR; // we want a NMT_ISO14443B2SR, but needed to ask for NMT_ISO14443B before
|
stcurrent = get_info(&nt, true);
|
||||||
if (nfc_initiator_select_passive_target(pnd, nm, NULL, 0, &nt) > 0)
|
if(stcurrent)
|
||||||
{
|
{
|
||||||
stcurrent = get_info(&nt, true);
|
printf("\n");
|
||||||
if(stcurrent)
|
|
||||||
{
|
|
||||||
printf("\n");
|
|
||||||
|
|
||||||
if(bIsBlock && (bIsRead || bIsWrite))
|
if(bIsBlock && (bIsRead || bIsWrite))
|
||||||
|
{
|
||||||
|
if(bIsRead)
|
||||||
{
|
{
|
||||||
if(bIsRead)
|
get_block_at(pnd, blockNumber, NULL, 0, true);
|
||||||
{
|
|
||||||
get_block_at(pnd, blockNumber, NULL, 0, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(bIsWrite)
|
|
||||||
{
|
|
||||||
set_block_at_confirmed(pnd, blockNumber, data, cbData, true);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else if(!bIsRead && !bIsWrite && !bIsBlock)
|
|
||||||
|
if(bIsWrite)
|
||||||
{
|
{
|
||||||
for(i = 0; i < stcurrent->nbNormalBlock; i++)
|
set_block_at_confirmed(pnd, blockNumber, data, cbData, true);
|
||||||
{
|
|
||||||
get_block_at(pnd, i, NULL, 0, true);
|
|
||||||
}
|
|
||||||
display_system_info(pnd, stcurrent);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if(!bIsRead && !bIsWrite && !bIsBlock)
|
||||||
|
{
|
||||||
|
for(i = 0; i < stcurrent->nbNormalBlock; i++)
|
||||||
|
{
|
||||||
|
get_block_at(pnd, i, NULL, 0, true);
|
||||||
|
}
|
||||||
|
display_system_info(pnd, stcurrent);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(res > 0)
|
|
||||||
{
|
|
||||||
printf("ERROR - We got a NMT_ISO14443B ?\n");
|
|
||||||
}
|
|
||||||
else printf("ERROR - nfc_initiator_list_passive_targets: %i\n", res);
|
|
||||||
}
|
}
|
||||||
else printf("ERROR - nfc_initiator_init: %i\n", res);
|
else printf("ERROR - nfc_initiator_init: %i\n", res);
|
||||||
|
|
||||||
|
@ -606,4 +596,5 @@ void print_hex(const uint8_t *pbtData, const size_t szBytes)
|
||||||
{
|
{
|
||||||
printf("%02hhx ", pbtData[szPos]);
|
printf("%02hhx ", pbtData[szPos]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1155,6 +1155,14 @@ pn53x_initiator_select_passive_target_ext(struct nfc_device *pnd,
|
||||||
uint8_t abtRx[1];
|
uint8_t abtRx[1];
|
||||||
uint8_t *pbtInitData = (uint8_t *) "\x0b";
|
uint8_t *pbtInitData = (uint8_t *) "\x0b";
|
||||||
size_t szInitData = 1;
|
size_t szInitData = 1;
|
||||||
|
|
||||||
|
if ((res = pn53x_write_register(pnd, PN53X_REG_CIU_TxAuto, 0xef, 0x07)) < 0) // Initial RFOn, Tx2 RFAutoEn, Tx1 RFAutoEn
|
||||||
|
return res;
|
||||||
|
if ((res = pn53x_write_register(pnd, PN53X_REG_CIU_CWGsP, 0x3f, 0x3f)) < 0) // Conductance of the P-Driver
|
||||||
|
return res;
|
||||||
|
if ((res = pn53x_write_register(pnd, PN53X_REG_CIU_ModGsP, 0x3f, 0x12)) < 0) // Driver P-output conductance for the time of modulation
|
||||||
|
return res;
|
||||||
|
|
||||||
// Getting random Chip_ID
|
// Getting random Chip_ID
|
||||||
if ((res = pn53x_initiator_transceive_bytes(pnd, abtInitiate, szInitiateLen, abtRx, sizeof(abtRx), timeout)) < 0) {
|
if ((res = pn53x_initiator_transceive_bytes(pnd, abtInitiate, szInitiateLen, abtRx, sizeof(abtRx), timeout)) < 0) {
|
||||||
if ((res == NFC_ERFTRANS) && (CHIP_DATA(pnd)->last_status_byte == 0x01)) { // Chip timeout
|
if ((res == NFC_ERFTRANS) && (CHIP_DATA(pnd)->last_status_byte == 0x01)) { // Chip timeout
|
||||||
|
|
|
@ -113,7 +113,7 @@ main(int argc, const char *argv[])
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
// Force TypeB for all derivatives of B
|
// Force TypeB for all derivatives of B
|
||||||
if (mask & 0xf0)
|
if (mask & 0xd0)
|
||||||
mask |= 0x08;
|
mask |= 0x08;
|
||||||
} else {
|
} else {
|
||||||
ERR("%s is not supported option.", argv[arg]);
|
ERR("%s is not supported option.", argv[arg]);
|
||||||
|
|
Loading…
Reference in a new issue