Rework and fix error frames detection.
While here, rename the pn53x_transceive_callback() function to pn53x_transceive_check_ack_frame_callback() to make it more obvious what it is supposed to do.
This commit is contained in:
parent
b0737bd1a0
commit
f4aa4edc94
3 changed files with 21 additions and 6 deletions
|
|
@ -68,9 +68,10 @@ const byte_t pncmd_target_get_status [ 2] = { 0xD4,0x8A };
|
|||
|
||||
static const byte_t pn53x_ack_frame[] = { 0x00,0x00,0xff,0x00,0xff,0x00 };
|
||||
static const byte_t pn53x_nack_frame[] = { 0x00,0x00,0xff,0xff,0x00,0x00 };
|
||||
static const byte_t pn53x_error_frame[] = { 0x00,0x00,0xff,0x01,0xff,0x7f,0x81,0x00 };
|
||||
|
||||
// XXX: Is this function correctly named ?
|
||||
bool pn53x_transceive_callback(nfc_device_t* pnd, const byte_t *pbtRxFrame, const size_t szRxFrameLen)
|
||||
bool pn53x_transceive_check_ack_frame_callback(nfc_device_t* pnd, const byte_t *pbtRxFrame, const size_t szRxFrameLen)
|
||||
{
|
||||
if (szRxFrameLen >= sizeof (pn53x_ack_frame)) {
|
||||
if (0 == memcmp (pbtRxFrame, pn53x_ack_frame, sizeof (pn53x_ack_frame))) {
|
||||
|
|
@ -93,6 +94,19 @@ bool pn53x_transceive_callback(nfc_device_t* pnd, const byte_t *pbtRxFrame, cons
|
|||
return false;
|
||||
}
|
||||
|
||||
bool pn53x_transceive_check_error_frame_callback(nfc_device_t* pnd, const byte_t *pbtRxFrame, const size_t szRxFrameLen)
|
||||
{
|
||||
if (szRxFrameLen >= sizeof (pn53x_error_frame)) {
|
||||
if (0 == memcmp (pbtRxFrame, pn53x_error_frame, sizeof (pn53x_error_frame))) {
|
||||
DBG("%s", "PN53x sent an error frame");
|
||||
pnd->iLastError = DEISERRFRAME;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool pn53x_transceive(nfc_device_t* pnd, const byte_t* pbtTx, const size_t szTxLen, byte_t* pbtRx, size_t* pszRxLen)
|
||||
{
|
||||
byte_t abtRx[MAX_FRAME_LEN];
|
||||
|
|
|
|||
|
|
@ -74,7 +74,8 @@
|
|||
#define DEACKMISMATCH 0x0200 /* Unexpected data */
|
||||
#define DEISERRFRAME 0x0300 /* Error frame */
|
||||
|
||||
bool pn53x_transceive_callback(nfc_device_t* pnd, const byte_t *pbtRxFrame, const size_t szRxFrameLen);
|
||||
bool pn53x_transceive_check_ack_frame_callback(nfc_device_t* pnd, const byte_t *pbtRxFrame, const size_t szRxFrameLen);
|
||||
bool pn53x_transceive_check_error_frame_callback(nfc_device_t* pnd, const byte_t *pbtRxFrame, const size_t szRxFrameLen);
|
||||
bool pn53x_transceive(nfc_device_t* pnd, const byte_t* pbtTx, const size_t szTxLen, byte_t* pbtRx, size_t* pszRxLen);
|
||||
byte_t pn53x_get_reg(nfc_device_t* pnd, uint16_t ui16Reg);
|
||||
bool pn53x_set_reg(nfc_device_t* pnd, uint16_t ui16Reg, uint8_t ui8SybmolMask, uint8_t ui8Value);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue