summaryrefslogtreecommitdiffstats
path: root/Linux_x86
diff options
context:
space:
mode:
authorDaniel TOMAS <dtomas.nxp@gmail.com>2011-09-01 17:09:40 +0200
committerJeff Hamilton <jham@android.com>2011-09-09 11:57:19 -0700
commitdf82c4dd7c6d5ad232b5628edf73aa9ea3f8c2c0 (patch)
tree57aafb732392542d0c04e9700c7f4b543e30c3cf /Linux_x86
parent34caeca8a5ec2aedade68a77393d0aff03f9bd72 (diff)
downloadexternal_libnfc-nxp-df82c4dd7c6d5ad232b5628edf73aa9ea3f8c2c0.zip
external_libnfc-nxp-df82c4dd7c6d5ad232b5628edf73aa9ea3f8c2c0.tar.gz
external_libnfc-nxp-df82c4dd7c6d5ad232b5628edf73aa9ea3f8c2c0.tar.bz2
Patch to add an API to load a FW image in the libnfc
This new API permit to load the PN544 FW image when a download is needed at boot time. Change-Id: I2b3406d7ae0f0211123bd680ef914e9948c81eef
Diffstat (limited to 'Linux_x86')
-rw-r--r--Linux_x86/phDal4Nfc.c61
1 files changed, 38 insertions, 23 deletions
diff --git a/Linux_x86/phDal4Nfc.c b/Linux_x86/phDal4Nfc.c
index 6d3c9fb..ec92566 100644
--- a/Linux_x86/phDal4Nfc.c
+++ b/Linux_x86/phDal4Nfc.c
@@ -282,7 +282,7 @@ NFCSTATUS phDal4Nfc_Shutdown( void *pContext, void *pHwRef)
return result;
}
-NFCSTATUS phDal4Nfc_ConfigRelease( void *pHwRef)
+NFCSTATUS phDal4Nfc_ConfigRelease(void *pHwRef)
{
NFCSTATUS result = NFCSTATUS_SUCCESS;
@@ -292,19 +292,23 @@ NFCSTATUS phDal4Nfc_ConfigRelease( void *pHwRef)
if (gDalContext.hw_valid == TRUE)
{
- DAL_PRINT("Release Read Semaphore");
- sem_post(&nfc_read_sem);
-
- /* Kill the read and write threads */
- DAL_PRINT("Stop Reader Thread");
- gReadWriteContext.nReadThreadAlive = 0;
- gReadWriteContext.nWriteThreadAlive = 0;
-
- if (pthread_join(gReadWriteContext.nReadThread, &pThreadReturn) != 0)
- {
- result = PHNFCSTVAL(CID_NFC_DAL, NFCSTATUS_FAILED);
- DAL_PRINT("phDal4Nfc_ConfigRelease KO");
- }
+ /* Signal the read and write threads to exit. NOTE: there
+ actually is no write thread! :) */
+ DAL_PRINT("Stop Reader Thread");
+ gReadWriteContext.nReadThreadAlive = 0;
+ gReadWriteContext.nWriteThreadAlive = 0;
+
+ /* Wake up the read thread so it can exit */
+ DAL_PRINT("Release Read Semaphore");
+ sem_post(&nfc_read_sem);
+
+ DAL_DEBUG("phDal4Nfc_ConfigRelease - doing pthread_join(%d)",
+ gReadWriteContext.nReadThread);
+ if (pthread_join(gReadWriteContext.nReadThread, &pThreadReturn) != 0)
+ {
+ result = PHNFCSTVAL(CID_NFC_DAL, NFCSTATUS_FAILED);
+ DAL_PRINT("phDal4Nfc_ConfigRelease KO");
+ }
/* Close the message queue */
#ifdef USE_MQ_MESSAGE_QUEUE
@@ -583,6 +587,7 @@ NFCSTATUS phDal4Nfc_Config(pphDal4Nfc_sConfig_t config,void **phwref)
gDalContext.hw_valid = TRUE;
+ phDal4Nfc_Reset(1);
phDal4Nfc_Reset(0);
phDal4Nfc_Reset(1);
@@ -677,12 +682,20 @@ int phDal4Nfc_ReaderThread(void * pArg)
DAL_PRINT("RX Thread Sem Lock\n");
sem_wait(&nfc_read_sem);
DAL_PRINT("RX Thread Sem UnLock\n");
+
+ if (!gReadWriteContext.nReadThreadAlive)
+ {
+ /* got the signal that we should exit. NOTE: we don't
+ attempt to read below, since the read may block */
+ break;
+ }
+
/* Issue read operation.*/
i2c_error_count = 0;
retry:
gReadWriteContext.nNbOfBytesRead=0;
- DAL_DEBUG("\n*New *** *****Request Length = %d",gReadWriteContext.nNbOfBytesToRead);
+ DAL_DEBUG("RX Thread *New *** *****Request Length = %d",gReadWriteContext.nNbOfBytesToRead);
memsetRet=memset(gReadWriteContext.pReadBuffer,0,gReadWriteContext.nNbOfBytesToRead);
/* Wait for IRQ !!! */
@@ -696,12 +709,12 @@ retry:
if(gReadWriteContext.nNbOfBytesToRead == 1 && gReadWriteContext.pReadBuffer[0] == 0x57)
{
i2c_error_count++;
- DAL_DEBUG("Read 0x57 %d times\n", i2c_error_count);
+ DAL_DEBUG("RX Thread Read 0x57 %d times\n", i2c_error_count);
if (i2c_error_count < 5) {
usleep(2000);
goto retry;
}
- DAL_PRINT("NOTHING TO READ, RECOVER");
+ DAL_PRINT("RX Thread NOTHING TO READ, RECOVER");
phOsalNfc_RaiseException(phOsalNfc_e_UnrecovFirmwareErr,1);
}
else
@@ -710,14 +723,14 @@ retry:
#ifdef LOW_LEVEL_TRACES
phOsalNfc_PrintData("Received buffer", (uint16_t)gReadWriteContext.nNbOfBytesRead, gReadWriteContext.pReadBuffer);
#endif
- DAL_DEBUG("Read ok. nbToRead=%d\n", gReadWriteContext.nNbOfBytesToRead);
- DAL_DEBUG("NbReallyRead=%d\n", gReadWriteContext.nNbOfBytesRead);
- DAL_PRINT("ReadBuff[]={ ");
+ DAL_DEBUG("RX Thread Read ok. nbToRead=%d\n", gReadWriteContext.nNbOfBytesToRead);
+ DAL_DEBUG("RX Thread NbReallyRead=%d\n", gReadWriteContext.nNbOfBytesRead);
+ DAL_PRINT("RX Thread ReadBuff[]={ ");
for (i = 0; i < gReadWriteContext.nNbOfBytesRead; i++)
{
- DAL_DEBUG("0x%x ", gReadWriteContext.pReadBuffer[i]);
+ DAL_DEBUG("RX Thread 0x%x ", gReadWriteContext.pReadBuffer[i]);
}
- DAL_PRINT("}\n");
+ DAL_PRINT("RX Thread }\n");
/* read completed immediately */
sMsg.eMsgType= PHDAL4NFC_READ_MESSAGE;
@@ -729,6 +742,9 @@ retry:
}
} /* End of thread Loop*/
+
+ DAL_PRINT("RX Thread exiting");
+
return TRUE;
}
@@ -952,4 +968,3 @@ void phDal4Nfc_DeferredCall(pphDal4Nfc_DeferFuncPointer_t func, void *param)
}
#undef _DAL_4_NFC_C
-