chips/pn53x: set ui8LastCommand in chip layer instead of driver layer.

This commit is contained in:
Romuald Conty 2011-05-09 14:22:12 +00:00
parent 902bbfb04c
commit 25e2dbec95
4 changed files with 10 additions and 8 deletions

View file

@ -119,12 +119,15 @@ pn53x_transceive (nfc_device_t * pnd, const byte_t * pbtTx, const size_t szTx, b
}
// Call the send/receice callback functions of the current driver
if (!CHIP_DATA(pnd)->io->send (pnd, pbtTx, szTx))
if (!CHIP_DATA (pnd)->io->send (pnd, pbtTx, szTx))
return false;
// Command is sent, we store the command
CHIP_DATA (pnd)->ui8LastCommand = pbtTx[0];
// 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
CHIP_DATA(pnd)->power_mode = POWERDOWN;
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;
}
int res = CHIP_DATA(pnd)->io->receive (pnd, pbtRx, *pszRx);
@ -443,7 +446,6 @@ bool
pn53x_read_register (nfc_device_t * pnd, uint16_t ui16Reg, uint8_t * ui8Value)
{
byte_t abtCmd[] = { ReadRegister, ui16Reg >> 8, ui16Reg & 0xff };
byte_t abtRegValue[2];
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))
return false;
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 {
abtCmd[3] = ui8Value;
return pn53x_transceive (pnd, abtCmd, sizeof (abtCmd), NULL, NULL);
}
return true;
}
bool

View file

@ -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"
CHIP_DATA (pnd)->ui8LastCommand = pbtData[0];
size_t szFrame = 0;
if (szData > PN53x_NORMAL_FRAME__DATA_MAX_LEN) {
// ARYGON Reader with PN532 equipped does not support extended frame (bug in ARYGON firmware?)

View file

@ -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"
CHIP_DATA (pnd)->ui8LastCommand = pbtData[0];
size_t szFrame = 0;
if (!pn53x_build_frame (abtFrame, &szFrame, pbtData, szData)) {

View file

@ -368,7 +368,6 @@ bool
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"
CHIP_DATA (pnd)->ui8LastCommand = pbtData[0];
size_t szFrame = 0;
pn53x_build_frame (abtFrame, &szFrame, pbtData, szData);