Lines Matching refs:gpphTmlNfc_Context

44 phTmlNfc_Context_t* gpphTmlNfc_Context = NULL;  variable
81 if (NULL != gpphTmlNfc_Context) { in phTmlNfc_Init()
92 gpphTmlNfc_Context = in phTmlNfc_Init()
95 if (NULL == gpphTmlNfc_Context) { in phTmlNfc_Init()
99 memset(gpphTmlNfc_Context, PH_TMLNFC_RESET_VALUE, in phTmlNfc_Init()
102 gpphTmlNfc_Context->bThreadDone = 1; in phTmlNfc_Init()
106 pConfig, &(gpphTmlNfc_Context->pDevHandle)); in phTmlNfc_Init()
110 gpphTmlNfc_Context->pDevHandle = NULL; in phTmlNfc_Init()
112 gpphTmlNfc_Context->tReadInfo.bEnable = 0; in phTmlNfc_Init()
113 gpphTmlNfc_Context->tWriteInfo.bEnable = 0; in phTmlNfc_Init()
114 gpphTmlNfc_Context->tReadInfo.bThreadBusy = false; in phTmlNfc_Init()
115 gpphTmlNfc_Context->tWriteInfo.bThreadBusy = false; in phTmlNfc_Init()
116 if (pthread_mutex_init(&gpphTmlNfc_Context->readInfoUpdateMutex, in phTmlNfc_Init()
119 } else if (0 != sem_init(&gpphTmlNfc_Context->rxSemaphore, 0, 0)) { in phTmlNfc_Init()
121 } else if (0 != sem_init(&gpphTmlNfc_Context->txSemaphore, 0, 0)) { in phTmlNfc_Init()
123 } else if (0 != sem_init(&gpphTmlNfc_Context->postMsgSemaphore, 0, 0)) { in phTmlNfc_Init()
126 sem_post(&gpphTmlNfc_Context->postMsgSemaphore); in phTmlNfc_Init()
132 gpphTmlNfc_Context->dwTimerId = phOsalNfc_Timer_Create(); in phTmlNfc_Init()
133 if (PH_OSALNFC_TIMER_ID_INVALID != gpphTmlNfc_Context->dwTimerId) { in phTmlNfc_Init()
135 gpphTmlNfc_Context->dwCallbackThreadId = in phTmlNfc_Init()
139 gpphTmlNfc_Context->eConfig = phTmlNfc_e_DisableRetrans; in phTmlNfc_Init()
142 gpphTmlNfc_Context->bRetryCount = in phTmlNfc_Init()
144 gpphTmlNfc_Context->bWriteCbInvoked = false; in phTmlNfc_Init()
182 gpphTmlNfc_Context->eConfig = eConfiguration; in phTmlNfc_ConfigNciPktReTx()
186 gpphTmlNfc_Context->bRetryCount = bRetryCounter; in phTmlNfc_ConfigNciPktReTx()
192 gpphTmlNfc_Context->bRetryCount = in phTmlNfc_ConfigNciPktReTx()
220 pthread_create(&gpphTmlNfc_Context->readerThread, NULL, in phTmlNfc_StartThread()
227 pthread_create(&gpphTmlNfc_Context->writerThread, NULL, in phTmlNfc_StartThread()
250 if ((gpphTmlNfc_Context->dwTimerId == dwTimerId) && (NULL == pContext)) { in phTmlNfc_ReTxTimerCb()
258 gpphTmlNfc_Context->tWriteInfo.bThreadBusy = true; in phTmlNfc_ReTxTimerCb()
259 gpphTmlNfc_Context->tWriteInfo.bEnable = 1; in phTmlNfc_ReTxTimerCb()
261 sem_post(&gpphTmlNfc_Context->txSemaphore); in phTmlNfc_ReTxTimerCb()
282 wStatus = phOsalNfc_Timer_Start(gpphTmlNfc_Context->dwTimerId, in phTmlNfc_InitiateTimer()
316 while (gpphTmlNfc_Context->bThreadDone) { in phTmlNfc_TmlThread()
320 sem_wait(&gpphTmlNfc_Context->rxSemaphore); in phTmlNfc_TmlThread()
323 if (1 == gpphTmlNfc_Context->tReadInfo.bEnable) { in phTmlNfc_TmlThread()
332 if (NULL != gpphTmlNfc_Context->pDevHandle) { in phTmlNfc_TmlThread()
335 phTmlNfc_i2c_read(gpphTmlNfc_Context->pDevHandle, temp, 260); in phTmlNfc_TmlThread()
345 sem_post(&gpphTmlNfc_Context->rxSemaphore); in phTmlNfc_TmlThread()
349 sem_post(&gpphTmlNfc_Context->rxSemaphore); in phTmlNfc_TmlThread()
351 pthread_mutex_lock(&gpphTmlNfc_Context->readInfoUpdateMutex); in phTmlNfc_TmlThread()
352 memcpy(gpphTmlNfc_Context->tReadInfo.pBuffer, temp, dwNoBytesWrRd); in phTmlNfc_TmlThread()
357 gpphTmlNfc_Context->tReadInfo.bEnable = 0; in phTmlNfc_TmlThread()
358 if ((phTmlNfc_e_EnableRetrans == gpphTmlNfc_Context->eConfig) && in phTmlNfc_TmlThread()
359 (0x00 != (gpphTmlNfc_Context->tReadInfo.pBuffer[0] & 0xE0))) { in phTmlNfc_TmlThread()
363 phOsalNfc_Timer_Stop(gpphTmlNfc_Context->dwTimerId); in phTmlNfc_TmlThread()
367 gpphTmlNfc_Context->bWriteCbInvoked = false; in phTmlNfc_TmlThread()
370 if (gpphTmlNfc_Context->tWriteInfo.bThreadBusy) { in phTmlNfc_TmlThread()
375 gpphTmlNfc_Context->tReadInfo.wLength = (uint16_t)(dwNoBytesWrRd); in phTmlNfc_TmlThread()
377 gpphTmlNfc_Context->tReadInfo.pBuffer, in phTmlNfc_TmlThread()
378 gpphTmlNfc_Context->tReadInfo.wLength); in phTmlNfc_TmlThread()
385 tTransactionInfo.pBuff = gpphTmlNfc_Context->tReadInfo.pBuffer; in phTmlNfc_TmlThread()
387 tTransactionInfo.wLength = gpphTmlNfc_Context->tReadInfo.wLength; in phTmlNfc_TmlThread()
397 pthread_mutex_unlock(&gpphTmlNfc_Context->readInfoUpdateMutex); in phTmlNfc_TmlThread()
399 phTmlNfc_DeferredCall(gpphTmlNfc_Context->dwCallbackThreadId, &tMsg); in phTmlNfc_TmlThread()
440 while (gpphTmlNfc_Context->bThreadDone) { in phTmlNfc_TmlWriterThread()
442 sem_wait(&gpphTmlNfc_Context->txSemaphore); in phTmlNfc_TmlWriterThread()
444 if (1 == gpphTmlNfc_Context->tWriteInfo.bEnable) { in phTmlNfc_TmlWriterThread()
448 if (NULL != gpphTmlNfc_Context->pDevHandle) { in phTmlNfc_TmlWriterThread()
450 gpphTmlNfc_Context->tWriteInfo.bEnable = 0; in phTmlNfc_TmlWriterThread()
456 phTmlNfc_i2c_write(gpphTmlNfc_Context->pDevHandle, in phTmlNfc_TmlWriterThread()
457 gpphTmlNfc_Context->tWriteInfo.pBuffer, in phTmlNfc_TmlWriterThread()
458 gpphTmlNfc_Context->tWriteInfo.wLength); in phTmlNfc_TmlWriterThread()
475 gpphTmlNfc_Context->tWriteInfo.pBuffer, in phTmlNfc_TmlWriterThread()
476 gpphTmlNfc_Context->tWriteInfo.wLength); in phTmlNfc_TmlWriterThread()
486 tTransactionInfo.pBuff = gpphTmlNfc_Context->tWriteInfo.pBuffer; in phTmlNfc_TmlWriterThread()
505 if ((phTmlNfc_e_EnableRetrans == gpphTmlNfc_Context->eConfig) && in phTmlNfc_TmlWriterThread()
506 (0x00 != (gpphTmlNfc_Context->tWriteInfo.pBuffer[0] & 0xE0))) { in phTmlNfc_TmlWriterThread()
507 if (gpphTmlNfc_Context->bWriteCbInvoked == false) { in phTmlNfc_TmlWriterThread()
510 phTmlNfc_DeferredCall(gpphTmlNfc_Context->dwCallbackThreadId, in phTmlNfc_TmlWriterThread()
512 gpphTmlNfc_Context->bWriteCbInvoked = true; in phTmlNfc_TmlWriterThread()
517 phTmlNfc_DeferredCall(gpphTmlNfc_Context->dwCallbackThreadId, &tMsg); in phTmlNfc_TmlWriterThread()
524 if ((phTmlNfc_e_EnableRetrans == gpphTmlNfc_Context->eConfig) && in phTmlNfc_TmlWriterThread()
525 (0x00 != (gpphTmlNfc_Context->tWriteInfo.pBuffer[0] & 0xE0))) { in phTmlNfc_TmlWriterThread()
531 gpphTmlNfc_Context->tWriteInfo.bEnable = 0; in phTmlNfc_TmlWriterThread()
557 if (NULL == gpphTmlNfc_Context) { in phTmlNfc_CleanUp()
560 if (NULL != gpphTmlNfc_Context->pDevHandle) { in phTmlNfc_CleanUp()
561 (void)phTmlNfc_i2c_reset(gpphTmlNfc_Context->pDevHandle, 0); in phTmlNfc_CleanUp()
562 gpphTmlNfc_Context->bThreadDone = 0; in phTmlNfc_CleanUp()
564 sem_destroy(&gpphTmlNfc_Context->rxSemaphore); in phTmlNfc_CleanUp()
565 sem_destroy(&gpphTmlNfc_Context->txSemaphore); in phTmlNfc_CleanUp()
566 sem_destroy(&gpphTmlNfc_Context->postMsgSemaphore); in phTmlNfc_CleanUp()
567 phTmlNfc_i2c_close(gpphTmlNfc_Context->pDevHandle); in phTmlNfc_CleanUp()
568 gpphTmlNfc_Context->pDevHandle = NULL; in phTmlNfc_CleanUp()
570 free((void*)gpphTmlNfc_Context); in phTmlNfc_CleanUp()
572 gpphTmlNfc_Context = NULL; in phTmlNfc_CleanUp()
597 if (NULL != gpphTmlNfc_Context) { in phTmlNfc_Shutdown()
599 gpphTmlNfc_Context->bThreadDone = 0; in phTmlNfc_Shutdown()
602 sem_post(&gpphTmlNfc_Context->rxSemaphore); in phTmlNfc_Shutdown()
604 sem_post(&gpphTmlNfc_Context->txSemaphore); in phTmlNfc_Shutdown()
606 sem_post(&gpphTmlNfc_Context->postMsgSemaphore); in phTmlNfc_Shutdown()
608 sem_post(&gpphTmlNfc_Context->postMsgSemaphore); in phTmlNfc_Shutdown()
610 pthread_mutex_destroy(&gpphTmlNfc_Context->readInfoUpdateMutex); in phTmlNfc_Shutdown()
611 if (0 != pthread_join(gpphTmlNfc_Context->readerThread, (void**)NULL)) { in phTmlNfc_Shutdown()
614 if (0 != pthread_join(gpphTmlNfc_Context->writerThread, (void**)NULL)) { in phTmlNfc_Shutdown()
664 if (NULL != gpphTmlNfc_Context) { in phTmlNfc_Write()
665 if ((NULL != gpphTmlNfc_Context->pDevHandle) && (NULL != pBuffer) && in phTmlNfc_Write()
667 if (!gpphTmlNfc_Context->tWriteInfo.bThreadBusy) { in phTmlNfc_Write()
669 gpphTmlNfc_Context->tWriteInfo.bThreadBusy = true; in phTmlNfc_Write()
673 gpphTmlNfc_Context->tWriteInfo.pBuffer = pBuffer; in phTmlNfc_Write()
674 gpphTmlNfc_Context->tWriteInfo.wLength = wLength; in phTmlNfc_Write()
675 gpphTmlNfc_Context->tWriteInfo.pThread_Callback = pTmlWriteComplete; in phTmlNfc_Write()
676 gpphTmlNfc_Context->tWriteInfo.pContext = pContext; in phTmlNfc_Write()
680 if (phTmlNfc_e_EnableRetrans == gpphTmlNfc_Context->eConfig) { in phTmlNfc_Write()
685 bCurrentRetryCount = gpphTmlNfc_Context->bRetryCount; in phTmlNfc_Write()
686 gpphTmlNfc_Context->bWriteCbInvoked = false; in phTmlNfc_Write()
689 gpphTmlNfc_Context->tWriteInfo.bEnable = 1; in phTmlNfc_Write()
690 sem_post(&gpphTmlNfc_Context->txSemaphore); in phTmlNfc_Write()
721 if ((NULL != gpphTmlNfc_Context) && (NULL != pTmlReadComplete)) { in phTmlNfc_UpdateReadCompleteCallback()
722 gpphTmlNfc_Context->tReadInfo.pThread_Callback = pTmlReadComplete; in phTmlNfc_UpdateReadCompleteCallback()
759 if (NULL != gpphTmlNfc_Context) { in phTmlNfc_Read()
760 if ((gpphTmlNfc_Context->pDevHandle != NULL) && (NULL != pBuffer) && in phTmlNfc_Read()
762 if (!gpphTmlNfc_Context->tReadInfo.bThreadBusy) { in phTmlNfc_Read()
763 pthread_mutex_lock(&gpphTmlNfc_Context->readInfoUpdateMutex); in phTmlNfc_Read()
765 gpphTmlNfc_Context->tReadInfo.bThreadBusy = true; in phTmlNfc_Read()
769 gpphTmlNfc_Context->tReadInfo.pBuffer = pBuffer; in phTmlNfc_Read()
770 gpphTmlNfc_Context->tReadInfo.wLength = wLength; in phTmlNfc_Read()
771 gpphTmlNfc_Context->tReadInfo.pThread_Callback = pTmlReadComplete; in phTmlNfc_Read()
772 gpphTmlNfc_Context->tReadInfo.pContext = pContext; in phTmlNfc_Read()
776 gpphTmlNfc_Context->tReadInfo.bEnable = 1; in phTmlNfc_Read()
777 pthread_mutex_unlock(&gpphTmlNfc_Context->readInfoUpdateMutex); in phTmlNfc_Read()
779 sem_post(&gpphTmlNfc_Context->rxSemaphore); in phTmlNfc_Read()
812 gpphTmlNfc_Context->tReadInfo.bEnable = 0; in phTmlNfc_ReadAbort()
815 gpphTmlNfc_Context->tReadInfo.bThreadBusy = false; in phTmlNfc_ReadAbort()
841 gpphTmlNfc_Context->tWriteInfo.bEnable = 0; in phTmlNfc_WriteAbort()
846 gpphTmlNfc_Context->tWriteInfo.bThreadBusy = false; in phTmlNfc_WriteAbort()
873 if (NULL == gpphTmlNfc_Context) { in phTmlNfc_IoCtl()
879 phTmlNfc_i2c_reset(gpphTmlNfc_Context->pDevHandle, 1); in phTmlNfc_IoCtl()
881 phTmlNfc_i2c_reset(gpphTmlNfc_Context->pDevHandle, 0); in phTmlNfc_IoCtl()
883 phTmlNfc_i2c_reset(gpphTmlNfc_Context->pDevHandle, 1); in phTmlNfc_IoCtl()
888 phTmlNfc_i2c_reset(gpphTmlNfc_Context->pDevHandle, 0); in phTmlNfc_IoCtl()
890 phTmlNfc_i2c_reset(gpphTmlNfc_Context->pDevHandle, 1); in phTmlNfc_IoCtl()
896 (void)phTmlNfc_i2c_reset(gpphTmlNfc_Context->pDevHandle, 2); in phTmlNfc_IoCtl()
928 sem_wait(&gpphTmlNfc_Context->postMsgSemaphore); in phTmlNfc_DeferredCall()
930 phDal4Nfc_msgsnd(gpphTmlNfc_Context->dwCallbackThreadId, ptWorkerMsg, 0); in phTmlNfc_DeferredCall()
931 sem_post(&gpphTmlNfc_Context->postMsgSemaphore); in phTmlNfc_DeferredCall()
950 gpphTmlNfc_Context->tReadInfo.bThreadBusy = false; in phTmlNfc_ReadDeferredCb()
951 gpphTmlNfc_Context->tReadInfo.pThread_Callback( in phTmlNfc_ReadDeferredCb()
952 gpphTmlNfc_Context->tReadInfo.pContext, pTransactionInfo); in phTmlNfc_ReadDeferredCb()
973 gpphTmlNfc_Context->tWriteInfo.bThreadBusy = false; in phTmlNfc_WriteDeferredCb()
974 gpphTmlNfc_Context->tWriteInfo.pThread_Callback( in phTmlNfc_WriteDeferredCb()
975 gpphTmlNfc_Context->tWriteInfo.pContext, pTransactionInfo); in phTmlNfc_WriteDeferredCb()