smart merge of r906 into trunk (Thanks to marko259 from libnfc forum).
This commit is contained in:
parent
4b6ba0aa3c
commit
2608b3dc55
2 changed files with 22 additions and 7 deletions
|
@ -62,6 +62,12 @@ pn53x_target_type_t pn53x_nm_to_ptt (const nfc_modulation_t nm);
|
||||||
bool
|
bool
|
||||||
pn53x_init(nfc_device_t * pnd)
|
pn53x_init(nfc_device_t * pnd)
|
||||||
{
|
{
|
||||||
|
// GetFirmwareVersion command is used to set PN53x chips type (PN531, PN532 or PN533)
|
||||||
|
char abtFirmwareText[18];
|
||||||
|
if (!pn53x_get_firmware_version (pnd, abtFirmwareText)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// CRC handling is enabled by default
|
// CRC handling is enabled by default
|
||||||
pnd->bCrc = true;
|
pnd->bCrc = true;
|
||||||
// Parity handling is enabled by default
|
// Parity handling is enabled by default
|
||||||
|
@ -79,11 +85,6 @@ pn53x_init(nfc_device_t * pnd)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
char abtFirmwareText[18];
|
|
||||||
if (!pn53x_get_firmware_version (pnd, abtFirmwareText)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add the firmware revision to the device name
|
// Add the firmware revision to the device name
|
||||||
char *pcName;
|
char *pcName;
|
||||||
pcName = strdup (pnd->acName);
|
pcName = strdup (pnd->acName);
|
||||||
|
@ -762,7 +763,22 @@ pn53x_get_firmware_version (nfc_device_t * pnd, char abtFirmwareText[18])
|
||||||
if (!pn53x_transceive (pnd, abtCmd, sizeof (abtCmd), abtFw, &szFwLen, false)) {
|
if (!pn53x_transceive (pnd, abtCmd, sizeof (abtCmd), abtFw, &szFwLen, false)) {
|
||||||
// Failed to get firmware revision??, whatever...let's disconnect and clean up and return err
|
// Failed to get firmware revision??, whatever...let's disconnect and clean up and return err
|
||||||
// FIXME: Wtf?
|
// FIXME: Wtf?
|
||||||
// pnd->pdc->disconnect (pnd);
|
return false;
|
||||||
|
}
|
||||||
|
// Determine which version of chip it is: PN531 will return only 2 bytes, while others return 4 bytes and have the first to tell the version IC
|
||||||
|
if (szFwLen == 2) {
|
||||||
|
((struct pn53x_data*)(pnd->chip_data))->type = PN531;
|
||||||
|
} else if (szFwLen == 4) {
|
||||||
|
if (abtFw[0] == 0x32) { // PN532 version IC
|
||||||
|
((struct pn53x_data*)(pnd->chip_data))->type = PN532;
|
||||||
|
} else if (abtFw[0] == 0x33) { // PN532 version IC
|
||||||
|
((struct pn53x_data*)(pnd->chip_data))->type = PN533;
|
||||||
|
} else {
|
||||||
|
// Unknown version IC
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Unknown chip
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// Convert firmware info in text, PN531 gives 2 bytes info, but PN532 and PN533 gives 4
|
// Convert firmware info in text, PN531 gives 2 bytes info, but PN532 and PN533 gives 4
|
||||||
|
|
|
@ -189,7 +189,6 @@ arygon_connect (const nfc_device_desc_t * pndd)
|
||||||
arygon_firmware((nfc_device_spec_t) sp, acFirmware);
|
arygon_firmware((nfc_device_spec_t) sp, acFirmware);
|
||||||
snprintf (pnd->acName, DEVICE_NAME_LENGTH - 1, "%s %s (%s)", pndd->acDevice, acFirmware, pndd->pcPort);
|
snprintf (pnd->acName, DEVICE_NAME_LENGTH - 1, "%s %s (%s)", pndd->acDevice, acFirmware, pndd->pcPort);
|
||||||
pnd->acName[DEVICE_NAME_LENGTH - 1] = '\0';
|
pnd->acName[DEVICE_NAME_LENGTH - 1] = '\0';
|
||||||
pnd->nc = NC_PN532;
|
|
||||||
pnd->nds = (nfc_device_spec_t) sp;
|
pnd->nds = (nfc_device_spec_t) sp;
|
||||||
pnd->bActive = true;
|
pnd->bActive = true;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue