phLibNfc.c revision 113bdd7504d69f483c4208bc30a457b7ff4b69fa
15d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/* 25d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * Copyright (C) 2010 NXP Semiconductors 35d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * 45d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * Licensed under the Apache License, Version 2.0 (the "License"); 55d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * you may not use this file except in compliance with the License. 65d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * You may obtain a copy of the License at 75d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * 85d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * http://www.apache.org/licenses/LICENSE-2.0 95d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * 105d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * Unless required by applicable law or agreed to in writing, software 115d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * distributed under the License is distributed on an "AS IS" BASIS, 125d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 135d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * See the License for the specific language governing permissions and 145d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * limitations under the License. 155d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly */ 165d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 175d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/*! 185d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * \file phLibNfc.c 195d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 205d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * Project: NFC FRI / HALDL 215d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * 225d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * $Date: Tue Jun 1 14:53:48 2010 $ 235d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * $Author: ing07385 $ 245d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * $Revision: 1.89 $ 255d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * $Aliases: NFC_FRI1.1_WK1024_SDK $ 265d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * 275d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly */ 285d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 295d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 305d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/* 315d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly************************* Header Files **************************************** 325d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly*/ 335d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 348d4d6a13c4c3bf4e966d12297cc9a9f6cf9d42a8Nick Pelly#define LOG_TAG "NFC" 358d4d6a13c4c3bf4e966d12297cc9a9f6cf9d42a8Nick Pelly 365d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#include <phLibNfc.h> 375d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#include <phDal4Nfc.h> 385d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#include <phHal4Nfc.h> 395d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#include <phOsalNfc.h> 405d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#include <phLibNfc_Internal.h> 415d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#include <phLibNfc_ndef_raw.h> 425d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#include <phLibNfc_initiator.h> 435d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#include <phLibNfc_discovery.h> 445d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#include <phNfcStatus.h> 45d625fb631ee97e320400f0c763839d166048c54bJeff Hamilton#include <cutils/log.h> 465d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/* 475d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly*************************** Macro's ****************************************** 485d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly*/ 495d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 50df82c4dd7c6d5ad232b5628edf73aa9ea3f8c2c0Daniel TOMASextern int dlopen_firmware(); 51df82c4dd7c6d5ad232b5628edf73aa9ea3f8c2c0Daniel TOMAS 525d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#ifndef STATIC_DISABLE 535d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#define STATIC static 545d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#else 555d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#define STATIC 565d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif 575d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 585d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 595d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/* 605d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly*************************** Global Variables ********************************** 615d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly*/ 625d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 635d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 645d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellypphLibNfc_LibContext_t gpphLibContext=NULL; 655d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 665d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/* 675d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly*************************** Static Function Declaration *********************** 685d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly*/ 695d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 705d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/* Init callback */ 715d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellySTATIC void phLibNfc_InitCb(void *pContext,NFCSTATUS status); 725d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 735d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/* Shutdown callback */ 745d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellySTATIC void phLibNfc_ShutdownCb(void *pContext,NFCSTATUS status); 755d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 765d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/**Default notification handler registered with lower layer immediately after 775d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly successful initialization*/ 785d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellySTATIC void phLibNfc_DefaultHandler( 795d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly void *context, 805d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHal_eNotificationType_t type, 815d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHal4Nfc_NotificationInfo_t info, 825d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS status 835d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ); 845d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/* 855d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly*************************** Function Definitions ****************************** 865d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly*/ 875d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 885d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyNFCSTATUS phLibNfc_Mgt_ConfigureDriver (pphLibNfc_sConfig_t psConfig, 895d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly void ** ppDriverHandle) 905d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly{ 915d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NULL != gpphLibContext) 925d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 935d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly return NFCSTATUS_ALREADY_INITIALISED; 945d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 955d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 965d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly return phDal4Nfc_Config(psConfig, ppDriverHandle); 975d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly} 985d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 995d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyNFCSTATUS phLibNfc_Mgt_UnConfigureDriver (void * pDriverHandle) 1005d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly{ 1015d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NULL != gpphLibContext) 1025d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 1035d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly return NFCSTATUS_ALREADY_INITIALISED; 1045d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 1055d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 1065d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly return phDal4Nfc_ConfigRelease(pDriverHandle); 1075d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly} 1085d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 1095e97605ca8d83414b122bae72e65ea388b66718adaniel_TomasNFCSTATUS phLibNfc_HW_Reset () 1103e98767aaf73b4779a2bb39601806045b2ba1739Jeff Hamilton{ 1115e97605ca8d83414b122bae72e65ea388b66718adaniel_Tomas NFCSTATUS Status = NFCSTATUS_SUCCESS; 1125e97605ca8d83414b122bae72e65ea388b66718adaniel_Tomas 113df82c4dd7c6d5ad232b5628edf73aa9ea3f8c2c0Daniel TOMAS Status = phDal4Nfc_Reset(1); 1145e97605ca8d83414b122bae72e65ea388b66718adaniel_Tomas Status = phDal4Nfc_Reset(0); 1155e97605ca8d83414b122bae72e65ea388b66718adaniel_Tomas Status = phDal4Nfc_Reset(1); 1165e97605ca8d83414b122bae72e65ea388b66718adaniel_Tomas 1175e97605ca8d83414b122bae72e65ea388b66718adaniel_Tomas return Status; 1183e98767aaf73b4779a2bb39601806045b2ba1739Jeff Hamilton} 1193e98767aaf73b4779a2bb39601806045b2ba1739Jeff Hamilton 1205e97605ca8d83414b122bae72e65ea388b66718adaniel_TomasNFCSTATUS phLibNfc_Download_Mode () 1213e98767aaf73b4779a2bb39601806045b2ba1739Jeff Hamilton{ 1225e97605ca8d83414b122bae72e65ea388b66718adaniel_Tomas return phDal4Nfc_Download(); 1233e98767aaf73b4779a2bb39601806045b2ba1739Jeff Hamilton} 1243e98767aaf73b4779a2bb39601806045b2ba1739Jeff Hamilton 125df82c4dd7c6d5ad232b5628edf73aa9ea3f8c2c0Daniel TOMASint phLibNfc_Load_Firmware_Image () 126df82c4dd7c6d5ad232b5628edf73aa9ea3f8c2c0Daniel TOMAS{ 127df82c4dd7c6d5ad232b5628edf73aa9ea3f8c2c0Daniel TOMAS int status; 128df82c4dd7c6d5ad232b5628edf73aa9ea3f8c2c0Daniel TOMAS status = dlopen_firmware(); 129df82c4dd7c6d5ad232b5628edf73aa9ea3f8c2c0Daniel TOMAS return status; 130df82c4dd7c6d5ad232b5628edf73aa9ea3f8c2c0Daniel TOMAS} 131df82c4dd7c6d5ad232b5628edf73aa9ea3f8c2c0Daniel TOMAS 13272854a2c28b99f9ab6aa60c906d5b3c1a36b04d7Martijn Coenen 13372854a2c28b99f9ab6aa60c906d5b3c1a36b04d7Martijn Coenenextern uint8_t nxp_nfc_isoxchg_timeout; 13472854a2c28b99f9ab6aa60c906d5b3c1a36b04d7Martijn CoenenNFCSTATUS phLibNfc_SetIsoXchgTimeout(uint8_t timeout) { 13572854a2c28b99f9ab6aa60c906d5b3c1a36b04d7Martijn Coenen nxp_nfc_isoxchg_timeout = timeout; 13672854a2c28b99f9ab6aa60c906d5b3c1a36b04d7Martijn Coenen return NFCSTATUS_SUCCESS; 13772854a2c28b99f9ab6aa60c906d5b3c1a36b04d7Martijn Coenen} 13872854a2c28b99f9ab6aa60c906d5b3c1a36b04d7Martijn Coenen 139b78322991a8bebe8d7ce6b7b978280c0508c4993Martijn Coenenint phLibNfc_GetIsoXchgTimeout() { 140b78322991a8bebe8d7ce6b7b978280c0508c4993Martijn Coenen return nxp_nfc_isoxchg_timeout; 141b78322991a8bebe8d7ce6b7b978280c0508c4993Martijn Coenen} 142b78322991a8bebe8d7ce6b7b978280c0508c4993Martijn Coenen 14372854a2c28b99f9ab6aa60c906d5b3c1a36b04d7Martijn Coenenextern uint32_t nxp_nfc_hci_response_timeout; 14472854a2c28b99f9ab6aa60c906d5b3c1a36b04d7Martijn CoenenNFCSTATUS phLibNfc_SetHciTimeout(uint32_t timeout_in_ms) { 14572854a2c28b99f9ab6aa60c906d5b3c1a36b04d7Martijn Coenen nxp_nfc_hci_response_timeout = timeout_in_ms; 14672854a2c28b99f9ab6aa60c906d5b3c1a36b04d7Martijn Coenen return NFCSTATUS_SUCCESS; 14772854a2c28b99f9ab6aa60c906d5b3c1a36b04d7Martijn Coenen} 14872854a2c28b99f9ab6aa60c906d5b3c1a36b04d7Martijn Coenen 149b78322991a8bebe8d7ce6b7b978280c0508c4993Martijn Coenenint phLibNfc_GetHciTimeout() { 150b78322991a8bebe8d7ce6b7b978280c0508c4993Martijn Coenen return nxp_nfc_hci_response_timeout; 151b78322991a8bebe8d7ce6b7b978280c0508c4993Martijn Coenen} 152b78322991a8bebe8d7ce6b7b978280c0508c4993Martijn Coenen 1531db6f8ed6317c429ced6d2d7c92fd5a64ffe4015Martijn Coenenextern uint32_t nxp_nfc_felica_timeout; 1541db6f8ed6317c429ced6d2d7c92fd5a64ffe4015Martijn CoenenNFCSTATUS phLibNfc_SetFelicaTimeout(uint8_t timeout_in_ms) { 1551db6f8ed6317c429ced6d2d7c92fd5a64ffe4015Martijn Coenen nxp_nfc_felica_timeout = timeout_in_ms; 1561db6f8ed6317c429ced6d2d7c92fd5a64ffe4015Martijn Coenen return NFCSTATUS_SUCCESS; 1571db6f8ed6317c429ced6d2d7c92fd5a64ffe4015Martijn Coenen} 1581db6f8ed6317c429ced6d2d7c92fd5a64ffe4015Martijn Coenen 159b78322991a8bebe8d7ce6b7b978280c0508c4993Martijn Coenenint phLibNfc_GetFelicaTimeout() { 160b78322991a8bebe8d7ce6b7b978280c0508c4993Martijn Coenen return nxp_nfc_felica_timeout; 161b78322991a8bebe8d7ce6b7b978280c0508c4993Martijn Coenen} 162b78322991a8bebe8d7ce6b7b978280c0508c4993Martijn Coenen 16301a91eaddd15d39b85c9950eb88a1c6348290556Martijn Coenenextern uint8_t nxp_nfc_mifareraw_timeout; 16401a91eaddd15d39b85c9950eb88a1c6348290556Martijn CoenenNFCSTATUS phLibNfc_SetMifareRawTimeout(uint8_t timeout) { 16501a91eaddd15d39b85c9950eb88a1c6348290556Martijn Coenen nxp_nfc_mifareraw_timeout = timeout; 16601a91eaddd15d39b85c9950eb88a1c6348290556Martijn Coenen return NFCSTATUS_SUCCESS; 16701a91eaddd15d39b85c9950eb88a1c6348290556Martijn Coenen} 16801a91eaddd15d39b85c9950eb88a1c6348290556Martijn Coenen 169b78322991a8bebe8d7ce6b7b978280c0508c4993Martijn Coenenint phLibNfc_GetMifareRawTimeout() { 170b78322991a8bebe8d7ce6b7b978280c0508c4993Martijn Coenen return nxp_nfc_mifareraw_timeout; 171b78322991a8bebe8d7ce6b7b978280c0508c4993Martijn Coenen} 172b78322991a8bebe8d7ce6b7b978280c0508c4993Martijn Coenen 1735d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/** 1745d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* Initialize the phLibNfc interface. 1755d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly*/ 1765d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 1775d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyNFCSTATUS phLibNfc_Mgt_Initialize(void *pDriverHandle, 1783e98767aaf73b4779a2bb39601806045b2ba1739Jeff Hamilton pphLibNfc_RspCb_t pInitCb, 1793e98767aaf73b4779a2bb39601806045b2ba1739Jeff Hamilton void *pContext) 1805d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly{ 1815d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS Status = NFCSTATUS_SUCCESS; 1825d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if((NULL == pDriverHandle)||(NULL == pInitCb)) 1835d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 1845d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly Status = NFCSTATUS_INVALID_PARAMETER; 1855d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 1865d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else if(NULL == gpphLibContext) 1875d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 1885d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Initialize the Lib context */ 1895d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext=(pphLibNfc_LibContext_t)phOsalNfc_GetMemory( 1905d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (uint32_t)sizeof(phLibNfc_LibContext_t)); 1915d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NULL == gpphLibContext) 1925d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 1935d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly Status=NFCSTATUS_INSUFFICIENT_RESOURCES; 1945d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 1955d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 1965d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 1975d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (void)memset((void *)gpphLibContext,0,( 1985d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (uint32_t)sizeof(phLibNfc_LibContext_t))); 1995d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 2005d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Store the Callback and context in LibContext structure*/ 2015d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->CBInfo.pClientInitCb=pInitCb; 2025d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->CBInfo.pClientInitCntx=pContext; 2035d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Initialize the HwReferece structure */ 2045d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->psHwReference=(phHal_sHwReference_t *) 2055d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phOsalNfc_GetMemory((uint32_t)sizeof(phHal_sHwReference_t)); 2065d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (void)memset((void *)gpphLibContext->psHwReference,0, 2075d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ((uint32_t)sizeof(phHal_sHwReference_t))); 2085d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Allocate the Memory for the Transceive info */ 2095d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if( gpphLibContext->psHwReference!=NULL) 2105d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 2115d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->psHwReference->p_board_driver = pDriverHandle; 2125d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly Status = phLibNfc_UpdateNextState(gpphLibContext, 2135d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly eLibNfcHalStateInitandIdle); 2145d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(Status==NFCSTATUS_SUCCESS) 2155d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 2165d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly Status=phHal4Nfc_Open( 2175d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->psHwReference, 2185d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly eInitDefault, 2195d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phLibNfc_InitCb, 2205d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (void *)gpphLibContext); 2215d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 2225d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 2235d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 2245d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 2255d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly Status = NFCSTATUS_INSUFFICIENT_RESOURCES; 2265d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 2275d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phLibNfc_Ndef_Init(); 2285d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 2295d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 2305d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else if(gpphLibContext->LibNfcState.next_state==eLibNfcHalStateShutdown) 2315d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 2325d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly Status = NFCSTATUS_SHUTDOWN; 2335d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 2345d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 2355d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 2365d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly Status=NFCSTATUS_ALREADY_INITIALISED; 2375d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 2385d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly return Status; 2395d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly} 2405d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 2415d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/* 2425d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * This function called by the HAL4 when the initialization seq is completed. 2435d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly */ 2445d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellySTATIC void phLibNfc_InitCb(void *pContext,NFCSTATUS status) 2455d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly{ 2465d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pphLibNfc_LibContext_t pLibContext=NULL; 2475d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pphLibNfc_RspCb_t pClientCb=NULL; 2485d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly void *pUpperLayerContext=NULL; 2495d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 2505d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 2515d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Initialize the local variable */ 2525d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pLibContext = (pphLibNfc_LibContext_t)pContext; 2535d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 2545d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pClientCb =pLibContext->CBInfo.pClientInitCb; 2555d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pUpperLayerContext=pLibContext->CBInfo.pClientInitCntx; 2565d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(status == NFCSTATUS_SUCCESS) 2575d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 2585d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Get the Lib context */ 2595d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pLibContext=(pphLibNfc_LibContext_t)gpphLibContext; 2605d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->sSeContext.eActivatedMode = phLibNfc_SE_ActModeOff; 2615d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(pLibContext->psHwReference->uicc_connected==TRUE) 2625d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 2635d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* populate state of the secured element */ 2645d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->sSeContext.eActivatedMode = phLibNfc_SE_ActModeDefault; 2655d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly sSecuredElementInfo[LIBNFC_SE_UICC_INDEX].eSE_CurrentState=phLibNfc_SE_Active; 2665d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pLibContext->sSeContext.uUiccActivate=TRUE; 2675d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 2685d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(pLibContext->psHwReference->smx_connected==TRUE) 2695d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 2705d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* populate state of the secured element */ 2715d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->sSeContext.eActivatedMode = phLibNfc_SE_ActModeDefault; 2725d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly sSecuredElementInfo[LIBNFC_SE_SMARTMX_INDEX].eSE_CurrentState=phLibNfc_SE_Inactive; 2735d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pLibContext->sSeContext.uSmxActivate =FALSE; 2745d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 2755d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 2765d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phLibNfc_UpdateCurState(status,pLibContext); 2775d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (void)phHal4Nfc_RegisterNotification( 2785d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pLibContext->psHwReference, 2795d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly eRegisterDefault, 2805d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phLibNfc_DefaultHandler, 2815d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (void*)pLibContext 2825d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ); 2835d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* call the upper layer register function */ 2845d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (*pClientCb)(pUpperLayerContext,status); 2855d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 2865d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 2875d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 2885d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 2895d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /*Change the status code failed*/ 2905d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = NFCSTATUS_FAILED; 2915d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Get the Lib context */ 2925d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pLibContext=(pphLibNfc_LibContext_t)gpphLibContext; 2935d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 2945d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phLibNfc_UpdateCurState(status,pLibContext); 2955d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 2965d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 2975d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 2985d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Allocate the Memory for the Transceive info */ 2995d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(pLibContext->psHwReference!= NULL) 3005d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 3015d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phOsalNfc_FreeMemory(pLibContext->psHwReference); 3025d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pLibContext->psHwReference = NULL; 3035d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 3045d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (*pClientCb)(pUpperLayerContext, status); 3055d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 3065d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phOsalNfc_FreeMemory(pLibContext); 3075d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pLibContext= NULL; 3085d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext = NULL; 3095d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 3105d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 3115d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly return; 3125d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly} 3135d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 3145d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/**Default notification handler registered with lower layer immediately after 3155d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly successful initialization*/ 3165d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellySTATIC void phLibNfc_DefaultHandler( 3175d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly void *context, 3185d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHal_eNotificationType_t type, 3195d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHal4Nfc_NotificationInfo_t info, 3205d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS status 3215d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ) 3225d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly{ 3235d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(context != (void *)gpphLibContext) 3245d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 3255d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phOsalNfc_RaiseException(phOsalNfc_e_InternalErr,1); 3265d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 3275d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 3285d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 3295d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly info = info; 3305d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if((NFC_EVENT_NOTIFICATION == type) && 3315d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (NFCSTATUS_BOARD_COMMUNICATION_ERROR == status)) 3325d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 3335d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phLibNfc_UpdateCurState(NFCSTATUS_FAILED,gpphLibContext); 3345d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phOsalNfc_RaiseException(phOsalNfc_e_UnrecovFirmwareErr,1); 3355d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 3365d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 3375d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly return; 3385d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly} 3395d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/** 3405d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* De-Initialize the LIB NFC. 3415d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly*/ 3425d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyNFCSTATUS phLibNfc_Mgt_DeInitialize(void * pDriverHandle, 3435d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pphLibNfc_RspCb_t pDeInitCb, 3445d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly void* pContext 3455d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ) 3465d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly{ 3475d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS Status = NFCSTATUS_SUCCESS; 3485d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pphLibNfc_LibContext_t pLibContext = gpphLibContext; 3495d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NULL==pDriverHandle) 3505d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 3515d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /*Check for valid parameters */ 3525d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly Status = NFCSTATUS_INVALID_PARAMETER; 3535d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 3545d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else if((pLibContext==NULL) 3555d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly || (pLibContext->LibNfcState.cur_state 3565d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly == eLibNfcHalStateShutdown)) 3575d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { /*Lib Nfc not initlized*/ 3585d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly Status = NFCSTATUS_NOT_INITIALISED; 3595d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 3605d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 3615d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 3625d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(pDeInitCb==NULL) 3635d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 3645d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHal4Nfc_Hal4Reset(pLibContext->psHwReference,(void *)pLibContext); 3655d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(pLibContext->psHwReference!=NULL) 3665d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 3675d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phOsalNfc_FreeMemory(pLibContext->psHwReference); 3685d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pLibContext->psHwReference = NULL; 3695d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 3705d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /*Free the memory allocated during NDEF read,write 3715d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly and NDEF formatting*/ 3725d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phLibNfc_Ndef_DeInit(); 3735d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phOsalNfc_FreeMemory(pLibContext); 3745d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext=NULL; 3755d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pLibContext= NULL; 3765d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 3775d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 3785d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 3795d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if (NULL!= pLibContext->CBInfo.pClientShutdownCb) 3805d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 3815d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Previous callback pending */ 3825d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly Status = NFCSTATUS_BUSY; 3835d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 3845d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly Status = NFCSTATUS_PENDING; 3855d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(TRUE != pLibContext->status.GenCb_pending_status) 3865d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 3875d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly Status = phHal4Nfc_Close(pLibContext->psHwReference, 3885d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phLibNfc_ShutdownCb, 3895d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (void *)pLibContext); 3905d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 3915d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(Status== NFCSTATUS_PENDING) 3925d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 3935d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pLibContext->CBInfo.pClientShutdownCb = pDeInitCb; 3945d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pLibContext->CBInfo.pClientShtdwnCntx = pContext; 3955d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pLibContext->status.GenCb_pending_status=TRUE; 3965d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pLibContext->LibNfcState.next_state= eLibNfcHalStateShutdown; 3975d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 3985d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 3995d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 4005d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly Status =NFCSTATUS_FAILED; 4015d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 4025d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 4035d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 4045d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly return Status; 4055d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly} 4065d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/* shutdown callback - 4075d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly Free the allocated memory here */ 4085d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellySTATIC void phLibNfc_ShutdownCb(void *pContext,NFCSTATUS status) 4095d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly{ 4105d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pphLibNfc_RspCb_t pClientCb=NULL; 4115d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly void *pUpperLayerContext=NULL; 4125d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pphLibNfc_LibContext_t pLibContext=NULL; 4135d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 4145d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly PHNFC_UNUSED_VARIABLE(pContext); 4155d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Get the Lib context */ 4165d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pLibContext=(pphLibNfc_LibContext_t)gpphLibContext; 4175d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 4185d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(pLibContext == NULL) 4195d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 4205d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = NFCSTATUS_FAILED; 4215d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 4225d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 4235d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 4245d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Initialize the local variable */ 4255d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pClientCb =pLibContext->CBInfo.pClientShutdownCb; 4265d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pUpperLayerContext=pLibContext->CBInfo.pClientShtdwnCntx; 4275d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(status == NFCSTATUS_SUCCESS) 4285d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 4295d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pLibContext->LibNfcState.cur_state = eLibNfcHalStateShutdown; 4305d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phLibNfc_UpdateCurState(status,pLibContext); 4315d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 4325d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pLibContext->status.GenCb_pending_status=FALSE; 4335d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 4345d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Allocate the Memory for the Transceive info */ 4355d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(pClientCb!=NULL) 4365d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 4375d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (*pClientCb)(pUpperLayerContext, status); 4385d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 4395d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(pLibContext->psHwReference!=NULL) 4405d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 4415d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phOsalNfc_FreeMemory(pLibContext->psHwReference); 4425d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pLibContext->psHwReference = NULL; 4435d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 4445d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NULL != gpphLibContext->psBufferedAuth) 4455d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 4465d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NULL != gpphLibContext->psBufferedAuth->sRecvData.buffer) 4475d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 4485d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phOsalNfc_FreeMemory( 4495d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->psBufferedAuth->sRecvData.buffer); 4505d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 4515d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NULL != gpphLibContext->psBufferedAuth->sSendData.buffer) 4525d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 4535d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phOsalNfc_FreeMemory( 4545d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->psBufferedAuth->sSendData.buffer); 4555d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 4565d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phOsalNfc_FreeMemory(gpphLibContext->psBufferedAuth); 4575d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->psBufferedAuth = NULL; 4585d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 4595d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /*Free the memory allocated during NDEF read,write 4605d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly and NDEF formatting*/ 4615d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phLibNfc_Ndef_DeInit(); 4625d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phOsalNfc_FreeMemory(pLibContext); 4635d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext=NULL; 4645d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pLibContext= NULL; 4655d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 4665d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 4675d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 4685d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 4695d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* shutdown sequence failed by HAL 4 */ 4705d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status= NFCSTATUS_FAILED; 4715d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pLibContext=(pphLibNfc_LibContext_t)gpphLibContext; 4725d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phLibNfc_UpdateCurState(status,pLibContext); 4735d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pLibContext->status.GenCb_pending_status=FALSE; 4745d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(pClientCb!=NULL) 4755d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 4765d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (*pClientCb)(pUpperLayerContext,status); 4775d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 4785d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 4795d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 4805d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly} 4815d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/** 4825d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* Pending shutdown call. 4835d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly*/ 4845d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 4855d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 4865d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pellyvoid phLibNfc_Pending_Shutdown(void) 4875d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly{ 4885d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS RetStatus = NFCSTATUS_SUCCESS ; 4895d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->status.GenCb_pending_status = FALSE; 4905d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly RetStatus = phHal4Nfc_Close( 4915d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->psHwReference, 4925d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phLibNfc_ShutdownCb, 4935d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (void *)gpphLibContext); 4945d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly PHNFC_UNUSED_VARIABLE(RetStatus); 4955d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly return; 4965d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly} 4975d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 4985d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 4995d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/** 5005d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* Reset the LIB NFC. 5015d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly*/ 5025d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyNFCSTATUS phLibNfc_Mgt_Reset(void *pContext) 5035d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly{ 5045d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS Status = NFCSTATUS_SUCCESS; 5055d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phLibNfc_LibContext_t *pLibNfc_Ctxt = (phLibNfc_LibContext_t *)pContext; 5065d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 5075d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if((pLibNfc_Ctxt == NULL) 5085d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly || (gpphLibContext->LibNfcState.cur_state 5095d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly == eLibNfcHalStateShutdown)) 5105d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { /*Lib Nfc not initlized*/ 5115d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly Status = NFCSTATUS_NOT_INITIALISED; 5125d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 5135d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else if(NULL == pContext) 5145d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 5155d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly Status = NFCSTATUS_INVALID_PARAMETER; 5165d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 5175d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Check for valid state,If De initialize is called then 5185d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly return NFCSTATUS_SHUTDOWN */ 5195d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else if(gpphLibContext->LibNfcState.next_state 5205d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly == eLibNfcHalStateShutdown) 5215d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 5225d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly Status = NFCSTATUS_SHUTDOWN; 5235d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 5245d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 5255d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 5265d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /*Reset all callback status*/ 5275d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (void) memset(&(gpphLibContext->RegNtfType),0, 5285d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly sizeof(phLibNfc_Registry_Info_t)); 5295d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (void) memset(&(gpphLibContext->sADDconfig),0, 5305d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly sizeof(phLibNfc_sADD_Cfg_t)); 5315d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (void) memset(&(gpphLibContext->ndef_cntx),0, 5325d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly sizeof(phLibNfc_NdefInfo_t)); 5335d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (void) memset(&(gpphLibContext->sNfcIp_Context),0, 5345d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly sizeof(phLibNfc_NfcIpInfo_t)); 5355d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (void) memset(&(gpphLibContext->sCardEmulCfg),0, 5365d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly sizeof(phHal_sEmulationCfg_t)); 5375d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (void) memset(&(gpphLibContext->Discov_handle),0, 5385d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly MAX_REMOTE_DEVICES); 5395d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 5405d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /*Free memory allocated for NDEF records*/ 5415d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NULL != gpphLibContext->psBufferedAuth) 5425d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 5435d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NULL != gpphLibContext->psBufferedAuth->sRecvData.buffer) 5445d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 5455d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phOsalNfc_FreeMemory( 5465d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->psBufferedAuth->sRecvData.buffer); 5475d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->psBufferedAuth->sRecvData.buffer = NULL; 5485d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 5495d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NULL != gpphLibContext->psBufferedAuth->sSendData.buffer) 5505d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 5515d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phOsalNfc_FreeMemory( 5525d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->psBufferedAuth->sSendData.buffer); 5535d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->psBufferedAuth->sSendData.buffer = NULL; 5545d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 5555d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phOsalNfc_FreeMemory(gpphLibContext->psBufferedAuth); 5565d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->psBufferedAuth = NULL; 5575d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 5585d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NULL != gpphLibContext->psTransInfo) 5595d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 5605d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phOsalNfc_FreeMemory(gpphLibContext->psTransInfo); 5615d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->psTransInfo = NULL; 5625d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 5635d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NULL != gpphLibContext->ndef_cntx.psNdefMap) 5645d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 5655d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NULL != gpphLibContext->ndef_cntx.psNdefMap->SendRecvBuf) 5665d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 5675d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phOsalNfc_FreeMemory(gpphLibContext->ndef_cntx.psNdefMap->SendRecvBuf); 5685d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->ndef_cntx.psNdefMap->SendRecvBuf = NULL; 5695d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 5705d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phOsalNfc_FreeMemory(gpphLibContext->ndef_cntx.psNdefMap); 5715d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->ndef_cntx.psNdefMap = NULL; 5725d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 5735d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NULL != gpphLibContext->psOverHalCtxt) 5745d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 5755d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phOsalNfc_FreeMemory(gpphLibContext->psOverHalCtxt); 5765d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->psTransInfo = NULL; 5775d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 5785d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NULL != gpphLibContext->psDevInputParam) 5795d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 5805d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phOsalNfc_FreeMemory(gpphLibContext->psDevInputParam); 5815d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->psDevInputParam = NULL; 5825d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 5835d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NULL != gpphLibContext->ndef_cntx.ndef_fmt) 5845d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 5855d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phOsalNfc_FreeMemory(gpphLibContext->ndef_cntx.ndef_fmt); 5865d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->ndef_cntx.ndef_fmt = NULL; 5875d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 5885d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NULL != pNdefRecord) 5895d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 5905d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NULL != pNdefRecord->Id) 5915d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 5925d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phOsalNfc_FreeMemory(pNdefRecord->Id); 5935d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pNdefRecord->Id = NULL; 5945d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 5955d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NULL != pNdefRecord->Type) 5965d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 5975d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phOsalNfc_FreeMemory(pNdefRecord->Type); 5985d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pNdefRecord->Type = NULL; 5995d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 6005d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NULL != pNdefRecord->PayloadData) 6015d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 6025d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phOsalNfc_FreeMemory(pNdefRecord->PayloadData); 6035d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pNdefRecord->PayloadData = NULL; 6045d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 6055d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 6065d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NULL != NdefInfo.pNdefRecord) 6075d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 6085d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phOsalNfc_FreeMemory(NdefInfo.pNdefRecord); 6095d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NdefInfo.pNdefRecord = NULL; 6105d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 6115d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NULL != gpphLibContext->phLib_NdefRecCntx.NdefCb) 6125d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 6135d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phOsalNfc_FreeMemory(gpphLibContext->phLib_NdefRecCntx.NdefCb); 6145d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->phLib_NdefRecCntx.NdefCb = NULL; 6155d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 6165d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NULL != gpphLibContext->phLib_NdefRecCntx.ndef_message.buffer) 6175d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 6185d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phOsalNfc_FreeMemory(gpphLibContext->phLib_NdefRecCntx.ndef_message.buffer); 6195d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->phLib_NdefRecCntx.ndef_message.buffer = NULL; 6205d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 6215d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* No device is connected */ 6225d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->Connected_handle = 0x00; 62334caeca8a5ec2aedade68a77393d0aff03f9bd72Daniel Tomas gpphLibContext->Prev_Connected_handle = 0x00; 6245d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->ReleaseType = NFC_INVALID_RELEASE_TYPE; 6255d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->eLibNfcCfgMode = NFC_DISCOVERY_STOP; 6265d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /*Lib Nfc Stack is initilized and in idle state*/ 6275d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->LibNfcState.cur_state = eLibNfcHalStateInitandIdle; 6285d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 6295d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Reset all callback status */ 6305d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->CBInfo.pClientCkNdefCb = NULL; 6315d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->CBInfo.pClientCkNdefCntx = NULL; 6325d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->CBInfo.pClientConCntx = NULL; 6335d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->CBInfo.pClientConnectCb = NULL; 6345d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->CBInfo.pClientDConCntx = NULL; 6355d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->CBInfo.pClientDisCfgCntx = NULL; 6365d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->CBInfo.pClientDisConfigCb = NULL; 6375d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->CBInfo.pClientInitCb = NULL; 6385d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->CBInfo.pClientInitCntx = gpphLibContext; 6395d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->CBInfo.pClientNdefNtfRespCb = NULL; 6405d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->CBInfo.pClientNdefNtfRespCntx = NULL; 6415d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->CBInfo.pClientNtfRegRespCB = NULL; 6425d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->CBInfo.pClientNtfRegRespCntx = NULL; 6435d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->CBInfo.pClientPresChkCb = NULL; 6445d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->CBInfo.pClientPresChkCntx = NULL; 6455d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->CBInfo.pClientRdNdefCb = NULL; 6465d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->CBInfo.pClientRdNdefCntx = NULL; 6475d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->CBInfo.pClientShtdwnCntx = NULL; 6485d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->CBInfo.pClientShutdownCb = NULL; 6495d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->CBInfo.pClientTransceiveCb = NULL; 6505d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->CBInfo.pClientTranseCntx = NULL; 6515d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->CBInfo.pClientWrNdefCb = NULL; 6525d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->CBInfo.pClientWrNdefCntx = NULL; 6535d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->sNfcIp_Context.pClientNfcIpCfgCb = NULL; 6545d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->sNfcIp_Context.pClientNfcIpCfgCntx = NULL; 6555d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->sNfcIp_Context.pClientNfcIpRxCb = NULL; 6565d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->sNfcIp_Context.pClientNfcIpRxCntx = NULL; 6575d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->sNfcIp_Context.pClientNfcIpTxCb = NULL; 6585d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->sNfcIp_Context.pClientNfcIpTxCntx = NULL; 6595d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->sSeContext.sSeCallabackInfo.pSeListenerNtfCb = NULL; 6605d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->sSeContext.sSeCallabackInfo.pSeListenerCtxt = NULL; 6615d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->sSeContext.sSeCallabackInfo.pSEsetModeCb = NULL; 6625d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->sSeContext.sSeCallabackInfo.pSEsetModeCtxt = NULL; 6635d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /*No callback is pending*/ 6645d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->status.GenCb_pending_status = FALSE; 6655d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 6665d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 6675d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly return Status; 6685d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly} 6695d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/** 6705d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* LibNfc state machine next state update. 6715d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly*/ 6725d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 6735d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyNFCSTATUS 6745d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyphLibNfc_UpdateNextState( 6755d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pphLibNfc_LibContext_t pLibContext, 6765d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phLibNfc_State_t next_state 6775d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ) 6785d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly{ 6795d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS status = NFCSTATUS_INVALID_STATE; 6805d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly switch(pLibContext->LibNfcState.cur_state) 6815d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 6825d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case eLibNfcHalStateShutdown: 6835d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 6845d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly switch(next_state) 6855d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 6865d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case eLibNfcHalStateShutdown: 6875d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case eLibNfcHalStateInitandIdle: 6885d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = NFCSTATUS_SUCCESS; 6895d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 6905d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly default: 6915d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 6925d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 6935d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 6945d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 6955d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case eLibNfcHalStateConfigReady: 6965d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 6975d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly switch(next_state) 6985d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 6995d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case eLibNfcHalStateShutdown: 7005d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case eLibNfcHalStateConfigReady: 7015d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case eLibNfcHalStateInitandIdle: 7025d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case eLibNfcHalStateConnect: 7035d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = NFCSTATUS_SUCCESS; 7045d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 7055d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly default: 7065d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 7075d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 7085d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 7095d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 7105d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case eLibNfcHalStateConnect: 7115d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 7125d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly switch(next_state) 7135d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 7145d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case eLibNfcHalStateShutdown: 7155d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case eLibNfcHalStateRelease: 7165d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case eLibNfcHalStateTransaction: 7175d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case eLibNfcHalStatePresenceChk: 7185d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = NFCSTATUS_SUCCESS; 7195d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 7205d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly default: 7215d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 7225d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 7235d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 7245d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 7255d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case eLibNfcHalStatePresenceChk: 7265d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 7275d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly switch(next_state) 7285d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 7295d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case eLibNfcHalStateShutdown: 7305d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case eLibNfcHalStateConfigReady: 7315d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case eLibNfcHalStateRelease: 7325d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case eLibNfcHalStateTransaction: 7335d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case eLibNfcHalStatePresenceChk: 7345d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = NFCSTATUS_SUCCESS; 7355d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 7365d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly default: 7375d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 7385d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 7395d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 7405d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 7415d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case eLibNfcHalStateInitandIdle: 7425d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 7435d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly switch(next_state) 7445d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 7455d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case eLibNfcHalStateShutdown: 7465d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case eLibNfcHalStateConfigReady: 7475d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = NFCSTATUS_SUCCESS; 7485d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 7495d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly default: 7505d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 7515d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 7525d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 7535d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 7545d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly default: 7555d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 7565d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 7575d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pLibContext->LibNfcState.next_state = 7585d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (uint8_t)((NFCSTATUS_SUCCESS == status)?next_state:pLibContext->LibNfcState.next_state); 7595d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 7605d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly return status; 7615d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly} 7625d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 7635d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/** 7645d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* LibNfc state machine current state update. 7655d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly*/ 7665d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 7675d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pellyvoid 7685d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyphLibNfc_UpdateCurState( 7695d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS status, 7705d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pphLibNfc_LibContext_t psLibContext 7715d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ) 7725d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly{ 7735d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly switch(psLibContext->LibNfcState.next_state) 7745d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 7755d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case eLibNfcHalStateTransaction: 7765d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psLibContext->LibNfcState.cur_state = (uint8_t)eLibNfcHalStateConnect; 7775d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 7785d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case eLibNfcHalStateRelease: 7795d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psLibContext->LibNfcState.cur_state 7805d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly = (uint8_t)(psLibContext->status.DiscEnbl_status == TRUE? 7815d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly eLibNfcHalStateInitandIdle:eLibNfcHalStateConfigReady); 7825d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 7835d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case eLibNfcHalStateInvalid: 7845d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 7855d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly default: 7865d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psLibContext->LibNfcState.cur_state 7875d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly = (uint8_t)((NFCSTATUS_SUCCESS == status)? 7885d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psLibContext->LibNfcState.next_state: 7895d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psLibContext->LibNfcState.cur_state); 7905d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 7915d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psLibContext->LibNfcState.next_state = (uint8_t)eLibNfcHalStateInvalid; 7925d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly return; 7935d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly} 7945d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/* Interface to stack capabilities */ 7955d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 7965d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyNFCSTATUS phLibNfc_Mgt_GetstackCapabilities( 7975d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phLibNfc_StackCapabilities_t *phLibNfc_StackCapabilities, 7985d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly void *pContext) 7995d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly{ 8005d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS RetVal = NFCSTATUS_FAILED; 8015d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /*Check Lib Nfc stack is initilized*/ 8025d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if((NULL == gpphLibContext)|| 8035d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (gpphLibContext->LibNfcState.cur_state == eLibNfcHalStateShutdown)) 8045d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 8055d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly RetVal = NFCSTATUS_NOT_INITIALISED; 8065d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 8075d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /*Check application has sent the valid parameters*/ 8085d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else if((NULL == phLibNfc_StackCapabilities) 8095d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly || (NULL == pContext)) 8105d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 8115d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly RetVal= NFCSTATUS_INVALID_PARAMETER; 8125d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 8135d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else if(gpphLibContext->LibNfcState.next_state == eLibNfcHalStateShutdown) 8145d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 8155d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly RetVal = NFCSTATUS_SHUTDOWN; 8165d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 8175d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else if(TRUE == gpphLibContext->status.GenCb_pending_status) 8185d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 8195d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /*Previous operation is pending */ 8205d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly RetVal = NFCSTATUS_BUSY; 8215d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 8225d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 8235d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 8245d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Tag Format Capabilities*/ 8255d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phLibNfc_StackCapabilities->psFormatCapabilities.Desfire = TRUE; 8265d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phLibNfc_StackCapabilities->psFormatCapabilities.MifareStd = TRUE; 8275d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phLibNfc_StackCapabilities->psFormatCapabilities.MifareUL = TRUE; 8285d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phLibNfc_StackCapabilities->psFormatCapabilities.FeliCa = FALSE; 8295d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phLibNfc_StackCapabilities->psFormatCapabilities.Jewel = FALSE; 8305d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phLibNfc_StackCapabilities->psFormatCapabilities.ISO14443_4A = FALSE; 8315d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phLibNfc_StackCapabilities->psFormatCapabilities.ISO14443_4B = FALSE; 8325d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phLibNfc_StackCapabilities->psFormatCapabilities.MifareULC = TRUE; 8335d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phLibNfc_StackCapabilities->psFormatCapabilities.ISO15693 = FALSE; 8345d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 8355d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Tag Mapping Capabilities */ 8365d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phLibNfc_StackCapabilities->psMappingCapabilities.FeliCa = TRUE; 8375d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phLibNfc_StackCapabilities->psMappingCapabilities.Desfire = TRUE; 8385d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phLibNfc_StackCapabilities->psMappingCapabilities.ISO14443_4A = TRUE; 8395d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phLibNfc_StackCapabilities->psMappingCapabilities.ISO14443_4B = TRUE; 8405d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phLibNfc_StackCapabilities->psMappingCapabilities.MifareStd = TRUE; 8415d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phLibNfc_StackCapabilities->psMappingCapabilities.MifareUL = TRUE; 8425d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phLibNfc_StackCapabilities->psMappingCapabilities.MifareULC = TRUE; 8435d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phLibNfc_StackCapabilities->psMappingCapabilities.Jewel = TRUE; 8445d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phLibNfc_StackCapabilities->psMappingCapabilities.ISO15693 = FALSE; 8455d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 8465d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /*Call Hal4 Get Dev Capabilities to get info about protocols supported 8475d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly by Lib Nfc*/ 8485d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly PHDBG_INFO("LibNfc:Get Stack capabilities "); 8495d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly RetVal= phHal4Nfc_GetDeviceCapabilities( 8505d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->psHwReference, 8515d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly &(phLibNfc_StackCapabilities->psDevCapabilities), 8525d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (void *)gpphLibContext); 8535d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 8545d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly LIB_NFC_VERSION_SET(phLibNfc_StackCapabilities->psDevCapabilities.hal_version, 8555d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly PH_HAL4NFC_VERSION, 8565d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly PH_HAL4NFC_REVISION, 8575d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly PH_HAL4NFC_PATCH, 8585d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly PH_HAL4NFC_BUILD); 8595d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 8605d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phLibNfc_StackCapabilities->psDevCapabilities.fw_version= 8615d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->psHwReference->device_info.fw_version; 8625d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phLibNfc_StackCapabilities->psDevCapabilities.hci_version= 8635d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->psHwReference->device_info.hci_version; 8645d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phLibNfc_StackCapabilities->psDevCapabilities.hw_version= 8655d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->psHwReference->device_info.hw_version; 8665d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phLibNfc_StackCapabilities->psDevCapabilities.model_id= 8675d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->psHwReference->device_info.model_id; 8685d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (void)memcpy(phLibNfc_StackCapabilities->psDevCapabilities.full_version, 8695d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->psHwReference->device_info.full_version,NXP_FULL_VERSION_LEN); 8705e97605ca8d83414b122bae72e65ea388b66718adaniel_Tomas /* Check the firmware version */ 871ac9c8c89d16e2c458c9c43e1def75d4e1f8f5b9bMartijn Coenen if (nxp_nfc_full_version == NULL) { 872ac9c8c89d16e2c458c9c43e1def75d4e1f8f5b9bMartijn Coenen // Couldn't load firmware, just pretend we're up to date. 873113bdd7504d69f483c4208bc30a457b7ff4b69faSteve Block ALOGW("Firmware image not available: this device might be running old NFC firmware!"); 874ac9c8c89d16e2c458c9c43e1def75d4e1f8f5b9bMartijn Coenen phLibNfc_StackCapabilities->psDevCapabilities.firmware_update_info = 0; 875ac9c8c89d16e2c458c9c43e1def75d4e1f8f5b9bMartijn Coenen } else { 876ac9c8c89d16e2c458c9c43e1def75d4e1f8f5b9bMartijn Coenen phLibNfc_StackCapabilities->psDevCapabilities.firmware_update_info = memcmp(phLibNfc_StackCapabilities->psDevCapabilities.full_version, nxp_nfc_full_version, 877ac9c8c89d16e2c458c9c43e1def75d4e1f8f5b9bMartijn Coenen NXP_FULL_VERSION_LEN); 878ac9c8c89d16e2c458c9c43e1def75d4e1f8f5b9bMartijn Coenen } 8795e97605ca8d83414b122bae72e65ea388b66718adaniel_Tomas 8805d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NFCSTATUS_SUCCESS != RetVal) 8815d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 8825d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly RetVal = NFCSTATUS_FAILED; 8835d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 8845d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 8855d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly return RetVal; 8865d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly} 8875d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 8885d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 8895d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 8905d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 8915d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 8925d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 8935d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyNFCSTATUS phLibNfc_Mgt_ConfigureTestMode(void *pDriverHandle, 8945d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pphLibNfc_RspCb_t pTestModeCb, 8955d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phLibNfc_Cfg_Testmode_t eTstmode, 8965d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly void *pContext) 8975d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly{ 8985d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS Status = NFCSTATUS_SUCCESS; 8995d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHal4Nfc_InitType_t eInitType=eInitDefault; 9005d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 9015d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if((NULL == pDriverHandle)||(NULL == pTestModeCb)) 9025d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 9035d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly Status = NFCSTATUS_INVALID_PARAMETER; 9045d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 9055d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else if((NULL != gpphLibContext) && \ 9065d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (gpphLibContext->LibNfcState.next_state==eLibNfcHalStateShutdown)) 9075d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 9085d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly Status = NFCSTATUS_SHUTDOWN; 9095d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 9105d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else if( (eTstmode == phLibNfc_TstMode_On) && (NULL != gpphLibContext)) 9115d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 9125d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly Status=NFCSTATUS_ALREADY_INITIALISED; 9135d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 9145d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else if( (eTstmode == phLibNfc_TstMode_Off) && (NULL == gpphLibContext)) 9155d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 9165d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly Status = NFCSTATUS_NOT_INITIALISED; 9175d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 9185d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else if( (eTstmode == phLibNfc_TstMode_Off) && (NULL != gpphLibContext)) 9195d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 9205d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if (NULL!= gpphLibContext->CBInfo.pClientShutdownCb) 9215d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { /* Previous callback pending */ 9225d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly Status = NFCSTATUS_BUSY; 9235d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 9245d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 9255d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 9265d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly Status = NFCSTATUS_PENDING; 9275d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(TRUE != gpphLibContext->status.GenCb_pending_status) 9285d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 9295d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly Status = phHal4Nfc_Close(gpphLibContext->psHwReference, 9305d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phLibNfc_ShutdownCb, 9315d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (void *)gpphLibContext); 9325d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 9335d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(Status== NFCSTATUS_PENDING) 9345d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 9355d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->CBInfo.pClientShutdownCb = pTestModeCb; 9365d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->CBInfo.pClientShtdwnCntx = pContext; 9375d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->status.GenCb_pending_status=TRUE; 9385d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->LibNfcState.next_state= eLibNfcHalStateShutdown; 9395d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 9405d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 9415d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 9425d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly Status =NFCSTATUS_FAILED; 9435d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 9445d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 9455d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 9465d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 9475d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 9485d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Initialize the Lib context */ 9495d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext=(pphLibNfc_LibContext_t)phOsalNfc_GetMemory( 9505d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (uint32_t)sizeof(phLibNfc_LibContext_t)); 9515d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NULL == gpphLibContext) 9525d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 9535d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly Status=NFCSTATUS_INSUFFICIENT_RESOURCES; 9545d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 9555d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 9565d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 9575d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (void)memset((void *)gpphLibContext,0,( 9585d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (uint32_t)sizeof(phLibNfc_LibContext_t))); 9595d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 9605d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Store the Callback and context in LibContext structure*/ 9615d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->CBInfo.pClientInitCb=pTestModeCb; 9625d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->CBInfo.pClientInitCntx=pContext; 9635d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Initialize the HwReferece structure */ 9645d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->psHwReference=(phHal_sHwReference_t *) 9655d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phOsalNfc_GetMemory((uint32_t)sizeof(phHal_sHwReference_t)); 9665d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (void)memset((void *)gpphLibContext->psHwReference,0, 9675d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ((uint32_t)sizeof(phHal_sHwReference_t))); 9685d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Allocate the Memory for the Transceive info */ 9695d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if( gpphLibContext->psHwReference!=NULL) 9705d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 9715d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->psHwReference->p_board_driver = pDriverHandle; 9725d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly Status = phLibNfc_UpdateNextState(gpphLibContext, 9735d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly eLibNfcHalStateInitandIdle); 9745d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(Status==NFCSTATUS_SUCCESS) 9755d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 9765d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(eTstmode == phLibNfc_TstMode_On) 9775d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly eInitType = eInitTestModeOn; 9785d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(eTstmode == phLibNfc_TstMode_Off) 9795d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly eInitType = eInitDefault; 9805d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly Status=phHal4Nfc_Open( 9815d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->psHwReference, 9825d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly eInitType, 9835d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phLibNfc_InitCb, 9845d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (void *)gpphLibContext); 9855d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 9865d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 9875d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 9885d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 9895d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly Status = NFCSTATUS_INSUFFICIENT_RESOURCES; 9905d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 9915d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phLibNfc_Ndef_Init(); 9925d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 9935d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 9945d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 9955d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly return Status; 9965d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly} 9975d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 998