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
|
||||
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
|
||||
pnd->bCrc = true;
|
||||
// Parity handling is enabled by default
|
||||
|
|
@ -79,11 +85,6 @@ pn53x_init(nfc_device_t * pnd)
|
|||
return false;
|
||||
}
|
||||
|
||||
char abtFirmwareText[18];
|
||||
if (!pn53x_get_firmware_version (pnd, abtFirmwareText)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Add the firmware revision to the device name
|
||||
char *pcName;
|
||||
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)) {
|
||||
// Failed to get firmware revision??, whatever...let's disconnect and clean up and return err
|
||||
// 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;
|
||||
}
|
||||
// Convert firmware info in text, PN531 gives 2 bytes info, but PN532 and PN533 gives 4
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue