First attempt to support Sony S330 reader
Tested: - nfc-list - nfc-anticol - nfc-mfultralight - nfc-mfclassic Commands momentarily disabled: - SetParameters - InDeselect - InRelease
This commit is contained in:
parent
f4c3d9d4ed
commit
91c46050c0
4 changed files with 31 additions and 13 deletions
|
@ -119,7 +119,8 @@ typedef struct {
|
||||||
typedef enum {
|
typedef enum {
|
||||||
PN531 = 0x01,
|
PN531 = 0x01,
|
||||||
PN532 = 0x02,
|
PN532 = 0x02,
|
||||||
PN533 = 0x04
|
PN533 = 0x04,
|
||||||
|
S330 = 0x08
|
||||||
} pn53x_type;
|
} pn53x_type;
|
||||||
|
|
||||||
#ifndef DEBUG
|
#ifndef DEBUG
|
||||||
|
@ -141,7 +142,7 @@ typedef enum {
|
||||||
static const pn53x_command pn53x_commands[] = {
|
static const pn53x_command pn53x_commands[] = {
|
||||||
// Miscellaneous
|
// Miscellaneous
|
||||||
PNCMD( Diagnose, PN531|PN532|PN533 ),
|
PNCMD( Diagnose, PN531|PN532|PN533 ),
|
||||||
PNCMD( GetFirmwareVersion, PN531|PN532|PN533 ),
|
PNCMD( GetFirmwareVersion, PN531|PN532|PN533|S330 ),
|
||||||
PNCMD( GetGeneralStatus, PN531|PN532|PN533 ),
|
PNCMD( GetGeneralStatus, PN531|PN532|PN533 ),
|
||||||
PNCMD( ReadRegister, PN531|PN532|PN533 ),
|
PNCMD( ReadRegister, PN531|PN532|PN533 ),
|
||||||
PNCMD( WriteRegister, PN531|PN532|PN533 ),
|
PNCMD( WriteRegister, PN531|PN532|PN533 ),
|
||||||
|
@ -204,12 +205,6 @@ typedef struct {
|
||||||
} pn53x_register;
|
} pn53x_register;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
|
||||||
#define PN531 0x01
|
|
||||||
#define PN532 0x02
|
|
||||||
#define PN533 0X04
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef DEBUG
|
#ifndef DEBUG
|
||||||
# define PNREG_DBG( X ) do { \
|
# define PNREG_DBG( X ) do { \
|
||||||
} while(0)
|
} while(0)
|
||||||
|
|
|
@ -593,8 +593,12 @@ pn53x_get_firmware_version (nfc_device_t * pnd, char abtFirmwareText[22])
|
||||||
} else if (szFwLen == 4) {
|
} else if (szFwLen == 4) {
|
||||||
if (abtFw[0] == 0x32) { // PN532 version IC
|
if (abtFw[0] == 0x32) { // PN532 version IC
|
||||||
CHIP_DATA(pnd)->type = PN532;
|
CHIP_DATA(pnd)->type = PN532;
|
||||||
} else if (abtFw[0] == 0x33) { // PN532 version IC
|
} else if (abtFw[0] == 0x33) { // PN533 version IC
|
||||||
CHIP_DATA(pnd)->type = PN533;
|
if (abtFw[1] == 0x01) { // Sony ROM code
|
||||||
|
CHIP_DATA(pnd)->type = S330;
|
||||||
|
} else {
|
||||||
|
CHIP_DATA(pnd)->type = PN533;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// Unknown version IC
|
// Unknown version IC
|
||||||
return false;
|
return false;
|
||||||
|
@ -614,6 +618,7 @@ pn53x_get_firmware_version (nfc_device_t * pnd, char abtFirmwareText[22])
|
||||||
pnd->btSupportByte = abtFw[3];
|
pnd->btSupportByte = abtFw[3];
|
||||||
break;
|
break;
|
||||||
case PN533:
|
case PN533:
|
||||||
|
case S330:
|
||||||
snprintf (abtFirmwareText, 22, "PN533 v%d.%d (0x%02x)", abtFw[1], abtFw[2], abtFw[3]);
|
snprintf (abtFirmwareText, 22, "PN533 v%d.%d (0x%02x)", abtFw[1], abtFw[2], abtFw[3]);
|
||||||
pnd->btSupportByte = abtFw[3];
|
pnd->btSupportByte = abtFw[3];
|
||||||
break;
|
break;
|
||||||
|
@ -1838,6 +1843,11 @@ pn53x_strerror (const nfc_device_t * pnd)
|
||||||
bool
|
bool
|
||||||
pn53x_SetParameters (nfc_device_t * pnd, const uint8_t ui8Value)
|
pn53x_SetParameters (nfc_device_t * pnd, const uint8_t ui8Value)
|
||||||
{
|
{
|
||||||
|
if (CHIP_DATA (pnd)->type == S330) {
|
||||||
|
// TODO add support for S330
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
byte_t abtCmd[] = { SetParameters, ui8Value };
|
byte_t abtCmd[] = { SetParameters, ui8Value };
|
||||||
|
|
||||||
if(!pn53x_transceive (pnd, abtCmd, sizeof (abtCmd), NULL, NULL)) {
|
if(!pn53x_transceive (pnd, abtCmd, sizeof (abtCmd), NULL, NULL)) {
|
||||||
|
@ -1955,6 +1965,10 @@ pn53x_InListPassiveTarget (nfc_device_t * pnd,
|
||||||
bool
|
bool
|
||||||
pn53x_InDeselect (nfc_device_t * pnd, const uint8_t ui8Target)
|
pn53x_InDeselect (nfc_device_t * pnd, const uint8_t ui8Target)
|
||||||
{
|
{
|
||||||
|
if (CHIP_DATA(pnd)->type == S330) {
|
||||||
|
// TODO Add support for S330
|
||||||
|
return true;
|
||||||
|
}
|
||||||
byte_t abtCmd[] = { InDeselect, ui8Target };
|
byte_t abtCmd[] = { InDeselect, ui8Target };
|
||||||
|
|
||||||
return (pn53x_transceive (pnd, abtCmd, sizeof (abtCmd), NULL, NULL));
|
return (pn53x_transceive (pnd, abtCmd, sizeof (abtCmd), NULL, NULL));
|
||||||
|
@ -1963,6 +1977,10 @@ pn53x_InDeselect (nfc_device_t * pnd, const uint8_t ui8Target)
|
||||||
bool
|
bool
|
||||||
pn53x_InRelease (nfc_device_t * pnd, const uint8_t ui8Target)
|
pn53x_InRelease (nfc_device_t * pnd, const uint8_t ui8Target)
|
||||||
{
|
{
|
||||||
|
if (CHIP_DATA(pnd)->type == S330) {
|
||||||
|
// TODO Add support for S330
|
||||||
|
return true;
|
||||||
|
}
|
||||||
byte_t abtCmd[] = { InRelease, ui8Target };
|
byte_t abtCmd[] = { InRelease, ui8Target };
|
||||||
|
|
||||||
return (pn53x_transceive (pnd, abtCmd, sizeof (abtCmd), NULL, NULL));
|
return (pn53x_transceive (pnd, abtCmd, sizeof (abtCmd), NULL, NULL));
|
||||||
|
|
|
@ -57,7 +57,8 @@ typedef enum {
|
||||||
SONY_PN531,
|
SONY_PN531,
|
||||||
NXP_PN533,
|
NXP_PN533,
|
||||||
ASK_LOGO,
|
ASK_LOGO,
|
||||||
SCM_SCL3711
|
SCM_SCL3711,
|
||||||
|
SONY_S330
|
||||||
} pn53x_usb_model;
|
} pn53x_usb_model;
|
||||||
|
|
||||||
struct pn53x_usb_data {
|
struct pn53x_usb_data {
|
||||||
|
@ -115,7 +116,8 @@ const struct pn53x_usb_supported_device pn53x_usb_supported_devices[] = {
|
||||||
{ 0x04CC, 0x2533, NXP_PN533, "NXP / PN533" },
|
{ 0x04CC, 0x2533, NXP_PN533, "NXP / PN533" },
|
||||||
{ 0x04E6, 0x5591, SCM_SCL3711, "SCM Micro / SCL3711-NFC&RW" },
|
{ 0x04E6, 0x5591, SCM_SCL3711, "SCM Micro / SCL3711-NFC&RW" },
|
||||||
{ 0x054c, 0x0193, SONY_PN531, "Sony / PN531" },
|
{ 0x054c, 0x0193, SONY_PN531, "Sony / PN531" },
|
||||||
{ 0x1FD3, 0x0608, ASK_LOGO, "ASK / LoGO" }
|
{ 0x1FD3, 0x0608, ASK_LOGO, "ASK / LoGO" },
|
||||||
|
{ 0x054C, 0x02E1, SONY_S330, "Sony / FeliCa S330 [PaSoRi]" }
|
||||||
};
|
};
|
||||||
|
|
||||||
pn53x_usb_model
|
pn53x_usb_model
|
||||||
|
@ -568,7 +570,9 @@ bool
|
||||||
pn53x_usb_init (nfc_device_t *pnd)
|
pn53x_usb_init (nfc_device_t *pnd)
|
||||||
{
|
{
|
||||||
// Sometimes PN53x USB doesn't reply ACK one the first frame, so we need to send a dummy one...
|
// Sometimes PN53x USB doesn't reply ACK one the first frame, so we need to send a dummy one...
|
||||||
pn53x_check_communication (pnd);
|
//pn53x_check_communication (pnd); // Sony S330 doesn't support this command for now so let's use a get_firmware_version instead:
|
||||||
|
const byte_t abtCmd[] = { GetFirmwareVersion };
|
||||||
|
pn53x_transceive (pnd, abtCmd, sizeof (abtCmd), NULL, NULL);
|
||||||
// ...and we don't care about error
|
// ...and we don't care about error
|
||||||
pnd->iLastError = 0;
|
pnd->iLastError = 0;
|
||||||
|
|
||||||
|
|
|
@ -12,5 +12,6 @@ ATTRS{idVendor}=="054c", ATTRS{idProduct}=="0193", MODE="0664", GROUP="plugdev"
|
||||||
ATTRS{idVendor}=="04cc", ATTRS{idProduct}=="2533", MODE="0664", GROUP="plugdev"
|
ATTRS{idVendor}=="04cc", ATTRS{idProduct}=="2533", MODE="0664", GROUP="plugdev"
|
||||||
ATTRS{idVendor}=="04e6", ATTRS{idProduct}=="5591", MODE="0664", GROUP="plugdev"
|
ATTRS{idVendor}=="04e6", ATTRS{idProduct}=="5591", MODE="0664", GROUP="plugdev"
|
||||||
ATTRS{idVendor}=="1fd3", ATTRS{idProduct}=="0608", MODE="0664", GROUP="plugdev"
|
ATTRS{idVendor}=="1fd3", ATTRS{idProduct}=="0608", MODE="0664", GROUP="plugdev"
|
||||||
|
ATTRS{idVendor}=="054c", ATTRS{idProduct}=="02e1", MODE="0664", GROUP="plugdev"
|
||||||
|
|
||||||
LABEL="pn53x_rules_end"
|
LABEL="pn53x_rules_end"
|
||||||
|
|
Loading…
Add table
Reference in a new issue