summaryrefslogtreecommitdiffstats
path: root/Linux_x86
diff options
context:
space:
mode:
authorDaniel Tomas <dtomas.nxp@gmail.com>2011-04-20 17:28:16 -0700
committerNick Pelly <npelly@google.com>2011-04-26 11:07:46 -0700
commite5201c1575b080d023a36ed36edd8017f5c4ce28 (patch)
treea61195f57278d1163d97b47eb86c295ac00784f1 /Linux_x86
parent17018c3fdfd2a3e17cb8ff950fea16ea1000506e (diff)
downloadexternal_libnfc-nxp-e5201c1575b080d023a36ed36edd8017f5c4ce28.zip
external_libnfc-nxp-e5201c1575b080d023a36ed36edd8017f5c4ce28.tar.gz
external_libnfc-nxp-e5201c1575b080d023a36ed36edd8017f5c4ce28.tar.bz2
Patch to perform a recover in case of a transaction failure
This patch permit to perform a recovery when a transaction failure is detected. To detect this exception, we are filtering the Ox57 bytes because this means that the IRQ line is high but no data is available from PN544. Change-Id: Ibb55ea3db2bc6cdff2c5b28bbe2127250c5637a8
Diffstat (limited to 'Linux_x86')
-rw-r--r--Linux_x86/phDal4Nfc.c34
1 files changed, 23 insertions, 11 deletions
diff --git a/Linux_x86/phDal4Nfc.c b/Linux_x86/phDal4Nfc.c
index 1222525..d7e306b 100644
--- a/Linux_x86/phDal4Nfc.c
+++ b/Linux_x86/phDal4Nfc.c
@@ -30,6 +30,7 @@
#include <unistd.h>
#include <pthread.h>
+#include <stdlib.h>
#ifdef ANDROID
#include <linux/ipc.h>
#else
@@ -681,8 +682,20 @@ int phDal4Nfc_ReaderThread(void * pArg)
memsetRet=memset(gReadWriteContext.pReadBuffer,0,gReadWriteContext.nNbOfBytesToRead);
/* Wait for IRQ !!! */
- gReadWriteContext.nNbOfBytesRead = gLinkFunc.read(gReadWriteContext.pReadBuffer, gReadWriteContext.nNbOfBytesToRead);
-
+ gReadWriteContext.nNbOfBytesRead = gLinkFunc.read(gReadWriteContext.pReadBuffer, gReadWriteContext.nNbOfBytesToRead);
+
+ /* TODO: Remove this hack
+ * Reading the value 0x57 indicates a HW I2C error at I2C address 0x57
+ * (pn544). There should not be false positives because a read of length 1
+ * must be a HCI length read, and a length of 0x57 is impossible (max is 33).
+ */
+ if(gReadWriteContext.nNbOfBytesToRead == 1 && gReadWriteContext.pReadBuffer[0] == 0x57)
+ {
+ DAL_PRINT("NOTHING TO READ, RECOVER");
+ phOsalNfc_RaiseException(phOsalNfc_e_UnrecovFirmwareErr,1);
+ }
+ else
+ {
DAL_DEBUG("Read ok. nbToRead=%d\n", gReadWriteContext.nNbOfBytesToRead);
DAL_DEBUG("NbReallyRead=%d\n", gReadWriteContext.nNbOfBytesRead);
DAL_PRINT("ReadBuff[]={ ");
@@ -691,17 +704,16 @@ int phDal4Nfc_ReaderThread(void * pArg)
DAL_DEBUG("0x%x ", gReadWriteContext.pReadBuffer[i]);
}
DAL_PRINT("}\n");
-
- /* read completed immediately */
- sMsg.eMsgType= PHDAL4NFC_READ_MESSAGE;
- /* Update the state */
- phDal4Nfc_FillMsg(&sMsg,&OsalMsg);
- phDal4Nfc_DeferredCall((pphDal4Nfc_DeferFuncPointer_t)phDal4Nfc_DeferredCb,(void *)pmsgType);
- memsetRet=memset(&sMsg,0,sizeof(phDal4Nfc_Message_t));
- memsetRet=memset(&OsalMsg,0,sizeof(phOsalNfc_Message_t));
+ /* read completed immediately */
+ sMsg.eMsgType= PHDAL4NFC_READ_MESSAGE;
+ /* Update the state */
+ phDal4Nfc_FillMsg(&sMsg,&OsalMsg);
+ phDal4Nfc_DeferredCall((pphDal4Nfc_DeferFuncPointer_t)phDal4Nfc_DeferredCb,(void *)pmsgType);
+ memsetRet=memset(&sMsg,0,sizeof(phDal4Nfc_Message_t));
+ memsetRet=memset(&OsalMsg,0,sizeof(phOsalNfc_Message_t));
+ }
-
} /* End of thread Loop*/
return TRUE;
}