Lines Matching refs:gpphTmlUwb_Context

39 static phTmlUwb_Context_t* gpphTmlUwb_Context;  variable
85 if (NULL != gpphTmlUwb_Context) { in phTmlUwb_Init()
95 gpphTmlUwb_Context = in phTmlUwb_Init()
98 if (NULL == gpphTmlUwb_Context) { in phTmlUwb_Init()
102 memset(gpphTmlUwb_Context, PH_TMLUWB_RESET_VALUE, in phTmlUwb_Init()
106 wInitStatus = phTmlUwb_spi_open_and_configure(pDevName, &(gpphTmlUwb_Context->pDevHandle)); in phTmlUwb_Init()
110 gpphTmlUwb_Context->pDevHandle = NULL; in phTmlUwb_Init()
112 gpphTmlUwb_Context->tWriteInfo.bThreadBusy = false; in phTmlUwb_Init()
113 gpphTmlUwb_Context->pClientMq = pClientMq; in phTmlUwb_Init()
115 … setDeviceHandle(gpphTmlUwb_Context->pDevHandle); // To set device handle for FW download usecase in phTmlUwb_Init()
117 if (0 != sem_init(&gpphTmlUwb_Context->rxSemaphore, 0, 0)) { in phTmlUwb_Init()
119 } else if (0 != sem_init(&gpphTmlUwb_Context->txSemaphore, 0, 0)) { in phTmlUwb_Init()
165 gpphTmlUwb_Context->tReadInfo.bThreadRunning = true; in phTmlUwb_TmlReaderThread()
169 while (!gpphTmlUwb_Context->tReadInfo.bThreadShouldStop) { in phTmlUwb_TmlReaderThread()
171 if(sem_wait(&gpphTmlUwb_Context->rxSemaphore)) { in phTmlUwb_TmlReaderThread()
179 if (!gpphTmlUwb_Context->pDevHandle) { in phTmlUwb_TmlReaderThread()
188 phTmlUwb_spi_read(gpphTmlUwb_Context->pDevHandle, temp, UCI_MAX_DATA_LEN); in phTmlUwb_TmlReaderThread()
190 if(gpphTmlUwb_Context->tReadInfo.bThreadShouldStop) { in phTmlUwb_TmlReaderThread()
196 sem_post(&gpphTmlUwb_Context->rxSemaphore); in phTmlUwb_TmlReaderThread()
199 sem_post(&gpphTmlUwb_Context->rxSemaphore); in phTmlUwb_TmlReaderThread()
202 sem_post(&gpphTmlUwb_Context->rxSemaphore); in phTmlUwb_TmlReaderThread()
204 memcpy(gpphTmlUwb_Context->tReadInfo.pBuffer, temp, dwNoBytesWrRd); in phTmlUwb_TmlReaderThread()
209 gpphTmlUwb_Context->tReadInfo.wLength = (uint16_t)(dwNoBytesWrRd); in phTmlUwb_TmlReaderThread()
218 tTransactionInfo.pBuff = gpphTmlUwb_Context->tReadInfo.pBuffer; in phTmlUwb_TmlReaderThread()
219 tTransactionInfo.wLength = gpphTmlUwb_Context->tReadInfo.wLength; in phTmlUwb_TmlReaderThread()
228 pthread_mutex_lock(&gpphTmlUwb_Context->wait_busy_lock); in phTmlUwb_TmlReaderThread()
229 if ((gpphTmlUwb_Context->gWriterCbflag == false) && in phTmlUwb_TmlReaderThread()
230 ((gpphTmlUwb_Context->tReadInfo.pBuffer[0] & 0x60) != 0x60)) { in phTmlUwb_TmlReaderThread()
234 pthread_mutex_unlock(&gpphTmlUwb_Context->wait_busy_lock); in phTmlUwb_TmlReaderThread()
241 gpphTmlUwb_Context->tReadInfo.bThreadRunning = false; in phTmlUwb_TmlReaderThread()
268 gpphTmlUwb_Context->tWriteInfo.bThreadRunning = true; in phTmlUwb_TmlWriterThread()
272 while (!gpphTmlUwb_Context->tWriteInfo.bThreadShouldStop) { in phTmlUwb_TmlWriterThread()
274 if (sem_wait(&gpphTmlUwb_Context->txSemaphore)) { in phTmlUwb_TmlWriterThread()
281 if (!gpphTmlUwb_Context->pDevHandle) { in phTmlUwb_TmlWriterThread()
290 pthread_mutex_lock(&gpphTmlUwb_Context->wait_busy_lock); in phTmlUwb_TmlWriterThread()
291 gpphTmlUwb_Context->gWriterCbflag = false; in phTmlUwb_TmlWriterThread()
293 phTmlUwb_spi_write(gpphTmlUwb_Context->pDevHandle, in phTmlUwb_TmlWriterThread()
294 gpphTmlUwb_Context->tWriteInfo.pBuffer, in phTmlUwb_TmlWriterThread()
295 gpphTmlUwb_Context->tWriteInfo.wLength); in phTmlUwb_TmlWriterThread()
297 pthread_mutex_unlock(&gpphTmlUwb_Context->wait_busy_lock); in phTmlUwb_TmlWriterThread()
305 gpphTmlUwb_Context->tWriteInfo.pBuffer, in phTmlUwb_TmlWriterThread()
306 gpphTmlUwb_Context->tWriteInfo.wLength); in phTmlUwb_TmlWriterThread()
318 tTransactionInfo.pBuff = gpphTmlUwb_Context->tWriteInfo.pBuffer; in phTmlUwb_TmlWriterThread()
331 pthread_mutex_lock(&gpphTmlUwb_Context->wait_busy_lock); in phTmlUwb_TmlWriterThread()
332 gpphTmlUwb_Context->gWriterCbflag = true; in phTmlUwb_TmlWriterThread()
335 pthread_mutex_unlock(&gpphTmlUwb_Context->wait_busy_lock); in phTmlUwb_TmlWriterThread()
339 gpphTmlUwb_Context->tWriteInfo.bThreadRunning = false; in phTmlUwb_TmlWriterThread()
357 if (NULL == gpphTmlUwb_Context) { in phTmlUwb_CleanUp()
360 if (NULL != gpphTmlUwb_Context->pDevHandle) { in phTmlUwb_CleanUp()
361 (void)phTmlUwb_Spi_Ioctl(gpphTmlUwb_Context->pDevHandle, phTmlUwb_ControlCode_t::SetPower, 0); in phTmlUwb_CleanUp()
364 sem_destroy(&gpphTmlUwb_Context->rxSemaphore); in phTmlUwb_CleanUp()
365 sem_destroy(&gpphTmlUwb_Context->txSemaphore); in phTmlUwb_CleanUp()
366 pthread_mutex_destroy(&gpphTmlUwb_Context->wait_busy_lock); in phTmlUwb_CleanUp()
367 pthread_cond_destroy(&gpphTmlUwb_Context->wait_busy_condition); in phTmlUwb_CleanUp()
368 phTmlUwb_spi_close(gpphTmlUwb_Context->pDevHandle); in phTmlUwb_CleanUp()
369 gpphTmlUwb_Context->pDevHandle = NULL; in phTmlUwb_CleanUp()
372 free((void*)gpphTmlUwb_Context); in phTmlUwb_CleanUp()
374 gpphTmlUwb_Context = NULL; in phTmlUwb_CleanUp()
397 if (!gpphTmlUwb_Context) { in phTmlUwb_Shutdown()
449 if (NULL != gpphTmlUwb_Context) { in phTmlUwb_Write()
450 if ((NULL != gpphTmlUwb_Context->pDevHandle) && (NULL != pBuffer) && in phTmlUwb_Write()
452 if (!gpphTmlUwb_Context->tWriteInfo.bThreadBusy) { in phTmlUwb_Write()
454 gpphTmlUwb_Context->tWriteInfo.bThreadBusy = true; in phTmlUwb_Write()
458 gpphTmlUwb_Context->tWriteInfo.pBuffer = pBuffer; in phTmlUwb_Write()
459 gpphTmlUwb_Context->tWriteInfo.wLength = wLength; in phTmlUwb_Write()
460 gpphTmlUwb_Context->tWriteInfo.pThread_Callback = pTmlWriteComplete; in phTmlUwb_Write()
461 gpphTmlUwb_Context->tWriteInfo.pContext = pContext; in phTmlUwb_Write()
465 sem_post(&gpphTmlUwb_Context->txSemaphore); in phTmlUwb_Write()
509 if (!gpphTmlUwb_Context || !gpphTmlUwb_Context->pDevHandle) { in phTmlUwb_StartRead()
517 if (gpphTmlUwb_Context->tReadInfo.bThreadRunning) { in phTmlUwb_StartRead()
522 gpphTmlUwb_Context->tReadInfo.pBuffer = pBuffer; in phTmlUwb_StartRead()
523 gpphTmlUwb_Context->tReadInfo.wLength = wLength; in phTmlUwb_StartRead()
524 gpphTmlUwb_Context->tReadInfo.pThread_Callback = pTmlReadComplete; in phTmlUwb_StartRead()
525 gpphTmlUwb_Context->tReadInfo.pContext = pContext; in phTmlUwb_StartRead()
528 sem_post(&gpphTmlUwb_Context->rxSemaphore); in phTmlUwb_StartRead()
531 gpphTmlUwb_Context->tReadInfo.bThreadShouldStop = false; in phTmlUwb_StartRead()
532 int ret = pthread_create(&gpphTmlUwb_Context->readerThread, NULL, in phTmlUwb_StartRead()
543 gpphTmlUwb_Context->tReadInfo.bThreadShouldStop = true; in phTmlUwb_StopRead()
545 if (gpphTmlUwb_Context->tReadInfo.bThreadRunning) { in phTmlUwb_StopRead()
547 …phTmlUwb_Spi_Ioctl(gpphTmlUwb_Context->pDevHandle, phTmlUwb_ControlCode_t::SetPower, ABORT_READ_PE… in phTmlUwb_StopRead()
548 sem_post(&gpphTmlUwb_Context->rxSemaphore); in phTmlUwb_StopRead()
550 pthread_join(gpphTmlUwb_Context->readerThread, NULL); in phTmlUwb_StopRead()
571 gpphTmlUwb_Context->tWriteInfo.bThreadShouldStop = false; in phTmlUwb_StartWriterThread()
574 ret = pthread_create(&gpphTmlUwb_Context->writerThread, NULL, in phTmlUwb_StartWriterThread()
597 gpphTmlUwb_Context->tWriteInfo.bThreadBusy = false; in phTmlUwb_StopWriterThread()
598 gpphTmlUwb_Context->tWriteInfo.bThreadShouldStop = true; in phTmlUwb_StopWriterThread()
600 if (gpphTmlUwb_Context->tWriteInfo.bThreadRunning) { in phTmlUwb_StopWriterThread()
601 sem_post(&gpphTmlUwb_Context->txSemaphore); in phTmlUwb_StopWriterThread()
603 pthread_join(gpphTmlUwb_Context->writerThread, NULL); in phTmlUwb_StopWriterThread()
621 gpphTmlUwb_Context->pClientMq->send(msg); in phTmlUwb_DeferredCall()
641 gpphTmlUwb_Context->tReadInfo.pThread_Callback( in phTmlUwb_ReadDeferredCb()
642 gpphTmlUwb_Context->tReadInfo.pContext, pTransactionInfo); in phTmlUwb_ReadDeferredCb()
644 sem_post(&gpphTmlUwb_Context->rxSemaphore); in phTmlUwb_ReadDeferredCb()
663 gpphTmlUwb_Context->tWriteInfo.bThreadBusy = false; in phTmlUwb_WriteDeferredCb()
664 gpphTmlUwb_Context->tWriteInfo.pThread_Callback( in phTmlUwb_WriteDeferredCb()
665 gpphTmlUwb_Context->tWriteInfo.pContext, pTransactionInfo); in phTmlUwb_WriteDeferredCb()
688 gpphTmlUwb_Context->wait_busy_flag = true; in phTmlUwb_WaitWriteComplete()
690 ret = pthread_cond_timedwait(&gpphTmlUwb_Context->wait_busy_condition, in phTmlUwb_WaitWriteComplete()
691 &gpphTmlUwb_Context->wait_busy_lock, in phTmlUwb_WaitWriteComplete()
713 if (gpphTmlUwb_Context->wait_busy_flag == true) { in phTmlUwb_SignalWriteComplete()
715 gpphTmlUwb_Context->wait_busy_flag = false; in phTmlUwb_SignalWriteComplete()
716 ret = pthread_cond_signal(&gpphTmlUwb_Context->wait_busy_condition); in phTmlUwb_SignalWriteComplete()
740 memset(&gpphTmlUwb_Context->wait_busy_condition, 0, in phTmlUwb_WaitReadInit()
741 sizeof(gpphTmlUwb_Context->wait_busy_condition)); in phTmlUwb_WaitReadInit()
742 pthread_mutex_init(&gpphTmlUwb_Context->wait_busy_lock, NULL); in phTmlUwb_WaitReadInit()
743 ret = pthread_cond_init(&gpphTmlUwb_Context->wait_busy_condition, &attr); in phTmlUwb_WaitReadInit()
762 if (NULL != gpphTmlUwb_Context->pDevHandle) { in phTmlUwb_Chip_Reset()
763 phTmlUwb_Spi_Ioctl(gpphTmlUwb_Context->pDevHandle, phTmlUwb_ControlCode_t::SetPower, 0); in phTmlUwb_Chip_Reset()
765 phTmlUwb_Spi_Ioctl(gpphTmlUwb_Context->pDevHandle, phTmlUwb_ControlCode_t::SetPower, 1); in phTmlUwb_Chip_Reset()
772 phTmlUwb_Spi_Ioctl(gpphTmlUwb_Context->pDevHandle, phTmlUwb_ControlCode_t::SetPower, PWR_SUSPEND); in phTmlUwb_Suspend()
779 phTmlUwb_Spi_Ioctl(gpphTmlUwb_Context->pDevHandle, phTmlUwb_ControlCode_t::SetPower, PWR_RESUME); in phTmlUwb_Resume()