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* \file phHciNfc_RFReaderB.c * 225d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* \brief HCI Reader B Management Routines. * 235d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* * 245d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* * 255d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* Project: NFC-FRI-1.1 * 265d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* * 275d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* $Date: Mon Aug 17 15:17:07 2009 $ * 285d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* $Author: ing04880 $ * 295d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* $Revision: 1.7 $ * 305d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* $Aliases: NFC_FRI1.1_WK934_R31_1,NFC_FRI1.1_WK941_PREP1,NFC_FRI1.1_WK941_PREP2,NFC_FRI1.1_WK941_1,NFC_FRI1.1_WK943_R32_1,NFC_FRI1.1_WK949_PREP1,NFC_FRI1.1_WK943_R32_10,NFC_FRI1.1_WK943_R32_13,NFC_FRI1.1_WK943_R32_14,NFC_FRI1.1_WK1007_R33_1,NFC_FRI1.1_WK1007_R33_4,NFC_FRI1.1_WK1017_PREP1,NFC_FRI1.1_WK1017_R34_1,NFC_FRI1.1_WK1017_R34_2,NFC_FRI1.1_WK1023_R35_1 $ 315d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* * 325d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* =========================================================================== * 335d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly*/ 345d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 355d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/* 365d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly***************************** Header File Inclusion **************************** 375d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly*/ 385d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#include <phNfcCompId.h> 395d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#include <phHciNfc_Pipe.h> 405d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#include <phHciNfc_RFReader.h> 415d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#include <phOsalNfc.h> 425d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 435d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#if defined (TYPE_B) 445d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#include <phHciNfc_RFReaderB.h> 455d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/* 465d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly****************************** Macro Definitions ******************************* 475d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly*/ 485d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 495d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#define RDR_B_SINGLE_TAG_FOUND 0x00U 505d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#define RDR_B_MULTIPLE_TAGS_FOUND 0x03U 515d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/* Commands exposed to the upper layer */ 525d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#define NXP_WRA_CONTINUE_ACTIVATION 0x12U 535d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 545d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#define RDR_B_PUPI_INDEX 0x03U 555d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#define RDR_B_APP_DATA_INDEX 0x04U 565d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#define RDR_B_AFI_INDEX 0x02U 575d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#define RDR_B_HIGHER_LAYER_RESP_INDEX 0x01U 585d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#define RDR_B_HIGHER_LAYER_DATA_INDEX 0x05U 595d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 605d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 615d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/* 625d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly*************************** Structure and Enumeration *************************** 635d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly*/ 645d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 655d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 665d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/* 675d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly*************************** Static Function Declaration ************************** 685d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly*/ 695d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 705d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pellystatic 715d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyNFCSTATUS 725d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyphHciNfc_Recv_ReaderB_Response( 735d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly void *psContext, 745d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly void *pHwRef, 755d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uint8_t *pResponse, 765d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#ifdef ONE_BYTE_LEN 775d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uint8_t length 785d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#else 795d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uint16_t length 805d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif 815d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ); 825d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 835d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pellystatic 845d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyNFCSTATUS 855d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyphHciNfc_Recv_ReaderB_Event( 865d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly void *psContext, 875d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly void *pHwRef, 885d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uint8_t *pEvent, 895d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#ifdef ONE_BYTE_LEN 905d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uint8_t length 915d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#else 925d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uint16_t length 935d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif 945d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ); 955d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 965d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pellystatic 975d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyNFCSTATUS 985d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyphHciNfc_ReaderB_InfoUpdate( 995d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_sContext_t *psHciContext, 1005d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uint8_t index, 1015d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uint8_t *reg_value, 1025d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uint8_t reg_length 1035d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ); 1045d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 1055d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pellystatic 1065d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyNFCSTATUS 1075d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyphHciNfc_Recv_Iso_B_Packet( 1085d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_sContext_t *psHciContext, 1095d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uint8_t *pResponse, 1105d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#ifdef ONE_BYTE_LEN 1115d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uint8_t length 1125d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#else 1135d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uint16_t length 1145d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif 1155d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ); 1165d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/* 1175d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly*************************** Function Definitions *************************** 1185d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly*/ 1195d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 1205d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyNFCSTATUS 1215d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyphHciNfc_ReaderB_Get_PipeID( 1225d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_sContext_t *psHciContext, 1235d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uint8_t *ppipe_id 1245d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ) 1255d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly{ 1265d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS status = NFCSTATUS_SUCCESS; 1275d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 1285d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if( (NULL != psHciContext) 1295d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly && ( NULL != ppipe_id ) 1305d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly && ( NULL != psHciContext->p_reader_b_info ) 1315d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ) 1325d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 1335d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_ReaderB_Info_t *p_rdr_b_info=NULL; 1345d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly p_rdr_b_info = (phHciNfc_ReaderB_Info_t *) 1355d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->p_reader_b_info ; 1365d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly *ppipe_id = p_rdr_b_info->pipe_id ; 1375d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 1385d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 1395d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 1405d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_INVALID_PARAMETER); 1415d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 1425d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly return status; 1435d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly} 1445d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 1455d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyNFCSTATUS 1465d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyphHciNfc_ReaderB_Init_Resources( 1475d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_sContext_t *psHciContext 1485d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ) 1495d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly{ 1505d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS status = NFCSTATUS_SUCCESS; 1515d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_ReaderB_Info_t *p_rdr_b_info=NULL; 1525d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if( NULL == psHciContext ) 1535d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 1545d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_INVALID_PARAMETER); 1555d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 1565d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 1575d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 1585d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if( 1595d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ( NULL == psHciContext->p_reader_b_info ) && 1605d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (phHciNfc_Allocate_Resource((void **)(&p_rdr_b_info), 1615d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly sizeof(phHciNfc_ReaderB_Info_t))== NFCSTATUS_SUCCESS) 1625d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ) 1635d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 1645d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->p_reader_b_info = p_rdr_b_info; 1655d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly p_rdr_b_info->current_seq = RDR_B_INVALID_SEQ; 1665d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly p_rdr_b_info->next_seq = RDR_B_INVALID_SEQ; 1675d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly p_rdr_b_info->pipe_id = (uint8_t)HCI_UNKNOWN_PIPE_ID; 1685d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 1695d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 1705d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 1715d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_INSUFFICIENT_RESOURCES); 1725d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 1735d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 1745d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 1755d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly return status; 1765d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly} 1775d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 1785d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyNFCSTATUS 1795d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyphHciNfc_ReaderB_Update_Info( 1805d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_sContext_t *psHciContext, 1815d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uint8_t infotype, 1825d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly void *rdr_b_info 1835d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ) 1845d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly{ 1855d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS status = NFCSTATUS_SUCCESS; 1865d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 1875d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if (NULL == psHciContext) 1885d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 1895d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_INVALID_PARAMETER); 1905d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 1915d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else if(NULL == psHciContext->p_reader_b_info) 1925d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 1935d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_FEATURE_NOT_SUPPORTED); 1945d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 1955d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 1965d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 1975d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_ReaderB_Info_t *ps_rdr_b_info=NULL; 1985d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ps_rdr_b_info = (phHciNfc_ReaderB_Info_t *) 1995d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->p_reader_b_info ; 2005d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 2015d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly switch(infotype) 2025d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 2035d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case HCI_READER_B_ENABLE: 2045d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 2055d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NULL != rdr_b_info) 2065d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 2075d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ps_rdr_b_info->enable_rdr_b_gate = 2085d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly *((uint8_t *)rdr_b_info); 2095d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 2105d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 2115d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 2125d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case HCI_READER_B_INFO_SEQ: 2135d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 2145d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ps_rdr_b_info->current_seq = RDR_B_PUPI; 2155d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ps_rdr_b_info->next_seq = RDR_B_PUPI; 2165d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 2175d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 2185d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly default: 2195d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 2205d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_INVALID_PARAMETER); 2215d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 2225d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 2235d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 2245d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 2255d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly return status; 2265d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly} 2275d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 2285d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 2295d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyNFCSTATUS 2305d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyphHciNfc_ReaderB_Update_PipeInfo( 2315d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_sContext_t *psHciContext, 2325d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uint8_t pipeID, 2335d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_Pipe_Info_t *pPipeInfo 2345d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ) 2355d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly{ 2365d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS status = NFCSTATUS_SUCCESS; 2375d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 2385d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if( NULL == psHciContext ) 2395d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 2405d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_INVALID_PARAMETER); 2415d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 2425d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else if(NULL == psHciContext->p_reader_b_info) 2435d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 2445d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_FEATURE_NOT_SUPPORTED); 2455d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 2465d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 2475d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 2485d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_ReaderB_Info_t *p_rdr_b_info=NULL; 2495d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly p_rdr_b_info = (phHciNfc_ReaderB_Info_t *) 2505d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->p_reader_b_info ; 2515d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Update the pipe_id of the reader B Gate obtained from the HCI Response */ 2525d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly p_rdr_b_info->pipe_id = pipeID; 2535d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly p_rdr_b_info->p_pipe_info = pPipeInfo; 2545d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Update the Response Receive routine of the reader B Gate */ 2555d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pPipeInfo->recv_resp = &phHciNfc_Recv_ReaderB_Response; 2565d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Update the event Receive routine of the reader B Gate */ 2575d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pPipeInfo->recv_event = &phHciNfc_Recv_ReaderB_Event; 2585d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 2595d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 2605d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly return status; 2615d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly} 2625d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 2635d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyNFCSTATUS 2645d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyphHciNfc_ReaderB_Info_Sequence ( 2655d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly void *psHciHandle, 2665d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly void *pHwRef 2675d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ) 2685d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly{ 2695d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS status = NFCSTATUS_SUCCESS; 2705d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_sContext_t *psHciContext = ((phHciNfc_sContext_t *)psHciHandle); 2715d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if( (NULL == psHciContext) 2725d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly || (NULL == pHwRef) 2735d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ) 2745d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 2755d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_INVALID_PARAMETER); 2765d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 2775d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else if((NULL == psHciContext->p_reader_b_info) || 2785d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (HCI_READER_B_ENABLE != 2795d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ((phHciNfc_ReaderB_Info_t *)(psHciContext->p_reader_b_info))-> 2805d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly enable_rdr_b_gate)) 2815d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 2825d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_FEATURE_NOT_SUPPORTED); 2835d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 2845d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 2855d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 2865d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_ReaderB_Info_t *p_rdr_b_info=NULL; 2875d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_Pipe_Info_t *p_pipe_info=NULL; 2885d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uint8_t pipeid = 0; 2895d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 2905d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly p_rdr_b_info = (phHciNfc_ReaderB_Info_t *) 2915d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->p_reader_b_info ; 2925d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly p_pipe_info = p_rdr_b_info->p_pipe_info; 2935d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NULL == p_pipe_info ) 2945d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 2955d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = PHNFCSTVAL(CID_NFC_HCI, 2965d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS_INVALID_HCI_SEQUENCE); 2975d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 2985d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 2995d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 3005d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly switch(p_rdr_b_info->current_seq) 3015d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 3025d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case RDR_B_PUPI: 3035d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 3045d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly p_pipe_info->reg_index = RDR_B_PUPI_INDEX; 3055d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pipeid = p_rdr_b_info->pipe_id ; 3065d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Fill the data buffer and send the command to the 3075d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly device */ 3085d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = 3095d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_Send_Generic_Cmd( psHciContext, pHwRef, 3105d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pipeid, (uint8_t)ANY_GET_PARAMETER); 3115d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NFCSTATUS_PENDING == status ) 3125d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 3135d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly p_rdr_b_info->next_seq = RDR_B_APP_DATA; 3145d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 3155d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 3165d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 3175d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case RDR_B_APP_DATA: 3185d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 3195d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly p_pipe_info->reg_index = RDR_B_APP_DATA_INDEX; 3205d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pipeid = p_rdr_b_info->pipe_id ; 3215d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Fill the data buffer and send the command to the 3225d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly device */ 3235d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = 3245d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_Send_Generic_Cmd( psHciContext, pHwRef, 3255d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pipeid, (uint8_t)ANY_GET_PARAMETER); 3265d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NFCSTATUS_PENDING == status ) 3275d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 3285d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly p_rdr_b_info->next_seq = RDR_B_AFI; 3295d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 3305d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 3315d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 3325d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case RDR_B_AFI: 3335d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 3345d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* RW to the registry */ 3355d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly p_pipe_info->reg_index = RDR_B_AFI_INDEX; 3365d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pipeid = p_rdr_b_info->pipe_id ; 3375d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Fill the data buffer and send the command to the 3385d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly device */ 3395d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = 3405d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_Send_Generic_Cmd( psHciContext, pHwRef, 3415d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pipeid, (uint8_t)ANY_GET_PARAMETER); 3425d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NFCSTATUS_PENDING == status ) 3435d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 3445d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly p_rdr_b_info->next_seq = RDR_B_HIGHER_LAYER_RESP; 3455d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 3465d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 3475d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 3485d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 3495d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case RDR_B_HIGHER_LAYER_RESP: 3505d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 3515d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly p_pipe_info->reg_index = RDR_B_HIGHER_LAYER_RESP_INDEX; 3525d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pipeid = p_rdr_b_info->pipe_id ; 3535d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Fill the data buffer and send the command to the 3545d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly device */ 3555d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = 3565d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_Send_Generic_Cmd( psHciContext, pHwRef, 3575d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pipeid, (uint8_t)ANY_GET_PARAMETER); 3585d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NFCSTATUS_PENDING == status ) 3595d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 3605d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly p_rdr_b_info->next_seq = RDR_B_HIGHER_LAYER_DATA; 3615d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 3625d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 3635d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 3645d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 3655d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case RDR_B_HIGHER_LAYER_DATA: 3665d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 3675d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* RW to the registry */ 3685d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly p_pipe_info->reg_index = RDR_B_HIGHER_LAYER_DATA_INDEX; 3695d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pipeid = p_rdr_b_info->pipe_id ; 3705d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Fill the data buffer and send the command to the 3715d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly device */ 3725d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = 3735d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_Send_Generic_Cmd( psHciContext, pHwRef, 3745d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pipeid, (uint8_t)ANY_GET_PARAMETER); 3755d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NFCSTATUS_PENDING == status ) 3765d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 3775d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly p_rdr_b_info->next_seq = RDR_B_END_SEQUENCE; 3785d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 3795d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 3805d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 3815d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case RDR_B_END_SEQUENCE: 3825d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 3835d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phNfc_sCompletionInfo_t CompInfo; 3845d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if (RDR_B_MULTIPLE_TAGS_FOUND == 3855d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly p_rdr_b_info->multiple_tgts_found) 3865d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 3875d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly CompInfo.status = NFCSTATUS_MULTIPLE_TAGS; 3885d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 3895d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 3905d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 3915d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly CompInfo.status = NFCSTATUS_SUCCESS; 3925d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 3935d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 3945d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly CompInfo.info = &(p_rdr_b_info->reader_b_info); 3955d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 3965d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly p_rdr_b_info->reader_b_info.RemDevType = phHal_eISO14443_B_PICC; 3975d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly p_rdr_b_info->current_seq = RDR_B_PUPI; 3985d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly p_rdr_b_info->next_seq = RDR_B_PUPI; 3995d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = NFCSTATUS_SUCCESS; 4005d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Notify to the upper layer */ 4015d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_Tag_Notify(psHciContext, 4025d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pHwRef, 4035d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFC_NOTIFY_TARGET_DISCOVERED, 4045d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly &CompInfo); 4055d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 4065d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 4075d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly default: 4085d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 4095d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = PHNFCSTVAL(CID_NFC_HCI, 4105d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS_INVALID_HCI_RESPONSE); 4115d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 4125d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 4135d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 4145d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 4155d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 4165d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly return status; 4175d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly} 4185d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 4195d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pellystatic 4205d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyNFCSTATUS 4215d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyphHciNfc_Recv_ReaderB_Response( 4225d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly void *psContext, 4235d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly void *pHwRef, 4245d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uint8_t *pResponse, 4255d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#ifdef ONE_BYTE_LEN 4265d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uint8_t length 4275d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#else 4285d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uint16_t length 4295d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif 4305d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ) 4315d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly{ 4325d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS status = NFCSTATUS_SUCCESS; 4335d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_sContext_t *psHciContext = 4345d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (phHciNfc_sContext_t *)psContext ; 4355d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 4365d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if( (NULL == psHciContext) || (NULL == pHwRef) || (NULL == pResponse) 4375d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly || (length == 0)) 4385d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 4395d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_INVALID_PARAMETER); 4405d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 4415d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else if(NULL == psHciContext->p_reader_b_info) 4425d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 4435d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_FEATURE_NOT_SUPPORTED); 4445d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 4455d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 4465d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 4475d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_ReaderB_Info_t *p_rdr_b_info=NULL; 4485d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uint8_t prev_cmd = ANY_GET_PARAMETER; 4495d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 4505d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly p_rdr_b_info = (phHciNfc_ReaderB_Info_t *) 4515d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->p_reader_b_info ; 4525d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if( NULL == p_rdr_b_info->p_pipe_info) 4535d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 4545d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = PHNFCSTVAL(CID_NFC_HCI, 4555d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS_INVALID_HCI_SEQUENCE); 4565d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 4575d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 4585d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 4595d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly prev_cmd = p_rdr_b_info->p_pipe_info->prev_msg ; 4605d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly switch(prev_cmd) 4615d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 4625d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case ANY_GET_PARAMETER: 4635d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 4645d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = phHciNfc_ReaderB_InfoUpdate(psHciContext, 4655d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly p_rdr_b_info->p_pipe_info->reg_index, 4665d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly &pResponse[HCP_HEADER_LEN], 4675d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (uint8_t)(length - HCP_HEADER_LEN)); 4685d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 4695d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 4705d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case ANY_SET_PARAMETER: 4715d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 4725d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly HCI_PRINT("Reader B Parameter Set \n"); 4735d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = phHciNfc_ReaderMgmt_Update_Sequence(psHciContext, 4745d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly UPDATE_SEQ); 4755d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly p_rdr_b_info->next_seq = RDR_B_PUPI; 4765d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 4775d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 4785d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case ANY_OPEN_PIPE: 4795d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 4805d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly HCI_PRINT("Reader B open pipe complete\n"); 4815d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = phHciNfc_ReaderMgmt_Update_Sequence(psHciContext, 4825d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly UPDATE_SEQ); 4835d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly p_rdr_b_info->next_seq = RDR_B_PUPI; 4845d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 4855d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 4865d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case ANY_CLOSE_PIPE: 4875d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 4885d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly HCI_PRINT("Reader B close pipe complete\n"); 4895d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = phHciNfc_ReaderMgmt_Update_Sequence(psHciContext, 4905d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly UPDATE_SEQ); 4915d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 4925d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 4935d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case NXP_WRA_CONTINUE_ACTIVATION: 4945d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case NXP_WR_ACTIVATE_ID: 4955d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 4965d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly HCI_PRINT("Reader B continue activation or "); 4975d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly HCI_PRINT("reactivation completed \n"); 4985d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = phHciNfc_ReaderMgmt_Update_Sequence(psHciContext, 4995d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly UPDATE_SEQ); 5005d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 5015d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 5025d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case WR_XCHGDATA: 5035d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 5045d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if (length >= HCP_HEADER_LEN) 5055d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 5065d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uint8_t i = 1; 5075d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly HCI_PRINT("ISO 14443-4B received \n"); 5085d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Copy buffer to the receive buffer */ 5095d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_Append_HCPFrame(psHciContext->recv_buffer, 5105d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 0, pResponse, length); 5115d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->rx_total = (length - i); 5125d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = phHciNfc_Recv_Iso_B_Packet(psHciContext, 5135d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly &pResponse[HCP_HEADER_LEN], 5145d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (length - HCP_HEADER_LEN)); 5155d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 5165d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 5175d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 5185d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = PHNFCSTVAL(CID_NFC_HCI, 5195d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS_INVALID_HCI_RESPONSE); 5205d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 5215d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 5225d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 5235d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case NXP_WR_PRESCHECK: 5245d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 5255d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly HCI_PRINT("Presence check completed \n"); 5265d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 5275d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 5285d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case NXP_WR_ACTIVATE_NEXT: 5295d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 5305d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if (length > HCP_HEADER_LEN) 5315d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 5325d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if (RDR_B_MULTIPLE_TAGS_FOUND == pResponse[HCP_HEADER_LEN]) 5335d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 5345d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly p_rdr_b_info->multiple_tgts_found = 5355d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly RDR_B_MULTIPLE_TAGS_FOUND; 5365d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 5375d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 5385d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 5395d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly p_rdr_b_info->multiple_tgts_found = FALSE; 5405d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 5415d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly HCI_PRINT("Activate next completed \n"); 5425d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 5435d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 5445d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 5455d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = PHNFCSTVAL(CID_NFC_HCI, 5465d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS_INVALID_HCI_RESPONSE); 5475d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 5485d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 5495d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 5505d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case NXP_WR_DISPATCH_TO_UICC: 5515d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 5525d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly switch(length) 5535d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 5545d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case HCP_HEADER_LEN: 5555d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 5565d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Error code field is optional, if no error 5575d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly code field in the response, then the command 5585d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly is successfully completed */ 5595d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly p_rdr_b_info->uicc_activation = 5605d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly UICC_CARD_ACTIVATION_SUCCESS; 5615d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 5625d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 5635d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case (HCP_HEADER_LEN + 1): 5645d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 5655d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly p_rdr_b_info->uicc_activation = 5665d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pResponse[HCP_HEADER_LEN]; 5675d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 5685d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } /* End of case (HCP_HEADER_LEN + index) */ 5695d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly default: 5705d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 5715d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = PHNFCSTVAL(CID_NFC_HCI, 5725d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS_INVALID_HCI_RESPONSE); 5735d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 5745d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 5755d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } /* End of switch(length) */ 5765d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if (NFCSTATUS_SUCCESS == status) 5775d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 5785d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = phHciNfc_ReaderMgmt_Update_Sequence(psHciContext, 5795d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly UPDATE_SEQ); 5805d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 5815d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 5825d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 5835d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly default: 5845d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 5855d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_INVALID_HCI_RESPONSE); 5865d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 5875d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 5885d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 5895d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if( NFCSTATUS_SUCCESS == status ) 5905d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 5915d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly p_rdr_b_info->p_pipe_info->prev_status = NFCSTATUS_SUCCESS; 5925d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly p_rdr_b_info->current_seq = p_rdr_b_info->next_seq; 5935d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 5945d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 5955d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 5965d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly return status; 5975d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly} 5985d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 5995d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 6005d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pellystatic 6015d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyNFCSTATUS 6025d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyphHciNfc_Recv_ReaderB_Event( 6035d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly void *psContext, 6045d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly void *pHwRef, 6055d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uint8_t *pEvent, 6065d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#ifdef ONE_BYTE_LEN 6075d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uint8_t length 6085d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#else 6095d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uint16_t length 6105d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif 6115d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ) 6125d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly{ 6135d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS status = NFCSTATUS_SUCCESS; 6145d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_sContext_t *psHciContext = 6155d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (phHciNfc_sContext_t *)psContext ; 6165d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if( (NULL == psHciContext) || (NULL == pHwRef) || (NULL == pEvent) 6175d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly || (length == 0)) 6185d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 6195d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_INVALID_PARAMETER); 6205d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 6215d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else if((NULL == psHciContext->p_reader_b_info) || 6225d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (HCI_READER_B_ENABLE != 6235d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ((phHciNfc_ReaderB_Info_t *)(psHciContext->p_reader_b_info))-> 6245d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly enable_rdr_b_gate)) 6255d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 6265d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_FEATURE_NOT_SUPPORTED); 6275d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 6285d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 6295d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 6305d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_HCP_Packet_t *p_packet = NULL; 6315d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_ReaderB_Info_t *p_rdr_b_info=NULL; 6325d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_HCP_Message_t *message = NULL; 6335d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uint8_t instruction=0, 6345d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly i = 0; 6355d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 6365d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly p_rdr_b_info = (phHciNfc_ReaderB_Info_t *) 6375d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->p_reader_b_info ; 6385d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly p_packet = (phHciNfc_HCP_Packet_t *)pEvent; 6395d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly message = &p_packet->msg.message; 6405d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Get the instruction bits from the Message Header */ 6415d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly instruction = (uint8_t) GET_BITS8( message->msg_header, 6425d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly HCP_MSG_INSTRUCTION_OFFSET, HCP_MSG_INSTRUCTION_LEN); 6435d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 6445d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if ((EVT_TARGET_DISCOVERED == instruction) 6455d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly && ((RDR_B_MULTIPLE_TAGS_FOUND == message->payload[i] ) 6465d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly || (RDR_B_SINGLE_TAG_FOUND == message->payload[i])) 6475d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ) 6485d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 6495d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phNfc_sCompletionInfo_t pCompInfo; 6505d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 6515d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if (RDR_B_MULTIPLE_TAGS_FOUND == message->payload[i]) 6525d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 6535d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly p_rdr_b_info->multiple_tgts_found = RDR_B_MULTIPLE_TAGS_FOUND; 6545d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pCompInfo.status = NFCSTATUS_MULTIPLE_TAGS; 6555d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 6565d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 6575d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 6585d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly p_rdr_b_info->multiple_tgts_found = FALSE; 6595d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pCompInfo.status = NFCSTATUS_SUCCESS; 6605d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 6615d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 6625d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->host_rf_type = phHal_eISO14443_B_PCD; 6635d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly p_rdr_b_info->reader_b_info.RemDevType = phHal_eISO14443_B_PICC; 6645d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly p_rdr_b_info->current_seq = RDR_B_PUPI; 6655d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 6665d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Notify to the HCI Generic layer To Update the FSM */ 6675d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_Notify_Event(psHciContext, pHwRef, 6685d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFC_NOTIFY_TARGET_DISCOVERED, 6695d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly &pCompInfo); 6705d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 6715d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 6725d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 6735d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 6745d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_INVALID_HCI_RESPONSE); 6755d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 6765d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 6775d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly return status; 6785d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly} 6795d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 6805d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pellystatic 6815d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyNFCSTATUS 6825d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyphHciNfc_ReaderB_InfoUpdate( 6835d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_sContext_t *psHciContext, 6845d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uint8_t index, 6855d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uint8_t *reg_value, 6865d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uint8_t reg_length 6875d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ) 6885d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly{ 6895d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS status = NFCSTATUS_SUCCESS; 6905d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_ReaderB_Info_t *p_rdr_b_info=NULL; 6915d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHal_sIso14443BInfo_t *p_tag_b_info = NULL; 6925d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 6935d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly p_rdr_b_info = (phHciNfc_ReaderB_Info_t *) 6945d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (psHciContext->p_reader_b_info ); 6955d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly p_tag_b_info = &(p_rdr_b_info->reader_b_info.RemoteDevInfo.Iso14443B_Info); 6965d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 6975d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly switch(index) 6985d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 6995d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case RDR_B_PUPI_INDEX: 7005d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 7015d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly HCI_PRINT_BUFFER("\tReader B PUPI", reg_value, reg_length); 7025d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Update PUPI buffer and length in the remote device info, 7035d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly PUPI length is 4 bytes */ 7045d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(PHHAL_PUPI_LENGTH == reg_length) 7055d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 7065d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (void)memcpy((void *)p_tag_b_info->AtqB.AtqResInfo.Pupi, 7075d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (void *)reg_value, reg_length); 7085d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 7095d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 7105d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 7115d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = PHNFCSTVAL(CID_NFC_HCI, 7125d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS_INVALID_HCI_RESPONSE); 7135d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 7145d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 7155d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 7165d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case RDR_B_APP_DATA_INDEX: 7175d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 7185d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly HCI_PRINT_BUFFER("\tReader B Application data", reg_value, reg_length); 7195d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Update application data buffer and length, 3 bytes, 7205d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly this includes CRC_B and number of application 7215d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly */ 7225d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(PHHAL_APP_DATA_B_LENGTH == reg_length) 7235d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 7245d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (void)memcpy((void *)p_tag_b_info->AtqB.AtqResInfo.AppData, 7255d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (void *)reg_value, reg_length); 7265d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 7275d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 7285d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 7295d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = PHNFCSTVAL(CID_NFC_HCI, 7305d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS_INVALID_HCI_RESPONSE); 7315d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 7325d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 7335d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 7345d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case RDR_B_AFI_INDEX: 7355d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 7365d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly HCI_PRINT_BUFFER("\tReader B AFI", reg_value, reg_length); 7375d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Update AFI byte, Only one byte */ 7385d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(sizeof(*reg_value) == reg_length) 7395d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 7405d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly p_tag_b_info->Afi = *reg_value; 7415d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 7425d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 7435d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 7445d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = PHNFCSTVAL(CID_NFC_HCI, 7455d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS_INVALID_HCI_RESPONSE); 7465d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 7475d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 7485d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 7495d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 7505d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case RDR_B_HIGHER_LAYER_RESP_INDEX: 7515d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 7525d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly HCI_PRINT_BUFFER("\tReader B higher layer response", reg_value, reg_length); 7535d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Update higher layer response buffer and length */ 7545d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if (reg_length <= PHHAL_MAX_ATR_LENGTH) 7555d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 7565d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (void)memcpy((void *)p_tag_b_info->HiLayerResp, 7575d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (void *)reg_value, reg_length); 7585d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 7595d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 7605d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 7615d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = PHNFCSTVAL(CID_NFC_HCI, 7625d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS_INVALID_HCI_RESPONSE); 7635d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 7645d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 7655d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 7665d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 7675d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case RDR_B_HIGHER_LAYER_DATA_INDEX: 7685d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 7695d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly HCI_PRINT_BUFFER("\tReader B higher layer data", reg_value, reg_length); 7705d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Update higher layer data buffer and length */ 7715d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 7725d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 7735d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly default: 7745d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 7755d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = PHNFCSTVAL(CID_NFC_HCI, 7765d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS_INVALID_HCI_RESPONSE); 7775d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 7785d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 7795d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 7805d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly return status; 7815d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly} 7825d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 7835d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 7845d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pellystatic 7855d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyNFCSTATUS 7865d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyphHciNfc_Recv_Iso_B_Packet( 7875d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_sContext_t *psHciContext, 7885d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uint8_t *pResponse, 7895d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#ifdef ONE_BYTE_LEN 7905d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uint8_t length 7915d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#else 7925d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uint16_t length 7935d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif 7945d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ) 7955d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly{ 7965d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS status = NFCSTATUS_SUCCESS; 7975d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uint8_t i = 1; 7985d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 7995d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->rx_index = HCP_HEADER_LEN; 8005d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* command WR_XCHG_DATA: so give ISO 14443-4B data to the upper layer */ 8015d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly HCI_PRINT_BUFFER("ISO 14443-4B Bytes received", pResponse, length); 8025d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(FALSE != pResponse[(length - i)]) 8035d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 8045d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = PHNFCSTVAL(CID_NFC_HCI, 8055d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS_RF_ERROR); 8065d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 8075d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly return status; 8085d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly} 8095d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 8105d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 8115d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyNFCSTATUS 8125d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyphHciNfc_ReaderB_Set_AFI( 8135d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly void *psContext, 8145d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly void *pHwRef, 8155d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uint8_t afi_value 8165d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ) 8175d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly{ 8185d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS status = NFCSTATUS_SUCCESS; 8195d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_sContext_t *psHciContext = 8205d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (phHciNfc_sContext_t *)psContext ; 8215d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if( (NULL == psHciContext) || (NULL == pHwRef)) 8225d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 8235d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_INVALID_PARAMETER); 8245d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 8255d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else if((NULL == psHciContext->p_reader_b_info) || 8265d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (HCI_READER_B_ENABLE != 8275d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ((phHciNfc_ReaderB_Info_t *)(psHciContext->p_reader_b_info))-> 8285d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly enable_rdr_b_gate)) 8295d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 8305d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_FEATURE_NOT_SUPPORTED); 8315d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 8325d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 8335d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 8345d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_ReaderB_Info_t *ps_rdr_b_info=NULL; 8355d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_Pipe_Info_t *p_pipe_info=NULL; 8365d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uint8_t pipeid = 0; 8375d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 8385d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ps_rdr_b_info = (phHciNfc_ReaderB_Info_t *) 8395d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->p_reader_b_info ; 8405d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly p_pipe_info = ps_rdr_b_info->p_pipe_info; 8415d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NULL == p_pipe_info ) 8425d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 8435d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = PHNFCSTVAL(CID_NFC_HCI, 8445d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS_INVALID_HCI_SEQUENCE); 8455d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 8465d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 8475d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 8485d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pipeid = ps_rdr_b_info->pipe_id ; 8495d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly p_pipe_info->reg_index = RDR_B_AFI_INDEX; 8505d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 8515d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly p_pipe_info->param_info = &afi_value; 8525d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly p_pipe_info->param_length = sizeof(uint8_t); 8535d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Fill the data buffer and send the command to the 8545d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly device */ 8555d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = 8565d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_Send_Generic_Cmd( psHciContext, pHwRef, 8575d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pipeid, (uint8_t)ANY_SET_PARAMETER); 8585d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 8595d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 8605d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly return status; 8615d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly} 8625d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 8635d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyNFCSTATUS 8645d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyphHciNfc_ReaderB_Set_LayerData( 8655d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly void *psContext, 8665d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly void *pHwRef, 8675d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phNfc_sData_t *layer_data_info 8685d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ) 8695d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly{ 8705d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS status = NFCSTATUS_SUCCESS; 8715d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_sContext_t *psHciContext = 8725d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (phHciNfc_sContext_t *)psContext ; 8735d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 8745d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if( (NULL == psHciContext) || (NULL == pHwRef) || 8755d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (NULL == layer_data_info) || (NULL == layer_data_info->buffer) 8765d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly || (0 == layer_data_info->length)) 8775d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 8785d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_INVALID_PARAMETER); 8795d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 8805d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else if((NULL == psHciContext->p_reader_b_info) || 8815d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (HCI_READER_B_ENABLE != 8825d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ((phHciNfc_ReaderB_Info_t *)(psHciContext->p_reader_b_info))-> 8835d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly enable_rdr_b_gate)) 8845d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 8855d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_FEATURE_NOT_SUPPORTED); 8865d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 8875d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 8885d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 8895d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_ReaderB_Info_t *ps_rdr_b_info=NULL; 8905d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_Pipe_Info_t *p_pipe_info=NULL; 8915d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uint8_t pipeid = 0; 8925d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 8935d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ps_rdr_b_info = (phHciNfc_ReaderB_Info_t *) 8945d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->p_reader_b_info ; 8955d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly p_pipe_info = ps_rdr_b_info->p_pipe_info; 8965d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NULL == p_pipe_info ) 8975d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 8985d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = PHNFCSTVAL(CID_NFC_HCI, 8995d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS_INVALID_HCI_SEQUENCE); 9005d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 9015d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 9025d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 9035d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly p_pipe_info->reg_index = RDR_B_HIGHER_LAYER_DATA_INDEX; 9045d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pipeid = ps_rdr_b_info->pipe_id ; 9055d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly p_pipe_info->param_info = (void *)layer_data_info->buffer; 9065d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly p_pipe_info->param_length = (uint8_t) 9075d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly layer_data_info->length; 9085d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Fill the data buffer and send the command to the 9095d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly device */ 9105d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = phHciNfc_Send_Generic_Cmd( psHciContext, pHwRef, 9115d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pipeid, (uint8_t)ANY_SET_PARAMETER); 9125d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 9135d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 9145d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly return status; 9155d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly} 9165d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif /* #if defined (TYPE_B) */ 9175d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 9185d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 919