Also use pn53x_transceive_callback() in the arygon driver.
While here, remove unneeded header in pn532_uart.c.
This commit is contained in:
parent
d0357cf3aa
commit
8fef257d16
2 changed files with 4 additions and 24 deletions
|
@ -219,9 +219,6 @@ bool arygon_transceive(nfc_device_t* pnd, const byte_t* pbtTx, const size_t szTx
|
|||
size_t szRxBufLen = BUFFER_LENGTH;
|
||||
size_t szPos;
|
||||
|
||||
const byte_t pn53x_ack_frame[] = { 0x00,0x00,0xff,0x00,0xff,0x00 };
|
||||
const byte_t pn53x_nack_frame[] = { 0x00,0x00,0xff,0xff,0x00,0x00 };
|
||||
|
||||
// Packet length = data length (len) + checksum (1) + end of stream marker (1)
|
||||
abtTxBuf[4] = szTxLen;
|
||||
// Packet length checksum
|
||||
|
@ -247,6 +244,7 @@ bool arygon_transceive(nfc_device_t* pnd, const byte_t* pbtTx, const size_t szTx
|
|||
return false;
|
||||
}
|
||||
|
||||
szRxBufLen = 6;
|
||||
if (!uart_receive((serial_port)pnd->nds,abtRxBuf,&szRxBufLen)) {
|
||||
ERR("%s", "Unable to receive data. (RX)");
|
||||
return false;
|
||||
|
@ -256,31 +254,14 @@ bool arygon_transceive(nfc_device_t* pnd, const byte_t* pbtTx, const size_t szTx
|
|||
PRINT_HEX("RX", abtRxBuf,szRxBufLen);
|
||||
#endif
|
||||
|
||||
if(szRxBufLen >= sizeof(pn53x_ack_frame)) {
|
||||
|
||||
// Check if PN53x reply ACK
|
||||
if(0!=memcmp(pn53x_ack_frame, abtRxBuf, sizeof(pn53x_ack_frame))) {
|
||||
DBG("%s", "PN53x doesn't respond ACK frame.");
|
||||
if (0==memcmp(pn53x_nack_frame, abtRxBuf, sizeof(pn53x_nack_frame))) {
|
||||
ERR("%s", "PN53x reply NACK frame.");
|
||||
// FIXME Handle NACK frame i.e. resend frame, PN53x doesn't received it correctly
|
||||
}
|
||||
if (!pn53x_transceive_callback(pnd, abtRxBuf, szRxBufLen))
|
||||
return false;
|
||||
}
|
||||
|
||||
szRxBufLen -= sizeof(pn53x_ack_frame);
|
||||
if(szRxBufLen) {
|
||||
memmove(abtRxBuf, abtRxBuf+sizeof(pn53x_ack_frame), szRxBufLen);
|
||||
}
|
||||
}
|
||||
szRxBufLen = BUFFER_LENGTH;
|
||||
|
||||
if(szRxBufLen == 0) {
|
||||
// There was no more data than ACK frame, we need to wait next frame
|
||||
DBG("%s", "There was no more data than ACK frame, we need to wait next frame");
|
||||
while (!uart_receive((serial_port)pnd->nds,abtRxBuf,&szRxBufLen)) {
|
||||
delay_ms(10);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
PRINT_HEX("RX", abtRxBuf,szRxBufLen);
|
||||
|
|
|
@ -27,7 +27,6 @@
|
|||
#endif // HAVE_CONFIG_H
|
||||
|
||||
#include "../drivers.h"
|
||||
#include "../chips/pn53x.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
|
Loading…
Reference in a new issue