chips/pn53x: set ui8LastCommand in chip layer instead of driver layer.
This commit is contained in:
parent
902bbfb04c
commit
25e2dbec95
4 changed files with 10 additions and 8 deletions
|
@ -122,6 +122,9 @@ pn53x_transceive (nfc_device_t * pnd, const byte_t * pbtTx, const size_t szTx, b
|
||||||
if (!CHIP_DATA (pnd)->io->send (pnd, pbtTx, szTx))
|
if (!CHIP_DATA (pnd)->io->send (pnd, pbtTx, szTx))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
// Command is sent, we store the command
|
||||||
|
CHIP_DATA (pnd)->ui8LastCommand = pbtTx[0];
|
||||||
|
|
||||||
// Handle power mode for PN532
|
// Handle power mode for PN532
|
||||||
if ((CHIP_DATA (pnd)->type == PN532) && (TgInitAsTarget == pbtTx[0])) { // PN532 automatically goes into PowerDown mode when TgInitAsTarget command will be sent
|
if ((CHIP_DATA (pnd)->type == PN532) && (TgInitAsTarget == pbtTx[0])) { // PN532 automatically goes into PowerDown mode when TgInitAsTarget command will be sent
|
||||||
CHIP_DATA (pnd)->power_mode = POWERDOWN;
|
CHIP_DATA (pnd)->power_mode = POWERDOWN;
|
||||||
|
@ -443,7 +446,6 @@ bool
|
||||||
pn53x_read_register (nfc_device_t * pnd, uint16_t ui16Reg, uint8_t * ui8Value)
|
pn53x_read_register (nfc_device_t * pnd, uint16_t ui16Reg, uint8_t * ui8Value)
|
||||||
{
|
{
|
||||||
byte_t abtCmd[] = { ReadRegister, ui16Reg >> 8, ui16Reg & 0xff };
|
byte_t abtCmd[] = { ReadRegister, ui16Reg >> 8, ui16Reg & 0xff };
|
||||||
|
|
||||||
byte_t abtRegValue[2];
|
byte_t abtRegValue[2];
|
||||||
size_t szRegValue = sizeof (abtRegValue);
|
size_t szRegValue = sizeof (abtRegValue);
|
||||||
|
|
||||||
|
@ -475,11 +477,14 @@ pn53x_write_register (nfc_device_t * pnd, const uint16_t ui16Reg, const uint8_t
|
||||||
if (!pn53x_read_register (pnd, ui16Reg, &ui8Current))
|
if (!pn53x_read_register (pnd, ui16Reg, &ui8Current))
|
||||||
return false;
|
return false;
|
||||||
abtCmd[3] = ((ui8Value & ui8SymbolMask) | (ui8Current & (~ui8SymbolMask)));
|
abtCmd[3] = ((ui8Value & ui8SymbolMask) | (ui8Current & (~ui8SymbolMask)));
|
||||||
return (abtCmd[3] != ui8Current) ? pn53x_transceive (pnd, abtCmd, sizeof (abtCmd), NULL, NULL) : true;
|
if (abtCmd[3] != ui8Current) {
|
||||||
|
return pn53x_transceive (pnd, abtCmd, sizeof (abtCmd), NULL, NULL);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
abtCmd[3] = ui8Value;
|
abtCmd[3] = ui8Value;
|
||||||
return pn53x_transceive (pnd, abtCmd, sizeof (abtCmd), NULL, NULL);
|
return pn53x_transceive (pnd, abtCmd, sizeof (abtCmd), NULL, NULL);
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
|
|
|
@ -230,7 +230,6 @@ arygon_tama_send (nfc_device_t * pnd, const byte_t * pbtData, const size_t szDat
|
||||||
{
|
{
|
||||||
byte_t abtFrame[ARYGON_TX_BUFFER_LEN] = { DEV_ARYGON_PROTOCOL_TAMA, 0x00, 0x00, 0xff }; // Every packet must start with "0x32 0x00 0x00 0xff"
|
byte_t abtFrame[ARYGON_TX_BUFFER_LEN] = { DEV_ARYGON_PROTOCOL_TAMA, 0x00, 0x00, 0xff }; // Every packet must start with "0x32 0x00 0x00 0xff"
|
||||||
|
|
||||||
CHIP_DATA (pnd)->ui8LastCommand = pbtData[0];
|
|
||||||
size_t szFrame = 0;
|
size_t szFrame = 0;
|
||||||
if (szData > PN53x_NORMAL_FRAME__DATA_MAX_LEN) {
|
if (szData > PN53x_NORMAL_FRAME__DATA_MAX_LEN) {
|
||||||
// ARYGON Reader with PN532 equipped does not support extended frame (bug in ARYGON firmware?)
|
// ARYGON Reader with PN532 equipped does not support extended frame (bug in ARYGON firmware?)
|
||||||
|
|
|
@ -241,7 +241,6 @@ pn532_uart_send (nfc_device_t * pnd, const byte_t * pbtData, const size_t szData
|
||||||
};
|
};
|
||||||
|
|
||||||
byte_t abtFrame[PN532_BUFFER_LEN] = { 0x00, 0x00, 0xff }; // Every packet must start with "00 00 ff"
|
byte_t abtFrame[PN532_BUFFER_LEN] = { 0x00, 0x00, 0xff }; // Every packet must start with "00 00 ff"
|
||||||
CHIP_DATA (pnd)->ui8LastCommand = pbtData[0];
|
|
||||||
size_t szFrame = 0;
|
size_t szFrame = 0;
|
||||||
|
|
||||||
if (!pn53x_build_frame (abtFrame, &szFrame, pbtData, szData)) {
|
if (!pn53x_build_frame (abtFrame, &szFrame, pbtData, szData)) {
|
||||||
|
|
|
@ -368,7 +368,6 @@ bool
|
||||||
pn53x_usb_send (nfc_device_t * pnd, const byte_t * pbtData, const size_t szData)
|
pn53x_usb_send (nfc_device_t * pnd, const byte_t * pbtData, const size_t szData)
|
||||||
{
|
{
|
||||||
byte_t abtFrame[PN53X_USB_BUFFER_LEN] = { 0x00, 0x00, 0xff }; // Every packet must start with "00 00 ff"
|
byte_t abtFrame[PN53X_USB_BUFFER_LEN] = { 0x00, 0x00, 0xff }; // Every packet must start with "00 00 ff"
|
||||||
CHIP_DATA (pnd)->ui8LastCommand = pbtData[0];
|
|
||||||
size_t szFrame = 0;
|
size_t szFrame = 0;
|
||||||
|
|
||||||
pn53x_build_frame (abtFrame, &szFrame, pbtData, szData);
|
pn53x_build_frame (abtFrame, &szFrame, pbtData, szData);
|
||||||
|
|
Loading…
Reference in a new issue