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/*! 195d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* =========================================================================== * 205d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* * 215d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* * 225d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* \file phHciNfc_Sequence.c * 235d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* \brief State Machine Implementation for the HCI Management and * 245d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* and the Function Sequence for a particular State * 255d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* * 265d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* * 275d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* Project: NFC-FRI-1.1 * 285d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* * 295d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* $Date: Tue Jun 8 09:33:46 2010 $ * 305d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* $Author: ing04880 $ * 315d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* $Revision: 1.85 $ * 325d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* $Aliases: NFC_FRI1.1_WK1023_R35_1 $ 335d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* * 345d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* =========================================================================== * 355d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly*/ 365d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 375d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/* 385d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly################################################################################ 395d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly***************************** Header File Inclusion **************************** 405d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly################################################################################ 415d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly*/ 425d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 435d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#include <phNfcCompId.h> 445d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#include <phNfcConfig.h> 455d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#include <phHciNfc.h> 465d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#include <phHciNfc_Sequence.h> 475d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#include <phHciNfc_AdminMgmt.h> 485d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#include <phHciNfc_IDMgmt.h> 495d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#include <phHciNfc_LinkMgmt.h> 505d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#include <phHciNfc_DevMgmt.h> 515d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#include <phHciNfc_PollingLoop.h> 525d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#include <phHciNfc_RFReader.h> 535d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#include <phHciNfc_RFReaderA.h> 545d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#include <phHciNfc_Emulation.h> 555d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#ifdef ENABLE_P2P 565d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#include <phHciNfc_NfcIPMgmt.h> 575d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif 585d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#include <phHciNfc_SWP.h> 595d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#include <phHciNfc_WI.h> 605d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#include <phOsalNfc.h> 615d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 625d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/* 635d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly################################################################################ 645d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly****************************** Macro Definitions ******************************* 655d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly################################################################################ 665d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly*/ 675d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 686dd948323de0f31b413c9f19a905f1c145c9c456Rob von Behren/* Address Definitions for HAL Configuration */ 696dd948323de0f31b413c9f19a905f1c145c9c456Rob von Behren#define NFC_ADDRESS_HAL_CONF 0x9FD0U 706dd948323de0f31b413c9f19a905f1c145c9c456Rob von Behren 716dd948323de0f31b413c9f19a905f1c145c9c456Rob von Behren 725d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/* 735d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly################################################################################ 745d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly********************** Structure/Enumeration Definitions *********************** 755d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly################################################################################ 765d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly*/ 775d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 785d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 795d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#ifdef VALIDATE_FSM 805d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 815d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pellytypedef struct phHciNfc_sFsm 825d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly{ 835d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_eState_t from_state; 845d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_eState_t to_state; 855d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uint8_t valid; 865d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly}phHciNfc_sFsm_t; 875d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 885d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pellystatic phHciNfc_sFsm_t phHciNfc_Valid_Fsm[] = { 895d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly {hciState_Reset, hciState_Initialise , TRUE}, 905d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* {hciState_Reset, hciState_Config, FALSE}, */ 915d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly {hciState_Initialise, hciState_Config, TRUE}, 925d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly {hciState_Initialise, hciState_Release, TRUE}, 935d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly {hciState_Config, hciState_Connect, TRUE}, 945d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly {hciState_Config, hciState_Release, TRUE}, 955d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly {hciState_Connect, hciState_Activate, TRUE}, 965d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly {hciState_Connect, hciState_Transact, TRUE}, 975d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly {hciState_Connect, hciState_Disconnect, TRUE}, 985d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly {hciState_Disconnect, hciState_Config, TRUE}, 995d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* {hciState_Disconnect, hciState_Release, TRUE}, */ 1005d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly {hciState_Reset, hciState_Initialise, TRUE}, 1015d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly}; 1025d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 1035d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif 1045d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 1055d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 1065d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/* 1075d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly################################################################################ 1085d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly************************* Function Prototype Declaration *********************** 1095d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly################################################################################ 1105d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly*/ 1115d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 1125d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 1135d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pellystatic 1145d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyNFCSTATUS 1155d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyphHciNfc_Config_Sequence( 1165d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_sContext_t *psHciContext, 1175d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly void *pHwRef 1185d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ); 1195d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 1205d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 1215d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/** 1225d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * \ingroup grp_hci_nfc 1235d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * 1245d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * The phHciNfc_Connect_Sequence function sequence selects the 1255d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * discovered target for performing the transaction. 1265d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * 1275d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * \param[in] psHciContext psHciContext is the context of 1285d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * the HCI Layer. 1295d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * \param[in] pHwRef pHwRef is the Information of 1305d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * the Device Interface Link . 1315d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * 1325d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * \retval NFCSTATUS_SUCCESS HCI target selection sequence successful. 1335d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters 1345d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * could not be interpreted properly. 1355d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * \retval Other errors Other related errors 1365d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * 1375d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly */ 1385d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 1395d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pellystatic 1405d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyNFCSTATUS 1415d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyphHciNfc_Transact_Sequence( 1425d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_sContext_t *psHciContext, 1435d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly void *pHwRef 1445d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ); 1455d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 1465d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/** 1475d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * \ingroup grp_hci_nfc 1485d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * 1495d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * The phHciNfc_Info_Sequence function sequence selects the 1505d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * discovered target for performing the transaction. 1515d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * 1525d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * \param[in] psHciContext psHciContext is the context of 1535d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * the HCI Layer. 1545d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * \param[in] pHwRef pHwRef is the Information of 1555d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * the Device Interface Link . 1565d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * 1575d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * \retval NFCSTATUS_SUCCESS HCI target selection sequence successful. 1585d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters 1595d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * could not be interpreted properly. 1605d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * \retval Other errors Other related errors 1615d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * 1625d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly */ 1635d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 1645d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pellystatic 1655d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyNFCSTATUS 1665d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyphHciNfc_Info_Sequence( 1675d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_sContext_t *psHciContext, 1685d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly void *pHwRef 1695d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ); 1705d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 1715d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pellystatic 1725d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyNFCSTATUS 1735d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyphHciNfc_Test_Sequence( 1745d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_sContext_t *psHciContext, 1755d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly void *pHwRef, 1765d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS test_status, 1775d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uint8_t *pdata, 1785d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uint8_t length 1795d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ); 1805d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 1815d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#ifdef HCI_FSM_RESET 1825d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 1835d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pellystatic 1845d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pellyvoid 1855d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyphHciNfc_FSM_Reset( 1865d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_sContext_t *psHciContext 1875d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ); 1885d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 1895d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif 1905d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 1915d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pellystatic 1925d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyNFCSTATUS 1935d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyphHciNfc_IO_Sequence( 1945d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_sContext_t *psHciContext, 1955d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly void *pHwRef, 1965d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS test_status, 1975d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uint8_t *pdata, 1985d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uint8_t length 1995d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ); 2005d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 2015d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pellystatic 2025d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyNFCSTATUS 2035d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyphHciNfc_Pending_Sequence( 2045d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_sContext_t *psHciContext, 2055d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly void *pHwRef 2065d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ); 2075d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 2085d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 2095d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/* 2105d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly################################################################################ 2115d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly***************************** Function Definitions ***************************** 2125d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly################################################################################ 2135d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly*/ 2145d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 2155d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyNFCSTATUS 2165d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyphHciNfc_FSM_Validate( 2175d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_sContext_t *psHciContext, 2185d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_eState_t state, 2195d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uint8_t validate_type 2205d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ) 2215d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly{ 2225d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_INVALID_STATE); 2235d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_eState_t cur_state = (phHciNfc_eState_t) 2245d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->hci_state.cur_state; 2255d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 2265d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly switch(validate_type) 2275d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 2285d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case NFC_FSM_CURRENT: 2295d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 2305d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if( cur_state == (uint8_t) state ) 2315d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 2325d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = NFCSTATUS_SUCCESS; 2335d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 2345d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 2355d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 2365d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case NFC_FSM_NEXT: 2375d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 2385d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_eState_t next_state = state; 2395d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly switch (cur_state) 2405d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 2415d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case hciState_Reset: 2425d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 2435d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly switch(next_state) 2445d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 2455d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Specifies the Starting of the init Sequence */ 2465d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case hciState_Initialise: 2475d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Initialise to Perform Test on 2485d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly the Antenna/SWP Link */ 2495d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case hciState_Test: 2506dd948323de0f31b413c9f19a905f1c145c9c456Rob von Behren { 2515d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = NFCSTATUS_SUCCESS; 2525d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 2536dd948323de0f31b413c9f19a905f1c145c9c456Rob von Behren } 2545d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly default: 2555d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 2565d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 2575d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 2585d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 2595d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case hciState_Initialise: 2605d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 2615d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly switch(next_state) 2625d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 2635d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Discovery Resume after connect failure */ 2645d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case hciState_Initialise: 2655d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Configuring the Discovery/Emulation */ 2665d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case hciState_Config: 2675d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Configuring the Memory */ 2685d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case hciState_IO: 2695d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Occurence of the Tag Discovered Event */ 2705d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case hciState_Select: 2715d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Occurence of the Target Activated Event */ 2725d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case hciState_Listen: 2735d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Specifies the Starting of the Release Sequence */ 2745d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case hciState_Release: 2756dd948323de0f31b413c9f19a905f1c145c9c456Rob von Behren { 2765d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = NFCSTATUS_SUCCESS; 2775d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 2786dd948323de0f31b413c9f19a905f1c145c9c456Rob von Behren } 2795d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly default: 2805d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 2815d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 2825d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 2835d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 2845d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case hciState_Test: 2855d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 2865d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if ((hciState_Test == next_state ) 2875d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly || (hciState_IO == next_state) 2885d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly || (hciState_Release == next_state)) 2895d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 2905d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Next Test/Reset Sequence */ 2915d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = NFCSTATUS_SUCCESS; 2925d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 2935d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 2945d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 2955d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case hciState_Select: 2965d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 2975d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly switch(next_state) 2985d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 2995d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Restart the Wheel */ 3005d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case hciState_Initialise: 3015d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Select the next Tag in the Field or 3025d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * already Selected Tag Again 3035d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly */ 3045d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Configuring the Memory */ 3055d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case hciState_IO: 3065d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case hciState_Select: 3075d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Configuring the Discovery/Emulation */ 3085d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case hciState_Config: 3095d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Re-Activate the Target or 3105d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * Discover the next target 3115d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly */ 3125d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case hciState_Reactivate: 3135d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Connect the Discovered Target */ 3145d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case hciState_Connect: 3155d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Specifies the Starting of the Release Sequence */ 3165d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case hciState_Release: 3176dd948323de0f31b413c9f19a905f1c145c9c456Rob von Behren { 3185d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = NFCSTATUS_SUCCESS; 3195d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 3206dd948323de0f31b413c9f19a905f1c145c9c456Rob von Behren } 3215d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly default: 3225d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 3235d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 3245d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 3255d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 3265d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case hciState_Connect: 3275d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 3285d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly switch(next_state) 3295d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 3305d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Disabling the Tag Discovery */ 3315d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case hciState_Initialise: 3325d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Configuring the Discovery/Emulation */ 3335d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* This should not be allowed if the target 3345d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * is connected. 3355d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly */ 3365d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Configuring the Memory */ 3375d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case hciState_IO: 3385d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case hciState_Config: 3395d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Re-Activate the Target or 3405d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * Discover the next target 3415d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly */ 3425d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case hciState_Reactivate: 3435d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Intermediate Transceive State */ 3445d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case hciState_Transact: 3455d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Intermediate Presence Check State */ 3465d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case hciState_Presence: 3475d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Disconnect the Target Connected */ 3485d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case hciState_Disconnect: 3495d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Specifies the Starting of the Release Sequence */ 3505d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case hciState_Release: 3516dd948323de0f31b413c9f19a905f1c145c9c456Rob von Behren { 3525d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = NFCSTATUS_SUCCESS; 3535d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 3546dd948323de0f31b413c9f19a905f1c145c9c456Rob von Behren } 3555d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly default: 3565d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 3575d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 3585d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 3595d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 3605d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case hciState_Listen: 3615d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 3625d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly switch(next_state) 3635d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 3645d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Releasing from the Emulation/Target Mode */ 3655d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case hciState_Initialise: 3665d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Occurence of the Tag Discovered Event 3675d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * after the Disconnect Operation 3685d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly */ 3695d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case hciState_Select: 3705d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Configuring the Memory */ 3715d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case hciState_IO: 3725d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Configuring the Discovery/Emulation */ 3735d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case hciState_Config: 3745d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Intermediate Transceive State */ 3755d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case hciState_Transact: 3765d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Specifies the Starting of the Release Sequence */ 3775d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case hciState_Release: 3786dd948323de0f31b413c9f19a905f1c145c9c456Rob von Behren { 3795d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = NFCSTATUS_SUCCESS; 3805d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 3816dd948323de0f31b413c9f19a905f1c145c9c456Rob von Behren } 3825d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly default: 3835d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 3845d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 3855d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 3865d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 3875d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case hciState_Reactivate: 3885d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 3895d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly switch(next_state) 3905d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 3915d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Restart/Discovery after the Target is removed 3925d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * after Reactivation. 3935d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly */ 3945d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* case hciState_Initialise: */ 3955d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Re-Connect the Re-Activated Target */ 3965d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case hciState_Connect: 3975d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Configuring the Memory */ 3985d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case hciState_IO: 3995d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Configuring the Discovery/Emulation */ 4005d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case hciState_Config: 4015d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Specifies the Starting of the Release Sequence */ 4025d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case hciState_Release: 4036dd948323de0f31b413c9f19a905f1c145c9c456Rob von Behren { 4045d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = NFCSTATUS_SUCCESS; 4055d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 4066dd948323de0f31b413c9f19a905f1c145c9c456Rob von Behren } 4075d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly default: 4085d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 4095d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 4105d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 4115d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 4125d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case hciState_Disconnect: 4135d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 4145d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly switch(next_state) 4155d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 4165d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Discovery Resume after connect failure 4175d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly after the disconnect */ 4185d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case hciState_Initialise: 4195d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Configuring the Memory */ 4205d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case hciState_IO: 4215d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Configuring the Discovery/Emulation */ 4225d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case hciState_Config: 4235d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Occurence of the Tag Discovered Event 4245d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * after the Disconnect Operation 4255d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly */ 4265d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case hciState_Select: 4275d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Occurence of the Target Activated Event */ 4285d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case hciState_Listen: 4295d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Specifies the Starting of the Release Sequence */ 4305d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case hciState_Release: 4316dd948323de0f31b413c9f19a905f1c145c9c456Rob von Behren { 4325d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = NFCSTATUS_SUCCESS; 4335d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 4346dd948323de0f31b413c9f19a905f1c145c9c456Rob von Behren } 4355d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly default: 4366dd948323de0f31b413c9f19a905f1c145c9c456Rob von Behren { 4375d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 4385d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 4396dd948323de0f31b413c9f19a905f1c145c9c456Rob von Behren } 4405d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 4415d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 4425d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#ifdef USE_M5 4435d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case hciState_Presence: 4445d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case hciState_Transact: 4455d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case hciState_Release: 4465d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 4475d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 4485d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 4495d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif 4505d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* case phHciNfc_Unknown: */ 4515d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly default: 4525d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 4535d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_INVALID_STATE); */ 4545d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 4555d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 4565d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } /* End of State Validation Switch */ 4575d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if( NFC_FSM_IN_PROGRESS == psHciContext->hci_state.transition ) 4585d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 45942f5b41d22bbbad1b16b9cd3aba0512a399f32a6Martijn Coenen status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_BUSY); 4605d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 4615d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 4625d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 4635d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly default: 4645d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 4655d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly HCI_DEBUG("State Validate Type:%x is Unknown/Incorrect \n", 4665d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly validate_type); 4675d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 4685d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 4695d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 4705d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly return status; 4715d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly} 4725d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 4735d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyNFCSTATUS 4745d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyphHciNfc_FSM_Update( 4755d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_sContext_t *psHciContext, 4765d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_eState_t next_state 4775d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ) 4785d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly{ 4795d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_INVALID_STATE); 4805d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 4815d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly HCI_DEBUG(" HCI: Current State --> %02u \n", 4825d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->hci_state.cur_state ); 4835d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly HCI_DEBUG(" HCI: Transition Before FSM Update --> %02u \n", 4845d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->hci_state.transition ); 4855d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly HCI_DEBUG(" HCI: Next State Before FSM Update --> %02u \n", 4865d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->hci_state.next_state ); 4875d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 4885d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = phHciNfc_FSM_Validate(psHciContext, next_state, NFC_FSM_NEXT ); 4895d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NFCSTATUS_SUCCESS == status) 4905d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 4915d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->hci_state.next_state = (uint8_t) next_state; 4925d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->hci_state.transition = NFC_FSM_IN_PROGRESS; 4935d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->response_pending = FALSE; 4945d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly HCI_DEBUG(" HCI: Next State After FSM Update --> %02u \n", 4955d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->hci_state.next_state ); 4965d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 4975d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 4985d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 4995d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly HCI_DEBUG(" HCI: FSM - Invalid next state --> %02u \n", 5005d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly next_state ); 5015d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 5025d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 5035d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly return status; 5045d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly} 5055d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 5065d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 5075d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyNFCSTATUS 5085d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyphHciNfc_FSM_Complete( 5095d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_sContext_t *psHciContext 5105d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ) 5115d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly{ 5125d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_INVALID_STATE); 5135d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 5145d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly HCI_DEBUG("HCI: In Function: %s \n", __FUNCTION__); 5155d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 5165d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly HCI_DEBUG(" HCI: Transition Before FSM Complete --> %02u \n", 5175d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->hci_state.transition ); 5185d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 5195d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly HCI_DEBUG(" HCI: Current State Before FSM Complete --> %02u \n", 5205d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->hci_state.cur_state ); 5215d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 5225d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly HCI_DEBUG(" HCI: Next State Before FSM Complete --> %02u \n", 5235d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->hci_state.next_state ); 5245d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 5255d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if( (NFC_FSM_IN_PROGRESS == psHciContext->hci_state.transition) 5265d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ) 5275d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 5285d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->hci_state.cur_state = 5295d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->hci_state.next_state ; 5305d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->hci_state.transition = NFC_FSM_COMPLETE ; 5315d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->hci_state.next_state = (uint8_t) hciState_Unknown ; 5325d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Reset the HCI Sequence */ 5335d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->response_pending = FALSE; 5345d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->hci_seq = HCI_INVALID_SEQ; 5355d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = NFCSTATUS_SUCCESS; 5365d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 5375d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 5385d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly HCI_DEBUG(" HCI: Current State After FSM Complete --> %02u \n", 5395d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->hci_state.cur_state ); 5405d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 5415d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly return status; 5425d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly} 5435d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 5445d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pellyvoid 5455d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyphHciNfc_FSM_Rollback( 5465d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_sContext_t *psHciContext 5475d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ) 5485d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly{ 5495d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 55034ff48f6cd6595a899e05fbd56f4c84891840d3fNick Pelly HCI_DEBUG("HCI: %s: transition=%02u, cur_state=%02u, next_state=%02u\n", 55134ff48f6cd6595a899e05fbd56f4c84891840d3fNick Pelly __func__, 55234ff48f6cd6595a899e05fbd56f4c84891840d3fNick Pelly psHciContext->hci_state.transition, 55334ff48f6cd6595a899e05fbd56f4c84891840d3fNick Pelly psHciContext->hci_state.cur_state, 55434ff48f6cd6595a899e05fbd56f4c84891840d3fNick Pelly psHciContext->hci_state.next_state); 55534ff48f6cd6595a899e05fbd56f4c84891840d3fNick Pelly 55634ff48f6cd6595a899e05fbd56f4c84891840d3fNick Pelly 55734ff48f6cd6595a899e05fbd56f4c84891840d3fNick Pelly 5585d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 5595d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 5605d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 5615d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if( (NFC_FSM_IN_PROGRESS == psHciContext->hci_state.transition) 5625d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ) 5635d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 5645d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->hci_state.transition = NFC_FSM_COMPLETE ; 5655d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->hci_state.next_state = (uint8_t) hciState_Unknown ; 5665d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Reset the HCI Sequence */ 5675d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->hci_seq = HCI_INVALID_SEQ; 5685d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->response_pending = FALSE; 5695d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 5705d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly} 5715d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 5725d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#ifdef HCI_FSM_RESET 5735d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pellystatic 5745d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pellyvoid 5755d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyphHciNfc_FSM_Reset( 5765d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_sContext_t *psHciContext 5775d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ) 5785d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly{ 5795d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 5805d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if( (hciState_Reset != psHciContext->hci_state.cur_state ) 5815d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ) 5825d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 5835d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->hci_state.cur_state = (uint8_t) hciState_Initialise ; 5845d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->hci_state.transition = NFC_FSM_COMPLETE ; 5855d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->hci_state.next_state = (uint8_t) hciState_Unknown ; 5865d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Reset the HCI Sequence */ 5875d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->hci_seq = HCI_INVALID_SEQ; 5885d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 5895d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 5905d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly} 5915d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif 5925d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 5935d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 5945d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 5955d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pellystatic 5965d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyNFCSTATUS 5975d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyphHciNfc_Pending_Sequence( 5985d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_sContext_t *psHciContext, 5995d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly void *pHwRef 6005d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ) 6015d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly{ 6025d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS status = NFCSTATUS_SUCCESS; 6035d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 6045d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly PHNFC_UNUSED_VARIABLE(status); 6055d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 6065d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly HCI_DEBUG("HCI: psHciContext->target_release --> %s \n", 6075d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (psHciContext->target_release)?"TRUE":"FALSE"); 6085d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(TRUE == psHciContext->target_release) 6095d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 6105d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#ifdef SW_RELEASE_TARGET 6115d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = phHciNfc_ReaderMgmt_Deselect( 6125d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext, pHwRef, phHal_eISO14443_A_PICC, TRUE); 6135d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NFCSTATUS_PENDING == status ) 6145d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 6155d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->target_release = FALSE ; 6165d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 6175d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 6185d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 6195d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 6205d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = psHciContext->error_status; 6215d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#else 6225d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->target_release = FALSE ; 6235d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif 6245d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 6255d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 6265d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly return status; 6275d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly} 6285d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 6295d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 6305d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pellyvoid 6315d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyphHciNfc_Error_Sequence( 6325d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly void *psContext, 6335d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly void *pHwRef, 6345d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS error_status, 6355d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly void *pdata, 6365d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uint8_t length 6375d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ) 6385d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly{ 6395d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS status = NFCSTATUS_SUCCESS; 6405d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_sContext_t *psHciContext = (phHciNfc_sContext_t *)psContext; 6415d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 6425d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly PHNFC_UNUSED_VARIABLE(status); 6435d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 6445d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly HCI_DEBUG("HCI: In Function: %s \n", 6455d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly __FUNCTION__); 6465d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 6475d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly HCI_DEBUG ("HCI : Error Status : %04X\n", error_status); 6485d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 6495d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly HCI_DEBUG(" HCI: Current HCI State --> %02u \n", 6505d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->hci_state.cur_state ); 6515d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly HCI_DEBUG(" HCI: Next HCI State --> %02u \n", 6525d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->hci_state.next_state ); 6535d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 6545d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 6555d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if ( NFC_FSM_IN_PROGRESS == psHciContext->hci_state.transition ) 6565d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 6575d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly switch(psHciContext->hci_state.next_state) 6585d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 6595d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case hciState_Initialise: 6605d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 6615d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if (hciState_Reset == psHciContext->hci_state.cur_state) 6625d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 6636dd948323de0f31b413c9f19a905f1c145c9c456Rob von Behren phNfc_sCompletionInfo_t comp_info={FALSE,0, NULL}; 6645d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 6655d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_Release_Lower( psHciContext, pHwRef ); 6665d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Release all the resources and 6675d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * Notify the Receive Error Scenario to the Upper Layer 6685d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly */ 6695d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly comp_info.status = error_status ; 6705d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_Release_Notify (psHciContext, pHwRef, 6715d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFC_NOTIFY_INIT_FAILED, &comp_info); 6725d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 6735d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else if (hciState_Config == psHciContext->hci_state.cur_state) 6745d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 6755d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Notify the Poll/Emulation Configure failure to the upper layer */ 6765d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 6776dd948323de0f31b413c9f19a905f1c145c9c456Rob von Behren phNfc_sCompletionInfo_t comp_info={FALSE,0, NULL}; 6785d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 6795d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly comp_info.status = error_status ; 6805d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 6815d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->error_status = error_status; 6825d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = phHciNfc_Pending_Sequence(psHciContext, pHwRef ); 6835d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Rollback the FSM as the Poll/Emulation configuration Failed */ 6845d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_FSM_Rollback(psHciContext); 6855d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->error_status = NFCSTATUS_SUCCESS; 6865d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_Notify(psHciContext->p_upper_notify, 6875d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->p_upper_context, pHwRef, 6885d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFC_NOTIFY_CONFIG_ERROR, &comp_info); 6895d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 6905d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 6915d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 6925d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 6935d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Notify the Poll Configure failure to the upper layer */ 6946dd948323de0f31b413c9f19a905f1c145c9c456Rob von Behren phNfc_sCompletionInfo_t comp_info={FALSE,0, NULL}; 6956dd948323de0f31b413c9f19a905f1c145c9c456Rob von Behren 6965d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 6975d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->error_status = error_status; 6985d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = phHciNfc_Pending_Sequence(psHciContext, pHwRef ); 6995d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Rollback the FSM as the Poll Disable Failed */ 7005d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_FSM_Rollback(psHciContext); 7015d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly comp_info.status = error_status ; 7025d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->error_status = NFCSTATUS_SUCCESS; 7035d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_Notify(psHciContext->p_upper_notify, 7045d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->p_upper_context, pHwRef, 7055d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFC_NOTIFY_ERROR, &comp_info); 7065d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 7075d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 7085d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 7095d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case hciState_Test: 7105d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 7115d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = phHciNfc_Test_Sequence( psHciContext, pHwRef , error_status, 7125d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (uint8_t *)pdata, length ); 7135d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 7145d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 7155d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case hciState_IO: 7165d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 7175d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = phHciNfc_IO_Sequence( psHciContext, pHwRef , error_status, 7185d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (uint8_t *)pdata, length ); 7195d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 7205d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 7215d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case hciState_Config: 7225d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 7235d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Notify the Configure failure to the upper layer */ 7246dd948323de0f31b413c9f19a905f1c145c9c456Rob von Behren phNfc_sCompletionInfo_t comp_info={FALSE,0, NULL}; 7255d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 7265d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->error_status = error_status; 7275d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = phHciNfc_Pending_Sequence(psHciContext, pHwRef ); 7285d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Rollback the FSM as the Poll Failed */ 7295d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_FSM_Rollback(psHciContext); 7305d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly comp_info.status = psHciContext->error_status ; 7315d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->error_status = NFCSTATUS_SUCCESS; 7325d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_Notify(psHciContext->p_upper_notify, 7335d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->p_upper_context, pHwRef, 7345d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFC_NOTIFY_CONFIG_ERROR, &comp_info); 7355d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 7365d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 7375d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case hciState_Select: 7385d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 7395d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Notify the Configure failure to the upper layer */ 7406dd948323de0f31b413c9f19a905f1c145c9c456Rob von Behren phNfc_sCompletionInfo_t comp_info={FALSE,0, NULL}; 7415d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 7425d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Rollback the FSM as the Target Discovery Failed */ 7435d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_FSM_Rollback(psHciContext); 7445d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = phHciNfc_ReaderMgmt_Update_Sequence( 7455d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext, INFO_SEQ ); 7465d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly comp_info.status = error_status ; 7475d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_Notify(psHciContext->p_upper_notify, 7485d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->p_upper_context, pHwRef, 7495d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFC_NOTIFY_DISCOVERY_ERROR, &comp_info); 7505d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 7515d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#if 0 7525d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Polling Wheel will be restarted by the upper layer 7535d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * to Rediscover again */ 7545d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NFCSTATUS_SUCCESS == status) 7555d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 7565d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = phHciNfc_ReaderMgmt_Deselect( 7575d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext, pHwRef, phHal_eISO14443_A_PICC, FALSE); 7585d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 7595d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_FSM_Rollback(psHciContext); 7605d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif 7615d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 7625d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 7635d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case hciState_Transact: 7645d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Notify the Transceive failure to the upper layer */ 7655d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 7666dd948323de0f31b413c9f19a905f1c145c9c456Rob von Behren phNfc_sTransactionInfo_t transact_info={FALSE,0,NULL,NULL,0}; 7675d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 7685d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Rollback the FSM as the Transceive Failed */ 7695d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_FSM_Rollback(psHciContext); 7705d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly transact_info.status = error_status; 7715d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly transact_info.buffer = NULL; 7725d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly transact_info.length = FALSE; 7735d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->p_xchg_info = NULL ; 7745d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_Notify(psHciContext->p_upper_notify, 7755d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->p_upper_context, pHwRef, 7765d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFC_NOTIFY_TRANSCEIVE_ERROR, &transact_info); 7775d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 7785d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 7795d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 7805d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case hciState_Connect: 7815d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 7825d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Notify the General failure to the upper layer */ 7836dd948323de0f31b413c9f19a905f1c145c9c456Rob von Behren phNfc_sCompletionInfo_t comp_info={FALSE,0, NULL}; 7845d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 7855d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* psHciContext->host_rf_type = phHal_eUnknown_DevType; */ 7865d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = phHciNfc_ReaderMgmt_Update_Sequence( 7875d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext, INFO_SEQ ); 7885d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->p_target_info = NULL; 7895d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->hci_state.cur_state = hciState_Select; 7905d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_FSM_Rollback(psHciContext); 7915d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly comp_info.status = error_status ; 7925d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_Notify(psHciContext->p_upper_notify, 7935d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->p_upper_context, pHwRef, 7945d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFC_NOTIFY_CONNECT_FAILED, &comp_info); 7955d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 7965d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 7975d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case hciState_Reactivate: 7985d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 7995d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Notify the General failure to the upper layer */ 8006dd948323de0f31b413c9f19a905f1c145c9c456Rob von Behren phNfc_sCompletionInfo_t comp_info={FALSE,0, NULL}; 8015d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 8025d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* psHciContext->host_rf_type = phHal_eUnknown_DevType; 8035d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = phHciNfc_ReaderMgmt_Update_Sequence( 8045d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext, INFO_SEQ ); 8055d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->p_target_info = NULL; 8065d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->hci_state.cur_state = hciState_Select; */ 8075d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_FSM_Rollback(psHciContext); 8085d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly comp_info.status = error_status ; 8095d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_Notify(psHciContext->p_upper_notify, 8105d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->p_upper_context, pHwRef, 8115d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFC_NOTIFY_CONNECT_FAILED, &comp_info); 8125d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 8135d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 8145d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case hciState_Presence: 8155d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 8166dd948323de0f31b413c9f19a905f1c145c9c456Rob von Behren phNfc_sCompletionInfo_t comp_info={FALSE,0, NULL}; 8175d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 8185d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Roll Back to Connect State as Presence Check is Complete */ 8195d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_FSM_Rollback(psHciContext); 8205d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 8215d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Initialisation Complete Notification to the Upper Layer */ 8225d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly comp_info.status = error_status; 8235d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_Notify(psHciContext->p_upper_notify, 8245d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->p_upper_context, pHwRef, 8255d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFC_NOTIFY_ERROR, &comp_info); 8265d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly HCI_PRINT(" HCI Remote Target Removed from the Field. \n"); 8275d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 8285d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 8295d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Notify the Connect or Disconnect failure to the upper layer */ 8305d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case hciState_Disconnect: 8315d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 8325d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Notify the General failure to the upper layer */ 8336dd948323de0f31b413c9f19a905f1c145c9c456Rob von Behren phNfc_sCompletionInfo_t comp_info={FALSE,0, NULL}; 8345d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 8355d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_FSM_Rollback(psHciContext); 8365d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly comp_info.status = error_status ; 8375d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_Notify(psHciContext->p_upper_notify, 8385d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->p_upper_context, pHwRef, 8395d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFC_NOTIFY_DISCONNECT_FAILED, &comp_info); 8405d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 8415d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 8425d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case hciState_Release: 8435d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 8445d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#ifdef NXP_HCI_SHUTDOWN_OVERRIDE 8455d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = phHciNfc_Release_Sequence(psHciContext ,pHwRef); 8465d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#else 8476dd948323de0f31b413c9f19a905f1c145c9c456Rob von Behren phNfc_sCompletionInfo_t comp_info={FALSE,0, NULL}; 8485d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 8495d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_Release_Lower( psHciContext, pHwRef ); 8505d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Release all the resources and 8515d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * Notify the Receive Error Scenario to the Upper Layer 8525d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly */ 8535d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly comp_info.status = error_status ; 8545d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_Release_Notify (psHciContext, pHwRef, 8555d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFC_NOTIFY_DEINIT_FAILED, &comp_info); 8565d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif 8575d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 8585d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 8595d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly default: 8605d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 8615d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Notify the General failure to the upper layer */ 8626dd948323de0f31b413c9f19a905f1c145c9c456Rob von Behren phNfc_sCompletionInfo_t comp_info={FALSE,0, NULL}; 8635d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 8645d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_FSM_Rollback(psHciContext); 8655d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly comp_info.status = error_status ; 8665d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->error_status = error_status; 8675d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = phHciNfc_Pending_Sequence(psHciContext, pHwRef ); 8685d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if (NFCSTATUS_PENDING != status) 8695d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 8705d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->error_status = NFCSTATUS_SUCCESS; 8715d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_Notify(psHciContext->p_upper_notify, 8725d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->p_upper_context, pHwRef, 8735d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFC_NOTIFY_ERROR, &comp_info); 8745d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 8755d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 8765d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 8775d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 8785d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } /* End of the Processing of HCI State*/ 8795d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 8805d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 8815d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 8825d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Notify the General failure to the upper layer */ 8836dd948323de0f31b413c9f19a905f1c145c9c456Rob von Behren phNfc_sCompletionInfo_t comp_info={FALSE,0, NULL}; 8845d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_FSM_Rollback(psHciContext); 8855d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly comp_info.status = error_status ; 8865d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Disable the Notification to the Upper Layer */ 8875d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NFCSTATUS_BOARD_COMMUNICATION_ERROR 8885d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly == PHNFCSTATUS(error_status)) 8895d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 8905d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_Notify(psHciContext->p_upper_notify, 8915d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->p_upper_context, pHwRef, 8925d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFC_NOTIFY_ERROR, &comp_info); 8935d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 8945d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 8955d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 8965d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->error_status = error_status; 8975d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = phHciNfc_Pending_Sequence(psHciContext, pHwRef ); 8985d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if (NFCSTATUS_PENDING != status) 8995d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 9005d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->error_status = NFCSTATUS_SUCCESS; 9015d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 9025d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 9035d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 9045d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly return; 9055d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly} 9065d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 9075d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 9085d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 9095d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyNFCSTATUS 9105d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyphHciNfc_Resume_Sequence( 9115d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_sContext_t *psHciContext, 9125d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly void *pHwRef 9135d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ) 9145d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly{ 9155d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS status = NFCSTATUS_SUCCESS; 9165d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 91734ff48f6cd6595a899e05fbd56f4c84891840d3fNick Pelly HCI_DEBUG("HCI: %s: cur_state=%02u, next_state=%02u", 91834ff48f6cd6595a899e05fbd56f4c84891840d3fNick Pelly __FUNCTION__, 91934ff48f6cd6595a899e05fbd56f4c84891840d3fNick Pelly psHciContext->hci_state.cur_state, 92034ff48f6cd6595a899e05fbd56f4c84891840d3fNick Pelly psHciContext->hci_state.next_state); 92134ff48f6cd6595a899e05fbd56f4c84891840d3fNick Pelly 92234ff48f6cd6595a899e05fbd56f4c84891840d3fNick Pelly 92334ff48f6cd6595a899e05fbd56f4c84891840d3fNick Pelly 9245d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 9255d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly switch(psHciContext->hci_state.next_state) 9265d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 9275d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Process the Admin Gate Response based on the HCI State */ 9285d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case hciState_Initialise: 9295d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 9305d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly switch (psHciContext->hci_state.cur_state) 9315d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 9325d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Initialise State after Power on */ 9335d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case hciState_Reset: 9345d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 9355d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = phHciNfc_Initialise_Sequence(psHciContext ,pHwRef); 9365d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 9375d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 9385d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Initialise State after Power on */ 9395d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case hciState_Config: 9405d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 9415d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = phHciNfc_Config_Sequence(psHciContext ,pHwRef); 9425d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 9435d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 9445d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Discovery Resume after connect failure */ 9455d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case hciState_Initialise: 9465d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case hciState_Select: 9475d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case hciState_Connect: 9485d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 9496dd948323de0f31b413c9f19a905f1c145c9c456Rob von Behren phNfc_sCompletionInfo_t comp_info={FALSE,0, NULL}; 9505d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 9515d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Update to the Intialise state as the discovery wheel is 9525d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * restarted. 9535d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly */ 9545d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = phHciNfc_FSM_Complete(psHciContext); 9555d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 9565d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->host_rf_type = phHal_eUnknown_DevType; 9575d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->p_target_info = NULL; 9585d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->p_xchg_info = NULL; 9595d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 9605d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Initialisation Complete Notification to the Upper Layer */ 9615d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly comp_info.status = status; 9625d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_Notify(psHciContext->p_upper_notify, 9635d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->p_upper_context, pHwRef, 9645d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFC_NOTIFY_POLL_RESTARTED , &comp_info); 9655d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly HCI_PRINT(" HCI Remote Target Still Present in the Field. \n"); 9665d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 9675d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 9685d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly default: 9695d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 9705d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_INVALID_STATE); 9715d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 9725d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 9735d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 9745d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 9755d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 9765d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case hciState_Release: 9775d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 9785d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = phHciNfc_Release_Sequence(psHciContext ,pHwRef); 9795d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 9805d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 9815d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case hciState_Config: 9825d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 9835d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = phHciNfc_Config_Sequence(psHciContext ,pHwRef); 9845d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 9855d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 9865d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case hciState_Listen: 9875d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case hciState_Select: 9885d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 9895d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = phHciNfc_Info_Sequence( psHciContext, pHwRef ); 9905d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 9915d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 9925d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case hciState_Reactivate: 9935d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case hciState_Connect: 9945d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 9955d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = phHciNfc_Connect_Sequence( psHciContext, pHwRef ); 9965d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 9975d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 9985d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case hciState_Transact: 9995d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 10005d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = phHciNfc_Transact_Sequence( 10015d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext, pHwRef ); 10025d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 10035d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 10045d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case hciState_Presence: 10055d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 10066dd948323de0f31b413c9f19a905f1c145c9c456Rob von Behren phNfc_sCompletionInfo_t comp_info={FALSE,0, NULL}; 10075d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 10085d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Roll Back to Connect State as Presence Check is Complete */ 10095d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_FSM_Rollback(psHciContext); 10105d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 10115d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Initialisation Complete Notification to the Upper Layer */ 10125d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly comp_info.status = NFCSTATUS_SUCCESS; 10135d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_Notify(psHciContext->p_upper_notify, 10145d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->p_upper_context, pHwRef, 10155d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFC_NOTIFY_TARGET_PRESENT , &comp_info); 10165d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly HCI_PRINT(" HCI Remote Target Still Present in the Field. \n"); 10175d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 10185d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 10195d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case hciState_Disconnect: 10205d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 10215d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = phHciNfc_Disconnect_Sequence( psHciContext, pHwRef ); 10225d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 10235d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 10245d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case hciState_Test: 10255d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 10265d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = phHciNfc_Test_Sequence( psHciContext, pHwRef , status, NULL, 0 ); 10275d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 10285d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 10295d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case hciState_IO: 10305d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 10315d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = phHciNfc_IO_Sequence( psHciContext, pHwRef , status, NULL, 0 ); 10325d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 10335d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 10345d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case hciState_Unknown: 10355d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 10365d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 10375d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 10385d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly default: 10395d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 10405d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_INVALID_STATE); 10415d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 10425d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 10435d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } /* End of the Processing of HCI State*/ 10445d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 10455d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly return status; 10465d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly} 10475d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 10485d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 10495d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyNFCSTATUS 10505d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyphHciNfc_Initialise_Sequence( 10515d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_sContext_t *psHciContext, 10525d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly void *pHwRef 10535d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ) 10545d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly{ 10555d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS status = NFCSTATUS_SUCCESS; 10565d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly static uint8_t config = 0; 10575d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 10585d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly PHNFC_UNUSED_VARIABLE(config); 10595d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 10605d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly switch(psHciContext->hci_seq) 10615d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 10625d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case ADMIN_INIT_SEQ: 10635d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 10645d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = phHciNfc_Admin_Initialise( psHciContext,pHwRef ); 10655d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NFCSTATUS_SUCCESS == status) 10665d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 10675d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#ifdef ESTABLISH_SESSION 10685d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if( hciMode_Session == psHciContext->hci_mode) 10695d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 10705d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* TODO: Initialise Link Management 10715d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly Gate Resources */ 10725d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS info_status = NFCSTATUS_SUCCESS; 10735d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly PHNFC_UNUSED_VARIABLE(info_status); 10745d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly info_status = phHciNfc_IDMgmt_Update_Sequence( 10755d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext, INFO_SEQ ); 10765d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 10775d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NFCSTATUS_SUCCESS == info_status) 10785d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 10795d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->hci_seq = PL_STOP_SEQ; 10805d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 10815d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 10825d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 10835d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->hci_seq = HCI_END_SEQ; 10845d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = PHNFCSTVAL(CID_NFC_HCI, 10855d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS_INVALID_HCI_SEQUENCE); 10865d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 10875d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 10885d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 10895d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif 10905d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 10915d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->hci_seq = LINK_MGMT_INIT_SEQ; 10925d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 10935d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 10945d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 10955d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 10965d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case LINK_MGMT_INIT_SEQ: 10975d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 10985d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = phHciNfc_LinkMgmt_Initialise( psHciContext,pHwRef ); 10995d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NFCSTATUS_SUCCESS == status) 11005d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 11015d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->hci_seq = IDENTITY_INIT_SEQ; 11025d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 11035d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 11045d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 11055d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case IDENTITY_INIT_SEQ: 11065d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 11075d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = phHciNfc_IDMgmt_Initialise( psHciContext,pHwRef ); 11085d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NFCSTATUS_SUCCESS == status) 11095d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 11105d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->hci_seq = DEV_INIT_SEQ; 11115d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 11125d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 11135d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 11145d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case DEV_INIT_SEQ: 11155d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 11165d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = phHciNfc_DevMgmt_Initialise( psHciContext,pHwRef ); 11175d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NFCSTATUS_SUCCESS == status) 11185d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 11195d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if (HCI_SELF_TEST != psHciContext->init_mode) 11205d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 11215d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->hci_seq = PL_INIT_SEQ; 11225d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 11235d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 11245d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 11256dd948323de0f31b413c9f19a905f1c145c9c456Rob von Behren#if defined( ESTABLISH_SESSION ) 11265d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS info_status = NFCSTATUS_SUCCESS; 11275d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly PHNFC_UNUSED_VARIABLE(info_status); 11285d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly info_status = phHciNfc_IDMgmt_Update_Sequence( 11295d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext, INFO_SEQ ); 11305d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 11315d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NFCSTATUS_SUCCESS == info_status) 11325d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 11336dd948323de0f31b413c9f19a905f1c145c9c456Rob von Behren#if ( NXP_HAL_MEM_INFO_SIZE > 0x00U ) 11346dd948323de0f31b413c9f19a905f1c145c9c456Rob von Behren psHciContext->hci_seq = DEV_HAL_INFO_SEQ; 11356dd948323de0f31b413c9f19a905f1c145c9c456Rob von Behren#else 11365d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->hci_seq = IDENTITY_INFO_SEQ; 11376dd948323de0f31b413c9f19a905f1c145c9c456Rob von Behren#endif /* #if ( NXP_HAL_MEM_INFO_SIZE > 0x00U ) */ 11385d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 11395d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 11405d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 11415d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->hci_seq = HCI_END_SEQ; 11425d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = PHNFCSTVAL(CID_NFC_HCI, 11435d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS_INVALID_HCI_SEQUENCE); 11445d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 11456dd948323de0f31b413c9f19a905f1c145c9c456Rob von Behren#elif ( NXP_HAL_MEM_INFO_SIZE > 0x00U ) 11466dd948323de0f31b413c9f19a905f1c145c9c456Rob von Behren psHciContext->hci_seq = DEV_HAL_INFO_SEQ; 11475d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#else 11485d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->hci_seq = HCI_END_SEQ; 11496dd948323de0f31b413c9f19a905f1c145c9c456Rob von Behren#endif /* #ifdef ESTABLISH_SESSION */ 11505d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 11515d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 11525d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 11535d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 11545d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 11555d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case PL_INIT_SEQ: 11565d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 11575d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = phHciNfc_PollLoop_Initialise( psHciContext,pHwRef ); 11585d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NFCSTATUS_SUCCESS == status) 11595d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 11605d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS reset_status = NFCSTATUS_SUCCESS; 11615d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly PHNFC_UNUSED_VARIABLE(reset_status); 11625d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly reset_status = phHciNfc_ReaderMgmt_Update_Sequence( 11635d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext, RESET_SEQ ); 11645d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->hci_seq = READER_MGMT_INIT_SEQ; 11655d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 11665d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 11675d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 11685d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case READER_MGMT_INIT_SEQ: 11695d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 11705d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = phHciNfc_ReaderMgmt_Initialise( psHciContext,pHwRef ); 11715d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NFCSTATUS_SUCCESS == status) 11725d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 11735d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS reset_status = NFCSTATUS_SUCCESS; 11745d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly PHNFC_UNUSED_VARIABLE(reset_status); 11755d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly reset_status = phHciNfc_EmuMgmt_Update_Seq( 11765d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext, RESET_SEQ ); 11775d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->hci_seq = EMULATION_INIT_SEQ; 11785d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 11795d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 11805d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 11815d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case EMULATION_INIT_SEQ: 11825d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 11835d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = phHciNfc_EmuMgmt_Initialise( psHciContext,pHwRef ); 11845d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NFCSTATUS_SUCCESS == status) 11855d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 11866dd948323de0f31b413c9f19a905f1c145c9c456Rob von Behren#if defined( ESTABLISH_SESSION ) 11875d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->hci_seq = ADMIN_SESSION_SEQ; 11886dd948323de0f31b413c9f19a905f1c145c9c456Rob von Behren#elif ( NXP_HAL_MEM_INFO_SIZE > 0x00U ) 11896dd948323de0f31b413c9f19a905f1c145c9c456Rob von Behren psHciContext->hci_seq = DEV_HAL_INFO_SEQ; 11905d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#else 11915d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->hci_seq = HCI_END_SEQ; 11925d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif 11935d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 11945d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 11955d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 11965d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#ifdef ESTABLISH_SESSION 11975d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case ADMIN_SESSION_SEQ: 11985d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 11995d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = phHciNfc_Admin_Initialise( psHciContext,pHwRef ); 12005d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NFCSTATUS_SUCCESS == status) 12015d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 12026dd948323de0f31b413c9f19a905f1c145c9c456Rob von Behren#if ( NXP_HAL_MEM_INFO_SIZE > 0x00U ) 12036dd948323de0f31b413c9f19a905f1c145c9c456Rob von Behren psHciContext->hci_seq = DEV_HAL_INFO_SEQ; 12046dd948323de0f31b413c9f19a905f1c145c9c456Rob von Behren#else 12055d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->hci_seq = IDENTITY_INFO_SEQ; 12066dd948323de0f31b413c9f19a905f1c145c9c456Rob von Behren#endif /* #if ( NXP_HAL_MEM_INFO_SIZE > 0x00U ) */ 12075d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 12085d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 12095d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 12105d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case PL_STOP_SEQ: 12115d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 12125d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = phHciNfc_ReaderMgmt_Disable_Discovery( 12135d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext, pHwRef ); 12145d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NFCSTATUS_SUCCESS == status) 12155d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 12166dd948323de0f31b413c9f19a905f1c145c9c456Rob von Behren#if defined( SW_AUTO_ACTIVATION ) 12175d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->hci_seq = READER_SW_AUTO_SEQ; 12186dd948323de0f31b413c9f19a905f1c145c9c456Rob von Behren#elif ( NXP_HAL_MEM_INFO_SIZE > 0x00U ) 12196dd948323de0f31b413c9f19a905f1c145c9c456Rob von Behren psHciContext->hci_seq = DEV_HAL_INFO_SEQ; 12205d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#else 12215d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->hci_seq = IDENTITY_INFO_SEQ; 12226dd948323de0f31b413c9f19a905f1c145c9c456Rob von Behren#endif /* #if ( NXP_HAL_MEM_INFO_SIZE > 0x00U ) */ 12235d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 12245d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 12255d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 12265d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#ifdef SW_AUTO_ACTIVATION 12275d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case READER_SW_AUTO_SEQ: 12285d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 12295d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uint8_t activate_enable = FALSE; 12305d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uint8_t rdr_enable = TRUE; 12315d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 12325d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = phHciNfc_ReaderA_Update_Info( 12335d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext, HCI_READER_A_ENABLE, 12345d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly &rdr_enable); 12355d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(status == NFCSTATUS_SUCCESS) 12365d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 12375d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = phHciNfc_ReaderA_Auto_Activate( psHciContext, 12385d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pHwRef, activate_enable ); 12395d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(status == NFCSTATUS_SUCCESS) 12405d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 12415d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->hci_seq = IDENTITY_INFO_SEQ; 12425d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 12435d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 12445d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 12455d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 12465d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif 12475d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* fall through */ 12485d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case IDENTITY_INFO_SEQ: 12495d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 12505d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = phHciNfc_IDMgmt_Info_Sequence( psHciContext,pHwRef ); 12515d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NFCSTATUS_SUCCESS == status) 12525d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 12535d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if ((HCI_SELF_TEST != psHciContext->init_mode) 12545d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* && ( TRUE == ((phHal_sHwReference_t *)pHwRef)->se_detect ) */ 12556dd948323de0f31b413c9f19a905f1c145c9c456Rob von Behren && (HCI_CUSTOM_INIT != psHciContext->init_mode) 12566dd948323de0f31b413c9f19a905f1c145c9c456Rob von Behren && (HCI_NFC_DEVICE_TEST != psHciContext->init_mode)) 12575d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 12585d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS info_status = NFCSTATUS_SUCCESS; 12595d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly PHNFC_UNUSED_VARIABLE(info_status); 12605d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly info_status = phHciNfc_EmuMgmt_Update_Seq( 12615d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext, INFO_SEQ ); 12625d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 12635d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NFCSTATUS_SUCCESS == info_status) 12645d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 12655d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->hci_seq = EMULATION_SWP_SEQ; 12665d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 12675d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 12685d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 12695d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 12705d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->hci_seq = HCI_END_SEQ; 12715d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 12725d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 12735d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 12745d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 12755d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case EMULATION_SWP_SEQ: 12765d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 12775d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = phHciNfc_EmuMgmt_Initialise( psHciContext,pHwRef ); 12785d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NFCSTATUS_SUCCESS == status) 12795d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 12805d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->hci_seq = HCI_END_SEQ; 12815d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 12825d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 12835d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 12846dd948323de0f31b413c9f19a905f1c145c9c456Rob von Behren#endif /* #ifdef ESTABLISH_SESSION */ 12856dd948323de0f31b413c9f19a905f1c145c9c456Rob von Behren 12866dd948323de0f31b413c9f19a905f1c145c9c456Rob von Behren#if ( NXP_HAL_MEM_INFO_SIZE > 0x00U ) 12876dd948323de0f31b413c9f19a905f1c145c9c456Rob von Behren case DEV_HAL_INFO_SEQ: 12886dd948323de0f31b413c9f19a905f1c145c9c456Rob von Behren { 12896dd948323de0f31b413c9f19a905f1c145c9c456Rob von Behren static uint8_t mem_index = 0; 12906dd948323de0f31b413c9f19a905f1c145c9c456Rob von Behren status = phHciNfc_DevMgmt_Get_Info(psHciContext, pHwRef, 12916dd948323de0f31b413c9f19a905f1c145c9c456Rob von Behren (NFC_ADDRESS_HAL_CONF + mem_index), 12926dd948323de0f31b413c9f19a905f1c145c9c456Rob von Behren (psHciContext->hal_mem_info + mem_index)); 12936dd948323de0f31b413c9f19a905f1c145c9c456Rob von Behren if(NFCSTATUS_PENDING == status) 12946dd948323de0f31b413c9f19a905f1c145c9c456Rob von Behren { 12956dd948323de0f31b413c9f19a905f1c145c9c456Rob von Behren mem_index++; 12966dd948323de0f31b413c9f19a905f1c145c9c456Rob von Behren if (NXP_HAL_MEM_INFO_SIZE <= mem_index ) 12976dd948323de0f31b413c9f19a905f1c145c9c456Rob von Behren { 12986dd948323de0f31b413c9f19a905f1c145c9c456Rob von Behren NFCSTATUS info_status = NFCSTATUS_SUCCESS; 12996dd948323de0f31b413c9f19a905f1c145c9c456Rob von Behren PHNFC_UNUSED_VARIABLE(info_status); 13006dd948323de0f31b413c9f19a905f1c145c9c456Rob von Behren info_status = phHciNfc_IDMgmt_Update_Sequence( 13016dd948323de0f31b413c9f19a905f1c145c9c456Rob von Behren psHciContext, INFO_SEQ ); 13026dd948323de0f31b413c9f19a905f1c145c9c456Rob von Behren mem_index = 0; 13036dd948323de0f31b413c9f19a905f1c145c9c456Rob von Behren psHciContext->hci_seq = IDENTITY_INFO_SEQ; 13046dd948323de0f31b413c9f19a905f1c145c9c456Rob von Behren /* psHciContext->hci_seq = 13056dd948323de0f31b413c9f19a905f1c145c9c456Rob von Behren (HCI_SELF_TEST != psHciContext->init_mode)? 13066dd948323de0f31b413c9f19a905f1c145c9c456Rob von Behren IDENTITY_INFO_SEQ : HCI_END_SEQ; */ 13076dd948323de0f31b413c9f19a905f1c145c9c456Rob von Behren } 13086dd948323de0f31b413c9f19a905f1c145c9c456Rob von Behren } 13096dd948323de0f31b413c9f19a905f1c145c9c456Rob von Behren break; 13106dd948323de0f31b413c9f19a905f1c145c9c456Rob von Behren } 13116dd948323de0f31b413c9f19a905f1c145c9c456Rob von Behren#endif /* #if ( NXP_HAL_MEM_INFO_SIZE > 0x00U ) */ 13125d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case HCI_END_SEQ: 13135d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 13146dd948323de0f31b413c9f19a905f1c145c9c456Rob von Behren phHal_sMemInfo_t *p_mem_info = 13156dd948323de0f31b413c9f19a905f1c145c9c456Rob von Behren (phHal_sMemInfo_t *) ( psHciContext->hal_mem_info ); 13166dd948323de0f31b413c9f19a905f1c145c9c456Rob von Behren if ( 13176dd948323de0f31b413c9f19a905f1c145c9c456Rob von Behren (HCI_SELF_TEST == psHciContext->init_mode ) 13186dd948323de0f31b413c9f19a905f1c145c9c456Rob von Behren || (HCI_NFC_DEVICE_TEST == psHciContext->init_mode ) 13196dd948323de0f31b413c9f19a905f1c145c9c456Rob von Behren ) 13205d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 13215d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->hci_state.next_state 13225d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly = (uint8_t) hciState_Test; 13235d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 13245d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = phHciNfc_FSM_Complete ( psHciContext ); 13255d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#ifdef UICC_CONNECTIVITY_PATCH 13265d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_Uicc_Connectivity( psHciContext, pHwRef ); 13275d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif /* #ifdef UICC_CONNECTIVITY_PATCH */ 13285d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 13296dd948323de0f31b413c9f19a905f1c145c9c456Rob von Behren#if ( NXP_HAL_MEM_INFO_SIZE > 0x00U ) 13306dd948323de0f31b413c9f19a905f1c145c9c456Rob von Behren if(NXP_FW_UPLOAD_SUCCESS != p_mem_info->fw_magic ) 13316dd948323de0f31b413c9f19a905f1c145c9c456Rob von Behren { 13326dd948323de0f31b413c9f19a905f1c145c9c456Rob von Behren status = PHNFCSTVAL( CID_NFC_HCI, NFCSTATUS_FAILED ); 13336dd948323de0f31b413c9f19a905f1c145c9c456Rob von Behren } 13346dd948323de0f31b413c9f19a905f1c145c9c456Rob von Behren#endif /* #if ( NXP_HAL_MEM_INFO_SIZE > 0x00U ) */ 13356dd948323de0f31b413c9f19a905f1c145c9c456Rob von Behren 13365d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Initialisation Complete Notification to the Upper Layer */ 13375d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NFCSTATUS_SUCCESS == status) 13385d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 13396dd948323de0f31b413c9f19a905f1c145c9c456Rob von Behren phNfc_sCompletionInfo_t comp_info={FALSE,0, NULL}; 13405d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 13415d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly comp_info.status = status; 13425d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_Notify(psHciContext->p_upper_notify, 13435d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->p_upper_context, pHwRef, 13445d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFC_NOTIFY_INIT_COMPLETED, &comp_info); 13455d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly HCI_PRINT("HCI Initialisation Completed \n"); 13465d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 13475d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 13485d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 13495d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pphNfcIF_Notification_CB_t p_upper_notify = psHciContext->p_upper_notify; 13505d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly void *pcontext = psHciContext->p_upper_context; 13515d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phNfc_sCompletionInfo_t comp_info; 13525d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 13535d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 13545d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_Release_Lower( psHciContext, pHwRef ); 13555d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_Release_Resources( &psHciContext ); 13565d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Notify the Failure to the Upper Layer */ 13575d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly comp_info.status = status; 13585d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_Notify( p_upper_notify, pcontext, pHwRef, 13595d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFC_NOTIFY_INIT_FAILED, &comp_info); 13605d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly HCI_PRINT("HCI FSM Initialisation Error \n"); 13615d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 13625d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 13635d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 13645d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly default: 13655d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 13665d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 13675d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 13685d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly return status; 13695d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly} 13705d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 13715d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 13725d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyNFCSTATUS 13735d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyphHciNfc_Release_Sequence( 13745d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_sContext_t *psHciContext, 13755d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly void *pHwRef 13765d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ) 13775d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly{ 13785d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS status = NFCSTATUS_SUCCESS; 13795d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 13805d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly switch(psHciContext->hci_seq) 13815d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 13825d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case PL_STOP_SEQ: 13835d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 13845d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = phHciNfc_ReaderMgmt_Disable_Discovery( 13855d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext, pHwRef ); 13865d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NFCSTATUS_SUCCESS == status) 13875d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 13885d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (void)phHciNfc_EmuMgmt_Update_Seq( 13895d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext, REL_SEQ ); 13905d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->hci_seq = EMULATION_REL_SEQ; 13915d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = NFCSTATUS_PENDING; 13925d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 13935d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 13945d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 13955d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case EMULATION_REL_SEQ: 13965d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 13975d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = phHciNfc_EmuMgmt_Release( psHciContext,pHwRef ); 13985d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NFCSTATUS_SUCCESS == status) 13995d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 14005d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (void)phHciNfc_DevMgmt_Update_Sequence( 14015d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext, REL_SEQ ); 14025d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->hci_seq = ADMIN_REL_SEQ; 14035d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = NFCSTATUS_PENDING; 14045d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 14055d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 14065d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 14075d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case DEV_REL_SEQ: 14085d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 14096dd948323de0f31b413c9f19a905f1c145c9c456Rob von Behren NFCSTATUS info_status = NFCSTATUS_SUCCESS; 14106dd948323de0f31b413c9f19a905f1c145c9c456Rob von Behren PHNFC_UNUSED_VARIABLE(info_status); 14116dd948323de0f31b413c9f19a905f1c145c9c456Rob von Behren info_status = phHciNfc_DevMgmt_Update_Sequence( 14126dd948323de0f31b413c9f19a905f1c145c9c456Rob von Behren psHciContext, REL_SEQ ); 14135d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = phHciNfc_DevMgmt_Release( psHciContext, pHwRef ); 14145d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NFCSTATUS_SUCCESS == status) 14155d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 14165d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->hci_seq = HCI_END_SEQ; 14175d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = NFCSTATUS_PENDING; 14185d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 14195d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 14205d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 14215d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case READER_MGMT_REL_SEQ: 14225d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 14235d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = phHciNfc_ReaderMgmt_Release( psHciContext,pHwRef ); 14245d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NFCSTATUS_SUCCESS == status) 14255d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 14265d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->hci_seq = PL_REL_SEQ; 14275d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = NFCSTATUS_PENDING; 14285d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 14295d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 14305d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 14315d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case PL_REL_SEQ: 14325d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 14335d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = phHciNfc_PollLoop_Release( psHciContext,pHwRef ); 14345d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NFCSTATUS_SUCCESS == status) 14355d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 14365d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->hci_seq = IDENTITY_REL_SEQ; 14375d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = NFCSTATUS_PENDING; 14385d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 14395d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 14405d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 14415d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case IDENTITY_REL_SEQ: 14425d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 14435d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = phHciNfc_IDMgmt_Release( psHciContext,pHwRef ); 14445d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NFCSTATUS_SUCCESS == status) 14455d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 14465d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->hci_seq = LINK_MGMT_REL_SEQ; 14475d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = NFCSTATUS_PENDING; 14485d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 14495d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 14505d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 14515d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case LINK_MGMT_REL_SEQ: 14525d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 14535d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = phHciNfc_LinkMgmt_Release( psHciContext,pHwRef ); 14545d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NFCSTATUS_SUCCESS == status) 14555d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 14565d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->hci_seq = ADMIN_REL_SEQ; 14575d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = NFCSTATUS_PENDING; 14585d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 14595d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 14605d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 14615d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case ADMIN_REL_SEQ: 14625d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 14635d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Admin Management Release Sequence */ 14645d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = phHciNfc_Admin_Release( psHciContext,pHwRef, phHciNfc_TerminalHostID ); 14655d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NFCSTATUS_SUCCESS == status) 14665d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 14675d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->hci_seq = DEV_REL_SEQ; 14685d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = NFCSTATUS_PENDING; 14695d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 14705d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 14715d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 14725d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case HCI_END_SEQ: 14735d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 14745d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pphNfcIF_Notification_CB_t p_upper_notify = 14755d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->p_upper_notify; 14765d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phNfc_sLowerIF_t *plower_if = 14775d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly &(psHciContext->lower_interface); 14785d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly void *pcontext = 14795d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->p_upper_context; 14805d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phNfc_sCompletionInfo_t comp_info; 14815d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 14825d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 14835d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = plower_if->release((void *)plower_if->pcontext, 14845d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (void *)pHwRef); 14855d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 14865d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_Release_Resources( &psHciContext ); 14875d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* De-Initialisation Complete Notification to the Upper Layer */ 14885d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly comp_info.status = status; 14895d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_Notify(p_upper_notify, pcontext, pHwRef, 14905d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFC_NOTIFY_DEINIT_COMPLETED, &comp_info); 14915d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 14925d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly HCI_PRINT("HCI Release Completed \n"); 14935d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 14945d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 14955d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly default: 14965d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 14975d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* psHciContext->hci_seq = HCI_END_SEQ; */ 14985d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 14995d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 15005d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 15015d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 15025d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly return status; 15035d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly} 15045d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 15055d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 15065d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pellystatic 15075d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyNFCSTATUS 15085d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyphHciNfc_Config_Sequence( 15095d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_sContext_t *psHciContext, 15105d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly void *pHwRef 15115d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ) 15125d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly{ 15135d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS status = NFCSTATUS_SUCCESS; 15146dd948323de0f31b413c9f19a905f1c145c9c456Rob von Behren phNfc_sCompletionInfo_t comp_info = {FALSE,0,NULL}; 15155d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 15165d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly switch(psHciContext->config_type) 15175d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 15185d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case POLL_LOOP_CFG: 15195d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 15205d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = phHciNfc_PollLoop_Sequence( psHciContext, pHwRef ); 15215d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 15225d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 15235d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case SMX_WI_MODE: 15245d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 15255d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = phHciNfc_SmartMx_Mode_Sequence( psHciContext, pHwRef ); 15265d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 15275d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 15285d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#ifdef ENABLE_P2P 15295d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case NFC_GENERAL_CFG: 15305d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 15315d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(TARGET_GENERAL_SEQ == psHciContext->hci_seq) 15325d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 15335d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = phHciNfc_NfcIP_SetATRInfo( psHciContext, 15345d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pHwRef, NFCIP_TARGET, 15355d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->p_config_params); 15365d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if( NFCSTATUS_PENDING != status ) 15375d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 15385d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Roll Back the State Machine to its Original State */ 15395d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_FSM_Rollback ( psHciContext ); 15405d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 15415d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 15425d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 15435d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->hci_seq = HCI_END_SEQ; 15445d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 15455d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 15465d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 15475d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 15485d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = phHciNfc_Pending_Sequence(psHciContext, pHwRef ); 15495d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if (NFCSTATUS_PENDING != status) 15505d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 15515d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Roll Back to its Current State as Configuration is Complete */ 15525d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_FSM_Rollback(psHciContext); 15535d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 15545d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly HCI_PRINT(" NFC-IP(P2P) Configuration Completed. \n"); 15555d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly comp_info.status = status; 15565d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->error_status = NFCSTATUS_SUCCESS; 15575d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_Notify(psHciContext->p_upper_notify, 15585d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->p_upper_context, pHwRef, 15595d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFC_NOTIFY_CONFIG_SUCCESS , &comp_info); 15605d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 15615d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 15625d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 15635d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 15645d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif 15655d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case SWP_PROTECT_CFG: 15665d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case SWP_EVT_CFG: 15675d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case SMX_WI_CFG: 15685d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 15695d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Roll Back to its Current State as Configuration is Complete */ 15705d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_FSM_Rollback(psHciContext); 15715d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 15725d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly HCI_DEBUG(" %s Configuration Completed. \n", 15735d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ((SMX_WI_CFG == psHciContext->config_type)? 15745d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly "SmartMX" : "SWP Event/Protection")); 15755d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 15765d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly comp_info.status = status; 15775d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_Notify(psHciContext->p_upper_notify, 15785d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->p_upper_context, pHwRef, 15795d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFC_NOTIFY_CONFIG_SUCCESS, &comp_info); 15805d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 15815d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 15825d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case NFC_TARGET_CFG: 15835d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 15845d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_FEATURE_NOT_SUPPORTED); 15855d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 15865d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 15875d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case UICC_SWP_CFG: 15885d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#if 0 15895d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 15905d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHal_sEmulationCfg_t *p_emulation_cfg = 15915d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (phHal_sEmulationCfg_t * ) 15925d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->p_config_params; 15935d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if (NULL != p_emulation_cfg) 15945d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 15955d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHal_sUiccEmuCfg_t *uicc_config = 15965d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly &p_emulation_cfg->config.uiccEmuCfg; 15975d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if( TRUE == uicc_config->enableUicc ) 15985d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 15995d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = phHciNfc_Uicc_Connect_Status(psHciContext,pHwRef); 16005d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if( NFCSTATUS_PENDING == status ) 16015d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 16025d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 16035d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } /* Or Else Fall through to notify the above layer */ 16045d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 16055d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 16065d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 16075d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif 16085d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* fall through */ 16095d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case NFC_CE_A_CFG: 16105d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case NFC_CE_B_CFG: 16115d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 16125d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = phHciNfc_EmulationCfg_Sequence( psHciContext, pHwRef ); 16135d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 16145d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 16155d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly default: 16165d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 16175d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_INVALID_HCI_SEQUENCE); 16185d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 16195d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 16205d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 16215d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 16225d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly return status; 16235d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly} 16245d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 16255d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 16265d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyNFCSTATUS 16275d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyphHciNfc_PollLoop_Sequence( 16285d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_sContext_t *psHciContext, 16295d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly void *pHwRef 16305d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ) 16315d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly{ 16325d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS status = NFCSTATUS_SUCCESS; 16335d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHal_sADD_Cfg_t *p_poll_config = (phHal_sADD_Cfg_t * ) 16345d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->p_config_params; 16355d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if (NULL != p_poll_config) 16365d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 16375d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uint8_t speed = 16385d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly p_poll_config->NfcIP_Mode; 163920b7bd5f6985dc890ac99d7d1e8154f965df02dbMartijn Coenen uint8_t targetSpeed = 164020b7bd5f6985dc890ac99d7d1e8154f965df02dbMartijn Coenen p_poll_config->NfcIP_Target_Mode; 16415d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly switch(psHciContext->hci_seq) 16425d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 16435d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case PL_DURATION_SEQ: 16445d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 16455d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = phHciNfc_PollLoop_Cfg( psHciContext, pHwRef, 16465d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (uint8_t)PL_DURATION , NULL); 16475d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NFCSTATUS_SUCCESS == status) 16485d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 16495d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#if defined (ENABLE_P2P) && defined (TARGET_SPEED) 16505d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->hci_seq = TARGET_SPEED_SEQ; 16515d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#elif defined (ENABLE_P2P) && defined (INITIATOR_SPEED) 16525d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->hci_seq = INITIATOR_SPEED_SEQ; 16535d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#elif defined (ENABLE_P2P) && defined (NFCIP_TGT_DISABLE_CFG) 16545d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->hci_seq = PL_TGT_DISABLE_SEQ; 16555d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#else 16565d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->hci_seq = PL_CONFIG_PHASE_SEQ; 16575d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif 16585d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 16595d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = NFCSTATUS_PENDING; 16605d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 16615d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 16625d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 16635d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#if defined (ENABLE_P2P) && defined (TARGET_SPEED) 16645d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case TARGET_SPEED_SEQ: 16655d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 16665d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#define NFCIP_ACTIVE_SHIFT 0x03U 16675d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#define NFCIP_PASSIVE_MASK 0x07U 166820b7bd5f6985dc890ac99d7d1e8154f965df02dbMartijn Coenen uint8_t mode = targetSpeed; 166925aa129fc1d808b678a2c0250ef12e1cabc6629eMartijn Coenen HCI_DEBUG("Setting target mode to 0x%02X", mode); 16705d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = 16715d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_NfcIP_SetMode( psHciContext, pHwRef, NFCIP_TARGET, 16725d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (uint8_t) mode ); 16735d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NFCSTATUS_PENDING == status) 16745d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 16755d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#if defined (INITIATOR_SPEED) 16765d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->hci_seq = INITIATOR_SPEED_SEQ; 16775d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#elif defined (NFCIP_TGT_DISABLE_CFG) 16785d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->hci_seq = PL_TGT_DISABLE_SEQ; 16795d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#else 16805d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->hci_seq = PL_CONFIG_PHASE_SEQ; 16815d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif 16825d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = NFCSTATUS_PENDING; 16835d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 16845d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 16855d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 16865d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif 16875d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#if defined (ENABLE_P2P) && defined (INITIATOR_SPEED) 16885d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case INITIATOR_SPEED_SEQ: 16895d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 169025aa129fc1d808b678a2c0250ef12e1cabc6629eMartijn Coenen HCI_DEBUG("Setting initiator mode to 0x%02X", speed); 16915d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = 16925d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_NfcIP_SetMode( psHciContext, pHwRef, NFCIP_INITIATOR, 169300c98d516cac9dcdad6c22400267a2fd2bea3adfNick Pelly (uint8_t) (speed & DEFAULT_NFCIP_INITIATOR_MODE_SUPPORT)); 16945d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NFCSTATUS_PENDING == status) 16955d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 16965d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#if defined (NFCIP_TGT_DISABLE_CFG) 16975d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->hci_seq = PL_TGT_DISABLE_SEQ; 16985d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#else 16995d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->hci_seq = PL_CONFIG_PHASE_SEQ; 17005d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif 17015d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = NFCSTATUS_PENDING; 17025d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 17035d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 17045d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 17055d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif 17065d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#if defined (ENABLE_P2P) && defined (NFCIP_TGT_DISABLE_CFG) 17075d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case PL_TGT_DISABLE_SEQ: 17085d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 17095d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Configure the Polling Loop Target Disable Parameter */ 17105d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = phHciNfc_PollLoop_Cfg( psHciContext, pHwRef, 17115d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (uint8_t)PL_DISABLE_TARGET, &p_poll_config->NfcIP_Tgt_Disable ); 17125d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NFCSTATUS_SUCCESS == status) 17135d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 17145d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->hci_seq = PL_CONFIG_PHASE_SEQ; 17155d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = NFCSTATUS_PENDING; 17165d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 17175d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 17185d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 17195d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif 17205d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case PL_CONFIG_PHASE_SEQ: 17215d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 17225d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHal_sPollDevInfo_t *p_poll_info = 17235d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly &(p_poll_config->PollDevInfo.PollCfgInfo); 17245d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 17255d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly p_poll_info->EnableIso14443A = 17265d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ( (p_poll_info->EnableIso14443A) 17275d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly || ( speed & (uint8_t)phHal_ePassive106 ) 17285d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ); 17295d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly p_poll_info->EnableFelica212 = 17305d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ( (p_poll_info->EnableFelica212) 17315d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly || ( speed & (uint8_t)phHal_ePassive212 ) 17325d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ); 17335d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly p_poll_info->EnableFelica424 = 17345d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ( (p_poll_info->EnableFelica424) 17355d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly || ( speed & (uint8_t)phHal_ePassive424 ) 17365d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ); 17375d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Configure the Polling Loop Gate Parameters */ 17385d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = phHciNfc_PollLoop_Cfg( psHciContext, pHwRef, 17395d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (uint8_t)PL_RD_PHASES, NULL ); 17405d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NFCSTATUS_SUCCESS == status) 17415d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 17425d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(((~(PL_RD_PHASES_DISABLE)) & 17435d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly p_poll_config->PollDevInfo.PollEnabled)!= 0) 17445d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 17455d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->hci_seq = READER_ENABLE_SEQ; 17465d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 17475d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 17485d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 17495d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* psHciContext->hci_seq = READER_DISABLE_SEQ; */ 17505d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->hci_seq = HCI_END_SEQ; 17515d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 17525d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = NFCSTATUS_PENDING; 17535d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 17545d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 17555d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 17565d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case READER_ENABLE_SEQ: 17575d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 17585d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = 17595d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_ReaderMgmt_Enable_Discovery( 17605d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext, pHwRef ); 17615d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NFCSTATUS_SUCCESS == status) 17625d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 17635d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* psHciContext->hci_seq = PL_CONFIG_PHASE_SEQ; */ 17645d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->hci_seq = HCI_END_SEQ; 17655d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = NFCSTATUS_PENDING; 17665d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 17675d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 17685d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 17695d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case READER_DISABLE_SEQ: 17705d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 17715d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = phHciNfc_ReaderMgmt_Disable_Discovery( 17725d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext, pHwRef ); 17735d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 17745d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NFCSTATUS_SUCCESS == status) 17755d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 17765d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if((~(PL_RD_PHASES_DISABLE) & 17775d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly p_poll_config->PollDevInfo.PollEnabled)!= 0) 17785d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 17795d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->hci_seq = PL_DURATION_SEQ; 17805d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 17815d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 17825d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 17835d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#if defined (ENABLE_P2P) && defined (INITIATOR_SPEED) 17845d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->hci_seq = INITIATOR_SPEED_SEQ; 17855d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#elif defined (ENABLE_P2P) && defined (NFCIP_TGT_DISABLE_CFG) 17865d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->hci_seq = PL_TGT_DISABLE_SEQ; 17875d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#else 17885d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->hci_seq = PL_CONFIG_PHASE_SEQ; 17895d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif 17905d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* psHciContext->hci_seq = HCI_END_SEQ; */ 17915d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 17925d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = NFCSTATUS_PENDING; 17935d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 17945d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 17955d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 17965d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case HCI_END_SEQ: 17975d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 17985d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phNfc_sCompletionInfo_t comp_info; 17995d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = phHciNfc_Pending_Sequence(psHciContext, pHwRef ); 18005d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if (NFCSTATUS_PENDING != status) 18015d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 18025d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* status = phHciNfc_FSM_Complete ( psHciContext );*/ 18035d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_FSM_Rollback ( psHciContext ); 18045d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Poll Configuration Notification to the Upper Layer */ 18055d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if((~(PL_RD_PHASES_DISABLE) & 18065d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly p_poll_config->PollDevInfo.PollEnabled)!= 0) 18075d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 18085d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly comp_info.status = status; 18095d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_Notify(psHciContext->p_upper_notify, 18105d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->p_upper_context, pHwRef, 18115d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFC_NOTIFY_POLL_ENABLED, &comp_info); 18125d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 18135d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 18145d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 18155d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly comp_info.status = status; 18165d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_Notify(psHciContext->p_upper_notify, 18175d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->p_upper_context, pHwRef, 18185d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFC_NOTIFY_POLL_DISABLED, &comp_info); 18195d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 18205d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly HCI_PRINT("HCI Discovery Configuration Completed \n"); 18215d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 18225d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 18235d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 18245d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly default: 18255d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 18265d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* psHciContext->hci_seq = HCI_END_SEQ; */ 18275d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 18285d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 18295d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly }/* End of the Poll Sequence Switch */ 18305d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly }/* End of the Poll Config info Check */ 18315d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 18325d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly return status; 18335d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly} 18345d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 18355d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 18365d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyNFCSTATUS 18375d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyphHciNfc_EmulationCfg_Sequence( 18385d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_sContext_t *psHciContext, 18395d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly void *pHwRef 18405d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ) 18415d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly{ 18425d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS status = NFCSTATUS_SUCCESS; 18436dd948323de0f31b413c9f19a905f1c145c9c456Rob von Behren static phNfc_sCompletionInfo_t comp_info = {FALSE,0,NULL}; 18445d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#if defined(HOST_EMULATION) 18455d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_GateID_t ce_gate = phHciNfc_UnknownGate; 18465d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif /* #ifdef HOST_EMULATION */ 18475d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHal_sEmulationCfg_t *p_emulation_cfg = (phHal_sEmulationCfg_t * ) 18485d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->p_config_params; 18495d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#ifdef UICC_SESSION_RESET 18505d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uint8_t uicc_clear_pipes = FALSE; 18515d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif 18525d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 18535d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 18545d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if (NULL != p_emulation_cfg) 18555d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 18565d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#if defined(HOST_EMULATION) 18575d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NFC_HOST_CE_A_EMULATION == p_emulation_cfg->emuType) 18585d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 18595d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->config_type = NFC_CE_A_CFG; 18605d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if (NULL == psHciContext->p_ce_a_info) 18615d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 18625d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ce_gate = phHciNfc_CETypeAGate; 18635d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 18645d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 18655d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else if (NFC_HOST_CE_B_EMULATION == p_emulation_cfg->emuType) 18665d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 18675d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->config_type = NFC_CE_B_CFG; 18685d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if (NULL == psHciContext->p_ce_b_info) 18695d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 18705d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ce_gate = phHciNfc_CETypeBGate; 18715d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 18725d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 18735d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#ifdef UICC_SESSION_RESET 18745d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else if ((NFC_UICC_EMULATION == p_emulation_cfg->emuType) 18755d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly &&(FALSE == p_emulation_cfg->config.uiccEmuCfg.enableUicc) 18765d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ) 18775d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 18785d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uicc_clear_pipes = TRUE; 18795d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 18805d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif 18815d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 18825d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 18835d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ; 18845d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 18855d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif /* #ifdef HOST_EMULATION */ 18865d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 18875d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly switch(psHciContext->hci_seq) 18885d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 18895d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#if defined(HOST_EMULATION) 18905d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case ADMIN_CE_SEQ: 18915d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 18925d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(phHciNfc_UnknownGate != ce_gate) 18935d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 18945d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = phHciNfc_Admin_CE_Init(psHciContext, pHwRef, ce_gate); 18955d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 18965d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 18975d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 18985d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_NOT_ALLOWED); 18995d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 19005d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 19015d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NFCSTATUS_SUCCESS == status) 19025d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 19035d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->hci_seq = EMULATION_CONFIG_SEQ; 19045d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* psHciContext->hci_seq = HCI_END_SEQ; */ 19055d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = NFCSTATUS_PENDING; 19065d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 19075d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 19085d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 19095d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif 19105d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case EMULATION_CONFIG_SEQ: 19115d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 19125d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = phHciNfc_Emulation_Cfg(psHciContext, pHwRef, 19135d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->config_type); 19145d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NFCSTATUS_SUCCESS == status) 19155d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 19165d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* psHciContext->hci_seq = PL_CONFIG_PHASE_SEQ; */ 19175d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#ifdef UICC_SESSION_RESET 19185d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(UICC_SWP_CFG == psHciContext->config_type) 19195d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 19205d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->hci_seq = ADMIN_REL_SEQ; 19215d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 19225d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 19235d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif /* UICC_SESSION_RESET */ 19245d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 19255d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->hci_seq = HCI_END_SEQ; 19265d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 19275d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = NFCSTATUS_PENDING; 19285d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 19295d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 19305d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 19315d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#ifdef UICC_SESSION_RESET 19325d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case ADMIN_REL_SEQ: 19335d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 19345d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if (TRUE == uicc_clear_pipes) 19355d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 19365d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Admin Management UICC Release Sequence */ 19375d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = phHciNfc_Admin_Release( psHciContext,pHwRef, phHciNfc_UICCHostID ); 19385d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NFCSTATUS_SUCCESS == status) 19395d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 19405d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->hci_seq = HCI_END_SEQ; 19415d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if (UICC_SWP_CFG == psHciContext->config_type) 19425d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 19435d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (void)phHciNfc_SWP_Update_Sequence(psHciContext, 19445d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly CONFIG_SEQ ); 19455d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 19465d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = NFCSTATUS_PENDING; 19475d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 19485d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 19495d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 19505d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 19515d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif /* UICC_SESSION_RESET */ 19525d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* fall through */ 19535d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case HCI_END_SEQ: 19545d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 19555d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_FSM_Rollback(psHciContext); 19565d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 19575d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly HCI_PRINT(" Emulation Configuration Completed. \n"); 19585d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 19595d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly comp_info.status = status; 19605d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_Notify(psHciContext->p_upper_notify, 19615d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->p_upper_context, pHwRef, 19625d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFC_NOTIFY_CONFIG_SUCCESS, &comp_info); 19635d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 19645d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 19655d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly default: 19665d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 19675d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* psHciContext->hci_seq = HCI_END_SEQ; */ 19685d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 19695d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 19705d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 19715d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* 19725d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFC_CE_A_CFG; 19735d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFC_CE_B_CFG; */ 19745d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 19755d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly }/* End of the Emulation Config info Check */ 19765d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 19775d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly return status; 19785d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly} 19795d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 19805d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 19815d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyNFCSTATUS 19825d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyphHciNfc_SmartMx_Mode_Sequence( 19835d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_sContext_t *psHciContext, 19845d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly void *pHwRef 19855d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ) 19865d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly{ 19875d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS status = NFCSTATUS_SUCCESS; 19885d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHal_sADD_Cfg_t *p_poll_config = (phHal_sADD_Cfg_t * ) 19895d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->p_config_params; 19906dd948323de0f31b413c9f19a905f1c145c9c456Rob von Behren phNfc_sCompletionInfo_t comp_info = {FALSE,0,NULL}; 19915d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if (NULL != p_poll_config) 19925d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 19935d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly switch(psHciContext->hci_seq) 19945d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 19955d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case READER_DISABLE_SEQ: 19965d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 19975d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = phHciNfc_ReaderMgmt_Disable_Discovery( 19985d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext, pHwRef ); 19995d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NFCSTATUS_SUCCESS == status) 20005d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 20015d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->hci_seq = EMULATION_CONFIG_SEQ; 20025d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* psHciContext->hci_seq = HCI_END_SEQ; */ 20035d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = NFCSTATUS_PENDING; 20045d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 20055d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 20065d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 20075d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case EMULATION_CONFIG_SEQ: 20085d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 20095d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = phHciNfc_WI_Configure_Mode( 20105d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext, pHwRef,psHciContext->smx_mode ); 20115d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NFCSTATUS_SUCCESS == status) 20125d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 20135d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->hci_seq = PL_CONFIG_PHASE_SEQ; 20145d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* psHciContext->hci_seq = HCI_END_SEQ; */ 20155d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = NFCSTATUS_PENDING; 20165d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 20175d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 20185d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 20195d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case PL_CONFIG_PHASE_SEQ: 20205d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 20215d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Configure the Polling Loop Gate Parameters */ 20225d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = phHciNfc_PollLoop_Cfg( psHciContext, pHwRef, 20235d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (uint8_t)PL_RD_PHASES, NULL ); 20245d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NFCSTATUS_SUCCESS == status) 20255d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 20265d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->hci_seq = READER_ENABLE_SEQ; 20275d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = NFCSTATUS_PENDING; 20285d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 20295d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 20305d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 20315d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case READER_ENABLE_SEQ: 20325d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 20335d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = 20345d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_ReaderMgmt_Enable_Discovery( 20355d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext, pHwRef ); 20365d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NFCSTATUS_SUCCESS == status) 20375d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 20385d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* psHciContext->hci_seq = PL_CONFIG_PHASE_SEQ; */ 20395d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->hci_seq = HCI_END_SEQ; 20405d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = NFCSTATUS_PENDING; 20415d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 20425d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 20435d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 20445d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case HCI_END_SEQ: 20455d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 20465d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = phHciNfc_Pending_Sequence(psHciContext, pHwRef ); 20475d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if (NFCSTATUS_PENDING != status) 20485d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 20495d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* status = phHciNfc_FSM_Complete ( psHciContext );*/ 20505d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_FSM_Rollback ( psHciContext ); 20515d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if( hciState_Disconnect == psHciContext->hci_state.cur_state) 20525d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 20535d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->host_rf_type = phHal_eUnknown_DevType; 20545d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->p_target_info = NULL; 20555d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->p_xchg_info = NULL; 20565d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 20575d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Poll Configuration Notification to the Upper Layer */ 20585d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if((~(PL_RD_PHASES_DISABLE) & 20595d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly p_poll_config->PollDevInfo.PollEnabled)!= 0) 20605d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 20615d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly comp_info.status = status; 20625d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_Notify(psHciContext->p_upper_notify, 20635d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->p_upper_context, pHwRef, 20645d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFC_NOTIFY_POLL_ENABLED, &comp_info); 20655d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 20665d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 20675d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 20685d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly comp_info.status = status; 20695d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_Notify(psHciContext->p_upper_notify, 20705d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->p_upper_context, pHwRef, 20715d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFC_NOTIFY_POLL_DISABLED, &comp_info); 20725d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 20735d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly HCI_PRINT("HCI Discovery Configuration Completed \n"); 20745d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 20755d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 20765d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 20775d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly default: 20785d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 20795d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* psHciContext->hci_seq = HCI_END_SEQ; */ 20805d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 20815d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 20825d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly }/* End of the Poll Sequence Switch */ 20835d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly }/* End of the Poll Config info Check */ 20845d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 20855d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly return status; 20865d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly} 20875d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 20885d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 20895d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyNFCSTATUS 20905d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyphHciNfc_Connect_Sequence( 20915d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_sContext_t *psHciContext, 20925d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly void *pHwRef 20935d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ) 20945d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly{ 20955d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS status = NFCSTATUS_SUCCESS; 20966dd948323de0f31b413c9f19a905f1c145c9c456Rob von Behren static phNfc_sCompletionInfo_t comp_info = {FALSE,0,NULL}; 20975d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHal_eRemDevType_t target_type = phHal_eUnknown_DevType; 20985d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 20995d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if( NULL != psHciContext->p_target_info ) 21005d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 21015d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 21025d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly target_type = psHciContext->p_target_info->RemDevType; 21035d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly switch(psHciContext->hci_seq) 21045d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 21055d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case READER_REACTIVATE_SEQ: 21065d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 21075d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Complete the Reactivate Sequence and notify the HAL */ 21085d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = phHciNfc_FSM_Complete ( psHciContext ); 21095d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Reactivate Complete Notification to the Upper Layer */ 21105d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NFCSTATUS_SUCCESS == status) 21115d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 21125d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly comp_info.status = status; 21135d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_Notify(psHciContext->p_upper_notify, 21145d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->p_upper_context, pHwRef, 21155d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFC_NOTIFY_TARGET_REACTIVATED , &comp_info); 21165d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly HCI_PRINT(" HCI Remote Target Reactivated. \n"); 21175d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 21185d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 21195d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 21205d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly comp_info.status = status; 21215d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_FSM_Rollback ( psHciContext ); 21225d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_Notify(psHciContext->p_upper_notify, 21235d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->p_upper_context, pHwRef, 21245d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFC_NOTIFY_ERROR , &comp_info); 21255d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly HCI_PRINT("HCI FSM Invalid Selection State \n"); 21265d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly HCI_PRINT("HCI Remote Target Reactivation Failed \n"); 21275d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 21285d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 21295d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 21305d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case READER_SELECT_SEQ: 21315d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 21325d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* If the Target is Mifare then it should fall through */ 21335d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(( phHal_eMifare_PICC != target_type ) 21345d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly &&(phHal_eISO14443_3A_PICC != target_type) 21355d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#ifdef TYPE_B 21365d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly && ( phHal_eISO14443_B_PICC != target_type ) 21375d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly && ( phHal_eISO14443_4B_PICC != target_type ) 21385d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif 21395d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#ifdef TYPE_FELICA 21405d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly && ( phHal_eFelica_PICC != target_type ) 21415d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif 21425d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#ifdef TYPE_JEWEL 21435d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly && ( phHal_eJewel_PICC != target_type ) 21445d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif /* #ifdef TYPE_JEWEL */ 21455d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#ifdef TYPE_ISO15693 21465d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly && ( phHal_eISO15693_PICC != target_type ) 21475d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif /* #ifdef TYPE_ISO15693 */ 21485d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 21495d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ) 21505d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 21515d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = phHciNfc_ReaderMgmt_Info_Sequence( psHciContext, pHwRef ); 21525d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NFCSTATUS_SUCCESS == status) 21535d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 21545d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->hci_seq = HCI_END_SEQ; 21555d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = NFCSTATUS_PENDING; 21565d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 21575d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 21585d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 21595d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 21605d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* fall through */ 21615d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case HCI_END_SEQ: 21625d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 21635d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Complete the Connect Sequence and notify the HAL */ 21645d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = phHciNfc_FSM_Complete ( psHciContext ); 21655d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Connection Complete Notification to the Upper Layer */ 21665d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NFCSTATUS_SUCCESS == status) 21675d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 21685d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Invalidate the previously polled RF Reader Type */ 21695d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* psHciContext->host_rf_type = phHal_eInvalidRFType;*/ 21705d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly comp_info.status = status; 21715d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_Notify(psHciContext->p_upper_notify, 21725d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->p_upper_context, pHwRef, 21735d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFC_NOTIFY_TARGET_CONNECTED , &comp_info); 21745d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly HCI_PRINT(" HCI Remote Target Selected for Transaction. \n"); 21755d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 21765d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 21775d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 21785d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly comp_info.status = status; 21795d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* phHciNfc_FSM_Rollback ( psHciContext ); */ 21805d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_Notify(psHciContext->p_upper_notify, 21815d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->p_upper_context, pHwRef, 21825d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFC_NOTIFY_ERROR , &comp_info); 21835d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly HCI_PRINT("HCI FSM Invalid Selection State \n"); 21845d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly HCI_PRINT("HCI Remote Target Selection Failed \n"); 21855d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 21865d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 21875d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 21885d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly default: 21895d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 21905d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly HCI_PRINT("\t Invalid HCI Connect Sequence \n"); 21915d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* psHciContext->hci_seq = HCI_END_SEQ; */ 21925d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 21935d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 21945d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly }/* End of the Connect Sequence Switch */ 21955d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 21965d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 21975d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly return status; 21985d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly} 21995d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 22005d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 22015d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyNFCSTATUS 22025d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyphHciNfc_Disconnect_Sequence( 22035d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_sContext_t *psHciContext, 22045d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly void *pHwRef 22055d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ) 22065d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly{ 22075d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS status = NFCSTATUS_SUCCESS; 22086dd948323de0f31b413c9f19a905f1c145c9c456Rob von Behren static phNfc_sCompletionInfo_t comp_info = {FALSE, 0 , NULL}; 22095d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHal_eRemDevType_t target_type = phHal_eUnknown_DevType; 22105d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uint8_t re_poll = 0; 22115d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 22125d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if( NULL != psHciContext->p_target_info ) 22135d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 22145d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 22155d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly target_type = psHciContext->p_target_info->RemDevType; 22165d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly switch(psHciContext->hci_seq) 22175d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 22185d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case READER_UICC_DISPATCH_SEQ: 22195d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 22205d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = phHciNfc_ReaderMgmt_UICC_Dispatch( 22215d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext, pHwRef, target_type ); 22225d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->hci_seq = READER_DESELECT_SEQ; 22235d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NFCSTATUS_PENDING == status) 22245d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 22255d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 22265d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 22275d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 22285d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* fall through */ 22295d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case READER_DESELECT_SEQ: 22305d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 22315d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly re_poll = (uint8_t) ( NULL != psHciContext->p_config_params )? 22325d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly *((uint8_t *)psHciContext->p_config_params):FALSE; 22335d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = phHciNfc_ReaderMgmt_Deselect( 22345d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext, pHwRef, target_type, re_poll); 22355d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NFCSTATUS_PENDING == status) 22365d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 22375d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->hci_seq = HCI_END_SEQ; 22385d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->p_config_params = NULL; 22395d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 22405d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 22415d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 22425d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case HCI_END_SEQ: 22435d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 22445d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Complete the Disconnect Sequence and notify the HAL */ 22455d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = phHciNfc_FSM_Complete ( psHciContext ); 22465d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Disconnect Notification to the Upper Layer */ 22475d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NFCSTATUS_SUCCESS == status) 22485d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 22495d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Invalidate the previously polled RF Reader Type */ 22505d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->host_rf_type = phHal_eUnknown_DevType; 22515d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->p_target_info = NULL; 22525d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->p_xchg_info = NULL; 22535d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly comp_info.status = status; 22545d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_Notify(psHciContext->p_upper_notify, 22555d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->p_upper_context, pHwRef, 22565d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFC_NOTIFY_TARGET_DISCONNECTED , &comp_info); 22575d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly HCI_PRINT(" HCI Remote Target De-Selected. \n"); 22585d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 22595d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 22605d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 22615d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly comp_info.status = status; 22625d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* phHciNfc_FSM_Rollback ( psHciContext ); */ 22635d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_Notify(psHciContext->p_upper_notify, 22645d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->p_upper_context, pHwRef, 22655d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFC_NOTIFY_ERROR , &comp_info); 22665d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly HCI_PRINT("HCI FSM Invalid De-Selection State \n"); 22675d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly HCI_PRINT("HCI Remote Target De-Selection Failed \n"); 22685d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 22695d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 22705d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 22715d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 22725d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly default: 22735d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 22745d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly HCI_PRINT("\t Invalid HCI Connect Sequence \n"); 22755d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* psHciContext->hci_seq = HCI_END_SEQ; */ 22765d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 22775d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 22785d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly }/* End of the Connect Sequence Switch */ 22795d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 22805d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 22815d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly return status; 22825d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly} 22835d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 22845d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 22855d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pellystatic 22865d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyNFCSTATUS 22875d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyphHciNfc_Transact_Sequence( 22885d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_sContext_t *psHciContext, 22895d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly void *pHwRef 22905d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ) 22915d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly{ 22926dd948323de0f31b413c9f19a905f1c145c9c456Rob von Behren static phNfc_sTransactionInfo_t transact_info = {FALSE,0,NULL,NULL,0}; 22935d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 22945d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pphNfcIF_Notification_CB_t p_upper_notify = psHciContext->p_upper_notify; 22955d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly void *pcontext = psHciContext->p_upper_context; 22965d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uint8_t transact_result = NFC_NOTIFY_ERROR; 22975d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 22985d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Roll Back to Connect State as Transceive is Complete */ 22995d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_FSM_Rollback(psHciContext); 23005d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 23015d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly switch (psHciContext->host_rf_type) 23025d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 23035d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case phHal_eISO14443_A_PCD: 23045d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#ifdef TYPE_B 23055d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case phHal_eISO14443_B_PCD: 23065d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif 23075d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case phHal_eISO14443_BPrime_PCD: 23085d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#ifdef TYPE_FELICA 23095d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case phHal_eFelica_PCD: 23105d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif 23115d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#ifdef TYPE_ISO15693 23125d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case phHal_eISO15693_PCD: 23135d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif 23145d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 23155d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(ZERO != psHciContext->rx_index) 23165d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 23175d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly transact_info.status = NFCSTATUS_SUCCESS; 23185d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly transact_info.buffer = 23195d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly &psHciContext->recv_buffer[psHciContext->rx_index]; 23205d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly transact_info.length = 23215d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->rx_total - psHciContext->rx_index; 23225d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly transact_result = NFC_NOTIFY_TRANSCEIVE_COMPLETED; 23235d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 23245d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 23255d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 23265d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly transact_info.status = NFCSTATUS_FAILED; 23275d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly transact_result = NFC_NOTIFY_TRANSCEIVE_ERROR; 23285d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 23295d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly HCI_PRINT(" HCI Transceive operation Completed. \n"); 23305d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->p_xchg_info = NULL ; 23315d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 23325d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 23335d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#ifdef TYPE_JEWEL 23345d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* fall through */ 23355d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case phHal_eJewel_PCD: 23365d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif 23375d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 23385d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly transact_info.status = NFCSTATUS_SUCCESS; 23395d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly transact_info.buffer = 23405d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly &psHciContext->recv_buffer[psHciContext->rx_index]; 23415d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly transact_info.length = 23425d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->rx_total - psHciContext->rx_index; 23435d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly transact_result = NFC_NOTIFY_TRANSCEIVE_COMPLETED; 23445d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly HCI_PRINT(" HCI Transceive operation Completed. \n"); 23455d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->p_xchg_info = NULL ; 23465d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 23475d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 23485d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#if defined(ENABLE_P2P) 23495d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case phHal_eNfcIP1_Initiator: 23505d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case phHal_eNfcIP1_Target: 23515d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif 23525d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 23535d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly HCI_PRINT(" HCI Send operation Completed. \n"); 23545d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly transact_info.status = NFCSTATUS_SUCCESS; 23555d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly transact_result = NFC_NOTIFY_SEND_COMPLETED; 23565d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 23575d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 23585d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case phHal_eUnknown_DevType: 23595d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly default: 23605d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 23615d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly transact_info.status = 23625d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_INVALID_PARAMETER); 23635d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 23645d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 23655d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 23665d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 23675d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Notify the Transceive Completion to the Upper layer */ 23685d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_Notify( p_upper_notify, pcontext , pHwRef, 23695d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly transact_result, &transact_info); 23705d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 23715d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly return (NFCSTATUS)NFCSTATUS_SUCCESS; 23725d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly} 23735d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 23745d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pellystatic 23755d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyNFCSTATUS 23765d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyphHciNfc_Info_Sequence( 23775d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_sContext_t *psHciContext, 23785d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly void *pHwRef 23795d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ) 23805d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly{ 23815d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS status = NFCSTATUS_SUCCESS; 23825d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 23835d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly HCI_DEBUG(" HCI: Info Sequence Entry --> Reader Type : %02X \n", 23845d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->host_rf_type); 23855d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly switch (psHciContext->host_rf_type) 23865d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 23875d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case phHal_eISO14443_A_PCD: 23885d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#ifdef TYPE_B 23895d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case phHal_eISO14443_B_PCD: 23905d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif 23915d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case phHal_eISO14443_BPrime_PCD: 23925d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#ifdef TYPE_FELICA 23935d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case phHal_eFelica_PCD: 23945d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif 23955d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#ifdef TYPE_JEWEL 23965d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case phHal_eJewel_PCD: 23975d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif 23985d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#ifdef TYPE_ISO15693 23995d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case phHal_eISO15693_PCD: 24005d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif 24015d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 24025d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* To update the select sequence to retrieve 24035d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * the target information using the reader type. 24045d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly */ 24055d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = phHciNfc_ReaderMgmt_Info_Sequence( psHciContext, pHwRef ); 24065d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 24075d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 24085d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#if defined(ENABLE_P2P) 24095d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case phHal_eNfcIP1_Initiator: 24105d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case phHal_eNfcIP1_Target: 24115d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 24125d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = phHciNfc_NfcIP_Info_Sequence( psHciContext, pHwRef ); 24135d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 24145d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 24155d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif 24165d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case phHal_eUnknown_DevType: 24175d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly default: 24185d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 24195d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = 24205d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_INVALID_PARAMETER); 24215d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 24225d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 24235d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 24245d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 24255d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly return status; 24265d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly} 24275d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 24285d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pellystatic 24295d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyNFCSTATUS 24305d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyphHciNfc_Test_Sequence( 24315d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_sContext_t *psHciContext, 24325d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly void *pHwRef, 24335d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS test_status, 24345d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uint8_t *pdata, 24355d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uint8_t length 24365d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ) 24375d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly{ 24385d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS status = NFCSTATUS_SUCCESS; 24396dd948323de0f31b413c9f19a905f1c145c9c456Rob von Behren static phNfc_sCompletionInfo_t comp_info = {0}; 24406dd948323de0f31b413c9f19a905f1c145c9c456Rob von Behren static phNfc_sData_t test_result= {NULL,0}; 24415d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 24425d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Complete the Test Sequence and notify the HAL */ 24435d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = phHciNfc_FSM_Complete ( psHciContext ); 24445d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Test Results to the Upper Layer */ 24455d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NFCSTATUS_SUCCESS == status) 24465d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 24475d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly comp_info.status = test_status; 24485d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if ( (NULL != pdata) && (length >= HCP_HEADER_LEN) ) 24495d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 24505d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly test_result.buffer = ( pdata + HCP_HEADER_LEN); 24515d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly test_result.length = length - HCP_HEADER_LEN; 24525d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 24535d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 24545d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 24555d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = phHciNfc_DevMgmt_Get_Test_Result( 24565d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext, &test_result ); 24575d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 24585d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly comp_info.info = &test_result; 24595d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_Notify(psHciContext->p_upper_notify, 24605d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->p_upper_context, pHwRef, 24615d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFC_NOTIFY_RESULT , &comp_info); 24626dd948323de0f31b413c9f19a905f1c145c9c456Rob von Behren HCI_DEBUG(" HCI System Test Completed : Status = %u\n", test_status); 24635d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 24645d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 24655d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 24665d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly comp_info.status = status; 24675d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_FSM_Rollback ( psHciContext ); 24685d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_Notify(psHciContext->p_upper_notify, 24695d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->p_upper_context, pHwRef, 24705d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFC_NOTIFY_ERROR , &comp_info); 24715d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly HCI_PRINT("HCI FSM Invalid Test State \n"); 24725d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 24735d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 24745d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly return status; 24755d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly} 24765d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 24775d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pellystatic 24785d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyNFCSTATUS 24795d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyphHciNfc_IO_Sequence( 24805d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_sContext_t *psHciContext, 24815d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly void *pHwRef, 24825d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS io_status, 24835d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uint8_t *pdata, 24845d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uint8_t length 24855d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ) 24865d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly{ 24875d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS status = NFCSTATUS_SUCCESS; 24886dd948323de0f31b413c9f19a905f1c145c9c456Rob von Behren static phNfc_sCompletionInfo_t comp_info = {0}; 24895d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 24905d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* To remove "warning (VS 4100) : unreferenced formal parameter" */ 24915d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly PHNFC_UNUSED_VARIABLE(pdata); 24925d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly PHNFC_UNUSED_VARIABLE(length); 24935d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Complete the Test Sequence and notify the HAL */ 24945d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_FSM_Rollback ( psHciContext ); 24955d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Test Results to the Upper Layer */ 24965d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly comp_info.status = io_status; 24975d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = phHciNfc_Pending_Sequence(psHciContext, pHwRef ); 24985d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NFCSTATUS_SUCCESS == io_status) 24995d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 25005d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_Notify(psHciContext->p_upper_notify, 25015d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->p_upper_context, pHwRef, 25025d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFC_IO_SUCCESS , &comp_info); 25035d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly HCI_PRINT(" HCI System IO Successful. \n"); 25045d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 25055d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 25065d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 25075d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_Notify(psHciContext->p_upper_notify, 25085d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->p_upper_context, pHwRef, 25095d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFC_IO_ERROR , &comp_info); 25105d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly HCI_PRINT("HCI IO Error \n"); 25115d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 25125d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly return status; 25135d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly} 25145d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 25155d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 25165d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 25175d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#ifdef OTHER_TAGS 25185d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 25195d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyNFCSTATUS 25205d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyphHciNfc_Activate_Sequence( 25215d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_sContext_t *psHciContext, 25225d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly void *pHwRef 25235d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ) 25245d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly{ 25255d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS status = NFCSTATUS_SUCCESS; 25265d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 25275d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly return status; 25285d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly} 25295d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 25305d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 25315d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif 25325d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 25335d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 2534