phLibNfc.c revision 5e97605ca8d83414b122bae72e65ea388b66718a
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 345d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#include <phLibNfc.h> 355d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#include <phDal4Nfc.h> 365d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#include <phHal4Nfc.h> 375d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#include <phOsalNfc.h> 385d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#include <phLibNfc_Internal.h> 395d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#include <phLibNfc_ndef_raw.h> 405d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#include <phLibNfc_initiator.h> 415d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#include <phLibNfc_discovery.h> 425d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#include <phNfcStatus.h> 435e97605ca8d83414b122bae72e65ea388b66718adaniel_Tomas#include <utils/Log.h> 445d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/* 455d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly*************************** Macro's ****************************************** 465d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly*/ 475d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 485d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#ifndef STATIC_DISABLE 495d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#define STATIC static 505d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#else 515d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#define STATIC 525d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif 535d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 545d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 555d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/* 565d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly*************************** Global Variables ********************************** 575d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly*/ 585d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 595d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 605d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellypphLibNfc_LibContext_t gpphLibContext=NULL; 615d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 625d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/* 635d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly*************************** Static Function Declaration *********************** 645d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly*/ 655d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 665d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/* Init callback */ 675d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellySTATIC void phLibNfc_InitCb(void *pContext,NFCSTATUS status); 685d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 695d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/* Shutdown callback */ 705d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellySTATIC void phLibNfc_ShutdownCb(void *pContext,NFCSTATUS status); 715d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 725d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/**Default notification handler registered with lower layer immediately after 735d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly successful initialization*/ 745d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellySTATIC void phLibNfc_DefaultHandler( 755d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly void *context, 765d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHal_eNotificationType_t type, 775d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHal4Nfc_NotificationInfo_t info, 785d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS status 795d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ); 805d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/* 815d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly*************************** Function Definitions ****************************** 825d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly*/ 835d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 845d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyNFCSTATUS phLibNfc_Mgt_ConfigureDriver (pphLibNfc_sConfig_t psConfig, 855d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly void ** ppDriverHandle) 865d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly{ 875d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NULL != gpphLibContext) 885d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 895d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly return NFCSTATUS_ALREADY_INITIALISED; 905d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 915d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 925d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly return phDal4Nfc_Config(psConfig, ppDriverHandle); 935d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly} 945d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 955d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyNFCSTATUS phLibNfc_Mgt_UnConfigureDriver (void * pDriverHandle) 965d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly{ 975d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NULL != gpphLibContext) 985d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 995d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly return NFCSTATUS_ALREADY_INITIALISED; 1005d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 1015d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 1025d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly return phDal4Nfc_ConfigRelease(pDriverHandle); 1035d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly} 1045d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 1055e97605ca8d83414b122bae72e65ea388b66718adaniel_TomasNFCSTATUS phLibNfc_HW_Reset () 1063e98767aaf73b4779a2bb39601806045b2ba1739Jeff Hamilton{ 1075e97605ca8d83414b122bae72e65ea388b66718adaniel_Tomas NFCSTATUS Status = NFCSTATUS_SUCCESS; 1085e97605ca8d83414b122bae72e65ea388b66718adaniel_Tomas 1095e97605ca8d83414b122bae72e65ea388b66718adaniel_Tomas Status = phDal4Nfc_Reset(0); 1105e97605ca8d83414b122bae72e65ea388b66718adaniel_Tomas Status = phDal4Nfc_Reset(1); 1115e97605ca8d83414b122bae72e65ea388b66718adaniel_Tomas 1125e97605ca8d83414b122bae72e65ea388b66718adaniel_Tomas return Status; 1133e98767aaf73b4779a2bb39601806045b2ba1739Jeff Hamilton} 1143e98767aaf73b4779a2bb39601806045b2ba1739Jeff Hamilton 1155e97605ca8d83414b122bae72e65ea388b66718adaniel_TomasNFCSTATUS phLibNfc_Download_Mode () 1163e98767aaf73b4779a2bb39601806045b2ba1739Jeff Hamilton{ 1175e97605ca8d83414b122bae72e65ea388b66718adaniel_Tomas return phDal4Nfc_Download(); 1183e98767aaf73b4779a2bb39601806045b2ba1739Jeff Hamilton} 1193e98767aaf73b4779a2bb39601806045b2ba1739Jeff Hamilton 1205d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/** 1215d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* Initialize the phLibNfc interface. 1225d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly*/ 1235d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 1245d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyNFCSTATUS phLibNfc_Mgt_Initialize(void *pDriverHandle, 1253e98767aaf73b4779a2bb39601806045b2ba1739Jeff Hamilton pphLibNfc_RspCb_t pInitCb, 1263e98767aaf73b4779a2bb39601806045b2ba1739Jeff Hamilton void *pContext) 1275d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly{ 1285d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS Status = NFCSTATUS_SUCCESS; 1295d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if((NULL == pDriverHandle)||(NULL == pInitCb)) 1305d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 1315d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly Status = NFCSTATUS_INVALID_PARAMETER; 1325d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 1335d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else if(NULL == gpphLibContext) 1345d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 1355d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Initialize the Lib context */ 1365d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext=(pphLibNfc_LibContext_t)phOsalNfc_GetMemory( 1375d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (uint32_t)sizeof(phLibNfc_LibContext_t)); 1385d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NULL == gpphLibContext) 1395d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 1405d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly Status=NFCSTATUS_INSUFFICIENT_RESOURCES; 1415d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 1425d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 1435d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 1445d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (void)memset((void *)gpphLibContext,0,( 1455d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (uint32_t)sizeof(phLibNfc_LibContext_t))); 1465d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 1475d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Store the Callback and context in LibContext structure*/ 1485d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->CBInfo.pClientInitCb=pInitCb; 1495d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->CBInfo.pClientInitCntx=pContext; 1505d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Initialize the HwReferece structure */ 1515d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->psHwReference=(phHal_sHwReference_t *) 1525d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phOsalNfc_GetMemory((uint32_t)sizeof(phHal_sHwReference_t)); 1535d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (void)memset((void *)gpphLibContext->psHwReference,0, 1545d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ((uint32_t)sizeof(phHal_sHwReference_t))); 1555d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Allocate the Memory for the Transceive info */ 1565d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if( gpphLibContext->psHwReference!=NULL) 1575d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 1585d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->psHwReference->p_board_driver = pDriverHandle; 1595d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly Status = phLibNfc_UpdateNextState(gpphLibContext, 1605d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly eLibNfcHalStateInitandIdle); 1615d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(Status==NFCSTATUS_SUCCESS) 1625d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 1635d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly Status=phHal4Nfc_Open( 1645d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->psHwReference, 1655d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly eInitDefault, 1665d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phLibNfc_InitCb, 1675d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (void *)gpphLibContext); 1685d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 1695d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 1705d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 1715d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 1725d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly Status = NFCSTATUS_INSUFFICIENT_RESOURCES; 1735d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 1745d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phLibNfc_Ndef_Init(); 1755d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 1765d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 1775d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else if(gpphLibContext->LibNfcState.next_state==eLibNfcHalStateShutdown) 1785d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 1795d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly Status = NFCSTATUS_SHUTDOWN; 1805d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 1815d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 1825d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 1835d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly Status=NFCSTATUS_ALREADY_INITIALISED; 1845d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 1855d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly return Status; 1865d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly} 1875d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 1885d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/* 1895d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * This function called by the HAL4 when the initialization seq is completed. 1905d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly */ 1915d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellySTATIC void phLibNfc_InitCb(void *pContext,NFCSTATUS status) 1925d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly{ 1935d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pphLibNfc_LibContext_t pLibContext=NULL; 1945d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pphLibNfc_RspCb_t pClientCb=NULL; 1955d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly void *pUpperLayerContext=NULL; 1965d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 1975d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 1985d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Initialize the local variable */ 1995d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pLibContext = (pphLibNfc_LibContext_t)pContext; 2005d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 2015d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pClientCb =pLibContext->CBInfo.pClientInitCb; 2025d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pUpperLayerContext=pLibContext->CBInfo.pClientInitCntx; 2035d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(status == NFCSTATUS_SUCCESS) 2045d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 2055d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Get the Lib context */ 2065d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pLibContext=(pphLibNfc_LibContext_t)gpphLibContext; 2075d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->sSeContext.eActivatedMode = phLibNfc_SE_ActModeOff; 2085d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(pLibContext->psHwReference->uicc_connected==TRUE) 2095d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 2105d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* populate state of the secured element */ 2115d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->sSeContext.eActivatedMode = phLibNfc_SE_ActModeDefault; 2125d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly sSecuredElementInfo[LIBNFC_SE_UICC_INDEX].eSE_CurrentState=phLibNfc_SE_Active; 2135d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pLibContext->sSeContext.uUiccActivate=TRUE; 2145d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 2155d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(pLibContext->psHwReference->smx_connected==TRUE) 2165d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 2175d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* populate state of the secured element */ 2185d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->sSeContext.eActivatedMode = phLibNfc_SE_ActModeDefault; 2195d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly sSecuredElementInfo[LIBNFC_SE_SMARTMX_INDEX].eSE_CurrentState=phLibNfc_SE_Inactive; 2205d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pLibContext->sSeContext.uSmxActivate =FALSE; 2215d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 2225d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 2235d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phLibNfc_UpdateCurState(status,pLibContext); 2245d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (void)phHal4Nfc_RegisterNotification( 2255d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pLibContext->psHwReference, 2265d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly eRegisterDefault, 2275d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phLibNfc_DefaultHandler, 2285d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (void*)pLibContext 2295d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ); 2305d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* call the upper layer register function */ 2315d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (*pClientCb)(pUpperLayerContext,status); 2325d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 2335d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 2345d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 2355d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 2365d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /*Change the status code failed*/ 2375d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = NFCSTATUS_FAILED; 2385d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Get the Lib context */ 2395d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pLibContext=(pphLibNfc_LibContext_t)gpphLibContext; 2405d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 2415d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phLibNfc_UpdateCurState(status,pLibContext); 2425d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 2435d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 2445d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 2455d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Allocate the Memory for the Transceive info */ 2465d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(pLibContext->psHwReference!= NULL) 2475d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 2485d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phOsalNfc_FreeMemory(pLibContext->psHwReference); 2495d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pLibContext->psHwReference = NULL; 2505d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 2515d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (*pClientCb)(pUpperLayerContext, status); 2525d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 2535d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phOsalNfc_FreeMemory(pLibContext); 2545d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pLibContext= NULL; 2555d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext = NULL; 2565d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 2575d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 2585d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly return; 2595d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly} 2605d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 2615d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/**Default notification handler registered with lower layer immediately after 2625d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly successful initialization*/ 2635d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellySTATIC void phLibNfc_DefaultHandler( 2645d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly void *context, 2655d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHal_eNotificationType_t type, 2665d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHal4Nfc_NotificationInfo_t info, 2675d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS status 2685d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ) 2695d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly{ 2705d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(context != (void *)gpphLibContext) 2715d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 2725d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phOsalNfc_RaiseException(phOsalNfc_e_InternalErr,1); 2735d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 2745d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 2755d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 2765d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly info = info; 2775d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if((NFC_EVENT_NOTIFICATION == type) && 2785d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (NFCSTATUS_BOARD_COMMUNICATION_ERROR == status)) 2795d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 2805d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phLibNfc_UpdateCurState(NFCSTATUS_FAILED,gpphLibContext); 2815d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phOsalNfc_RaiseException(phOsalNfc_e_UnrecovFirmwareErr,1); 2825d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 2835d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 2845d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly return; 2855d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly} 2865d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/** 2875d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* De-Initialize the LIB NFC. 2885d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly*/ 2895d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyNFCSTATUS phLibNfc_Mgt_DeInitialize(void * pDriverHandle, 2905d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pphLibNfc_RspCb_t pDeInitCb, 2915d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly void* pContext 2925d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ) 2935d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly{ 2945d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS Status = NFCSTATUS_SUCCESS; 2955d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pphLibNfc_LibContext_t pLibContext = gpphLibContext; 2965d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NULL==pDriverHandle) 2975d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 2985d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /*Check for valid parameters */ 2995d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly Status = NFCSTATUS_INVALID_PARAMETER; 3005d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 3015d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else if((pLibContext==NULL) 3025d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly || (pLibContext->LibNfcState.cur_state 3035d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly == eLibNfcHalStateShutdown)) 3045d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { /*Lib Nfc not initlized*/ 3055d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly Status = NFCSTATUS_NOT_INITIALISED; 3065d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 3075d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 3085d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 3095d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(pDeInitCb==NULL) 3105d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 3115d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHal4Nfc_Hal4Reset(pLibContext->psHwReference,(void *)pLibContext); 3125d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(pLibContext->psHwReference!=NULL) 3135d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 3145d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phOsalNfc_FreeMemory(pLibContext->psHwReference); 3155d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pLibContext->psHwReference = NULL; 3165d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 3175d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /*Free the memory allocated during NDEF read,write 3185d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly and NDEF formatting*/ 3195d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phLibNfc_Ndef_DeInit(); 3205d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phOsalNfc_FreeMemory(pLibContext); 3215d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext=NULL; 3225d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pLibContext= NULL; 3235d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 3245d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 3255d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 3265d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if (NULL!= pLibContext->CBInfo.pClientShutdownCb) 3275d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 3285d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Previous callback pending */ 3295d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly Status = NFCSTATUS_BUSY; 3305d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 3315d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly Status = NFCSTATUS_PENDING; 3325d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(TRUE != pLibContext->status.GenCb_pending_status) 3335d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 3345d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly Status = phHal4Nfc_Close(pLibContext->psHwReference, 3355d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phLibNfc_ShutdownCb, 3365d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (void *)pLibContext); 3375d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 3385d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(Status== NFCSTATUS_PENDING) 3395d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 3405d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pLibContext->CBInfo.pClientShutdownCb = pDeInitCb; 3415d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pLibContext->CBInfo.pClientShtdwnCntx = pContext; 3425d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pLibContext->status.GenCb_pending_status=TRUE; 3435d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pLibContext->LibNfcState.next_state= eLibNfcHalStateShutdown; 3445d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 3455d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 3465d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 3475d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly Status =NFCSTATUS_FAILED; 3485d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 3495d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 3505d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 3515d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly return Status; 3525d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly} 3535d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/* shutdown callback - 3545d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly Free the allocated memory here */ 3555d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellySTATIC void phLibNfc_ShutdownCb(void *pContext,NFCSTATUS status) 3565d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly{ 3575d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pphLibNfc_RspCb_t pClientCb=NULL; 3585d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly void *pUpperLayerContext=NULL; 3595d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pphLibNfc_LibContext_t pLibContext=NULL; 3605d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 3615d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly PHNFC_UNUSED_VARIABLE(pContext); 3625d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Get the Lib context */ 3635d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pLibContext=(pphLibNfc_LibContext_t)gpphLibContext; 3645d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 3655d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(pLibContext == NULL) 3665d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 3675d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = NFCSTATUS_FAILED; 3685d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 3695d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 3705d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 3715d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Initialize the local variable */ 3725d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pClientCb =pLibContext->CBInfo.pClientShutdownCb; 3735d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pUpperLayerContext=pLibContext->CBInfo.pClientShtdwnCntx; 3745d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(status == NFCSTATUS_SUCCESS) 3755d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 3765d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pLibContext->LibNfcState.cur_state = eLibNfcHalStateShutdown; 3775d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phLibNfc_UpdateCurState(status,pLibContext); 3785d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 3795d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pLibContext->status.GenCb_pending_status=FALSE; 3805d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 3815d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Allocate the Memory for the Transceive info */ 3825d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(pClientCb!=NULL) 3835d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 3845d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (*pClientCb)(pUpperLayerContext, status); 3855d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 3865d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(pLibContext->psHwReference!=NULL) 3875d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 3885d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phOsalNfc_FreeMemory(pLibContext->psHwReference); 3895d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pLibContext->psHwReference = NULL; 3905d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 3915d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NULL != gpphLibContext->psBufferedAuth) 3925d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 3935d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NULL != gpphLibContext->psBufferedAuth->sRecvData.buffer) 3945d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 3955d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phOsalNfc_FreeMemory( 3965d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->psBufferedAuth->sRecvData.buffer); 3975d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 3985d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NULL != gpphLibContext->psBufferedAuth->sSendData.buffer) 3995d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 4005d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phOsalNfc_FreeMemory( 4015d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->psBufferedAuth->sSendData.buffer); 4025d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 4035d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phOsalNfc_FreeMemory(gpphLibContext->psBufferedAuth); 4045d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->psBufferedAuth = NULL; 4055d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 4065d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /*Free the memory allocated during NDEF read,write 4075d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly and NDEF formatting*/ 4085d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phLibNfc_Ndef_DeInit(); 4095d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phOsalNfc_FreeMemory(pLibContext); 4105d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext=NULL; 4115d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pLibContext= NULL; 4125d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 4135d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 4145d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 4155d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 4165d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* shutdown sequence failed by HAL 4 */ 4175d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status= NFCSTATUS_FAILED; 4185d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pLibContext=(pphLibNfc_LibContext_t)gpphLibContext; 4195d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phLibNfc_UpdateCurState(status,pLibContext); 4205d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pLibContext->status.GenCb_pending_status=FALSE; 4215d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(pClientCb!=NULL) 4225d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 4235d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (*pClientCb)(pUpperLayerContext,status); 4245d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 4255d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 4265d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 4275d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly} 4285d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/** 4295d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* Pending shutdown call. 4305d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly*/ 4315d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 4325d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 4335d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pellyvoid phLibNfc_Pending_Shutdown(void) 4345d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly{ 4355d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS RetStatus = NFCSTATUS_SUCCESS ; 4365d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->status.GenCb_pending_status = FALSE; 4375d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly RetStatus = phHal4Nfc_Close( 4385d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->psHwReference, 4395d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phLibNfc_ShutdownCb, 4405d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (void *)gpphLibContext); 4415d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly PHNFC_UNUSED_VARIABLE(RetStatus); 4425d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly return; 4435d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly} 4445d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 4455d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 4465d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/** 4475d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* Reset the LIB NFC. 4485d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly*/ 4495d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyNFCSTATUS phLibNfc_Mgt_Reset(void *pContext) 4505d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly{ 4515d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS Status = NFCSTATUS_SUCCESS; 4525d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phLibNfc_LibContext_t *pLibNfc_Ctxt = (phLibNfc_LibContext_t *)pContext; 4535d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 4545d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if((pLibNfc_Ctxt == NULL) 4555d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly || (gpphLibContext->LibNfcState.cur_state 4565d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly == eLibNfcHalStateShutdown)) 4575d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { /*Lib Nfc not initlized*/ 4585d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly Status = NFCSTATUS_NOT_INITIALISED; 4595d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 4605d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else if(NULL == pContext) 4615d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 4625d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly Status = NFCSTATUS_INVALID_PARAMETER; 4635d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 4645d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Check for valid state,If De initialize is called then 4655d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly return NFCSTATUS_SHUTDOWN */ 4665d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else if(gpphLibContext->LibNfcState.next_state 4675d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly == eLibNfcHalStateShutdown) 4685d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 4695d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly Status = NFCSTATUS_SHUTDOWN; 4705d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 4715d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 4725d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 4735d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /*Reset all callback status*/ 4745d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (void) memset(&(gpphLibContext->RegNtfType),0, 4755d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly sizeof(phLibNfc_Registry_Info_t)); 4765d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (void) memset(&(gpphLibContext->sADDconfig),0, 4775d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly sizeof(phLibNfc_sADD_Cfg_t)); 4785d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (void) memset(&(gpphLibContext->ndef_cntx),0, 4795d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly sizeof(phLibNfc_NdefInfo_t)); 4805d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (void) memset(&(gpphLibContext->sNfcIp_Context),0, 4815d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly sizeof(phLibNfc_NfcIpInfo_t)); 4825d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (void) memset(&(gpphLibContext->sCardEmulCfg),0, 4835d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly sizeof(phHal_sEmulationCfg_t)); 4845d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (void) memset(&(gpphLibContext->Discov_handle),0, 4855d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly MAX_REMOTE_DEVICES); 4865d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 4875d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /*Free memory allocated for NDEF records*/ 4885d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NULL != gpphLibContext->psBufferedAuth) 4895d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 4905d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NULL != gpphLibContext->psBufferedAuth->sRecvData.buffer) 4915d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 4925d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phOsalNfc_FreeMemory( 4935d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->psBufferedAuth->sRecvData.buffer); 4945d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->psBufferedAuth->sRecvData.buffer = NULL; 4955d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 4965d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NULL != gpphLibContext->psBufferedAuth->sSendData.buffer) 4975d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 4985d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phOsalNfc_FreeMemory( 4995d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->psBufferedAuth->sSendData.buffer); 5005d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->psBufferedAuth->sSendData.buffer = NULL; 5015d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 5025d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phOsalNfc_FreeMemory(gpphLibContext->psBufferedAuth); 5035d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->psBufferedAuth = NULL; 5045d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 5055d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NULL != gpphLibContext->psTransInfo) 5065d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 5075d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phOsalNfc_FreeMemory(gpphLibContext->psTransInfo); 5085d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->psTransInfo = NULL; 5095d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 5105d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NULL != gpphLibContext->ndef_cntx.psNdefMap) 5115d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 5125d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NULL != gpphLibContext->ndef_cntx.psNdefMap->SendRecvBuf) 5135d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 5145d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phOsalNfc_FreeMemory(gpphLibContext->ndef_cntx.psNdefMap->SendRecvBuf); 5155d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->ndef_cntx.psNdefMap->SendRecvBuf = NULL; 5165d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 5175d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phOsalNfc_FreeMemory(gpphLibContext->ndef_cntx.psNdefMap); 5185d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->ndef_cntx.psNdefMap = NULL; 5195d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 5205d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NULL != gpphLibContext->psOverHalCtxt) 5215d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 5225d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phOsalNfc_FreeMemory(gpphLibContext->psOverHalCtxt); 5235d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->psTransInfo = NULL; 5245d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 5255d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NULL != gpphLibContext->psDevInputParam) 5265d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 5275d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phOsalNfc_FreeMemory(gpphLibContext->psDevInputParam); 5285d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->psDevInputParam = NULL; 5295d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 5305d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NULL != gpphLibContext->ndef_cntx.ndef_fmt) 5315d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 5325d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phOsalNfc_FreeMemory(gpphLibContext->ndef_cntx.ndef_fmt); 5335d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->ndef_cntx.ndef_fmt = NULL; 5345d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 5355d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NULL != pNdefRecord) 5365d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 5375d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NULL != pNdefRecord->Id) 5385d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 5395d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phOsalNfc_FreeMemory(pNdefRecord->Id); 5405d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pNdefRecord->Id = NULL; 5415d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 5425d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NULL != pNdefRecord->Type) 5435d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 5445d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phOsalNfc_FreeMemory(pNdefRecord->Type); 5455d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pNdefRecord->Type = NULL; 5465d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 5475d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NULL != pNdefRecord->PayloadData) 5485d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 5495d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phOsalNfc_FreeMemory(pNdefRecord->PayloadData); 5505d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pNdefRecord->PayloadData = NULL; 5515d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 5525d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 5535d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NULL != NdefInfo.pNdefRecord) 5545d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 5555d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phOsalNfc_FreeMemory(NdefInfo.pNdefRecord); 5565d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NdefInfo.pNdefRecord = NULL; 5575d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 5585d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NULL != gpphLibContext->phLib_NdefRecCntx.NdefCb) 5595d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 5605d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phOsalNfc_FreeMemory(gpphLibContext->phLib_NdefRecCntx.NdefCb); 5615d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->phLib_NdefRecCntx.NdefCb = NULL; 5625d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 5635d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NULL != gpphLibContext->phLib_NdefRecCntx.ndef_message.buffer) 5645d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 5655d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phOsalNfc_FreeMemory(gpphLibContext->phLib_NdefRecCntx.ndef_message.buffer); 5665d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->phLib_NdefRecCntx.ndef_message.buffer = NULL; 5675d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 5685d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* No device is connected */ 5695d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->Connected_handle = 0x00; 5705d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->ReleaseType = NFC_INVALID_RELEASE_TYPE; 5715d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->eLibNfcCfgMode = NFC_DISCOVERY_STOP; 5725d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /*Lib Nfc Stack is initilized and in idle state*/ 5735d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->LibNfcState.cur_state = eLibNfcHalStateInitandIdle; 5745d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 5755d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Reset all callback status */ 5765d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->CBInfo.pClientCkNdefCb = NULL; 5775d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->CBInfo.pClientCkNdefCntx = NULL; 5785d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->CBInfo.pClientConCntx = NULL; 5795d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->CBInfo.pClientConnectCb = NULL; 5805d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->CBInfo.pClientDConCntx = NULL; 5815d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->CBInfo.pClientDisCfgCntx = NULL; 5825d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->CBInfo.pClientDisConfigCb = NULL; 5835d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->CBInfo.pClientInitCb = NULL; 5845d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->CBInfo.pClientInitCntx = gpphLibContext; 5855d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->CBInfo.pClientNdefNtfRespCb = NULL; 5865d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->CBInfo.pClientNdefNtfRespCntx = NULL; 5875d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->CBInfo.pClientNtfRegRespCB = NULL; 5885d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->CBInfo.pClientNtfRegRespCntx = NULL; 5895d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->CBInfo.pClientPresChkCb = NULL; 5905d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->CBInfo.pClientPresChkCntx = NULL; 5915d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->CBInfo.pClientRdNdefCb = NULL; 5925d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->CBInfo.pClientRdNdefCntx = NULL; 5935d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->CBInfo.pClientShtdwnCntx = NULL; 5945d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->CBInfo.pClientShutdownCb = NULL; 5955d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->CBInfo.pClientTransceiveCb = NULL; 5965d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->CBInfo.pClientTranseCntx = NULL; 5975d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->CBInfo.pClientWrNdefCb = NULL; 5985d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->CBInfo.pClientWrNdefCntx = NULL; 5995d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->sNfcIp_Context.pClientNfcIpCfgCb = NULL; 6005d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->sNfcIp_Context.pClientNfcIpCfgCntx = NULL; 6015d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->sNfcIp_Context.pClientNfcIpRxCb = NULL; 6025d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->sNfcIp_Context.pClientNfcIpRxCntx = NULL; 6035d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->sNfcIp_Context.pClientNfcIpTxCb = NULL; 6045d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->sNfcIp_Context.pClientNfcIpTxCntx = NULL; 6055d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->sSeContext.sSeCallabackInfo.pSeListenerNtfCb = NULL; 6065d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->sSeContext.sSeCallabackInfo.pSeListenerCtxt = NULL; 6075d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->sSeContext.sSeCallabackInfo.pSEsetModeCb = NULL; 6085d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->sSeContext.sSeCallabackInfo.pSEsetModeCtxt = NULL; 6095d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /*No callback is pending*/ 6105d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->status.GenCb_pending_status = FALSE; 6115d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 6125d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 6135d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly return Status; 6145d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly} 6155d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/** 6165d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* LibNfc state machine next state update. 6175d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly*/ 6185d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 6195d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyNFCSTATUS 6205d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyphLibNfc_UpdateNextState( 6215d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pphLibNfc_LibContext_t pLibContext, 6225d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phLibNfc_State_t next_state 6235d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ) 6245d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly{ 6255d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS status = NFCSTATUS_INVALID_STATE; 6265d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly switch(pLibContext->LibNfcState.cur_state) 6275d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 6285d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case eLibNfcHalStateShutdown: 6295d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 6305d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly switch(next_state) 6315d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 6325d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case eLibNfcHalStateShutdown: 6335d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case eLibNfcHalStateInitandIdle: 6345d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = NFCSTATUS_SUCCESS; 6355d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 6365d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly default: 6375d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 6385d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 6395d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 6405d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 6415d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case eLibNfcHalStateConfigReady: 6425d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 6435d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly switch(next_state) 6445d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 6455d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case eLibNfcHalStateShutdown: 6465d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case eLibNfcHalStateConfigReady: 6475d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case eLibNfcHalStateInitandIdle: 6485d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case eLibNfcHalStateConnect: 6495d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = NFCSTATUS_SUCCESS; 6505d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 6515d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly default: 6525d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 6535d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 6545d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 6555d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 6565d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case eLibNfcHalStateConnect: 6575d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 6585d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly switch(next_state) 6595d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 6605d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case eLibNfcHalStateShutdown: 6615d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case eLibNfcHalStateRelease: 6625d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case eLibNfcHalStateTransaction: 6635d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case eLibNfcHalStatePresenceChk: 6645d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = NFCSTATUS_SUCCESS; 6655d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 6665d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly default: 6675d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 6685d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 6695d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 6705d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 6715d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case eLibNfcHalStatePresenceChk: 6725d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 6735d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly switch(next_state) 6745d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 6755d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case eLibNfcHalStateShutdown: 6765d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case eLibNfcHalStateConfigReady: 6775d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case eLibNfcHalStateRelease: 6785d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case eLibNfcHalStateTransaction: 6795d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case eLibNfcHalStatePresenceChk: 6805d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = NFCSTATUS_SUCCESS; 6815d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 6825d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly default: 6835d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 6845d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 6855d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 6865d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 6875d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case eLibNfcHalStateInitandIdle: 6885d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 6895d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly switch(next_state) 6905d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 6915d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case eLibNfcHalStateShutdown: 6925d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case eLibNfcHalStateConfigReady: 6935d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = NFCSTATUS_SUCCESS; 6945d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 6955d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly default: 6965d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 6975d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 6985d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 6995d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 7005d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly default: 7015d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 7025d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 7035d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pLibContext->LibNfcState.next_state = 7045d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (uint8_t)((NFCSTATUS_SUCCESS == status)?next_state:pLibContext->LibNfcState.next_state); 7055d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 7065d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly return status; 7075d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly} 7085d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 7095d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/** 7105d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* LibNfc state machine current state update. 7115d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly*/ 7125d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 7135d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pellyvoid 7145d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyphLibNfc_UpdateCurState( 7155d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS status, 7165d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pphLibNfc_LibContext_t psLibContext 7175d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ) 7185d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly{ 7195d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly switch(psLibContext->LibNfcState.next_state) 7205d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 7215d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case eLibNfcHalStateTransaction: 7225d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psLibContext->LibNfcState.cur_state = (uint8_t)eLibNfcHalStateConnect; 7235d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 7245d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case eLibNfcHalStateRelease: 7255d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psLibContext->LibNfcState.cur_state 7265d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly = (uint8_t)(psLibContext->status.DiscEnbl_status == TRUE? 7275d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly eLibNfcHalStateInitandIdle:eLibNfcHalStateConfigReady); 7285d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 7295d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case eLibNfcHalStateInvalid: 7305d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 7315d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly default: 7325d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psLibContext->LibNfcState.cur_state 7335d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly = (uint8_t)((NFCSTATUS_SUCCESS == status)? 7345d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psLibContext->LibNfcState.next_state: 7355d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psLibContext->LibNfcState.cur_state); 7365d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 7375d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psLibContext->LibNfcState.next_state = (uint8_t)eLibNfcHalStateInvalid; 7385d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly return; 7395d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly} 7405d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/* Interface to stack capabilities */ 7415d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 7425d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyNFCSTATUS phLibNfc_Mgt_GetstackCapabilities( 7435d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phLibNfc_StackCapabilities_t *phLibNfc_StackCapabilities, 7445d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly void *pContext) 7455d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly{ 7465d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS RetVal = NFCSTATUS_FAILED; 7475d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /*Check Lib Nfc stack is initilized*/ 7485d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if((NULL == gpphLibContext)|| 7495d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (gpphLibContext->LibNfcState.cur_state == eLibNfcHalStateShutdown)) 7505d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 7515d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly RetVal = NFCSTATUS_NOT_INITIALISED; 7525d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 7535d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /*Check application has sent the valid parameters*/ 7545d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else if((NULL == phLibNfc_StackCapabilities) 7555d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly || (NULL == pContext)) 7565d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 7575d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly RetVal= NFCSTATUS_INVALID_PARAMETER; 7585d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 7595d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else if(gpphLibContext->LibNfcState.next_state == eLibNfcHalStateShutdown) 7605d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 7615d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly RetVal = NFCSTATUS_SHUTDOWN; 7625d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 7635d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else if(TRUE == gpphLibContext->status.GenCb_pending_status) 7645d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 7655d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /*Previous operation is pending */ 7665d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly RetVal = NFCSTATUS_BUSY; 7675d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 7685d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 7695d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 7705d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Tag Format Capabilities*/ 7715d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phLibNfc_StackCapabilities->psFormatCapabilities.Desfire = TRUE; 7725d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phLibNfc_StackCapabilities->psFormatCapabilities.MifareStd = TRUE; 7735d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phLibNfc_StackCapabilities->psFormatCapabilities.MifareUL = TRUE; 7745d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phLibNfc_StackCapabilities->psFormatCapabilities.FeliCa = FALSE; 7755d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phLibNfc_StackCapabilities->psFormatCapabilities.Jewel = FALSE; 7765d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phLibNfc_StackCapabilities->psFormatCapabilities.ISO14443_4A = FALSE; 7775d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phLibNfc_StackCapabilities->psFormatCapabilities.ISO14443_4B = FALSE; 7785d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phLibNfc_StackCapabilities->psFormatCapabilities.MifareULC = TRUE; 7795d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phLibNfc_StackCapabilities->psFormatCapabilities.ISO15693 = FALSE; 7805d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 7815d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Tag Mapping Capabilities */ 7825d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phLibNfc_StackCapabilities->psMappingCapabilities.FeliCa = TRUE; 7835d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phLibNfc_StackCapabilities->psMappingCapabilities.Desfire = TRUE; 7845d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phLibNfc_StackCapabilities->psMappingCapabilities.ISO14443_4A = TRUE; 7855d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phLibNfc_StackCapabilities->psMappingCapabilities.ISO14443_4B = TRUE; 7865d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phLibNfc_StackCapabilities->psMappingCapabilities.MifareStd = TRUE; 7875d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phLibNfc_StackCapabilities->psMappingCapabilities.MifareUL = TRUE; 7885d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phLibNfc_StackCapabilities->psMappingCapabilities.MifareULC = TRUE; 7895d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phLibNfc_StackCapabilities->psMappingCapabilities.Jewel = TRUE; 7905d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phLibNfc_StackCapabilities->psMappingCapabilities.ISO15693 = FALSE; 7915d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 7925d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /*Call Hal4 Get Dev Capabilities to get info about protocols supported 7935d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly by Lib Nfc*/ 7945d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly PHDBG_INFO("LibNfc:Get Stack capabilities "); 7955d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly RetVal= phHal4Nfc_GetDeviceCapabilities( 7965d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->psHwReference, 7975d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly &(phLibNfc_StackCapabilities->psDevCapabilities), 7985d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (void *)gpphLibContext); 7995d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 8005d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly LIB_NFC_VERSION_SET(phLibNfc_StackCapabilities->psDevCapabilities.hal_version, 8015d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly PH_HAL4NFC_VERSION, 8025d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly PH_HAL4NFC_REVISION, 8035d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly PH_HAL4NFC_PATCH, 8045d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly PH_HAL4NFC_BUILD); 8055d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 8065d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phLibNfc_StackCapabilities->psDevCapabilities.fw_version= 8075d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->psHwReference->device_info.fw_version; 8085d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phLibNfc_StackCapabilities->psDevCapabilities.hci_version= 8095d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->psHwReference->device_info.hci_version; 8105d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phLibNfc_StackCapabilities->psDevCapabilities.hw_version= 8115d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->psHwReference->device_info.hw_version; 8125d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phLibNfc_StackCapabilities->psDevCapabilities.model_id= 8135d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->psHwReference->device_info.model_id; 8145d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (void)memcpy(phLibNfc_StackCapabilities->psDevCapabilities.full_version, 8155d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->psHwReference->device_info.full_version,NXP_FULL_VERSION_LEN); 8165d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 8175e97605ca8d83414b122bae72e65ea388b66718adaniel_Tomas /* Check the firmware version */ 8185e97605ca8d83414b122bae72e65ea388b66718adaniel_Tomas phLibNfc_StackCapabilities->psDevCapabilities.firmware_update_info = memcmp(phLibNfc_StackCapabilities->psDevCapabilities.full_version, nxp_nfc_full_version, 8195e97605ca8d83414b122bae72e65ea388b66718adaniel_Tomas NXP_FULL_VERSION_LEN); 8205e97605ca8d83414b122bae72e65ea388b66718adaniel_Tomas 8215d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NFCSTATUS_SUCCESS != RetVal) 8225d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 8235d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly RetVal = NFCSTATUS_FAILED; 8245d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 8255d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 8265d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly return RetVal; 8275d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly} 8285d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 8295d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 8305d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 8315d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 8325d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 8335d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 8345d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyNFCSTATUS phLibNfc_Mgt_ConfigureTestMode(void *pDriverHandle, 8355d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pphLibNfc_RspCb_t pTestModeCb, 8365d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phLibNfc_Cfg_Testmode_t eTstmode, 8375d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly void *pContext) 8385d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly{ 8395d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS Status = NFCSTATUS_SUCCESS; 8405d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHal4Nfc_InitType_t eInitType=eInitDefault; 8415d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 8425d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if((NULL == pDriverHandle)||(NULL == pTestModeCb)) 8435d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 8445d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly Status = NFCSTATUS_INVALID_PARAMETER; 8455d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 8465d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else if((NULL != gpphLibContext) && \ 8475d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (gpphLibContext->LibNfcState.next_state==eLibNfcHalStateShutdown)) 8485d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 8495d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly Status = NFCSTATUS_SHUTDOWN; 8505d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 8515d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else if( (eTstmode == phLibNfc_TstMode_On) && (NULL != gpphLibContext)) 8525d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 8535d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly Status=NFCSTATUS_ALREADY_INITIALISED; 8545d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 8555d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else if( (eTstmode == phLibNfc_TstMode_Off) && (NULL == gpphLibContext)) 8565d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 8575d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly Status = NFCSTATUS_NOT_INITIALISED; 8585d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 8595d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else if( (eTstmode == phLibNfc_TstMode_Off) && (NULL != gpphLibContext)) 8605d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 8615d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if (NULL!= gpphLibContext->CBInfo.pClientShutdownCb) 8625d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { /* Previous callback pending */ 8635d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly Status = NFCSTATUS_BUSY; 8645d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 8655d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 8665d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 8675d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly Status = NFCSTATUS_PENDING; 8685d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(TRUE != gpphLibContext->status.GenCb_pending_status) 8695d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 8705d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly Status = phHal4Nfc_Close(gpphLibContext->psHwReference, 8715d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phLibNfc_ShutdownCb, 8725d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (void *)gpphLibContext); 8735d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 8745d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(Status== NFCSTATUS_PENDING) 8755d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 8765d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->CBInfo.pClientShutdownCb = pTestModeCb; 8775d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->CBInfo.pClientShtdwnCntx = pContext; 8785d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->status.GenCb_pending_status=TRUE; 8795d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->LibNfcState.next_state= eLibNfcHalStateShutdown; 8805d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 8815d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 8825d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 8835d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly Status =NFCSTATUS_FAILED; 8845d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 8855d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 8865d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 8875d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 8885d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 8895d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Initialize the Lib context */ 8905d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext=(pphLibNfc_LibContext_t)phOsalNfc_GetMemory( 8915d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (uint32_t)sizeof(phLibNfc_LibContext_t)); 8925d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NULL == gpphLibContext) 8935d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 8945d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly Status=NFCSTATUS_INSUFFICIENT_RESOURCES; 8955d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 8965d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 8975d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 8985d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (void)memset((void *)gpphLibContext,0,( 8995d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (uint32_t)sizeof(phLibNfc_LibContext_t))); 9005d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 9015d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Store the Callback and context in LibContext structure*/ 9025d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->CBInfo.pClientInitCb=pTestModeCb; 9035d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->CBInfo.pClientInitCntx=pContext; 9045d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Initialize the HwReferece structure */ 9055d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->psHwReference=(phHal_sHwReference_t *) 9065d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phOsalNfc_GetMemory((uint32_t)sizeof(phHal_sHwReference_t)); 9075d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (void)memset((void *)gpphLibContext->psHwReference,0, 9085d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ((uint32_t)sizeof(phHal_sHwReference_t))); 9095d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Allocate the Memory for the Transceive info */ 9105d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if( gpphLibContext->psHwReference!=NULL) 9115d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 9125d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->psHwReference->p_board_driver = pDriverHandle; 9135d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly Status = phLibNfc_UpdateNextState(gpphLibContext, 9145d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly eLibNfcHalStateInitandIdle); 9155d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(Status==NFCSTATUS_SUCCESS) 9165d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 9175d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(eTstmode == phLibNfc_TstMode_On) 9185d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly eInitType = eInitTestModeOn; 9195d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(eTstmode == phLibNfc_TstMode_Off) 9205d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly eInitType = eInitDefault; 9215d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly Status=phHal4Nfc_Open( 9225d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphLibContext->psHwReference, 9235d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly eInitType, 9245d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phLibNfc_InitCb, 9255d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (void *)gpphLibContext); 9265d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 9275d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 9285d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 9295d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 9305d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly Status = NFCSTATUS_INSUFFICIENT_RESOURCES; 9315d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 9325d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phLibNfc_Ndef_Init(); 9335d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 9345d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 9355d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 9365d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly return Status; 9375d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly} 9385d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 939