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_Generic.c * 235d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* \brief Generic HCI Source for the HCI Management. * 245d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* * 255d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* * 265d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* Project: NFC-FRI-1.1 * 275d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* * 285d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* $Date: Tue Jun 8 09:31:49 2010 $ * 295d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* $Author: ing04880 $ * 305d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* $Revision: 1.108 $ * 315d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* $Aliases: NFC_FRI1.1_WK1023_R35_1 $ 325d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* * 335d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* =========================================================================== * 345d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly*/ 355d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 365d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/* 375d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly################################################################################ 385d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly***************************** Header File Inclusion **************************** 395d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly################################################################################ 405d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly*/ 415d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 425d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#include <phNfcCompId.h> 435d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#include <phHciNfc_Sequence.h> 445d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#include <phHciNfc_Pipe.h> 455d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#include <phHciNfc_AdminMgmt.h> 465d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#include <phHciNfc_IDMgmt.h> 475d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#include <phHciNfc_LinkMgmt.h> 485d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#include <phHciNfc_PollingLoop.h> 495d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#include <phHciNfc_RFReader.h> 505d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#include <phHciNfc_RFReaderA.h> 515d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#include <phOsalNfc.h> 525d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 535d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/* 545d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly################################################################################ 555d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly****************************** Macro Definitions ******************************* 565d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly################################################################################ 575d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly*/ 585d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 5972854a2c28b99f9ab6aa60c906d5b3c1a36b04d7Martijn Coenen/* HCI timeout value */ 6072854a2c28b99f9ab6aa60c906d5b3c1a36b04d7Martijn Coenenuint32_t nxp_nfc_hci_response_timeout = NXP_NFC_HCI_TIMEOUT; 615d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 625d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/* 635d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly################################################################################ 645d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly************************ Static Variable Definitions *************************** 655d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly################################################################################ 665d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly*/ 675d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 685d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 695d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#if (NXP_NFC_HCI_TIMER == 1) 705d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 715d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#define NXP_HCI_RESPONSE_TIMEOUT (NXP_NFC_HCI_TIMEOUT) 725d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 735d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#include <phOsalNfc_Timer.h> 745d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/** \internal HCI Response Timer to detect the 755d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * Stalled HCI Response */ 765d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pellystatic uint32_t hci_resp_timer_id = NXP_INVALID_TIMER_ID; 775d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pellystatic phHciNfc_sContext_t *gpsHciContext= NULL; 785d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 795d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif /* (NXP_NFC_HCI_TIMER == 1) */ 805d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 815d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 825d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/* 835d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly################################################################################ 845d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly************************* Function Prototype Declaration *********************** 855d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly################################################################################ 865d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly*/ 875d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 885d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#if (NXP_NFC_HCI_TIMER == 1) 895d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 905d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pellystatic 915d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pellyvoid 925d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyphHciNfc_Response_Timeout ( 9334ff48f6cd6595a899e05fbd56f4c84891840d3fNick Pelly uint32_t resp_timer_id, void *pContext 945d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ); 955d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 965d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif /* (NXP_NFC_HCI_TIMER == 1) */ 975d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 985d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/** 995d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * \ingroup grp_hci_nfc 1005d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * 1015d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * The phHciNfc_Send function sends the HCI Commands to the 1025d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * corresponding peripheral device, described by the HCI Context Structure. 1035d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * 1045d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * \param[in] psContext psContext is the context of 1055d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * the HCI Layer. 1065d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * \param[in] pHwRef pHwRef is the Information of 1075d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * the Device Interface Link . 1085d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * \param[in] pdata Pointer to the buffer containing 1095d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * the command to be sent. 1105d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * \param[in] length Variable that receives 1115d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * the number of bytes actually sent. 1125d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * 1135d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * \retval NFCSTATUS_PENDING Command successfully sent. 1145d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters 1155d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * could not be interpreted properly. 1165d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * \retval Other errors Errors related to the lower layers 1175d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * 1185d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly */ 1195d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 1205d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pellystatic 1215d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS 1225d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_Send( 1235d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly void *psContext, 1245d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly void *pHwRef, 1255d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uint8_t *pdata, 1265d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#ifdef ONE_BYTE_LEN 1275d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uint8_t length 1285d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#else 1295d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uint16_t length 1305d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif 1315d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ); 1325d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 1335d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly static 1345d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS 1355d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_Process_HCP ( 1365d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_sContext_t *psHciContext, 1375d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly void *pHwRef, 1385d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly void *pdata, 1395d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#ifdef ONE_BYTE_LEN 1405d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uint8_t length 1415d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#else 1425d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uint16_t length 1435d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif 1445d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ); 1455d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 1465d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 1475d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pellystatic 1485d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyNFCSTATUS 1495d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyphHciNfc_Process_Response ( 1505d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_sContext_t *psHciContext, 1515d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly void *pHwRef, 1525d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly void *pdata, 1535d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#ifdef ONE_BYTE_LEN 1545d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uint8_t length 1555d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#else 1565d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uint16_t length 1575d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif 1585d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ); 1595d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 1605d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pellystatic 1615d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyNFCSTATUS 1625d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyphHciNfc_Error_Response ( 1635d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_sContext_t *psHciContext, 1645d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly void *pHwRef, 1655d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly void *pdata, 1665d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#ifdef ONE_BYTE_LEN 1675d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uint8_t length 1685d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#else 1695d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uint16_t length 1705d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif 1715d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ); 1725d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 1735d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pellystatic 1745d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyNFCSTATUS 1755d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyphHciNfc_Process_Event ( 1765d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_sContext_t *psHciContext, 1775d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly void *pHwRef, 1785d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly void *pdata, 1795d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#ifdef ONE_BYTE_LEN 1805d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uint8_t length 1815d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#else 1825d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uint16_t length 1835d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif 1845d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ); 1855d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 1865d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 1875d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pellystatic 1885d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyNFCSTATUS 1895d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyphHciNfc_Process_Command ( 1905d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_sContext_t *psHciContext, 1915d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly void *pHwRef, 1925d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly void *pdata, 1935d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#ifdef ONE_BYTE_LEN 1945d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uint8_t length 1955d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#else 1965d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uint16_t length 1975d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif 1985d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ); 1995d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 2005d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 2015d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pellystatic 2025d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pellyvoid 2035d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyphHciNfc_Reset_Pipe_MsgInfo( 2045d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_Pipe_Info_t *p_pipe_info 2055d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ); 2065d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 2075d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pellystatic 2085d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pellyvoid 2095d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyphHciNfc_Build_HCPMessage( 2105d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_HCP_Packet_t *hcp_packet, 2115d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uint8_t msg_type, 2125d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uint8_t instruction 2135d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ); 2145d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 2155d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pellystatic 2165d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pellyvoid 2175d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyphHciNfc_Build_HCPHeader( 2185d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_HCP_Packet_t *hcp_packet, 2195d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uint8_t chainbit, 2205d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uint8_t pipe_id 2215d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ); 2225d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/** 2235d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * \ingroup grp_hci_nfc 2245d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * 2255d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * The phHciNfc_Receive_HCP function receive the HCI Host Control Packet 2265d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * Frames from the device. 2275d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * 2285d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * \param[in] psHciContext psHciContext is the context of 2295d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * the HCI Layer. 2305d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * \param[in] pHwRef pHwRef is the Information of 2315d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * the Device Interface Link . 2325d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * \param[in] pdata Pointer to the response buffer that 2335d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * receives the response read. 2345d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * \param[in] length Variable that receives 2355d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * the number of bytes read. 2365d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * 2375d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * \retval NFCSTATUS_PENDING HCP Frame receive pending. 2385d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters 2395d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * could not be interpreted properly. 2405d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * \retval Other errors Other related errors 2415d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * 2425d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * 2435d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly */ 2445d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 2455d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 2465d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pellystatic 2475d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyNFCSTATUS 2485d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyphHciNfc_Receive_HCP ( 2495d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_sContext_t *psHciContext, 2505d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly void *pHwRef, 2515d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uint8_t *pdata, 2525d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#ifdef ONE_BYTE_LEN 2535d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uint8_t length 2545d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#else 2555d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uint16_t length 2565d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif 2575d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ); 2585d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 2595d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 2605d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/* 2615d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly################################################################################ 2625d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly***************************** Function Definitions ***************************** 2635d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly################################################################################ 2645d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly*/ 2655d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 2665d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 2675d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#if (NXP_NFC_HCI_TIMER == 1) 2685d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 2695d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pellystatic 2705d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pellyvoid 2715d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyphHciNfc_Response_Timeout ( 27234ff48f6cd6595a899e05fbd56f4c84891840d3fNick Pelly uint32_t resp_timer_id, void *pContext 2735d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ) 2745d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly{ 27534ff48f6cd6595a899e05fbd56f4c84891840d3fNick Pelly phNfc_sCompletionInfo_t comp_info = {0,0,0}; 2765d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 2775d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if ( ( NULL != gpsHciContext) 2785d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly && (resp_timer_id == hci_resp_timer_id )) 2795d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 2805d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pphNfcIF_Notification_CB_t p_upper_notify = 2815d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpsHciContext->p_upper_notify; 2825d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly void *p_upper_context = 2835d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpsHciContext->p_upper_context; 2845d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHal_sHwReference_t *pHwRef = gpsHciContext->p_hw_ref; 2855d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uint32_t i = 0; 2865d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 2875d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 2885d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly HCI_DEBUG(" HCI TIMEOUT: HCI Response Timeout Occurred in %X Timer\n" 2895d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ,resp_timer_id); 2905d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Stop the Response Timer */ 2915d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phOsalNfc_Timer_Stop( hci_resp_timer_id ); 2925d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 2935d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly comp_info.status = PHNFCSTVAL(CID_NFC_HCI, 2945d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS_BOARD_COMMUNICATION_ERROR); 2955d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Roll Back to the Select State */ 2965d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_FSM_Rollback(gpsHciContext); 2975d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 2985d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly for(i=0;i < PHHCINFC_MAX_PIPE; i++) 2995d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 3005d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_Reset_Pipe_MsgInfo(gpsHciContext->p_pipe_list[i]); 3015d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 3025d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 3035d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Notify the Error/Success Scenario to the upper layer */ 3045d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_Notify( p_upper_notify, p_upper_context, 3055d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pHwRef, (uint8_t) NFC_NOTIFY_DEVICE_ERROR, &comp_info ); 3065d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 3075d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 3085d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly return ; 3095d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 3105d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly} 3115d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 3125d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif /* (NXP_NFC_HCI_TIMER == 1) */ 3135d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 3145d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 3155d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 3165d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/*! 3175d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * \brief Allocation of the HCI Interface resources. 3185d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * 3195d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * This function releases and frees all the resources used by HCI Command and 3205d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * Response Mechanism 3215d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly */ 3225d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 3235d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS 3245d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_Allocate_Resource ( 3255d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly void **ppBuffer, 3265d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uint16_t size 3275d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ) 3285d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly{ 3295d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS status = NFCSTATUS_SUCCESS; 3305d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 3315d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly *ppBuffer = (void *) phOsalNfc_GetMemory(size); 3325d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if( *ppBuffer != NULL ) 3335d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 3345d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (void )memset(((void *)*ppBuffer), 0, 3355d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly size); 3365d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 3375d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 3385d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 3395d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly *ppBuffer = NULL; 3405d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = PHNFCSTVAL(CID_NFC_HCI, 3415d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS_INSUFFICIENT_RESOURCES); 3425d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 3435d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly return status; 3445d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly} 3455d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 3465d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 3475d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 3485d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/*! 3495d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * \brief Release of the HCI Interface resources. 3505d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * 3515d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * This function releases and frees all the resources used by HCI Command and 3525d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * Response Mechanism 3535d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly */ 3545d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly void 3555d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_Release_Resources ( 3565d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_sContext_t **ppsHciContext 3575d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ) 3585d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly{ 3595d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uint8_t i = 0; 3605d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 3615d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 3625d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#if (NXP_NFC_HCI_TIMER == 1) 3635d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 3645d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if ( NXP_INVALID_TIMER_ID != hci_resp_timer_id ) 3655d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 3665d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Stop and Un-Intialise the Response Timer */ 3675d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phOsalNfc_Timer_Stop( hci_resp_timer_id ); 3685d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phOsalNfc_Timer_Delete( hci_resp_timer_id ); 3695d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly HCI_DEBUG(" HCI : Timer %X Stopped and Released\n", 3705d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly hci_resp_timer_id); 3715d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly hci_resp_timer_id = NXP_INVALID_TIMER_ID; 3725d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 3735d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpsHciContext = NULL; 3745d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 3755d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif /* (NXP_NFC_HCI_TIMER == 1) */ 3765d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 3775d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 3785d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NULL != (*ppsHciContext)->p_admin_info) 3795d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 3805d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phOsalNfc_FreeMemory((*ppsHciContext)->p_admin_info); 3815d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (*ppsHciContext)->p_admin_info = NULL; 3825d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 3835d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NULL !=(*ppsHciContext)->p_link_mgmt_info) 3845d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 3855d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phOsalNfc_FreeMemory((*ppsHciContext)->p_link_mgmt_info); 3865d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (*ppsHciContext)->p_link_mgmt_info = NULL; 3875d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 3885d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NULL !=(*ppsHciContext)->p_identity_info) 3895d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 3905d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phOsalNfc_FreeMemory((*ppsHciContext)->p_identity_info); 3915d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (*ppsHciContext)->p_identity_info = NULL; 3925d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 3935d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NULL !=(*ppsHciContext)->p_device_mgmt_info) 3945d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 3955d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phOsalNfc_FreeMemory((*ppsHciContext)->p_device_mgmt_info); 3965d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (*ppsHciContext)->p_device_mgmt_info = NULL; 3975d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 3985d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NULL !=(*ppsHciContext)->p_reader_mgmt_info) 3995d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 4005d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phOsalNfc_FreeMemory((*ppsHciContext)->p_reader_mgmt_info); 4015d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (*ppsHciContext)->p_reader_mgmt_info = NULL; 4025d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 4035d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NULL !=(*ppsHciContext)->p_poll_loop_info) 4045d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 4055d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phOsalNfc_FreeMemory((*ppsHciContext)->p_poll_loop_info); 4065d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (*ppsHciContext)->p_poll_loop_info = NULL; 4075d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 4085d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NULL !=(*ppsHciContext)->p_reader_a_info) 4095d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 4105d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phOsalNfc_FreeMemory((*ppsHciContext)->p_reader_a_info); 4115d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (*ppsHciContext)->p_reader_a_info = NULL; 4125d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 4135d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#ifdef TYPE_B 4145d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NULL !=(*ppsHciContext)->p_reader_b_info) 4155d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 4165d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phOsalNfc_FreeMemory((*ppsHciContext)->p_reader_b_info); 4175d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (*ppsHciContext)->p_reader_b_info = NULL; 4185d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 4195d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif 4205d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#ifdef TYPE_FELICA 4215d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NULL !=(*ppsHciContext)->p_felica_info) 4225d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 4235d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phOsalNfc_FreeMemory((*ppsHciContext)->p_felica_info); 4245d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (*ppsHciContext)->p_felica_info = NULL; 4255d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 4265d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif 4275d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#ifdef TYPE_JEWEL 4285d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NULL !=(*ppsHciContext)->p_jewel_info) 4295d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 4305d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phOsalNfc_FreeMemory((*ppsHciContext)->p_jewel_info); 4315d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (*ppsHciContext)->p_jewel_info = NULL; 4325d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 4335d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif 4345d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#ifdef TYPE_ISO15693 4355d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NULL !=(*ppsHciContext)->p_iso_15693_info) 4365d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 4375d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phOsalNfc_FreeMemory((*ppsHciContext)->p_iso_15693_info); 4385d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (*ppsHciContext)->p_iso_15693_info = NULL; 4395d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 4405d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif /* #ifdef TYPE_ISO15693 */ 4415d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#ifdef ENABLE_P2P 4425d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NULL !=(*ppsHciContext)->p_nfcip_info) 4435d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 4445d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phOsalNfc_FreeMemory((*ppsHciContext)->p_nfcip_info); 4455d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (*ppsHciContext)->p_nfcip_info = NULL; 4465d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 4475d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif 4485d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NULL !=(*ppsHciContext)->p_emulation_mgmt_info) 4495d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 4505d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phOsalNfc_FreeMemory((*ppsHciContext)->p_emulation_mgmt_info); 4515d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (*ppsHciContext)->p_emulation_mgmt_info = NULL; 4525d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 4535d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NULL !=(*ppsHciContext)->p_wi_info) 4545d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 4555d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phOsalNfc_FreeMemory((*ppsHciContext)->p_wi_info); 4565d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (*ppsHciContext)->p_wi_info = NULL; 4575d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 4585d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NULL !=(*ppsHciContext)->p_swp_info) 4595d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 4605d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phOsalNfc_FreeMemory((*ppsHciContext)->p_swp_info); 4615d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (*ppsHciContext)->p_swp_info = NULL; 4625d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 4635d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NULL !=(*ppsHciContext)->p_uicc_info) 4645d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 4655d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phOsalNfc_FreeMemory((*ppsHciContext)->p_uicc_info); 4665d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (*ppsHciContext)->p_uicc_info = NULL; 4675d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 4685d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#ifdef HOST_EMULATION 4695d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NULL !=(*ppsHciContext)->p_ce_a_info) 4705d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 4715d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phOsalNfc_FreeMemory((*ppsHciContext)->p_ce_a_info); 4725d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (*ppsHciContext)->p_ce_a_info = NULL; 4735d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 4745d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NULL !=(*ppsHciContext)->p_ce_b_info) 4755d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 4765d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phOsalNfc_FreeMemory((*ppsHciContext)->p_ce_b_info); 4775d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (*ppsHciContext)->p_ce_b_info = NULL; 4785d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 4795d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif 4805d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 4815d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly for(i=0;i < PHHCINFC_MAX_PIPE; i++) 4825d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 4835d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NULL != (*ppsHciContext)->p_pipe_list[i]) 4845d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 4855d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phOsalNfc_FreeMemory((*ppsHciContext)->p_pipe_list[i]); 4865d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 4875d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 4885d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 4895d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 4905d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phOsalNfc_FreeMemory((*ppsHciContext)); 4915d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (*ppsHciContext) = NULL; 4925d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 4935d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly return ; 4945d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly} 4955d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 4965d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pellystatic 4975d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pellyvoid 4985d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyphHciNfc_Reset_Pipe_MsgInfo( 4995d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_Pipe_Info_t *p_pipe_info 5005d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ) 5015d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly{ 5025d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if (p_pipe_info != NULL) 5035d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 5045d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly p_pipe_info->sent_msg_type = HCP_MSG_TYPE_RESERVED; 5055d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly p_pipe_info->prev_msg = MSG_INSTRUCTION_UNKNWON; 5065d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly p_pipe_info->prev_status = NFCSTATUS_INVALID_HCI_INSTRUCTION; 5075d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly p_pipe_info->param_info = NULL; 5085d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly p_pipe_info->param_length = FALSE ; 5095d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 5105d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly return; 5115d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly} 5125d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 5135d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 5145d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pellyvoid 5155d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyphHciNfc_Release_Lower( 5165d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_sContext_t *psHciContext, 5175d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly void *pHwRef 5185d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ) 5195d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly{ 5205d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phNfc_sLowerIF_t *plower_if = 5215d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly &(psHciContext->lower_interface); 5225d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS status = NFCSTATUS_SUCCESS; 5235d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 5245d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly PHNFC_UNUSED_VARIABLE(status); 5255d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NULL != plower_if->release) 5265d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 5275d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = plower_if->release((void *)plower_if->pcontext, 5285d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (void *)pHwRef); 5295d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (void) memset((void *)plower_if, 0, sizeof(phNfc_sLowerIF_t)); 5305d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly HCI_DEBUG(" HCI Releasing the Lower Layer Resources: Status = %02X\n" 5315d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ,status); 5325d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 5335d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 5345d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly return; 5355d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly} 5365d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 5375d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 5385d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 5395d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/*! 5405d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * \brief Sends the HCI Commands to the corresponding peripheral device. 5415d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * 5425d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * This function sends the HCI Commands to the connected NFC Pheripheral device 5435d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly */ 5445d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly static 5455d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS 5465d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_Send ( 5475d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly void *psContext, 5485d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly void *pHwRef, 5495d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uint8_t *pdata, 5505d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#ifdef ONE_BYTE_LEN 5515d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uint8_t length 5525d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#else 5535d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uint16_t length 5545d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif 5555d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ) 5565d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly{ 5575d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_sContext_t *psHciContext= (phHciNfc_sContext_t *)psContext; 5585d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS status = NFCSTATUS_SUCCESS; 5595d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 5605d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phNfc_sLowerIF_t *plower_if = &(psHciContext->lower_interface); 5615d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 5625d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if( (NULL != plower_if) 5635d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly && (NULL != plower_if->send) 5645d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ) 5655d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 5665d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly HCI_DEBUG("HCI: In Function: %s \n", __FUNCTION__); 5675d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly HCI_DEBUG("HCI: Response Pending status --> %s \n", 5685d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (psHciContext->response_pending)?"TRUE":"FALSE"); 5695d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly HCI_PRINT_BUFFER("Send Buffer",pdata,length); 5705d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* psHciContext->hci_transact_state = NFC_TRANSACT_SEND_IN_PROGRESS; */ 5715d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 5725d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#if (NXP_NFC_HCI_TIMER == 1) 5735d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 5745d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if ( 5755d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (TRUE != psHciContext->tx_hcp_chaining) 5765d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly && (TRUE == psHciContext->response_pending) 5775d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly && ( NXP_INVALID_TIMER_ID != hci_resp_timer_id ) 5785d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ) 5795d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 5805d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Start the HCI Response Timer */ 5815d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phOsalNfc_Timer_Start( hci_resp_timer_id, 58272854a2c28b99f9ab6aa60c906d5b3c1a36b04d7Martijn Coenen nxp_nfc_hci_response_timeout, phHciNfc_Response_Timeout, NULL ); 5835d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly HCI_DEBUG(" HCI : Timer %X Started \n", hci_resp_timer_id); 5845d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 5855d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 5865d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif /* (NXP_NFC_HCI_TIMER == 1) */ 5875d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 5885d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = plower_if->send((void *)plower_if->pcontext, 5895d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (void *)pHwRef, pdata, length); 5905d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 5915d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 5925d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly return status; 5935d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly} 5945d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 5955d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 5965d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/*! 5975d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * \brief Receives the HCI Response from the corresponding peripheral device. 5985d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * 5995d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * This function receives the HCI Command Response to the connected NFC 6005d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * Pheripheral device. 6015d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly */ 6025d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 6035d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyNFCSTATUS 6045d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyphHciNfc_Receive( 6055d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly void *psContext, 6065d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly void *pHwRef, 6075d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uint8_t *pdata, 6085d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#ifdef ONE_BYTE_LEN 6095d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uint8_t length 6105d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#else 6115d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uint16_t length 6125d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif 6135d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ) 6145d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly{ 6155d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_sContext_t *psHciContext= (phHciNfc_sContext_t *)psContext; 6165d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phNfc_sLowerIF_t *plower_if = NULL ; 6175d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS status = NFCSTATUS_SUCCESS; 6185d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 6195d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NULL == psHciContext ) 6205d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 6215d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_INVALID_PARAMETER); 6225d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 6235d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 6245d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 6255d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly plower_if = &(psHciContext->lower_interface); 6265d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 6275d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if( (NULL != plower_if) 6285d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly && (NULL != plower_if->receive) 6295d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ) 6305d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 6315d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* psHciContext->hci_transact_state = NFC_TRANSACT_RECV_IN_PROGRESS; */ 6325d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = plower_if->receive((void *)plower_if->pcontext, 6335d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (void *)pHwRef, pdata, length); 6345d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 6355d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 6365d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly return status; 6375d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly} 6385d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 6395d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 6405d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/*! 6415d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * \brief Sends the HCP Packet to the lower link layer . 6425d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * 6435d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * This function Sends the HCI Data in the HCP packet format to the below 6445d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * Link layer. 6455d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly */ 6465d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 6475d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS 6485d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_Send_HCP ( 6495d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_sContext_t *psHciContext, 6505d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly void *pHwRef 6515d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ) 6525d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly{ 6535d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS status = NFCSTATUS_SUCCESS; 6545d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_HCP_Packet_t *tx_data = (phHciNfc_HCP_Packet_t *) 6555d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->send_buffer; 6565d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Skip the HCP Header Byte initially */ 6575d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uint16_t tx_length = psHciContext->tx_total - 1 ; 6585d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uint16_t hcp_index = HCP_ZERO_LEN; 6595d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uint8_t pipe_id = (uint8_t) HCI_UNKNOWN_PIPE_ID; 6605d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly static uint8_t chain_bit = HCP_CHAINBIT_DEFAULT; 6615d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 6625d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pipe_id = (uint8_t) GET_BITS8( tx_data->hcp_header, 6635d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly HCP_PIPEID_OFFSET, HCP_PIPEID_LEN); 6645d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 6655d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Fragmentation of the HCP Frames */ 6665d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if ( tx_length > PHHCINFC_MAX_PACKET_DATA ) 6675d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 6685d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly tx_data = &psHciContext->tx_packet; 6695d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (void)memset((void *)tx_data, FALSE, 6705d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly sizeof(phHciNfc_HCP_Packet_t)); 6715d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if (HCP_CHAINBIT_DEFAULT == chain_bit) 6725d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 6735d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* HCI Chaining Needs to be Done */ 6745d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->tx_remain = tx_length; 6755d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->tx_hcp_frgmnt_index = HCP_ZERO_LEN ; 6765d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly chain_bit = HCP_CHAINBIT_BEGIN; 6775d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Increment the Fragment index to skip the HCP Header */ 6785d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->tx_hcp_frgmnt_index++; 6795d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->tx_hcp_chaining = TRUE ; 6805d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly tx_length = PHHCINFC_MAX_PACKET_DATA ; 6815d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 6825d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else if ( psHciContext->tx_remain > PHHCINFC_MAX_PACKET_DATA ) 6835d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 6845d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Intermediate Chained HCI Frames */ 6855d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly tx_length = PHHCINFC_MAX_PACKET_DATA ; 6865d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 6875d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 6885d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 6895d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* End of Chaining Reached */ 6905d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly chain_bit = HCP_CHAINBIT_END; 6915d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly tx_length = psHciContext->tx_remain ; 6925d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->tx_hcp_chaining = FALSE ; 6935d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 6945d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 6955d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Build the HCP Header to have Chaining Enabled */ 6965d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_Build_HCPHeader(tx_data, chain_bit , pipe_id ); 6975d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 6985d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_Append_HCPFrame((uint8_t *)tx_data->msg.payload, hcp_index, 6995d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (&psHciContext->send_buffer[psHciContext->tx_hcp_frgmnt_index]) 7005d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly , tx_length ); 7015d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 7025d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 7035d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 7045d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* No Chaining Required */ 7055d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly chain_bit = HCP_CHAINBIT_DEFAULT; 7065d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 7075d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->tx_hcp_chaining = FALSE ; 7085d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 7095d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->tx_remain = tx_length ; 7105d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 7115d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 7125d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Include the Skipped HCP Header Byte */ 7135d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly tx_length++; 7145d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 7155d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = phHciNfc_Send ( (void *) psHciContext, pHwRef, 7165d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (uint8_t *)tx_data, tx_length ); 7175d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 7185d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly return status; 7195d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly} 7205d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 7215d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 7225d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/*! 7235d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * \brief Receives the HCP Packet from the lower link layer . 7245d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * 7255d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * This function receives the HCI Data in the HCP packet format from the below 7265d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * Link layer. 7275d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly */ 7285d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly static 7295d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS 7305d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_Receive_HCP ( 7315d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_sContext_t *psHciContext, 7325d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly void *pHwRef, 7335d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uint8_t *pdata, 7345d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#ifdef ONE_BYTE_LEN 7355d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uint8_t length 7365d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#else 7375d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uint16_t length 7385d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif 7395d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ) 7405d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly{ 7415d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS status = NFCSTATUS_SUCCESS; 7425d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_HCP_Packet_t *packet = NULL; 7435d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uint8_t chainbit = HCP_CHAINBIT_DEFAULT; 7445d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uint16_t hcp_index = 0; 7455d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 7465d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly packet = (phHciNfc_HCP_Packet_t *)pdata; 7475d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly chainbit = (uint8_t) GET_BITS8( packet->hcp_header, 7485d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly HCP_CHAINBIT_OFFSET, HCP_CHAINBIT_LEN); 7495d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly hcp_index = psHciContext->rx_hcp_frgmnt_index; 7505d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly HCI_PRINT_BUFFER("Receive Buffer",((uint8_t *)pdata),length); 7515d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if (HCP_CHAINBIT_BEGIN == chainbit) 7525d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 7535d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* pdata = (uint8_t *)&psHciContext->rx_packet; */ 7545d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* De Fragmentation of the Received HCP Frames */ 7555d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Subsequent Chaining Frames */ 7565d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if( hcp_index > 0 ) 7575d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 7585d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Copy the obtained fragment and receive the next fragment */ 7595d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_Append_HCPFrame( 7605d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->recv_buffer, hcp_index, 7615d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (uint8_t *)&pdata[HCP_MESSAGE_LEN], 7625d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (length - HCP_MESSAGE_LEN) ); 7635d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->rx_hcp_frgmnt_index =(uint16_t) 7645d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (hcp_index + length - HCP_MESSAGE_LEN); 7655d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 7665d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* First Chaining Frame*/ 7675d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 7685d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 7695d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->rx_hcp_chaining = TRUE ; 7705d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Copy the obtained fragment and receive the next fragment */ 7715d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_Append_HCPFrame(psHciContext->recv_buffer, 7725d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly hcp_index, pdata, length); 7735d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->rx_hcp_frgmnt_index = ( hcp_index + length ) ; 7745d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 7755d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 7765d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = phHciNfc_Receive ( (void *) psHciContext, pHwRef, 7775d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pdata, length); 7785d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 7795d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 7805d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 7815d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(TRUE == psHciContext->rx_hcp_chaining) 7825d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 7835d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* If the chaining was done earlier */ 7845d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->rx_hcp_chaining = FALSE ; 7855d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Copy the Remaining buffer to the RX_BUFFER */ 7865d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_Append_HCPFrame( 7875d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->recv_buffer, hcp_index, 7885d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (uint8_t *)&pdata[HCP_MESSAGE_LEN], 7895d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (length - HCP_MESSAGE_LEN) ); 7905d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* If there is chaining done the return the same data */ 7915d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->rx_total = 7925d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (hcp_index + length - HCP_MESSAGE_LEN); 7935d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->rx_hcp_frgmnt_index = FALSE ; 7945d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 7955d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 7965d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 7975d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (void) memcpy( psHciContext->recv_buffer, pdata, length); 7985d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* If there is no chaining done then return the same data */ 7995d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->rx_total = (hcp_index + length); 8005d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 8015d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 8025d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 8035d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 8045d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly return status; 8055d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly} 8065d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 8075d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 8085d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/*! 8095d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * \brief Receives the HCP Packet from the lower link layer . 8105d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * 8115d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * This function receives the HCI Data in the HCP packet format from the below 8125d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * Link layer. 8135d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly */ 8145d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 8155d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly static 8165d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS 8175d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_Process_HCP ( 8185d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_sContext_t *psHciContext, 8195d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly void *pHwRef, 8205d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly void *pdata, 8215d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#ifdef ONE_BYTE_LEN 8225d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uint8_t length 8235d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#else 8245d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uint16_t length 8255d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif 8265d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ) 8275d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly{ 8285d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_HCP_Packet_t *packet = NULL; 8295d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_HCP_Message_t *message = NULL; 8305d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS status = NFCSTATUS_SUCCESS; 8315d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uint8_t msg_type = 0; 8325d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 8335d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if( (NULL == pdata) 8345d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly || ( length < HCP_HEADER_LEN ) 8355d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ) 8365d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 8375d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_INVALID_PARAMETER); 8385d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 8395d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 8405d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 8415d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = phHciNfc_Receive_HCP( psHciContext, pHwRef, pdata, length ); 8425d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly }/* End of the Valid Data Handling */ 8435d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 8445d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if( NFCSTATUS_SUCCESS == status ) 8455d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 8465d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly packet = (phHciNfc_HCP_Packet_t *)psHciContext->recv_buffer; 8475d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly length = 8485d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#ifdef ONE_BYTE_LEN 8495d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (uint8_t) 8505d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif 8515d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->rx_total ; 8525d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly message = &packet->msg.message; 8535d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* HCI_PRINT_BUFFER("Total Receive Buffer",((uint8_t *)pdata),length); */ 8545d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly msg_type = (uint8_t) GET_BITS8( message->msg_header, 8555d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly HCP_MSG_TYPE_OFFSET, HCP_MSG_TYPE_LEN); 8565d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly switch ( msg_type ) 8575d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 8585d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case HCP_MSG_TYPE_RESPONSE: 8595d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 8605d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = phHciNfc_Process_Response( psHciContext, 8615d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pHwRef, (void *)packet, length ); 8625d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 8635d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 8645d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case HCP_MSG_TYPE_EVENT: 8655d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 8665d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = phHciNfc_Process_Event( psHciContext, 8675d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pHwRef,(void *)packet, length ); 8685d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 8695d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 8705d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case HCP_MSG_TYPE_COMMAND: 8715d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 8725d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 8735d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = phHciNfc_Process_Command( psHciContext, 8745d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pHwRef, (void *)packet, length ); 8755d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 8765d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 8775d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* case HCP_MSG_TYPE_RESERVED: */ 8785d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly default: 8795d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 8805d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_INVALID_HCI_RESPONSE); 8815d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 8825d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 8835d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 8845d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly }/* End of Receive HCP Status */ 8855d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly return status; 8865d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly} 8875d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 8885d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 8895d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly static 8905d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS 8915d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_Process_Response ( 8925d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_sContext_t *psHciContext, 8935d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly void *pHwRef, 8945d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly void *pdata, 8955d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#ifdef ONE_BYTE_LEN 8965d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uint8_t length 8975d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#else 8985d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uint16_t length 8995d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif 9005d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ) 9015d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly{ 9025d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_HCP_Packet_t *packet = NULL; 9035d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_HCP_Message_t *message = NULL; 9045d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uint8_t instruction=0; 9055d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uint8_t pipe_id = (uint8_t)HCI_UNKNOWN_PIPE_ID; 9065d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_Pipe_Info_t *p_pipe_info = NULL; 9075d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 9085d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS status = NFCSTATUS_SUCCESS; 9095d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 9105d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly packet = (phHciNfc_HCP_Packet_t *)pdata; 9115d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly message = &packet->msg.message; 9125d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Get the instruction bits from the Message Header */ 9135d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly instruction = (uint8_t) GET_BITS8( message->msg_header, 9145d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly HCP_MSG_INSTRUCTION_OFFSET, HCP_MSG_INSTRUCTION_LEN); 9155d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Get the Pipe ID from the HCP Header */ 9165d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pipe_id = (uint8_t) GET_BITS8( packet->hcp_header, 9175d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly HCP_PIPEID_OFFSET, HCP_PIPEID_LEN); 9185d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 9195d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#if (NXP_NFC_HCI_TIMER == 1) 9205d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 9215d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if ( NXP_INVALID_TIMER_ID != hci_resp_timer_id ) 9225d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 9235d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Stop the HCI Response Timer */ 9245d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly HCI_DEBUG(" HCI : Timer %X Stopped \n", hci_resp_timer_id); 9255d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phOsalNfc_Timer_Stop( hci_resp_timer_id ); 9265d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 9275d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 9285d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif /* (NXP_NFC_HCI_TIMER == 1) */ 9295d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 9305d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if (pipe_id >= PHHCINFC_MAX_PIPE ) 9315d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 9325d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_INVALID_HCI_INFORMATION); 9335d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 9345d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else if( ((uint8_t) ANY_OK != instruction) 9355d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly && ( (pipe_id != PIPETYPE_STATIC_ADMIN ) 9365d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly && ( ADM_CLEAR_ALL_PIPE != (psHciContext->p_pipe_list[pipe_id])->prev_msg )) 9375d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ) 9385d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 9395d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = phHciNfc_Error_Response( psHciContext, pHwRef, pdata, length ); 9405d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 9415d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 9425d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 9435d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly p_pipe_info = psHciContext->p_pipe_list[pipe_id]; 9445d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if( ( NULL != p_pipe_info ) 9455d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly && ( HCP_MSG_TYPE_COMMAND == p_pipe_info->sent_msg_type ) 9465d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly && ( NULL != p_pipe_info->recv_resp ) 9475d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ) 9485d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 9495d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = psHciContext->p_pipe_list[pipe_id]->recv_resp( psHciContext, 9505d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pHwRef, pdata, length ); 9515d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 9525d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 9535d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 9545d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_FEATURE_NOT_SUPPORTED); 9555d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 9565d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* There is no Pending Response */ 9575d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->response_pending = FALSE ; 9585d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly HCI_DEBUG("HCI: Response Pending status --> FALSE, %s \n", 9595d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly __FUNCTION__); 9605d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if( NFCSTATUS_SUCCESS == status ) 9615d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 9625d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_Reset_Pipe_MsgInfo(psHciContext->p_pipe_list[pipe_id]); 9635d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = phHciNfc_Resume_Sequence(psHciContext, pHwRef); 9645d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 9655d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly }/* End of Success Status validation */ 9665d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 9675d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 9685d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly HCI_DEBUG("HCI: Status --> %X \n", status ); 9695d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 9705d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 9715d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } /* End of the Valid Response handling */ 9725d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly return status; 9735d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly} 9745d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 9755d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 9765d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pellystatic 9775d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS 9785d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_Error_Response ( 9795d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_sContext_t *psHciContext, 9805d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly void *pHwRef, 9815d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly void *pdata, 9825d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#ifdef ONE_BYTE_LEN 9835d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uint8_t length 9845d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#else 9855d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uint16_t length 9865d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif 9875d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ) 9885d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly{ 9895d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 9905d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_HCP_Packet_t *packet = (phHciNfc_HCP_Packet_t *)pdata; 9915d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_HCP_Message_t *message = &packet->msg.message; 9925d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS status = NFCSTATUS_SUCCESS; 9935d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uint8_t pipe_id = (uint8_t)HCI_UNKNOWN_PIPE_ID; 9945d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#if defined(HCI_TRACE) || defined (ERROR_INSTRUCTION) 9955d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uint8_t instruction = 0; 9965d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly instruction = (uint8_t) GET_BITS8(message->msg_header, 9975d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly HCP_MSG_INSTRUCTION_OFFSET, HCP_MSG_INSTRUCTION_LEN); 9985d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif 9995d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 10005d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Get the Pipe ID from the HCP Header */ 10015d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pipe_id = (uint8_t) GET_BITS8( packet->hcp_header, 10025d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly HCP_PIPEID_OFFSET, HCP_PIPEID_LEN); 10035d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Process the Error Response based on the obtained instruction */ 10045d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#ifdef ERROR_INSTRUCTION 10055d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly switch(instruction) 10065d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 10075d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case ANY_E_NOT_CONNECTED: 10085d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case ANY_E_CMD_PAR_UNKNOWN: 10095d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case ANY_E_NOK: 10105d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case ANY_E_PIPES_FULL: 10115d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case ANY_E_REG_PAR_UNKNOWN: 10125d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case ANY_E_PIPE_NOT_OPENED: 10135d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case ANY_E_CMD_NOT_SUPPORTED: 10145d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case ANY_E_TIMEOUT: 10155d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case ANY_E_REG_ACCESS_DENIED: 10165d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case ANY_E_PIPE_ACCESS_DENIED: 10175d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 10185d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Receive Error Notification to the Upper Layer */ 10195d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = PHNFCSTVAL( CID_NFC_HCI, \ 10205d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly message->msg_header); 10215d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_Error_Sequence(psHciContext, pHwRef, status , pdata, length ); 10225d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Return Success as the Error Sequence is already handled */ 10235d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->response_pending = FALSE ; 10245d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly HCI_DEBUG("HCI: Response Pending status --> FALSE, %s \n", 10255d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly __FUNCTION__); 10265d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = NFCSTATUS_SUCCESS; 10275d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 10285d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 10295d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* The Statement should not reach this case */ 10305d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* case ANY_OK: */ 10315d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly default: 10325d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 10335d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_INVALID_HCI_RESPONSE); */ 10345d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 10355d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 10365d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 10375d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#else 10385d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = PHNFCSTVAL( CID_NFC_HCI, message->msg_header); 10395d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly HCI_DEBUG("HCI Error Response(%u) from the Device \n", instruction); 10405d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->response_pending = FALSE ; 10415d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly HCI_DEBUG("HCI: Response Pending status --> FALSE, %s \n", 10425d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly __FUNCTION__); 10435d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_Reset_Pipe_MsgInfo(psHciContext->p_pipe_list[pipe_id]); 10445d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_Error_Sequence(psHciContext, pHwRef, status , pdata, (uint8_t) length ); 10455d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Return Success as the Error Sequence is already handled */ 10465d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = NFCSTATUS_SUCCESS; 10475d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif 10485d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 10495d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly return status; 10505d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly} 10515d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 10525d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 10535d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pellystatic 10545d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS 10555d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_Process_Event ( 10565d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_sContext_t *psHciContext, 10575d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly void *pHwRef, 10585d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly void *pdata, 10595d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#ifdef ONE_BYTE_LEN 10605d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uint8_t length 10615d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#else 10625d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uint16_t length 10635d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif 10645d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ) 10655d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly{ 10665d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_HCP_Packet_t *packet = NULL; 10675d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_HCP_Message_t *message = NULL; 10685d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_Pipe_Info_t *p_pipe_info = NULL; 10695d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uint8_t instruction=0; 10705d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uint8_t pipe_id = (uint8_t)HCI_UNKNOWN_PIPE_ID; 10715d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 10725d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS status = NFCSTATUS_SUCCESS; 10735d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 10745d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly packet = (phHciNfc_HCP_Packet_t *)pdata; 10755d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly message = &packet->msg.message; 10765d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Get the instruction bits from the Message Header */ 10775d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly PHNFC_UNUSED_VARIABLE(instruction); 10785d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly instruction = (uint8_t) GET_BITS8( message->msg_header, 10795d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly HCP_MSG_INSTRUCTION_OFFSET, HCP_MSG_INSTRUCTION_LEN); 10805d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Get the Pipe ID from the HCP Header */ 10815d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pipe_id = (uint8_t) GET_BITS8( packet->hcp_header, 10825d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly HCP_PIPEID_OFFSET, HCP_PIPEID_LEN); 10835d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 10845d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if (pipe_id >= PHHCINFC_MAX_PIPE ) 10855d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 10865d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_INVALID_HCI_INFORMATION); 10875d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 10885d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 10895d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 10905d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly p_pipe_info = psHciContext->p_pipe_list[pipe_id]; 10915d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 10925d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 10935d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if( (p_pipe_info != NULL ) ) 10945d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 10955d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if( NULL != p_pipe_info->recv_event) 10965d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 10975d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = p_pipe_info->recv_event( psHciContext, pHwRef, 10985d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pdata, length ); 10995d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 11005d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 11015d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 11025d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly HCI_DEBUG(" Event Handling Not Supported by the #%u Pipe \n", 11035d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pipe_id); 11045d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = PHNFCSTVAL(CID_NFC_HCI, 11055d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS_FEATURE_NOT_SUPPORTED); 11065d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 11075d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 11085d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 11095d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 11105d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_FEATURE_NOT_SUPPORTED); 11115d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 11125d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 11135d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly HCI_DEBUG("HCI: In Function: %s \n", 11145d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly __FUNCTION__); 11155d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly HCI_DEBUG("HCI: Response Pending status --> %s \n", 11165d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (psHciContext->response_pending)?"TRUE":"FALSE"); 11175d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly HCI_DEBUG("HCI: Event Pending status --> %s \n", 11185d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (psHciContext->event_pending)?"TRUE":"FALSE"); 11195d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 11205d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if ((TRUE == psHciContext->response_pending) 11215d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly || (TRUE == psHciContext->event_pending)) 11225d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 11235d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (void)memset(psHciContext->recv_buffer, 11245d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly FALSE, PHHCINFC_MAX_BUFFERSIZE); 11255d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (void)memset((void *)&psHciContext->rx_packet, 11265d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly FALSE, sizeof(phHciNfc_HCP_Packet_t)); 11275d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 11285d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Reset the Received Data Index */ 11295d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->rx_index = ZERO; 11305d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Reset the size of the total response data received */ 11315d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->rx_total = ZERO; 11325d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 11335d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* psHciContext->hci_transact_state = NFC_TRANSACT_SEND_COMPLETE;*/ 11345d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Receive the Response Packet */ 11355d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 11365d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = phHciNfc_Receive( psHciContext, pHwRef, 11375d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (uint8_t *)(&psHciContext->rx_packet), 11385d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly sizeof(phHciNfc_HCP_Packet_t) ); 11395d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 11405d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* HCI_DEBUG("HCI Lower Layer Send Completion After Receive,\ 11415d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly Status = %02X\n",status); */ 11425d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 11435d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 11445d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 11455d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if( 11465d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/* #define EVENT_NOTIFY */ 11475d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#ifndef EVENT_NOTIFY 11485d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ( NFCSTATUS_SUCCESS == status ) 11495d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly || ( NFCSTATUS_RF_TIMEOUT == status ) 115034ff48f6cd6595a899e05fbd56f4c84891840d3fNick Pelly || (( NFCSTATUS_MORE_INFORMATION == status ) 11515d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#else 115234ff48f6cd6595a899e05fbd56f4c84891840d3fNick Pelly ((FALSE == psHciContext->event_pending ) 11535d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif 115434ff48f6cd6595a899e05fbd56f4c84891840d3fNick Pelly && ( pipe_id <= PHHCINFC_MAX_PIPE )) 11555d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ) 11565d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 11575d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* phHciNfc_Reset_Pipe_MsgInfo(psHciContext->p_pipe_list[pipe_id]); */ 11585d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = phHciNfc_Resume_Sequence(psHciContext, pHwRef); 11595d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 11605d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly }/* End of Success Status validation */ 11615d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 11625d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 11635d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly HCI_DEBUG(" HCI: Pipe-ID --> %02X \n", pipe_id); 11645d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly HCI_DEBUG(" HCI: PROCESS EVENT - Pending/Invalid Status : %X\n", status); 11655d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 11665d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 11675d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 11685d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly return status; 11695d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly} 11705d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 11715d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pellystatic 11725d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS 11735d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_Process_Command ( 11745d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_sContext_t *psHciContext, 11755d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly void *pHwRef, 11765d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly void *pdata, 11775d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#ifdef ONE_BYTE_LEN 11785d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uint8_t length 11795d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#else 11805d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uint16_t length 11815d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif 11825d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ) 11835d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly{ 11845d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_HCP_Packet_t *packet = NULL; 11855d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_HCP_Message_t *message = NULL; 11865d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_Pipe_Info_t *p_pipe_info = NULL; 11875d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uint8_t instruction=0; 11885d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uint8_t pipe_id = (uint8_t)HCI_UNKNOWN_PIPE_ID; 11895d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 11905d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS status = NFCSTATUS_SUCCESS; 11915d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 11925d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly packet = (phHciNfc_HCP_Packet_t *)pdata; 11935d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly message = &packet->msg.message; 11945d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Get the instruction bits from the Message Header */ 11955d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly PHNFC_UNUSED_VARIABLE(instruction); 11965d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 11975d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly instruction = (uint8_t) GET_BITS8( message->msg_header, 11985d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly HCP_MSG_INSTRUCTION_OFFSET, HCP_MSG_INSTRUCTION_LEN); 11995d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Get the Pipe ID from the HCP Header */ 12005d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pipe_id = (uint8_t) GET_BITS8( packet->hcp_header, 12015d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly HCP_PIPEID_OFFSET, HCP_PIPEID_LEN); 12025d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if (pipe_id >= PHHCINFC_MAX_PIPE ) 12035d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 12045d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_INVALID_HCI_INFORMATION); 12055d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 12065d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 12075d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 12085d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly p_pipe_info = psHciContext->p_pipe_list[pipe_id]; 12095d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 12105d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 12115d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if( (p_pipe_info != NULL ) 12125d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ) 12135d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 12145d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if( NULL != p_pipe_info->recv_cmd) 12155d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 12165d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = p_pipe_info->recv_cmd( psHciContext, pHwRef, 12175d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pdata, length ); 12185d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 12195d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 12205d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 12215d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly HCI_DEBUG(" Command Handling Not Supported by the #%u Pipe \n", 12225d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pipe_id); 12235d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = PHNFCSTVAL(CID_NFC_HCI, 12245d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS_FEATURE_NOT_SUPPORTED); 12255d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 12265d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 12275d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 12285d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 12295d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_FEATURE_NOT_SUPPORTED); 12305d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 12315d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 12325d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly HCI_DEBUG("HCI: In Function: %s \n", __FUNCTION__); 12335d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly HCI_DEBUG("HCI: Response Pending status --> %s \n", 12345d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (psHciContext->response_pending)?"TRUE":"FALSE"); 12355d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 12365d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(( NFCSTATUS_SUCCESS == status ) 12375d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly && (TRUE != psHciContext->response_pending) 12385d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ) 12395d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 12405d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Reset the Pipe Information Stored in the particular Pipe */ 12415d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* phHciNfc_Reset_Pipe_MsgInfo(psHciContext->p_pipe_list[pipe_id]); */ 12425d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Resume the Execution Sequence */ 12435d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = phHciNfc_Resume_Sequence(psHciContext, pHwRef); 12445d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 12455d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly }/* End of Success Status validation */ 12465d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 12475d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly return status; 12485d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly} 12495d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 12505d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 12515d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pellystatic 12525d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pellyvoid 12535d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyphHciNfc_Build_HCPMessage( 12545d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_HCP_Packet_t *hcp_packet, 12555d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uint8_t msg_type, 12565d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uint8_t instruction 12575d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ) 12585d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly{ 12595d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_HCP_Message_t *hcp_message = NULL; 12605d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 12615d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly hcp_message = &(hcp_packet->msg.message); 12625d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Set the type to the provided message type in the HCP Message Header */ 12635d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly hcp_message->msg_header = (uint8_t) SET_BITS8(hcp_message->msg_header,HCP_MSG_TYPE_OFFSET, 12645d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly HCP_MSG_TYPE_LEN, msg_type); 12655d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Set the instruction to the kind of instruction in the HCP Message Header */ 12665d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly hcp_message->msg_header = (uint8_t) SET_BITS8(hcp_message->msg_header,HCP_MSG_INSTRUCTION_OFFSET, 12675d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly HCP_MSG_INSTRUCTION_LEN, instruction); 12685d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* hcp_message->msg_header = hcp_message->msg_header | temp ; */ 12695d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 12705d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly} 12715d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 12725d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 12735d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pellystatic 12745d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pellyvoid 12755d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyphHciNfc_Build_HCPHeader( 12765d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_HCP_Packet_t *hcp_packet, 12775d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uint8_t chainbit, 12785d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uint8_t pipe_id 12795d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ) 12805d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly{ 12815d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Set the Chaining bit to the default type */ 12825d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly hcp_packet->hcp_header = (uint8_t) SET_BITS8(hcp_packet->hcp_header, 12835d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly HCP_CHAINBIT_OFFSET, HCP_CHAINBIT_LEN, chainbit); 12845d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Populate the Pipe ID to the HCP Header */ 12855d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly hcp_packet->hcp_header = (uint8_t) SET_BITS8(hcp_packet->hcp_header,HCP_PIPEID_OFFSET, 12865d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly HCP_PIPEID_LEN, pipe_id); 12875d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 12885d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly} 12895d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 12905d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/*! 12915d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * \brief Builds the HCP Frame Packet. 12925d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * 12935d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * This function builds the HCP Frame in the HCP packet format to send to the 12945d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * connected reader device. 12955d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly */ 12965d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 12975d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pellyvoid 12985d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_Build_HCPFrame ( 12995d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_HCP_Packet_t *hcp_packet, 13005d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uint8_t chainbit, 13015d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uint8_t pipe_id, 13025d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uint8_t msg_type, 13035d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uint8_t instruction 13045d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ) 13055d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly{ 13065d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Fills the HCP Header in the packet */ 13075d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_Build_HCPHeader( hcp_packet,chainbit,pipe_id ); 13085d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Fills the HCP Message in the packet */ 13095d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_Build_HCPMessage( hcp_packet,msg_type,instruction ); 13105d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly} 13115d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 13125d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/*! 13135d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * \brief Appends the HCP Frame Packet. 13145d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * 13155d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * This function Appends the HCP Frame of the HCP packet to complete the 13165d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * entire HCP Packet. 13175d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly */ 13185d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 13195d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pellyvoid 13205d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_Append_HCPFrame ( 13215d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/* phHciNfc_sContext_t *psHciContext, */ 13225d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uint8_t *hcp_data, 13235d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uint16_t hcp_index, 13245d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uint8_t *src_data, 13255d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uint16_t src_len 13265d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ) 13275d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly{ 13285d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uint16_t src_index = 0; 13295d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if( (NULL != src_data) 13305d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* && (hcp_index >= 0) */ 13315d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly && (src_len > 0) 13325d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ) 13335d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 13345d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly for(src_index=0; src_index < src_len ; src_index++) 13355d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 13365d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly hcp_data[hcp_index + src_index] = src_data[src_index]; 13375d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 13385d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 13395d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly return; 13405d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly} 13415d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 13425d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 13435d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/*! 13445d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * \brief Sends the Generic HCI Commands to the connected reader device. 13455d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * 13465d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * This function Sends the Generic HCI Command frames in the HCP packet format to the 13475d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * connected reader device. 13485d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly */ 13495d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 13505d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS 13515d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_Send_Generic_Cmd ( 13525d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_sContext_t *psHciContext, 13535d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly void *pHwRef, 13545d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uint8_t pipe_id, 13555d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uint8_t cmd 13565d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ) 13575d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 13585d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_HCP_Packet_t *hcp_packet = NULL; 13595d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_HCP_Message_t *hcp_message = NULL; 13605d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_Pipe_Info_t *p_pipe_info = NULL; 13615d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uint16_t length = 0; 13625d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uint16_t i=0; 13635d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS status = NFCSTATUS_SUCCESS; 13645d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 13655d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if((NULL == psHciContext) 13665d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly || ( pipe_id > PHHCINFC_MAX_PIPE) 13675d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ||(NULL == psHciContext->p_pipe_list[pipe_id]) 13685d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ) 13695d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 13705d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_INVALID_PARAMETER); 13715d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly HCI_DEBUG("%s: Invalid Arguments passed \n", 13725d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly "phHciNfc_Send_Generic_Cmd"); 13735d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 13745d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 13755d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 13765d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly p_pipe_info = (phHciNfc_Pipe_Info_t *) 13775d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->p_pipe_list[pipe_id]; 13785d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->tx_total = 0 ; 13795d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly length += HCP_HEADER_LEN ; 13805d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly switch( cmd ) 13815d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 13825d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case ANY_SET_PARAMETER: 13835d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 13845d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 13855d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly hcp_packet = (phHciNfc_HCP_Packet_t *) psHciContext->send_buffer; 13865d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Construct the HCP Frame */ 13875d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_Build_HCPFrame(hcp_packet,HCP_CHAINBIT_DEFAULT, 13885d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (uint8_t) pipe_id, HCP_MSG_TYPE_COMMAND, cmd); 13895d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly hcp_message = &(hcp_packet->msg.message); 13905d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly hcp_message->payload[i++] = p_pipe_info->reg_index ; 13915d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_Append_HCPFrame((uint8_t *)hcp_message->payload, 13925d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly i, (uint8_t *)p_pipe_info->param_info, 13935d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly p_pipe_info->param_length); 13945d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly length =(uint16_t)(length + i + p_pipe_info->param_length); 13955d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 13965d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 13975d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case ANY_GET_PARAMETER: 13985d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 13995d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 14005d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly hcp_packet = (phHciNfc_HCP_Packet_t *) psHciContext->send_buffer; 14015d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Construct the HCP Frame */ 14025d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_Build_HCPFrame(hcp_packet,HCP_CHAINBIT_DEFAULT, 14035d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (uint8_t) pipe_id, HCP_MSG_TYPE_COMMAND, cmd); 14045d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly hcp_message = &(hcp_packet->msg.message); 14055d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly hcp_message->payload[i++] = p_pipe_info->reg_index ; 14065d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly length =(uint16_t)(length + i); 14075d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 14085d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 14095d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case ANY_OPEN_PIPE: 14105d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case ANY_CLOSE_PIPE: 14115d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 14125d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 14135d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly hcp_packet = (phHciNfc_HCP_Packet_t *) psHciContext->send_buffer; 14145d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Construct the HCP Frame */ 14155d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_Build_HCPFrame(hcp_packet,HCP_CHAINBIT_DEFAULT, 14165d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (uint8_t) pipe_id, HCP_MSG_TYPE_COMMAND, cmd); 14175d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 14185d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 14195d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly default: 14205d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 14215d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = PHNFCSTVAL( CID_NFC_HCI, NFCSTATUS_FEATURE_NOT_SUPPORTED ); 14225d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly HCI_DEBUG("%s: Statement Should Not Occur \n","phHciNfc_Send_Generic_Cmd"); 14235d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 14245d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 14255d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 14265d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if( NFCSTATUS_SUCCESS == status ) 14275d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 14285d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly p_pipe_info->sent_msg_type = HCP_MSG_TYPE_COMMAND; 14295d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly p_pipe_info->prev_msg = cmd; 14305d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->tx_total = length; 14315d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->response_pending = TRUE ; 14325d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Send the Constructed HCP packet to the lower layer */ 14335d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = phHciNfc_Send_HCP( psHciContext, pHwRef ); 14345d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly p_pipe_info->prev_status = NFCSTATUS_PENDING; 14355d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 14365d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 14375d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 14385d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly return status; 14395d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly} 14405d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 14415d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 14425d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/*! 14435d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * \brief Sets the parameter of the registers in a particular Pipe. 14445d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * 14455d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * This function configures the registers in a particular Pipe. 14465d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly */ 14475d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 14485d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyNFCSTATUS 14495d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyphHciNfc_Set_Param ( 14505d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_sContext_t *psHciContext, 14515d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly void *pHwRef, 14525d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_Pipe_Info_t *p_pipe_info, 14535d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uint8_t reg_index, 14545d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly void *p_param, 14555d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uint16_t param_length 14565d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ) 14575d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 14585d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS status = NFCSTATUS_SUCCESS ; 14595d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 14605d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if( (NULL == p_pipe_info) 14615d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly || (NULL == p_param) 14625d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly || (0 == param_length) 14635d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ) 14645d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 14655d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = PHNFCSTVAL( CID_NFC_HCI, NFCSTATUS_INVALID_HCI_INFORMATION ); 14665d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 14675d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 14685d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 14695d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly p_pipe_info->param_info = (uint8_t *)p_param; 14705d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly p_pipe_info->param_length = param_length; 14715d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly p_pipe_info->reg_index = reg_index; 14725d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = phHciNfc_Send_Generic_Cmd( psHciContext, pHwRef, 14735d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (uint8_t)p_pipe_info->pipe.pipe_id, 14745d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (uint8_t)ANY_SET_PARAMETER); 14755d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly p_pipe_info->prev_status = status; 14765d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 14775d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 14785d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly return status; 14795d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 14805d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 14815d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 14825d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#if 0 14835d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /*! 14845d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * \brief Gets the parameter of the registers in a particular Pipe. 14855d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * 14865d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * This function configures the registers in a particular Pipe. 14875d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly */ 14885d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 14895d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS 14905d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_Get_Param ( 14915d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_sContext_t *psHciContext, 14925d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly void *pHwRef, 14935d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_Pipe_Info_t *p_pipe_info, 14945d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uint8_t reg_index, 14955d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ) 14965d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 14975d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS status = NFCSTATUS_SUCCESS ; 14985d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 14995d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly return status; 15005d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 15015d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif 15025d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 15035d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 15045d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pellyvoid 15055d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyphHciNfc_Send_Complete ( 15065d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly void *psContext, 15075d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly void *pHwRef, 15085d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phNfc_sTransactionInfo_t *pInfo 15095d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ) 15105d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly{ 15115d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS status = NFCSTATUS_SUCCESS ; 15125d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uint16_t length = 0; 15135d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 15145d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly HCI_PRINT("HCI Send Completion....\n"); 15155d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if ( (NULL != psContext) 15165d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly && (NULL != pInfo) 15175d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly && (NULL != pHwRef) 15185d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ) 15195d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 15205d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_sContext_t *psHciContext = (phHciNfc_sContext_t *)psContext; 15215d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = pInfo->status ; 15225d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly length = pInfo->length ; 15235d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* HCI_DEBUG("HCI Lower Layer Send Completion Before Receive,\ 15245d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly Status = %02X\n",status); */ 15255d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(status != NFCSTATUS_SUCCESS) 15265d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 15275d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Handle the Error Scenario */ 15285d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (void)memset(psHciContext->send_buffer, 15295d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly FALSE, PHHCINFC_MAX_BUFFERSIZE); 15305d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* psHciContext->hci_transact_state = NFC_TRANSACT_COMPLETE;*/ 15315d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_Error_Sequence( psHciContext, pHwRef, status, NULL, 0 ); 15325d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 15335d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 15345d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 15355d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly HCI_DEBUG("HCI Send Completion... Length = %02X\n", length); 15365d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* To complete the send complete with the send 15375d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * or receive with chaining. 15385d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly */ 15395d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if( (TRUE == psHciContext->tx_hcp_chaining) 15405d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly &&( psHciContext->tx_remain > HCP_ZERO_LEN )) 15415d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 15425d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Skip the HCP Header Byte Sent */ 15435d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->tx_remain -= length - 1; 15445d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 15455d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Skip the HCP Header Byte Sent */ 15465d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->tx_hcp_frgmnt_index += length - 1; 15475d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 15485d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Send the Remaining HCP Data Frames */ 15495d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = phHciNfc_Send_HCP( psHciContext, pHwRef ); 15505d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 15515d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly HCI_DEBUG("HCI (Chaining) Send Resume: Status = %02X\n", status); 15525d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 15535d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if( ( NFCSTATUS_SUCCESS != status ) 15545d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly && (NFCSTATUS_PENDING != status ) 15555d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ) 15565d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 15575d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_Error_Sequence( psHciContext, pHwRef, status, NULL, 0 ); 15585d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly }/* End of the Status check */ 15595d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 15605d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 15615d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 15625d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->tx_total = HCP_ZERO_LEN ; 15635d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->tx_remain = HCP_ZERO_LEN ; 15645d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->tx_hcp_frgmnt_index = HCP_ZERO_LEN ; 156534ff48f6cd6595a899e05fbd56f4c84891840d3fNick Pelly HCI_DEBUG("HCI: %s: response_pending=%s, event_pending=%s", 156634ff48f6cd6595a899e05fbd56f4c84891840d3fNick Pelly __FUNCTION__, 156734ff48f6cd6595a899e05fbd56f4c84891840d3fNick Pelly (psHciContext->response_pending)?"TRUE":"FALSE", 156834ff48f6cd6595a899e05fbd56f4c84891840d3fNick Pelly (psHciContext->event_pending)?"TRUE":"FALSE" 156934ff48f6cd6595a899e05fbd56f4c84891840d3fNick Pelly ); 15705d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if ((TRUE == psHciContext->response_pending) 15715d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly || (TRUE == psHciContext->event_pending)) 15725d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 15735d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (void) memset(psHciContext->recv_buffer, 15745d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly FALSE, PHHCINFC_MAX_BUFFERSIZE); 15755d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (void) memset((void *)&psHciContext->rx_packet, 15765d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly FALSE, sizeof(phHciNfc_HCP_Packet_t)); 15775d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 15785d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Reset the Received Data Index */ 15795d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->rx_index = ZERO; 15805d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Reset the size of the total response data received */ 15815d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->rx_total = ZERO; 15825d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 15835d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* psHciContext->hci_transact_state = NFC_TRANSACT_SEND_COMPLETE;*/ 15845d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Receive the Response Packet */ 15855d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = phHciNfc_Receive( psHciContext, pHwRef, 15865d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (uint8_t *)(&psHciContext->rx_packet), 15875d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly sizeof(phHciNfc_HCP_Packet_t) ); 15885d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 15895d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* HCI_DEBUG("HCI Lower Layer Send Completion After Receive,\ 15905d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly Status = %02X\n",status); */ 15915d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 15925d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if( ( NFCSTATUS_SUCCESS != status ) 15935d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly && (NFCSTATUS_PENDING != status ) 15945d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ) 15955d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 15965d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_Error_Sequence( psHciContext, pHwRef, status, NULL, 0 ); 15975d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly }/* End of the Status check */ 15985d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 15995d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 16005d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 16015d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = phHciNfc_Resume_Sequence(psHciContext, pHwRef ); 16025d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 16035d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 16045d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 16055d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } /* End of status != Success */ 16065d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 16075d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } /* End of Context != NULL */ 16085d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly} 16095d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 16105d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 16115d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pellyvoid 16125d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyphHciNfc_Receive_Complete ( 16135d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly void *psContext, 16145d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly void *pHwRef, 16155d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phNfc_sTransactionInfo_t *pInfo 16165d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ) 16175d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly{ 16185d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS status = NFCSTATUS_SUCCESS ; 16195d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly void *pdata = NULL ; 16205d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uint16_t length = 0 ; 16215d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 16225d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly HCI_PRINT("HCI Receive Completion....\n"); 16235d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if ( (NULL != psContext) 16245d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly && (NULL != pInfo) 16255d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly && (NULL != pHwRef) 16265d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ) 16275d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 16285d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_sContext_t *psHciContext = (phHciNfc_sContext_t *)psContext; 16295d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 16305d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = pInfo->status ; 16315d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pdata = pInfo->buffer ; 16325d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly length = pInfo->length ; 16335d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly HCI_DEBUG("HCI Lower Layer Receive Completion, Status = %02X\n",status); 16345d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if( NFCSTATUS_SUCCESS != status ) 16355d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 16365d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Handle the Error Scenario */ 16375d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* psHciContext->hci_transact_state = NFC_TRANSACT_COMPLETE; */ 16385d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_Error_Sequence(psHciContext, pHwRef, status , pdata, (uint8_t)length ); 16395d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 16405d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 16415d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 16425d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Receive the remaining Response Packet */ 16435d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* psHciContext->hci_transact_state = NFC_TRANSACT_RECV_COMPLETE; */ 16445d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = phHciNfc_Process_HCP( psHciContext, pHwRef, pdata,(uint8_t) length ); 16455d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if( ( NFCSTATUS_SUCCESS != status ) 16465d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly && (NFCSTATUS_PENDING != status ) 16475d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ) 16485d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 16495d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_Error_Sequence(psHciContext, pHwRef, status , pdata, (uint8_t) length ); 16505d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 16515d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 16525d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 16535d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly} 16545d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 16555d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pellyvoid 16565d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyphHciNfc_Notify( 16575d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pphNfcIF_Notification_CB_t p_upper_notify, 16585d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly void *p_upper_context, 16595d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly void *pHwRef, 16605d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uint8_t type, 16615d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly void *pInfo 16625d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ) 16635d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly{ 16645d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if( ( NULL != p_upper_notify) ) 16655d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 16665d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Notify the to the Upper Layer */ 16675d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (p_upper_notify)(p_upper_context, pHwRef, type, pInfo); 16685d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 16695d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 16705d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly} 16715d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 16725d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 16735d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pellyvoid 16745d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyphHciNfc_Tag_Notify( 16755d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_sContext_t *psHciContext, 16765d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly void *pHwRef, 16775d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uint8_t type, 16785d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly void *pInfo 16795d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ) 16805d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly{ 16815d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phNfc_sCompletionInfo_t *psCompInfo = 16825d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (phNfc_sCompletionInfo_t *)pInfo; 16835d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pphNfcIF_Notification_CB_t p_upper_notify = psHciContext->p_upper_notify; 16845d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly void *pcontext = psHciContext->p_upper_context; 16855d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS status = NFCSTATUS_SUCCESS; 16865d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 16875d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly switch( psHciContext->hci_state.next_state ) 16885d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 16895d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case hciState_Activate: 16905d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 16915d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Roll Back to the Select State */ 16925d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_FSM_Rollback(psHciContext); 16935d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 16945d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 16955d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case hciState_Select: 16965d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 16975d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = phHciNfc_FSM_Complete(psHciContext); 16985d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 16995d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 17005d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly default: 17015d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 17025d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Roll Back to the Select State */ 17035d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_FSM_Rollback(psHciContext); 17045d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 17055d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 17065d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 17075d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 17085d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 17095d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NFCSTATUS_SUCCESS == status ) 17105d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 17115d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Notify the Tag Events to the Upper layer */ 17125d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_Notify( p_upper_notify, pcontext , pHwRef, 17135d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly type, psCompInfo); 17145d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 17155d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 17165d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 17175d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_Error_Sequence( psHciContext, pHwRef, status, NULL, 0 ); 17185d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 17195d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly} 17205d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 17215d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 17225d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pellyvoid 17235d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyphHciNfc_Target_Select_Notify( 17245d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_sContext_t *psHciContext, 17255d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly void *pHwRef, 17265d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uint8_t type, 17275d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly void *pInfo 17285d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ) 17295d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly{ 17305d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phNfc_sCompletionInfo_t *psCompInfo = 17315d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (phNfc_sCompletionInfo_t *)pInfo; 17325d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pphNfcIF_Notification_CB_t p_upper_notify = psHciContext->p_upper_notify; 17335d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly void *pcontext = psHciContext->p_upper_context; 17345d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS status = NFCSTATUS_SUCCESS; 17355d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 17365d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly switch( psHciContext->hci_state.next_state ) 17375d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 17385d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case hciState_Listen: 17395d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 17405d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Roll Back to the Select State */ 17415d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = phHciNfc_FSM_Complete(psHciContext); 17425d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 17435d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 17445d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case hciState_Select: 17455d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 17465d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = phHciNfc_FSM_Complete(psHciContext); 17475d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 17485d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 17495d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly default: 17505d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 17515d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Roll Back to the Select State */ 17525d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_FSM_Rollback(psHciContext); 17535d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 17545d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 17555d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 17565d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 17575d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 17585d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NFCSTATUS_SUCCESS == status ) 17595d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 17605d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Notify the Tag Events to the Upper layer */ 17615d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_Notify( p_upper_notify, pcontext , pHwRef, 17625d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly type, psCompInfo); 17635d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 17645d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 17655d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 17665d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_Error_Sequence( psHciContext, pHwRef, status, NULL, 0 ); 17675d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 17685d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 17695d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly} 17705d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 17715d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 17725d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 17735d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 17745d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pellyvoid 17755d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyphHciNfc_Release_Notify( 17765d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_sContext_t *psHciContext, 17775d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly void *pHwRef, 17785d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uint8_t type, 17795d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly void *pInfo 17805d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ) 17815d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly{ 17825d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phNfc_sCompletionInfo_t *psCompInfo = 17835d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (phNfc_sCompletionInfo_t *)pInfo; 17845d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pphNfcIF_Notification_CB_t p_upper_notify = psHciContext->p_upper_notify; 17855d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly void *pcontext = psHciContext->p_upper_context; 17865d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_Release_Resources( &psHciContext ); 17875d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Notify the Failure to the Upper Layer */ 17885d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_Notify( p_upper_notify, pcontext , pHwRef, 17895d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly type, psCompInfo); 17905d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly} 17915d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 17925d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 17935d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pellyvoid 17945d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyphHciNfc_Notify_Event( 17955d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly void *psContext, 17965d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly void *pHwRef, 17975d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uint8_t type, 17985d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly void *pInfo 17995d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ) 18005d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly{ 18015d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS status = NFCSTATUS_SUCCESS; 18025d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 18035d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if ( (NULL != psContext) 18045d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly && (NULL != pInfo) 18055d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly && (NULL != pHwRef) 18065d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ) 18075d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 18085d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_sContext_t *psHciContext = (phHciNfc_sContext_t *)psContext; 18095d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 18105d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Process based on the Notification type */ 18115d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly switch(type) 18125d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 18135d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case NFC_NOTIFY_INIT_COMPLETED: 18145d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 18155d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phNfc_sCompletionInfo_t *psCompInfo = 18165d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (phNfc_sCompletionInfo_t *)pInfo; 18175d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NFCSTATUS_SUCCESS == psCompInfo->status) 18185d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 18195d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 18205d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#if (NXP_NFC_HCI_TIMER == 1) 18215d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if ( NXP_INVALID_TIMER_ID == hci_resp_timer_id ) 18225d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 18235d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Create and Intialise the Response Timer */ 18245d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly hci_resp_timer_id = phOsalNfc_Timer_Create( ); 18255d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly HCI_DEBUG(" HCI : Timer %X Created \n", 18265d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly hci_resp_timer_id); 18275d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 18285d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 18295d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 18305d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly HCI_DEBUG(" HCI : Timer Already Created, Timer ID : %X\n", 18315d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly hci_resp_timer_id); 18325d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 18335d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpsHciContext = psHciContext; 18345d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 18355d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif /* (NXP_NFC_HCI_TIMER == 1) */ 18365d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 18375d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Complete the Initialisation Sequence */ 18385d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = phHciNfc_Resume_Sequence(psContext ,pHwRef); 18395d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 18405d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 18415d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 18425d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Notify the Error Scenario to the Upper Layer */ 18435d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_Notify(psHciContext->p_upper_notify, 18445d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->p_upper_context, pHwRef, 18455d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFC_NOTIFY_ERROR, psCompInfo); 18465d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 18475d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 18485d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 18495d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case NFC_NOTIFY_INIT_FAILED: 18505d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 18515d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Notify the Failure to the Upper Layer */ 18525d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_Release_Notify( psContext,pHwRef, 18535d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly type, pInfo ); 18545d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 18555d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 18565d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case NFC_NOTIFY_RECV_COMPLETED: 18575d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 18585d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Receive Completed from the Lower Layer */ 18595d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_Receive_Complete(psContext,pHwRef,pInfo); 18605d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 18615d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 18625d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 18635d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case NFC_NOTIFY_SEND_COMPLETED: 18645d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 18655d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Receive Completed from the Lower Layer */ 18665d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_Send_Complete(psContext,pHwRef,pInfo); 18675d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 18685d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 18695d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 18705d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case NFC_NOTIFY_TRANSCEIVE_COMPLETED: 18715d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 18725d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* TODO: TO handle Both Send and Receive Complete */ 18735d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 18745d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 18755d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case NFC_NOTIFY_TARGET_DISCOVERED: 18765d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 18775d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly HCI_PRINT(" PICC Discovery ! Obtain PICC Info .... \n"); 18785d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* psHciContext->hci_seq = PL_DURATION_SEQ; */ 18795d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if ( hciState_Unknown == psHciContext->hci_state.next_state ) 18805d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 18815d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 18825d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = phHciNfc_FSM_Update ( psHciContext, hciState_Select ); 18835d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 18845d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 18855d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if (NFCSTATUS_SUCCESS != status) 18865d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 18875d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = phHciNfc_ReaderMgmt_Deselect( 18885d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext, pHwRef, phHal_eISO14443_A_PICC, FALSE); 18895d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 18905d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 18915d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 18925d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 18935d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#ifdef SW_RELEASE_TARGET 18945d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /*status = phHciNfc_ReaderMgmt_Deselect( 18955d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext, pHwRef, phHal_eISO14443_A_PICC, FALSE); */ 18965d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->target_release = TRUE; 18975d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#else 18985d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_INVALID_STATE); 18995d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif 19005d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 19015d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 19025d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 19035d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* To Notify the Target Released Notification 19045d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * to the Above Layer */ 19055d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case NFC_NOTIFY_TARGET_RELEASED: 19065d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* To Notify the NFC Secure Element Transaction 19075d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * Information to the Above Layer */ 19085d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* case NFC_NOTIFY_TRANSACTION: */ 19095d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* To Notify the Generic Events To the Upper 19105d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * Layer */ 19115d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case NFC_NOTIFY_EVENT: 19125d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* To Notify the Data Receive Notification 19135d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * to the Above Layer */ 19145d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case NFC_NOTIFY_RECV_EVENT: 19155d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 19165d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phNfc_sCompletionInfo_t *psCompInfo = 19175d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (phNfc_sCompletionInfo_t *)pInfo; 19185d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 19195d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if (((TRUE == psHciContext->event_pending) || 19205d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (NFCSTATUS_RF_TIMEOUT == psCompInfo->status)) 19215d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly && ( hciState_Transact == psHciContext->hci_state.next_state)) 19225d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 19235d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Rollback due to Transmission Error */ 19245d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_FSM_Rollback(psHciContext); 19255d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 19265d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->event_pending = FALSE; 19275d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_Notify(psHciContext->p_upper_notify, 19285d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->p_upper_context, pHwRef, 19295d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly type, pInfo); 19305d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 19315d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 19325d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case NFC_NOTIFY_DEVICE_ACTIVATED: 19335d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 19345d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly HCI_PRINT(" Device Activated! Obtaining Remote Reader Info .... \n"); 19355d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if ( hciState_Unknown == psHciContext->hci_state.next_state ) 19365d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 19375d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly switch (psHciContext->host_rf_type) 19385d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 19395d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case phHal_eISO14443_A_PCD: 19405d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case phHal_eISO14443_B_PCD: 19415d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case phHal_eISO14443_BPrime_PCD: 19425d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case phHal_eFelica_PCD: 19435d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 19445d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 19455d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 19465d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case phHal_eNfcIP1_Initiator: 19475d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case phHal_eNfcIP1_Target: 19485d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 19495d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 19505d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 19515d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case phHal_eUnknown_DevType: 19525d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly default: 19535d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 19545d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = PHNFCSTVAL(CID_NFC_HCI, 19555d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS_INVALID_PARAMETER); 19565d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 19575d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 19585d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 19595d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 19605d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = phHciNfc_FSM_Update ( psHciContext, hciState_Listen ); 19615d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 19625d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 19635d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 19645d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_INVALID_STATE); 19655d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 19665d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 19675d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 19685d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case NFC_NOTIFY_DEVICE_DEACTIVATED: 19695d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 19705d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly HCI_PRINT(" Device De-Activated! \n"); 19715d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if ( hciState_Unknown == psHciContext->hci_state.next_state ) 19725d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 19735d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = phHciNfc_FSM_Update ( psHciContext, hciState_Initialise ); 19745d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NFCSTATUS_SUCCESS == status) 19755d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 19765d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Complete to the Select State */ 19775d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = phHciNfc_FSM_Complete(psHciContext); 19785d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 19795d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 19805d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 19815d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly HCI_PRINT(" Device Deactivated.. But Invalid State \n"); 19825d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_INVALID_STATE); 19835d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 19845d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 19855d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 19865d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 19875d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = phHciNfc_ReaderMgmt_Update_Sequence( 19885d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext, INFO_SEQ ); 19895d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 19905d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(( hciState_Listen == psHciContext->hci_state.next_state) 19915d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly || (hciState_Transact == psHciContext->hci_state.next_state)) 19925d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 19935d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->hci_state.next_state = hciState_Initialise; 19945d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Roll Back to the Default State */ 19955d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = phHciNfc_FSM_Complete(psHciContext); 19965d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 19975d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 19985d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->event_pending = FALSE; 19995d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_Notify(psHciContext->p_upper_notify, 20005d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->p_upper_context, pHwRef, 20015d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFC_NOTIFY_EVENT, pInfo); 20025d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 20035d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 20045d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case NFC_NOTIFY_DEVICE_ERROR: 20055d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 20065d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phNfc_sCompletionInfo_t *psCompInfo = 20075d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (phNfc_sCompletionInfo_t *)pInfo; 20085d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 20095d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psCompInfo->status = ( NFCSTATUS_BOARD_COMMUNICATION_ERROR 20105d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly != PHNFCSTATUS(psCompInfo->status))? 20115d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS_BOARD_COMMUNICATION_ERROR: 20125d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psCompInfo->status ; 20135d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 20145d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#if (NXP_NFC_HCI_TIMER == 1) 20155d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 20165d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if ( NXP_INVALID_TIMER_ID != hci_resp_timer_id ) 20175d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 201834ff48f6cd6595a899e05fbd56f4c84891840d3fNick Pelly HCI_DEBUG(" HCI : Response Timer Stop, Status:%02X", 20195d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psCompInfo->status); 20205d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Stop and Un-Intialise the Response Timer */ 20215d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phOsalNfc_Timer_Stop( hci_resp_timer_id ); 20225d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 20235d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 20245d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif /* (NXP_NFC_HCI_TIMER == 1) */ 20255d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 20265d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_Notify(psHciContext->p_upper_notify, 20275d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->p_upper_context, pHwRef, 20285d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (uint8_t) NFC_NOTIFY_DEVICE_ERROR, pInfo); 20295d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 20305d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 20315d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 20325d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 20335d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case NFC_NOTIFY_ERROR: 20345d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly default: 20355d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 20365d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phNfc_sCompletionInfo_t *psCompInfo = 20375d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (phNfc_sCompletionInfo_t *)pInfo; 20385d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 20395d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#if (NXP_NFC_HCI_TIMER == 1) 20405d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 20415d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if (( NFCSTATUS_BOARD_COMMUNICATION_ERROR == PHNFCSTATUS(psCompInfo->status)) 20425d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly && ( NXP_INVALID_TIMER_ID != hci_resp_timer_id )) 20435d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 204434ff48f6cd6595a899e05fbd56f4c84891840d3fNick Pelly HCI_DEBUG(" HCI : Response Timer Stop, Status:%02X", 20455d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psCompInfo->status); 20465d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Stop the HCI Response Timer */ 20475d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phOsalNfc_Timer_Stop( hci_resp_timer_id ); 20485d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 20495d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 20505d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif /* (NXP_NFC_HCI_TIMER == 1) */ 20515d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 20525d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_Error_Sequence( psHciContext, pHwRef, 20535d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psCompInfo->status, NULL, 0); 20545d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 20555d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 20565d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } /* End of Switch */ 20575d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } /* End of Context != NULL */ 20585d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly} 20595d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 2060