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 1328206325bc6b3a60aed3c5cce157369ec2989437aSunil Jogi// Function for delay the recovery in case wired mode is set 1338206325bc6b3a60aed3c5cce157369ec2989437aSunil Jogi// to complete the possible pending transaction with SE 1348206325bc6b3a60aed3c5cce157369ec2989437aSunil Jogivoid phLibNfc_Mgt_Recovery () 1358206325bc6b3a60aed3c5cce157369ec2989437aSunil Jogi{ 1368206325bc6b3a60aed3c5cce157369ec2989437aSunil Jogi /* Wait before recovery if wired mode */ 1378206325bc6b3a60aed3c5cce157369ec2989437aSunil Jogi if (gpphLibContext->sSeContext.eActivatedMode == phLibNfc_SE_ActModeWired) 1388206325bc6b3a60aed3c5cce157369ec2989437aSunil Jogi { 1398206325bc6b3a60aed3c5cce157369ec2989437aSunil Jogi usleep (12000000); 1408206325bc6b3a60aed3c5cce157369ec2989437aSunil Jogi } 1418206325bc6b3a60aed3c5cce157369ec2989437aSunil Jogi 1428206325bc6b3a60aed3c5cce157369ec2989437aSunil Jogi return; 1438206325bc6b3a60aed3c5cce157369ec2989437aSunil Jogi} 14472854a2c28b99f9ab6aa60c906d5b3c1a36b04d7Martijn Coenen 14572854a2c28b99f9ab6aa60c906d5b3c1a36b04d7Martijn Coenenextern uint8_t nxp_nfc_isoxchg_timeout; 14672854a2c28b99f9ab6aa60c906d5b3c1a36b04d7Martijn CoenenNFCSTATUS phLibNfc_SetIsoXchgTimeout(uint8_t timeout) { 14772854a2c28b99f9ab6aa60c906d5b3c1a36b04d7Martijn Coenen nxp_nfc_isoxchg_timeout = timeout; 14872854a2c28b99f9ab6aa60c906d5b3c1a36b04d7Martijn Coenen return NFCSTATUS_SUCCESS; 14972854a2c28b99f9ab6aa60c906d5b3c1a36b04d7Martijn Coenen} 15072854a2c28b99f9ab6aa60c906d5b3c1a36b04d7Martijn Coenen 151b78322991a8bebe8d7ce6b7b978280c0508c4993Martijn Coenenint phLibNfc_GetIsoXchgTimeout() { 152b78322991a8bebe8d7ce6b7b978280c0508c4993Martijn Coenen return nxp_nfc_isoxchg_timeout; 153b78322991a8bebe8d7ce6b7b978280c0508c4993Martijn Coenen} 154b78322991a8bebe8d7ce6b7b978280c0508c4993Martijn Coenen 15572854a2c28b99f9ab6aa60c906d5b3c1a36b04d7Martijn Coenenextern uint32_t nxp_nfc_hci_response_timeout; 15672854a2c28b99f9ab6aa60c906d5b3c1a36b04d7Martijn CoenenNFCSTATUS phLibNfc_SetHciTimeout(uint32_t timeout_in_ms) { 15772854a2c28b99f9ab6aa60c906d5b3c1a36b04d7Martijn Coenen nxp_nfc_hci_response_timeout = timeout_in_ms; 15872854a2c28b99f9ab6aa60c906d5b3c1a36b04d7Martijn Coenen return NFCSTATUS_SUCCESS; 15972854a2c28b99f9ab6aa60c906d5b3c1a36b04d7Martijn Coenen} 16072854a2c28b99f9ab6aa60c906d5b3c1a36b04d7Martijn Coenen 161b78322991a8bebe8d7ce6b7b978280c0508c4993Martijn Coenenint phLibNfc_GetHciTimeout() { 162b78322991a8bebe8d7ce6b7b978280c0508c4993Martijn Coenen return nxp_nfc_hci_response_timeout; 163b78322991a8bebe8d7ce6b7b978280c0508c4993Martijn Coenen} 164b78322991a8bebe8d7ce6b7b978280c0508c4993Martijn Coenen 165ba0407599b6271f47a4e6e6d539522ae5b207287Sunil Jogiextern uint8_t nxp_nfc_felica_timeout; 1661db6f8ed6317c429ced6d2d7c92fd5a64ffe4015Martijn CoenenNFCSTATUS phLibNfc_SetFelicaTimeout(uint8_t timeout_in_ms) { 1671db6f8ed6317c429ced6d2d7c92fd5a64ffe4015Martijn Coenen nxp_nfc_felica_timeout = timeout_in_ms; 1681db6f8ed6317c429ced6d2d7c92fd5a64ffe4015Martijn Coenen return NFCSTATUS_SUCCESS; 1691db6f8ed6317c429ced6d2d7c92fd5a64ffe4015Martijn Coenen} 1701db6f8ed6317c429ced6d2d7c92fd5a64ffe4015Martijn Coenen 171b78322991a8bebe8d7ce6b7b978280c0508c4993Martijn Coenenint phLibNfc_GetFelicaTimeout() { 172b78322991a8bebe8d7ce6b7b978280c0508c4993Martijn Coenen return nxp_nfc_felica_timeout; 173b78322991a8bebe8d7ce6b7b978280c0508c4993Martijn Coenen} 174b78322991a8bebe8d7ce6b7b978280c0508c4993Martijn Coenen 17501a91eaddd15d39b85c9950eb88a1c6348290556Martijn Coenenextern uint8_t nxp_nfc_mifareraw_timeout; 17601a91eaddd15d39b85c9950eb88a1c6348290556Martijn CoenenNFCSTATUS phLibNfc_SetMifareRawTimeout(uint8_t timeout) { 17701a91eaddd15d39b85c9950eb88a1c6348290556Martijn Coenen nxp_nfc_mifareraw_timeout = timeout; 17801a91eaddd15d39b85c9950eb88a1c6348290556Martijn Coenen return NFCSTATUS_SUCCESS; 17901a91eaddd15d39b85c9950eb88a1c6348290556Martijn Coenen} 18001a91eaddd15d39b85c9950eb88a1c6348290556Martijn Coenen 181b78322991a8bebe8d7ce6b7b978280c0508c4993Martijn Coenenint phLibNfc_GetMifareRawTimeout() { 182b78322991a8bebe8d7ce6b7b978280c0508c4993Martijn Coenen return nxp_nfc_mifareraw_timeout; 183b78322991a8bebe8d7ce6b7b978280c0508c4993Martijn Coenen} 184b78322991a8bebe8d7ce6b7b978280c0508c4993Martijn Coenen 1855d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/** 1865d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* Initialize the phLibNfc interface. 1875d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly*/ 1885d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 1895d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyNFCSTATUS phLibNfc_Mgt_Initialize(void *pDriverHandle, 1903e98767aaf73b4779a2bb39601806045b2ba1739Jeff Hamilton pphLibNfc_RspCb_t pInitCb, 1913e98767aaf73b4779a2bb39601806045b2ba1739Jeff Hamilton void *pContext) 1925d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly{ 1935d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS Status = NFCSTATUS_SUCCESS; 1945d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if((NULL == pDriverHandle)||(NULL == pInitCb)) 1955d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 1965d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly Status = NFCSTATUS_INVALID_PARAMETER; 1975d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 1985d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else if(NULL == gpphLibContext) 1995d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 2005d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Initialize the Lib context */ 2015d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext=(pphLibNfc_LibContext_t)phOsalNfc_GetMemory( 2025d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (uint32_t)sizeof(phLibNfc_LibContext_t)); 2035d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NULL == gpphLibContext) 2045d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 2055d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly Status=NFCSTATUS_INSUFFICIENT_RESOURCES; 2065d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 2075d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 2085d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 2095d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (void)memset((void *)gpphLibContext,0,( 2105d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (uint32_t)sizeof(phLibNfc_LibContext_t))); 2115d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 2125d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Store the Callback and context in LibContext structure*/ 2135d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->CBInfo.pClientInitCb=pInitCb; 2145d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->CBInfo.pClientInitCntx=pContext; 2155d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Initialize the HwReferece structure */ 2165d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->psHwReference=(phHal_sHwReference_t *) 2175d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phOsalNfc_GetMemory((uint32_t)sizeof(phHal_sHwReference_t)); 2185d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (void)memset((void *)gpphLibContext->psHwReference,0, 2195d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ((uint32_t)sizeof(phHal_sHwReference_t))); 2205d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Allocate the Memory for the Transceive info */ 2215d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if( gpphLibContext->psHwReference!=NULL) 2225d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 2235d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->psHwReference->p_board_driver = pDriverHandle; 2245d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly Status = phLibNfc_UpdateNextState(gpphLibContext, 2255d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly eLibNfcHalStateInitandIdle); 2265d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(Status==NFCSTATUS_SUCCESS) 2275d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 2285d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly Status=phHal4Nfc_Open( 2295d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->psHwReference, 2305d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly eInitDefault, 2315d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phLibNfc_InitCb, 2325d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (void *)gpphLibContext); 2335d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 2345d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 2355d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 2365d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 2375d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly Status = NFCSTATUS_INSUFFICIENT_RESOURCES; 2385d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 2395d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phLibNfc_Ndef_Init(); 2405d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 2415d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 2425d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else if(gpphLibContext->LibNfcState.next_state==eLibNfcHalStateShutdown) 2435d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 2445d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly Status = NFCSTATUS_SHUTDOWN; 2455d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 2465d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 2475d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 2485d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly Status=NFCSTATUS_ALREADY_INITIALISED; 2495d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 2505d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly return Status; 2515d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly} 2525d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 2535d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/* 2545d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * This function called by the HAL4 when the initialization seq is completed. 2555d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly */ 2565d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellySTATIC void phLibNfc_InitCb(void *pContext,NFCSTATUS status) 2575d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly{ 2585d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pphLibNfc_LibContext_t pLibContext=NULL; 2595d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pphLibNfc_RspCb_t pClientCb=NULL; 2605d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly void *pUpperLayerContext=NULL; 2615d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 2625d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 2635d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Initialize the local variable */ 2645d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pLibContext = (pphLibNfc_LibContext_t)pContext; 2655d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 2665d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pClientCb =pLibContext->CBInfo.pClientInitCb; 2675d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pUpperLayerContext=pLibContext->CBInfo.pClientInitCntx; 2685d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(status == NFCSTATUS_SUCCESS) 2695d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 2705d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Get the Lib context */ 2715d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pLibContext=(pphLibNfc_LibContext_t)gpphLibContext; 2725d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->sSeContext.eActivatedMode = phLibNfc_SE_ActModeOff; 2735d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(pLibContext->psHwReference->uicc_connected==TRUE) 2745d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 2755d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* populate state of the secured element */ 2765d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->sSeContext.eActivatedMode = phLibNfc_SE_ActModeDefault; 2775d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly sSecuredElementInfo[LIBNFC_SE_UICC_INDEX].eSE_CurrentState=phLibNfc_SE_Active; 2785d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pLibContext->sSeContext.uUiccActivate=TRUE; 2795d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 2805d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(pLibContext->psHwReference->smx_connected==TRUE) 2815d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 2825d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* populate state of the secured element */ 2835d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->sSeContext.eActivatedMode = phLibNfc_SE_ActModeDefault; 2845d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly sSecuredElementInfo[LIBNFC_SE_SMARTMX_INDEX].eSE_CurrentState=phLibNfc_SE_Inactive; 2855d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pLibContext->sSeContext.uSmxActivate =FALSE; 2865d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 2875d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 2885d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phLibNfc_UpdateCurState(status,pLibContext); 2895d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (void)phHal4Nfc_RegisterNotification( 2905d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pLibContext->psHwReference, 2915d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly eRegisterDefault, 2925d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phLibNfc_DefaultHandler, 2935d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (void*)pLibContext 2945d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ); 2955d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* call the upper layer register function */ 2965d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (*pClientCb)(pUpperLayerContext,status); 2975d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 2985d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 2995d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 3005d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 3015d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /*Change the status code failed*/ 3025d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = NFCSTATUS_FAILED; 3035d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Get the Lib context */ 3045d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pLibContext=(pphLibNfc_LibContext_t)gpphLibContext; 3055d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 3065d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phLibNfc_UpdateCurState(status,pLibContext); 3075d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 3085d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 3095d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 3105d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Allocate the Memory for the Transceive info */ 3115d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(pLibContext->psHwReference!= NULL) 3125d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 3135d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phOsalNfc_FreeMemory(pLibContext->psHwReference); 3145d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pLibContext->psHwReference = NULL; 3155d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 3165d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (*pClientCb)(pUpperLayerContext, status); 3175d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 3185d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phOsalNfc_FreeMemory(pLibContext); 3195d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pLibContext= NULL; 3205d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext = NULL; 3215d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 3225d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 3235d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly return; 3245d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly} 3255d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 3265d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/**Default notification handler registered with lower layer immediately after 3275d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly successful initialization*/ 3285d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellySTATIC void phLibNfc_DefaultHandler( 3295d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly void *context, 3305d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHal_eNotificationType_t type, 3315d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHal4Nfc_NotificationInfo_t info, 3325d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS status 3335d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ) 3345d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly{ 3355d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(context != (void *)gpphLibContext) 3365d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 3375d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phOsalNfc_RaiseException(phOsalNfc_e_InternalErr,1); 3385d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 3395d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 3405d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 3415d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly info = info; 3425d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if((NFC_EVENT_NOTIFICATION == type) && 3435d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (NFCSTATUS_BOARD_COMMUNICATION_ERROR == status)) 3445d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 3455d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phLibNfc_UpdateCurState(NFCSTATUS_FAILED,gpphLibContext); 3465d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phOsalNfc_RaiseException(phOsalNfc_e_UnrecovFirmwareErr,1); 3475d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 3485d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 3495d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly return; 3505d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly} 3515d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/** 3525d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* De-Initialize the LIB NFC. 3535d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly*/ 3545d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyNFCSTATUS phLibNfc_Mgt_DeInitialize(void * pDriverHandle, 3555d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pphLibNfc_RspCb_t pDeInitCb, 3565d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly void* pContext 3575d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ) 3585d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly{ 3595d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS Status = NFCSTATUS_SUCCESS; 3605d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pphLibNfc_LibContext_t pLibContext = gpphLibContext; 3615d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NULL==pDriverHandle) 3625d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 3635d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /*Check for valid parameters */ 3645d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly Status = NFCSTATUS_INVALID_PARAMETER; 3655d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 3665d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else if((pLibContext==NULL) 3675d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly || (pLibContext->LibNfcState.cur_state 3685d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly == eLibNfcHalStateShutdown)) 3695d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { /*Lib Nfc not initlized*/ 3705d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly Status = NFCSTATUS_NOT_INITIALISED; 3715d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 3725d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 3735d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 3745d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(pDeInitCb==NULL) 3755d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 3765d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHal4Nfc_Hal4Reset(pLibContext->psHwReference,(void *)pLibContext); 3775d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(pLibContext->psHwReference!=NULL) 3785d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 3795d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phOsalNfc_FreeMemory(pLibContext->psHwReference); 3805d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pLibContext->psHwReference = NULL; 3815d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 3825d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /*Free the memory allocated during NDEF read,write 3835d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly and NDEF formatting*/ 3845d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phLibNfc_Ndef_DeInit(); 3855d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phOsalNfc_FreeMemory(pLibContext); 3865d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext=NULL; 3875d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pLibContext= NULL; 3885d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 3895d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 3905d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 3915d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if (NULL!= pLibContext->CBInfo.pClientShutdownCb) 3925d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 3935d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Previous callback pending */ 3945d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly Status = NFCSTATUS_BUSY; 3955d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 3965d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly Status = NFCSTATUS_PENDING; 3975d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(TRUE != pLibContext->status.GenCb_pending_status) 3985d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 3995d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly Status = phHal4Nfc_Close(pLibContext->psHwReference, 4005d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phLibNfc_ShutdownCb, 4015d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (void *)pLibContext); 4025d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 4035d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(Status== NFCSTATUS_PENDING) 4045d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 4055d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pLibContext->CBInfo.pClientShutdownCb = pDeInitCb; 4065d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pLibContext->CBInfo.pClientShtdwnCntx = pContext; 4075d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pLibContext->status.GenCb_pending_status=TRUE; 4085d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pLibContext->LibNfcState.next_state= eLibNfcHalStateShutdown; 4095d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 4105d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 4115d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 4125d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly Status =NFCSTATUS_FAILED; 4135d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 4145d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 4155d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 4165d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly return Status; 4175d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly} 4185d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/* shutdown callback - 4195d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly Free the allocated memory here */ 4205d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellySTATIC void phLibNfc_ShutdownCb(void *pContext,NFCSTATUS status) 4215d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly{ 4225d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pphLibNfc_RspCb_t pClientCb=NULL; 4235d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly void *pUpperLayerContext=NULL; 4245d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pphLibNfc_LibContext_t pLibContext=NULL; 4255d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 4265d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly PHNFC_UNUSED_VARIABLE(pContext); 4275d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Get the Lib context */ 4285d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pLibContext=(pphLibNfc_LibContext_t)gpphLibContext; 4295d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 4305d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(pLibContext == NULL) 4315d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 4325d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = NFCSTATUS_FAILED; 4335d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 4345d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 4355d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 4365d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Initialize the local variable */ 4375d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pClientCb =pLibContext->CBInfo.pClientShutdownCb; 4385d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pUpperLayerContext=pLibContext->CBInfo.pClientShtdwnCntx; 4395d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(status == NFCSTATUS_SUCCESS) 4405d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 4415d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pLibContext->LibNfcState.cur_state = eLibNfcHalStateShutdown; 4425d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phLibNfc_UpdateCurState(status,pLibContext); 4435d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 4445d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pLibContext->status.GenCb_pending_status=FALSE; 4455d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 4465d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Allocate the Memory for the Transceive info */ 4475d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(pClientCb!=NULL) 4485d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 4495d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (*pClientCb)(pUpperLayerContext, status); 4505d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 4515d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(pLibContext->psHwReference!=NULL) 4525d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 4535d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phOsalNfc_FreeMemory(pLibContext->psHwReference); 4545d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pLibContext->psHwReference = NULL; 4555d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 4565d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NULL != gpphLibContext->psBufferedAuth) 4575d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 4585d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NULL != gpphLibContext->psBufferedAuth->sRecvData.buffer) 4595d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 4605d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phOsalNfc_FreeMemory( 4615d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->psBufferedAuth->sRecvData.buffer); 4625d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 4635d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NULL != gpphLibContext->psBufferedAuth->sSendData.buffer) 4645d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 4655d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phOsalNfc_FreeMemory( 4665d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->psBufferedAuth->sSendData.buffer); 4675d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 4685d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phOsalNfc_FreeMemory(gpphLibContext->psBufferedAuth); 4695d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->psBufferedAuth = NULL; 4705d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 4715d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /*Free the memory allocated during NDEF read,write 4725d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly and NDEF formatting*/ 4735d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phLibNfc_Ndef_DeInit(); 4745d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phOsalNfc_FreeMemory(pLibContext); 4755d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext=NULL; 4765d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pLibContext= NULL; 4775d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 4785d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 4795d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 4805d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 4815d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* shutdown sequence failed by HAL 4 */ 4825d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status= NFCSTATUS_FAILED; 4835d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pLibContext=(pphLibNfc_LibContext_t)gpphLibContext; 4845d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phLibNfc_UpdateCurState(status,pLibContext); 4855d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pLibContext->status.GenCb_pending_status=FALSE; 4865d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(pClientCb!=NULL) 4875d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 4885d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (*pClientCb)(pUpperLayerContext,status); 4895d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 4905d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 4915d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 4925d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly} 4935d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/** 4945d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* Pending shutdown call. 4955d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly*/ 4965d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 4975d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 4985d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pellyvoid phLibNfc_Pending_Shutdown(void) 4995d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly{ 5005d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS RetStatus = NFCSTATUS_SUCCESS ; 5015d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->status.GenCb_pending_status = FALSE; 5025d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly RetStatus = phHal4Nfc_Close( 5035d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->psHwReference, 5045d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phLibNfc_ShutdownCb, 5055d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (void *)gpphLibContext); 5065d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly PHNFC_UNUSED_VARIABLE(RetStatus); 5075d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly return; 5085d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly} 5095d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 5105d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 5115d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/** 5125d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* Reset the LIB NFC. 5135d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly*/ 5145d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyNFCSTATUS phLibNfc_Mgt_Reset(void *pContext) 5155d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly{ 5165d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS Status = NFCSTATUS_SUCCESS; 5175d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phLibNfc_LibContext_t *pLibNfc_Ctxt = (phLibNfc_LibContext_t *)pContext; 5185d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 5195d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if((pLibNfc_Ctxt == NULL) 5205d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly || (gpphLibContext->LibNfcState.cur_state 5215d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly == eLibNfcHalStateShutdown)) 5225d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { /*Lib Nfc not initlized*/ 5235d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly Status = NFCSTATUS_NOT_INITIALISED; 5245d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 5255d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else if(NULL == pContext) 5265d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 5275d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly Status = NFCSTATUS_INVALID_PARAMETER; 5285d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 5295d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Check for valid state,If De initialize is called then 5305d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly return NFCSTATUS_SHUTDOWN */ 5315d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else if(gpphLibContext->LibNfcState.next_state 5325d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly == eLibNfcHalStateShutdown) 5335d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 5345d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly Status = NFCSTATUS_SHUTDOWN; 5355d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 5365d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 5375d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 5385d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /*Reset all callback status*/ 5395d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (void) memset(&(gpphLibContext->RegNtfType),0, 5405d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly sizeof(phLibNfc_Registry_Info_t)); 5415d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (void) memset(&(gpphLibContext->sADDconfig),0, 5425d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly sizeof(phLibNfc_sADD_Cfg_t)); 5435d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (void) memset(&(gpphLibContext->ndef_cntx),0, 5445d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly sizeof(phLibNfc_NdefInfo_t)); 5455d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (void) memset(&(gpphLibContext->sNfcIp_Context),0, 5465d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly sizeof(phLibNfc_NfcIpInfo_t)); 5475d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (void) memset(&(gpphLibContext->sCardEmulCfg),0, 5485d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly sizeof(phHal_sEmulationCfg_t)); 5495d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (void) memset(&(gpphLibContext->Discov_handle),0, 5505d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly MAX_REMOTE_DEVICES); 5515d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 5525d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /*Free memory allocated for NDEF records*/ 5535d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NULL != gpphLibContext->psBufferedAuth) 5545d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 5555d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NULL != gpphLibContext->psBufferedAuth->sRecvData.buffer) 5565d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 5575d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phOsalNfc_FreeMemory( 5585d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->psBufferedAuth->sRecvData.buffer); 5595d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->psBufferedAuth->sRecvData.buffer = NULL; 5605d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 5615d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NULL != gpphLibContext->psBufferedAuth->sSendData.buffer) 5625d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 5635d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phOsalNfc_FreeMemory( 5645d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->psBufferedAuth->sSendData.buffer); 5655d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->psBufferedAuth->sSendData.buffer = NULL; 5665d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 5675d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phOsalNfc_FreeMemory(gpphLibContext->psBufferedAuth); 5685d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->psBufferedAuth = NULL; 5695d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 5705d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NULL != gpphLibContext->psTransInfo) 5715d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 5725d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phOsalNfc_FreeMemory(gpphLibContext->psTransInfo); 5735d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->psTransInfo = NULL; 5745d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 5755d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NULL != gpphLibContext->ndef_cntx.psNdefMap) 5765d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 5775d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NULL != gpphLibContext->ndef_cntx.psNdefMap->SendRecvBuf) 5785d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 5795d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phOsalNfc_FreeMemory(gpphLibContext->ndef_cntx.psNdefMap->SendRecvBuf); 5805d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->ndef_cntx.psNdefMap->SendRecvBuf = NULL; 5815d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 5825d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phOsalNfc_FreeMemory(gpphLibContext->ndef_cntx.psNdefMap); 5835d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->ndef_cntx.psNdefMap = NULL; 5845d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 5855d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NULL != gpphLibContext->psOverHalCtxt) 5865d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 5875d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phOsalNfc_FreeMemory(gpphLibContext->psOverHalCtxt); 5885d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->psTransInfo = NULL; 5895d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 5905d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NULL != gpphLibContext->psDevInputParam) 5915d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 5925d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phOsalNfc_FreeMemory(gpphLibContext->psDevInputParam); 5935d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->psDevInputParam = NULL; 5945d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 5955d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NULL != gpphLibContext->ndef_cntx.ndef_fmt) 5965d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 5975d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phOsalNfc_FreeMemory(gpphLibContext->ndef_cntx.ndef_fmt); 5985d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->ndef_cntx.ndef_fmt = NULL; 5995d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 6005d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NULL != pNdefRecord) 6015d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 6025d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NULL != pNdefRecord->Id) 6035d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 6045d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phOsalNfc_FreeMemory(pNdefRecord->Id); 6055d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pNdefRecord->Id = NULL; 6065d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 6075d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NULL != pNdefRecord->Type) 6085d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 6095d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phOsalNfc_FreeMemory(pNdefRecord->Type); 6105d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pNdefRecord->Type = NULL; 6115d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 6125d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NULL != pNdefRecord->PayloadData) 6135d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 6145d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phOsalNfc_FreeMemory(pNdefRecord->PayloadData); 6155d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pNdefRecord->PayloadData = NULL; 6165d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 6175d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 6185d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NULL != NdefInfo.pNdefRecord) 6195d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 6205d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phOsalNfc_FreeMemory(NdefInfo.pNdefRecord); 6215d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NdefInfo.pNdefRecord = NULL; 6225d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 6235d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NULL != gpphLibContext->phLib_NdefRecCntx.NdefCb) 6245d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 6255d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phOsalNfc_FreeMemory(gpphLibContext->phLib_NdefRecCntx.NdefCb); 6265d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->phLib_NdefRecCntx.NdefCb = NULL; 6275d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 6285d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NULL != gpphLibContext->phLib_NdefRecCntx.ndef_message.buffer) 6295d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 6305d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phOsalNfc_FreeMemory(gpphLibContext->phLib_NdefRecCntx.ndef_message.buffer); 6315d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->phLib_NdefRecCntx.ndef_message.buffer = NULL; 6325d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 6335d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* No device is connected */ 6345d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->Connected_handle = 0x00; 63534caeca8a5ec2aedade68a77393d0aff03f9bd72Daniel Tomas gpphLibContext->Prev_Connected_handle = 0x00; 6365d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->ReleaseType = NFC_INVALID_RELEASE_TYPE; 6375d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->eLibNfcCfgMode = NFC_DISCOVERY_STOP; 6385d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /*Lib Nfc Stack is initilized and in idle state*/ 6395d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->LibNfcState.cur_state = eLibNfcHalStateInitandIdle; 6405d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 6415d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Reset all callback status */ 6425d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->CBInfo.pClientCkNdefCb = NULL; 6435d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->CBInfo.pClientCkNdefCntx = NULL; 6445d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->CBInfo.pClientConCntx = NULL; 6455d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->CBInfo.pClientConnectCb = NULL; 6465d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->CBInfo.pClientDConCntx = NULL; 6475d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->CBInfo.pClientDisCfgCntx = NULL; 6485d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->CBInfo.pClientDisConfigCb = NULL; 6495d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->CBInfo.pClientInitCb = NULL; 6505d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->CBInfo.pClientInitCntx = gpphLibContext; 6515d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->CBInfo.pClientNdefNtfRespCb = NULL; 6525d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->CBInfo.pClientNdefNtfRespCntx = NULL; 6535d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->CBInfo.pClientNtfRegRespCB = NULL; 6545d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->CBInfo.pClientNtfRegRespCntx = NULL; 6555d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->CBInfo.pClientPresChkCb = NULL; 6565d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->CBInfo.pClientPresChkCntx = NULL; 6575d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->CBInfo.pClientRdNdefCb = NULL; 6585d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->CBInfo.pClientRdNdefCntx = NULL; 6595d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->CBInfo.pClientShtdwnCntx = NULL; 6605d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->CBInfo.pClientShutdownCb = NULL; 6615d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->CBInfo.pClientTransceiveCb = NULL; 6625d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->CBInfo.pClientTranseCntx = NULL; 6635d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->CBInfo.pClientWrNdefCb = NULL; 6645d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->CBInfo.pClientWrNdefCntx = NULL; 6655d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->sNfcIp_Context.pClientNfcIpCfgCb = NULL; 6665d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->sNfcIp_Context.pClientNfcIpCfgCntx = NULL; 6675d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->sNfcIp_Context.pClientNfcIpRxCb = NULL; 6685d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->sNfcIp_Context.pClientNfcIpRxCntx = NULL; 6695d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->sNfcIp_Context.pClientNfcIpTxCb = NULL; 6705d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->sNfcIp_Context.pClientNfcIpTxCntx = NULL; 6715d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->sSeContext.sSeCallabackInfo.pSeListenerNtfCb = NULL; 6725d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->sSeContext.sSeCallabackInfo.pSeListenerCtxt = NULL; 6735d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->sSeContext.sSeCallabackInfo.pSEsetModeCb = NULL; 6745d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->sSeContext.sSeCallabackInfo.pSEsetModeCtxt = NULL; 6755d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /*No callback is pending*/ 6765d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->status.GenCb_pending_status = FALSE; 6775d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 6785d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 6795d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly return Status; 6805d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly} 6815d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/** 6825d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* LibNfc state machine next state update. 6835d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly*/ 6845d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 6855d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyNFCSTATUS 6865d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyphLibNfc_UpdateNextState( 6875d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pphLibNfc_LibContext_t pLibContext, 6885d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phLibNfc_State_t next_state 6895d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ) 6905d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly{ 6915d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS status = NFCSTATUS_INVALID_STATE; 6925d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly switch(pLibContext->LibNfcState.cur_state) 6935d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 6945d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case eLibNfcHalStateShutdown: 6955d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 6965d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly switch(next_state) 6975d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 6985d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case eLibNfcHalStateShutdown: 6995d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case eLibNfcHalStateInitandIdle: 7005d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = NFCSTATUS_SUCCESS; 7015d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 7025d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly default: 7035d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 7045d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 7055d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 7065d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 7075d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case eLibNfcHalStateConfigReady: 7085d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 7095d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly switch(next_state) 7105d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 7115d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case eLibNfcHalStateShutdown: 7125d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case eLibNfcHalStateConfigReady: 7135d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case eLibNfcHalStateInitandIdle: 7145d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case eLibNfcHalStateConnect: 7155d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = NFCSTATUS_SUCCESS; 7165d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 7175d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly default: 7185d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 7195d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 7205d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 7215d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 7225d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case eLibNfcHalStateConnect: 7235d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 7245d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly switch(next_state) 7255d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 7265d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case eLibNfcHalStateShutdown: 7275d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case eLibNfcHalStateRelease: 7285d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case eLibNfcHalStateTransaction: 7295d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case eLibNfcHalStatePresenceChk: 7305d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = NFCSTATUS_SUCCESS; 7315d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 7325d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly default: 7335d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 7345d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 7355d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 7365d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 7375d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case eLibNfcHalStatePresenceChk: 7385d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 7395d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly switch(next_state) 7405d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 7415d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case eLibNfcHalStateShutdown: 7425d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case eLibNfcHalStateConfigReady: 7435d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case eLibNfcHalStateRelease: 7445d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case eLibNfcHalStateTransaction: 7455d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case eLibNfcHalStatePresenceChk: 7465d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = NFCSTATUS_SUCCESS; 7475d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 7485d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly default: 7495d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 7505d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 7515d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 7525d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 7535d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case eLibNfcHalStateInitandIdle: 7545d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 7555d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly switch(next_state) 7565d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 7575d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case eLibNfcHalStateShutdown: 7585d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case eLibNfcHalStateConfigReady: 7595d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = NFCSTATUS_SUCCESS; 7605d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 7615d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly default: 7625d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 7635d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 7645d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 7655d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 7665d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly default: 7675d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 7685d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 7695d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pLibContext->LibNfcState.next_state = 7705d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (uint8_t)((NFCSTATUS_SUCCESS == status)?next_state:pLibContext->LibNfcState.next_state); 7715d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 7725d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly return status; 7735d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly} 7745d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 7755d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/** 7765d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* LibNfc state machine current state update. 7775d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly*/ 7785d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 7795d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pellyvoid 7805d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyphLibNfc_UpdateCurState( 7815d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS status, 7825d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pphLibNfc_LibContext_t psLibContext 7835d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ) 7845d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly{ 7855d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly switch(psLibContext->LibNfcState.next_state) 7865d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 7875d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case eLibNfcHalStateTransaction: 7885d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psLibContext->LibNfcState.cur_state = (uint8_t)eLibNfcHalStateConnect; 7895d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 7905d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case eLibNfcHalStateRelease: 7915d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psLibContext->LibNfcState.cur_state 7925d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly = (uint8_t)(psLibContext->status.DiscEnbl_status == TRUE? 7935d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly eLibNfcHalStateInitandIdle:eLibNfcHalStateConfigReady); 7945d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 7955d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case eLibNfcHalStateInvalid: 7965d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 7975d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly default: 7985d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psLibContext->LibNfcState.cur_state 7995d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly = (uint8_t)((NFCSTATUS_SUCCESS == status)? 8005d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psLibContext->LibNfcState.next_state: 8015d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psLibContext->LibNfcState.cur_state); 8025d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 8035d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psLibContext->LibNfcState.next_state = (uint8_t)eLibNfcHalStateInvalid; 8045d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly return; 8055d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly} 8065d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/* Interface to stack capabilities */ 8075d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 8085d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyNFCSTATUS phLibNfc_Mgt_GetstackCapabilities( 8095d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phLibNfc_StackCapabilities_t *phLibNfc_StackCapabilities, 8105d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly void *pContext) 8115d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly{ 8125d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS RetVal = NFCSTATUS_FAILED; 8135d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /*Check Lib Nfc stack is initilized*/ 8145d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if((NULL == gpphLibContext)|| 8155d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (gpphLibContext->LibNfcState.cur_state == eLibNfcHalStateShutdown)) 8165d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 8175d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly RetVal = NFCSTATUS_NOT_INITIALISED; 8185d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 8195d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /*Check application has sent the valid parameters*/ 8205d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else if((NULL == phLibNfc_StackCapabilities) 8215d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly || (NULL == pContext)) 8225d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 8235d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly RetVal= NFCSTATUS_INVALID_PARAMETER; 8245d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 8255d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else if(gpphLibContext->LibNfcState.next_state == eLibNfcHalStateShutdown) 8265d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 8275d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly RetVal = NFCSTATUS_SHUTDOWN; 8285d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 8295d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else if(TRUE == gpphLibContext->status.GenCb_pending_status) 8305d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 8315d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /*Previous operation is pending */ 8325d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly RetVal = NFCSTATUS_BUSY; 8335d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 8345d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 8355d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 8365d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Tag Format Capabilities*/ 8375d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phLibNfc_StackCapabilities->psFormatCapabilities.Desfire = TRUE; 8385d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phLibNfc_StackCapabilities->psFormatCapabilities.MifareStd = TRUE; 8395d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phLibNfc_StackCapabilities->psFormatCapabilities.MifareUL = TRUE; 8405d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phLibNfc_StackCapabilities->psFormatCapabilities.FeliCa = FALSE; 8415d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phLibNfc_StackCapabilities->psFormatCapabilities.Jewel = FALSE; 8425d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phLibNfc_StackCapabilities->psFormatCapabilities.ISO14443_4A = FALSE; 8435d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phLibNfc_StackCapabilities->psFormatCapabilities.ISO14443_4B = FALSE; 8445d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phLibNfc_StackCapabilities->psFormatCapabilities.MifareULC = TRUE; 8455d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phLibNfc_StackCapabilities->psFormatCapabilities.ISO15693 = FALSE; 8465d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 8475d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Tag Mapping Capabilities */ 8485d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phLibNfc_StackCapabilities->psMappingCapabilities.FeliCa = TRUE; 8495d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phLibNfc_StackCapabilities->psMappingCapabilities.Desfire = TRUE; 8505d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phLibNfc_StackCapabilities->psMappingCapabilities.ISO14443_4A = TRUE; 8515d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phLibNfc_StackCapabilities->psMappingCapabilities.ISO14443_4B = TRUE; 8525d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phLibNfc_StackCapabilities->psMappingCapabilities.MifareStd = TRUE; 8535d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phLibNfc_StackCapabilities->psMappingCapabilities.MifareUL = TRUE; 8545d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phLibNfc_StackCapabilities->psMappingCapabilities.MifareULC = TRUE; 8555d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phLibNfc_StackCapabilities->psMappingCapabilities.Jewel = TRUE; 8565d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phLibNfc_StackCapabilities->psMappingCapabilities.ISO15693 = FALSE; 8575d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 8585d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /*Call Hal4 Get Dev Capabilities to get info about protocols supported 8595d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly by Lib Nfc*/ 8605d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly PHDBG_INFO("LibNfc:Get Stack capabilities "); 8615d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly RetVal= phHal4Nfc_GetDeviceCapabilities( 8625d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->psHwReference, 8635d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly &(phLibNfc_StackCapabilities->psDevCapabilities), 8645d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (void *)gpphLibContext); 8655d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 8665d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly LIB_NFC_VERSION_SET(phLibNfc_StackCapabilities->psDevCapabilities.hal_version, 8675d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly PH_HAL4NFC_VERSION, 8685d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly PH_HAL4NFC_REVISION, 8695d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly PH_HAL4NFC_PATCH, 8705d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly PH_HAL4NFC_BUILD); 8715d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 8725d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phLibNfc_StackCapabilities->psDevCapabilities.fw_version= 8735d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->psHwReference->device_info.fw_version; 8745d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phLibNfc_StackCapabilities->psDevCapabilities.hci_version= 8755d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->psHwReference->device_info.hci_version; 8765d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phLibNfc_StackCapabilities->psDevCapabilities.hw_version= 8775d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->psHwReference->device_info.hw_version; 8785d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phLibNfc_StackCapabilities->psDevCapabilities.model_id= 8795d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->psHwReference->device_info.model_id; 8805d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (void)memcpy(phLibNfc_StackCapabilities->psDevCapabilities.full_version, 8815d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->psHwReference->device_info.full_version,NXP_FULL_VERSION_LEN); 8825e97605ca8d83414b122bae72e65ea388b66718adaniel_Tomas /* Check the firmware version */ 883ac9c8c89d16e2c458c9c43e1def75d4e1f8f5b9bMartijn Coenen if (nxp_nfc_full_version == NULL) { 884ac9c8c89d16e2c458c9c43e1def75d4e1f8f5b9bMartijn Coenen // Couldn't load firmware, just pretend we're up to date. 885113bdd7504d69f483c4208bc30a457b7ff4b69faSteve Block ALOGW("Firmware image not available: this device might be running old NFC firmware!"); 886ac9c8c89d16e2c458c9c43e1def75d4e1f8f5b9bMartijn Coenen phLibNfc_StackCapabilities->psDevCapabilities.firmware_update_info = 0; 887ac9c8c89d16e2c458c9c43e1def75d4e1f8f5b9bMartijn Coenen } else { 888ac9c8c89d16e2c458c9c43e1def75d4e1f8f5b9bMartijn Coenen phLibNfc_StackCapabilities->psDevCapabilities.firmware_update_info = memcmp(phLibNfc_StackCapabilities->psDevCapabilities.full_version, nxp_nfc_full_version, 889ac9c8c89d16e2c458c9c43e1def75d4e1f8f5b9bMartijn Coenen NXP_FULL_VERSION_LEN); 890ac9c8c89d16e2c458c9c43e1def75d4e1f8f5b9bMartijn Coenen } 8915e97605ca8d83414b122bae72e65ea388b66718adaniel_Tomas 8925d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NFCSTATUS_SUCCESS != RetVal) 8935d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 8945d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly RetVal = NFCSTATUS_FAILED; 8955d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 8965d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 8975d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly return RetVal; 8985d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly} 8995d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 9005d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 9015d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 9025d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 9035d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 9045d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 9055d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyNFCSTATUS phLibNfc_Mgt_ConfigureTestMode(void *pDriverHandle, 9065d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pphLibNfc_RspCb_t pTestModeCb, 9075d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phLibNfc_Cfg_Testmode_t eTstmode, 9085d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly void *pContext) 9095d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly{ 9105d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS Status = NFCSTATUS_SUCCESS; 9115d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHal4Nfc_InitType_t eInitType=eInitDefault; 9125d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 9135d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if((NULL == pDriverHandle)||(NULL == pTestModeCb)) 9145d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 9155d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly Status = NFCSTATUS_INVALID_PARAMETER; 9165d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 9175d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else if((NULL != gpphLibContext) && \ 9185d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (gpphLibContext->LibNfcState.next_state==eLibNfcHalStateShutdown)) 9195d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 9205d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly Status = NFCSTATUS_SHUTDOWN; 9215d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 9225d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else if( (eTstmode == phLibNfc_TstMode_On) && (NULL != gpphLibContext)) 9235d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 9245d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly Status=NFCSTATUS_ALREADY_INITIALISED; 9255d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 9265d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else if( (eTstmode == phLibNfc_TstMode_Off) && (NULL == gpphLibContext)) 9275d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 9285d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly Status = NFCSTATUS_NOT_INITIALISED; 9295d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 9305d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else if( (eTstmode == phLibNfc_TstMode_Off) && (NULL != gpphLibContext)) 9315d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 9325d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if (NULL!= gpphLibContext->CBInfo.pClientShutdownCb) 9335d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { /* Previous callback pending */ 9345d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly Status = NFCSTATUS_BUSY; 9355d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 9365d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 9375d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 9385d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly Status = NFCSTATUS_PENDING; 9395d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(TRUE != gpphLibContext->status.GenCb_pending_status) 9405d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 9415d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly Status = phHal4Nfc_Close(gpphLibContext->psHwReference, 9425d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phLibNfc_ShutdownCb, 9435d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (void *)gpphLibContext); 9445d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 9455d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(Status== NFCSTATUS_PENDING) 9465d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 9475d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->CBInfo.pClientShutdownCb = pTestModeCb; 9485d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->CBInfo.pClientShtdwnCntx = pContext; 9495d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->status.GenCb_pending_status=TRUE; 9505d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->LibNfcState.next_state= eLibNfcHalStateShutdown; 9515d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 9525d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 9535d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 9545d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly Status =NFCSTATUS_FAILED; 9555d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 9565d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 9575d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 9585d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 9595d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 9605d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Initialize the Lib context */ 9615d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext=(pphLibNfc_LibContext_t)phOsalNfc_GetMemory( 9625d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (uint32_t)sizeof(phLibNfc_LibContext_t)); 9635d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NULL == gpphLibContext) 9645d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 9655d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly Status=NFCSTATUS_INSUFFICIENT_RESOURCES; 9665d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 9675d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 9685d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 9695d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (void)memset((void *)gpphLibContext,0,( 9705d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (uint32_t)sizeof(phLibNfc_LibContext_t))); 9715d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 9725d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Store the Callback and context in LibContext structure*/ 9735d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->CBInfo.pClientInitCb=pTestModeCb; 9745d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->CBInfo.pClientInitCntx=pContext; 9755d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Initialize the HwReferece structure */ 9765d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->psHwReference=(phHal_sHwReference_t *) 9775d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phOsalNfc_GetMemory((uint32_t)sizeof(phHal_sHwReference_t)); 9785d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (void)memset((void *)gpphLibContext->psHwReference,0, 9795d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ((uint32_t)sizeof(phHal_sHwReference_t))); 9805d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Allocate the Memory for the Transceive info */ 9815d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if( gpphLibContext->psHwReference!=NULL) 9825d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 9835d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->psHwReference->p_board_driver = pDriverHandle; 9845d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly Status = phLibNfc_UpdateNextState(gpphLibContext, 9855d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly eLibNfcHalStateInitandIdle); 9865d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(Status==NFCSTATUS_SUCCESS) 9875d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 9885d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(eTstmode == phLibNfc_TstMode_On) 9895d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly eInitType = eInitTestModeOn; 9905d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(eTstmode == phLibNfc_TstMode_Off) 9915d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly eInitType = eInitDefault; 9925d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly Status=phHal4Nfc_Open( 9935d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->psHwReference, 9945d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly eInitType, 9955d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phLibNfc_InitCb, 9965d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (void *)gpphLibContext); 9975d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 9985d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 9995d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 10005d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 10015d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly Status = NFCSTATUS_INSUFFICIENT_RESOURCES; 10025d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 10035d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phLibNfc_Ndef_Init(); 10045d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 10055d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 10065d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 10075d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly return Status; 10085d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly} 10095d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 1010