From e5201c1575b080d023a36ed36edd8017f5c4ce28 Mon Sep 17 00:00:00 2001 From: Daniel Tomas Date: Wed, 20 Apr 2011 17:28:16 -0700 Subject: 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 --- Linux_x86/phDal4Nfc.c | 34 +++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-) (limited to 'Linux_x86') 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 #include +#include #ifdef ANDROID #include #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; } -- cgit v1.1