summaryrefslogtreecommitdiffstats
path: root/Linux_x86
diff options
context:
space:
mode:
authorNick Pelly <npelly@google.com>2011-05-07 20:25:41 -0700
committerNick Pelly <npelly@google.com>2011-05-12 13:53:55 -0700
commit92c7e0144b84a27b4573043fef718a8ba458d062 (patch)
tree629639d996135d4e55f2d561700c6d89b03f4778 /Linux_x86
parente5201c1575b080d023a36ed36edd8017f5c4ce28 (diff)
downloadexternal_libnfc-nxp-92c7e0144b84a27b4573043fef718a8ba458d062.zip
external_libnfc-nxp-92c7e0144b84a27b4573043fef718a8ba458d062.tar.gz
external_libnfc-nxp-92c7e0144b84a27b4573043fef718a8ba458d062.tar.bz2
Retry i2c read 5 times on i2c read error.
Change-Id: I9fd0291bfd8ba9d26a0c93bc14d7184a9a188b90
Diffstat (limited to 'Linux_x86')
-rw-r--r--Linux_x86/phDal4Nfc.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/Linux_x86/phDal4Nfc.c b/Linux_x86/phDal4Nfc.c
index d7e306b..a39f062 100644
--- a/Linux_x86/phDal4Nfc.c
+++ b/Linux_x86/phDal4Nfc.c
@@ -661,6 +661,7 @@ int phDal4Nfc_ReaderThread(void * pArg)
phDal4Nfc_Message_t sMsg;
phOsalNfc_Message_t OsalMsg ;
int i;
+ int i2c_error_count;
pthread_setname_np(pthread_self(), "reader");
@@ -677,6 +678,9 @@ int phDal4Nfc_ReaderThread(void * pArg)
sem_wait(&nfc_read_sem);
DAL_PRINT("RX Thread Sem UnLock\n");
/* Issue read operation.*/
+
+ i2c_error_count = 0;
+retry:
gReadWriteContext.nNbOfBytesRead=0;
DAL_DEBUG("\n*New *** *****Request Length = %d",gReadWriteContext.nNbOfBytesToRead);
memsetRet=memset(gReadWriteContext.pReadBuffer,0,gReadWriteContext.nNbOfBytesToRead);
@@ -691,11 +695,18 @@ int phDal4Nfc_ReaderThread(void * pArg)
*/
if(gReadWriteContext.nNbOfBytesToRead == 1 && gReadWriteContext.pReadBuffer[0] == 0x57)
{
+ i2c_error_count++;
+ DAL_DEBUG("Read 0x57 %d times\n", i2c_error_count);
+ if (i2c_error_count < 5) {
+ usleep(2000);
+ goto retry;
+ }
DAL_PRINT("NOTHING TO READ, RECOVER");
phOsalNfc_RaiseException(phOsalNfc_e_UnrecovFirmwareErr,1);
}
else
{
+ i2c_error_count = 0;
DAL_DEBUG("Read ok. nbToRead=%d\n", gReadWriteContext.nNbOfBytesToRead);
DAL_DEBUG("NbReallyRead=%d\n", gReadWriteContext.nNbOfBytesRead);
DAL_PRINT("ReadBuff[]={ ");