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_RFReader.c                                                  *
225d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* \brief HCI RF Reader Management Gate Routines.                              *
235d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly*                                                                             *
245d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly*                                                                             *
255d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* Project: NFC-FRI-1.1                                                        *
265d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly*                                                                             *
275d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* $Date: Wed Apr 21 12:21:15 2010 $                                           *
285d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* $Author: ing07385 $                                                         *
295d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* $Revision: 1.53 $                                                            *
30e1b8bffcf9ff1a5c290c03be5a1d85be0c103223aferir* $Aliases: NFC_FRI1.1_WK1007_R33_6 $                                                                *
315d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly*                                                                             *
325d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* =========================================================================== *
335d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly*/
345d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
355d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/*
365d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly***************************** Header File Inclusion ****************************
375d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly*/
385d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#include <phNfcConfig.h>
395d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#include <phNfcCompId.h>
405d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#include <phHciNfc_Pipe.h>
415d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#include <phHciNfc_RFReader.h>
425d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#include <phHciNfc_RFReaderA.h>
435d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#ifdef TYPE_B
445d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#include <phHciNfc_RFReaderB.h>
455d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif
465d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#ifdef ENABLE_P2P
475d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#include <phHciNfc_NfcIPMgmt.h>
485d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif
495d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#ifdef TYPE_FELICA
505d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#include <phHciNfc_Felica.h>
515d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif
525d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#ifdef TYPE_JEWEL
535d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#include <phHciNfc_Jewel.h>
545d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif
555d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#ifdef TYPE_ISO15693
565d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#include <phHciNfc_ISO15693.h>
575d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif /* #ifdef    TYPE_ISO15693 */
585d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#include <phOsalNfc.h>
595d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
605d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/*
615d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly****************************** Macro Definitions *******************************
625d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly*/
635d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
645d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#define NFCIP_ACTIVATE_DELAY       0x05U
655d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
6672854a2c28b99f9ab6aa60c906d5b3c1a36b04d7Martijn Coenenuint8_t nxp_nfc_isoxchg_timeout = NXP_ISO_XCHG_TIMEOUT;
675d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/*
685d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly*************************** Structure and Enumeration ***************************
695d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly*/
705d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
715d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
725d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/** \defgroup grp_hci_nfc HCI Reader RF Management Component
735d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly *
745d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly *
755d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly */
765d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
775d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
785d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pellytypedef enum phHciNfc_ReaderMgmt_Seq{
795d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    READERA_PIPE_OPEN       = 0x00U,
805d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    READERB_PIPE_OPEN,
815d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    FELICA_PROP_PIPE_OPEN,
825d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    JEWEL_PROP_PIPE_OPEN,
835d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    ISO15693_PROP_PIPE_OPEN,
845d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    NFCIP1_INITIATOR_PIPE_OPEN,
855d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    NFCIP1_INITIATOR_MODE_CONFIG,
865d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    NFCIP1_INITIATOR_PSL1_CONFIG,
875d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    NFCIP1_INITIATOR_PSL2_CONFIG,
885d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    READERA_DISABLE_AUTO_ACTIVATE,
895d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
905d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
915d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    READERA_PIPE_CLOSE,
925d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    READERB_PIPE_CLOSE,
935d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    FELICA_PROP_PIPE_CLOSE,
945d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    JEWEL_PROP_PIPE_CLOSE,
955d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    ISO15693_PROP_PIPE_CLOSE,
965d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    NFCIP1_INITIATOR_PIPE_CLOSE,
975d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    END_READER_SEQUENCE
985d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly} phHciNfc_ReaderMgmt_Seq_t;
995d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
1005d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pellytypedef struct phHciNfc_ReaderMgmt_Info{
1015d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    phHciNfc_ReaderMgmt_Seq_t   rf_gate_cur_seq;
1025d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    phHciNfc_ReaderMgmt_Seq_t   rf_gate_next_seq;
1035d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly} phHciNfc_ReaderMgmt_Info_t;
1045d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
1055d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
1065d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/*
1075d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly*************************** Static Function Declaration **************************
1085d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly*/
1095d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pellystatic
1105d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyNFCSTATUS
1115d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyphHciNfc_ReaderMgmt_End_Discovery(
1125d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                phHciNfc_sContext_t     *psHciContext,
1135d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                void                    *pHwRef,
1145d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                uint8_t                 reader_pipe_id
1155d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                             );
1165d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
1175d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pellystatic
1185d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyNFCSTATUS
1195d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyphHciNfc_ReaderMgmt_Initiate_Discovery(
1205d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                phHciNfc_sContext_t     *psHciContext,
1215d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                void                    *pHwRef,
1225d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                uint8_t                 reader_pipe_id
1235d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                             );
1245d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
1255d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/*
1265d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly*************************** Function Definitions ***************************
1275d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly*/
1285d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
1295d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#ifdef READER_INIT
1305d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/*!
1315d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * \brief Allocates the resources of RF Reader Managment Gate.
1325d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly *
1335d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * This function Allocates the resources of the RF Reader Management
1345d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * gate Information Structure.
1355d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly *
1365d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly */
1375d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
1385d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyNFCSTATUS
1395d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyphHciNfc_ReaderMgmt_Init_Resources(
1405d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                phHciNfc_sContext_t     *psHciContext
1415d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                             )
1425d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly{
1435d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    NFCSTATUS                   status = NFCSTATUS_SUCCESS;
1445d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    phHciNfc_ReaderMgmt_Info_t  *p_reader_mgmt_info=NULL;
1455d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    if( NULL == psHciContext )
1465d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    {
1475d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_INVALID_PARAMETER);
1485d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    }
1495d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    else
1505d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    {
1515d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        if( ( NULL == psHciContext->p_reader_mgmt_info )
1525d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            && (phHciNfc_Allocate_Resource((void **)(&p_reader_mgmt_info),
1535d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    sizeof(phHciNfc_ReaderMgmt_Info_t))== NFCSTATUS_SUCCESS)
1545d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        )
1555d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        {
1565d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            psHciContext->p_reader_mgmt_info = p_reader_mgmt_info;
1575d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            p_reader_mgmt_info->rf_gate_cur_seq = READERA_PIPE_OPEN;
1585d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            p_reader_mgmt_info->rf_gate_next_seq = END_READER_SEQUENCE;
1595d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        }
1605d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        else
1615d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        {
1625d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_INSUFFICIENT_RESOURCES);
1635d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        }
1645d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    }
1655d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    return status;
1665d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly}
1675d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
1685d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif
1695d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
1705d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/*!
1715d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * \brief Updates the Sequence of RF Reader Managment Gate.
1725d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly *
1735d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * This function Resets/Updates the sequence of the RF Reader Management
1745d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * gate.
1755d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly *
1765d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly */
1775d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
1785d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyNFCSTATUS
1795d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyphHciNfc_ReaderMgmt_Update_Sequence(
1805d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                phHciNfc_sContext_t     *psHciContext,
1815d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                phHciNfc_eSeqType_t     reader_seq
1825d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                             )
1835d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly{
1845d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    NFCSTATUS                   status = NFCSTATUS_SUCCESS;
1855d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    phHciNfc_ReaderMgmt_Info_t  *p_reader_mgmt_info = NULL;
1865d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    if( NULL == psHciContext )
1875d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    {
1885d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_INVALID_PARAMETER);
1895d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    }
1905d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    else
1915d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    {
1925d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        if( NULL == psHciContext->p_reader_mgmt_info )
1935d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        {
1945d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            status = PHNFCSTVAL(CID_NFC_HCI,
1955d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                        NFCSTATUS_INVALID_HCI_INFORMATION);
1965d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        }
1975d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        else
1985d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        {
1995d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            p_reader_mgmt_info = (phHciNfc_ReaderMgmt_Info_t *)
2005d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                psHciContext->p_reader_mgmt_info ;
2015d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            switch(reader_seq)
2025d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            {
2035d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                case RESET_SEQ:
2045d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                case INIT_SEQ:
2055d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                {
2065d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    p_reader_mgmt_info->rf_gate_cur_seq = READERA_PIPE_OPEN;
2075d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    p_reader_mgmt_info->rf_gate_next_seq = END_READER_SEQUENCE;
2085d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    break;
2095d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                }
2105d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                case UPDATE_SEQ:
2115d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                {
2125d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    p_reader_mgmt_info->rf_gate_cur_seq =
2135d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                            p_reader_mgmt_info->rf_gate_next_seq;
2145d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    break;
2155d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                }
2165d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                case INFO_SEQ:
2175d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                {
2185d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    status = phHciNfc_ReaderA_Update_Info(psHciContext,
2195d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                            HCI_READER_A_INFO_SEQ, NULL);
2205d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#if defined( TYPE_B )
2215d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    status = phHciNfc_ReaderB_Update_Info(psHciContext,
2225d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                            HCI_READER_B_INFO_SEQ, NULL);
2235d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif /* end of #if defined(TYPE_B) */
2245d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#if defined( TYPE_FELICA )
2255d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    status = phHciNfc_Felica_Update_Info(psHciContext,
2265d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                            HCI_FELICA_INFO_SEQ, NULL);
2275d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif /* end of #if defined(TYPE_FELICA) */
2285d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#if defined( TYPE_JEWEL )
2295d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    status = phHciNfc_Jewel_Update_Info(psHciContext,
2305d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                            HCI_JEWEL_INFO_SEQ, NULL);
2315d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif /* end of #if defined(TYPE_JEWEL) */
2325d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#if defined( TYPE_ISO15693 )
2335d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    status = phHciNfc_ISO15693_Update_Info(psHciContext,
2345d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                            HCI_ISO_15693_INFO_SEQ, NULL);
2355d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif /* end of #if defined(TYPE_ISO15693) */
2365d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    break;
2375d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                }
2385d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                case REL_SEQ:
2395d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                {
2405d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    p_reader_mgmt_info->rf_gate_cur_seq = READERA_PIPE_CLOSE;
2415d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    p_reader_mgmt_info->rf_gate_next_seq = END_READER_SEQUENCE;
2425d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    break;
2435d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                }
2445d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                default:
2455d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                {
2465d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    break;
2475d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                }
2485d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            }
2495d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        }
2505d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    }
2515d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
2525d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    return status;
2535d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
2545d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly}
2555d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
2565d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
2575d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/*!
2585d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * \brief Initialisation of RF Reader Managment Gate.
2595d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly *
2605d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * This function initialses the RF Reader Management gate and
2615d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * populates the Reader Management Information Structure
2625d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly *
2635d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly */
2645d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
2655d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyNFCSTATUS
2665d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyphHciNfc_ReaderMgmt_Initialise(
2675d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                phHciNfc_sContext_t     *psHciContext,
2685d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                void                    *pHwRef
2695d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                         )
2705d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly{
2715d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    NFCSTATUS                       status = NFCSTATUS_SUCCESS;
2725d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    phHciNfc_Pipe_Info_t            *p_pipe_info = NULL;
2735d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    phHciNfc_ReaderMgmt_Info_t      *p_reader_mgmt_info=NULL;
2745d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
2755d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    if( NULL == psHciContext )
2765d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    {
2775d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_INVALID_PARAMETER);
2785d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    }
2795d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    else
2805d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    {
2815d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
2825d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        if( ( NULL == psHciContext->p_reader_mgmt_info )
2835d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            && (phHciNfc_Allocate_Resource((void **)(&p_reader_mgmt_info),
2845d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    sizeof(phHciNfc_ReaderMgmt_Info_t))== NFCSTATUS_SUCCESS)
2855d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        )
2865d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        {
2875d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            psHciContext->p_reader_mgmt_info = p_reader_mgmt_info;
2885d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            p_reader_mgmt_info->rf_gate_cur_seq = READERA_PIPE_OPEN;
2895d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            p_reader_mgmt_info->rf_gate_next_seq = END_READER_SEQUENCE;
2905d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        }
2915d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        else
2925d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        {
2935d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            p_reader_mgmt_info = (phHciNfc_ReaderMgmt_Info_t *)
2945d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                psHciContext->p_reader_mgmt_info ;
2955d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        }
2965d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
2975d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        if( NULL == psHciContext->p_reader_mgmt_info )
2985d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        {
2995d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            status = PHNFCSTVAL(CID_NFC_HCI,
3005d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                NFCSTATUS_INSUFFICIENT_RESOURCES);
3015d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        }
3025d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#ifdef ESTABLISH_SESSION
3035d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        else if( hciMode_Session == psHciContext->hci_mode )
3045d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        {
3055d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            status = NFCSTATUS_SUCCESS;
3065d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        }
3075d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif
3085d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        else
3095d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        {
3105d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            switch(p_reader_mgmt_info->rf_gate_cur_seq )
3115d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            {
3125d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                /* Reader A pipe open sequence */
3135d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                case READERA_PIPE_OPEN:
3145d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                {
3155d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    p_pipe_info = ((phHciNfc_ReaderA_Info_t *)
3165d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                            psHciContext->p_reader_a_info)->p_pipe_info;
3175d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    if(NULL == p_pipe_info )
3185d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    {
3195d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                        status = PHNFCSTVAL(CID_NFC_HCI,
3205d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                        NFCSTATUS_INVALID_HCI_SEQUENCE);
3215d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    }
3225d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    else
3235d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    {
3245d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                        status = phHciNfc_Open_Pipe( psHciContext,
3255d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                                        pHwRef, p_pipe_info );
3265d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                        if(status == NFCSTATUS_SUCCESS)
3275d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                        {
3285d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                            uint8_t rdr_enable = TRUE;
3295d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                            status = phHciNfc_ReaderA_Update_Info(
3305d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                    psHciContext, HCI_READER_A_ENABLE,
3315d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                                            &rdr_enable);
3325d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#if defined( TYPE_B )  && defined ( ENABLE_AUTO_ACTIVATE )
3335d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                            p_reader_mgmt_info->rf_gate_next_seq =
3345d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                                    READERB_PIPE_OPEN;
3355d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                            status = NFCSTATUS_PENDING;
3365d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/* end of #ifdef TYPE_B */
3375d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#elif !defined( ENABLE_AUTO_ACTIVATE )
3385d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                            p_reader_mgmt_info->rf_gate_next_seq =
3395d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                                        READERA_DISABLE_AUTO_ACTIVATE;
3405d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                            status = NFCSTATUS_PENDING;
3415d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/* #ifdef ENABLE_AUTO_ACTIVATE */
3425d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#elif defined( ENABLE_P2P )
3435d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                            p_reader_mgmt_info->rf_gate_next_seq =
3445d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                                    NFCIP1_INITIATOR_PIPE_OPEN;
3455d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                            status = NFCSTATUS_PENDING;
3465d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/* #ifdef ENABLE_P2P */
3475d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#else
3485d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                            p_reader_mgmt_info->rf_gate_next_seq =
3495d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                                END_READER_SEQUENCE;
3505d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                            /* status = NFCSTATUS_PENDING; */
3515d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif
3525d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                        }
3535d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    }
3545d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    break;
3555d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                }
3565d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                /* Reader A Auto Activate Disable */
3575d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                case READERA_DISABLE_AUTO_ACTIVATE:
3585d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                {
3595d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    uint8_t     activate_enable = FALSE;
3605d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    p_pipe_info = ((phHciNfc_ReaderA_Info_t *)
3615d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                            psHciContext->p_reader_a_info)->p_pipe_info;
3625d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    if(NULL == p_pipe_info )
3635d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    {
3645d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                        status = PHNFCSTVAL(CID_NFC_HCI,
3655d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                        NFCSTATUS_INVALID_HCI_SEQUENCE);
3665d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    }
3675d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    else
3685d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    {
3695d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
3705d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                        status = phHciNfc_ReaderA_Auto_Activate( psHciContext,
3715d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                                        pHwRef, activate_enable );
3725d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                        if(status == NFCSTATUS_SUCCESS)
3735d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                        {
3745d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#if defined (TYPE_B)
3755d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                            p_reader_mgmt_info->rf_gate_next_seq =
3765d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                                    READERB_PIPE_OPEN;
3775d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                            status = NFCSTATUS_PENDING;
3785d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/* end of #ifdef TYPE_B */
3795d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#elif defined(TYPE_FELICA)
3805d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                            p_reader_mgmt_info->rf_gate_next_seq =
3815d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                                        FELICA_PROP_PIPE_OPEN;
3825d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                            status = NFCSTATUS_PENDING;
3835d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/* end of #elif defined(TYPE_FELICA) */
3845d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#elif defined(TYPE_JEWEL)
3855d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                            p_reader_mgmt_info->rf_gate_next_seq =
3865d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                                        JEWEL_PROP_PIPE_OPEN;
3875d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                            status = NFCSTATUS_PENDING;
3885d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/* end of #elif defined(TYPE_JEWEL) */
3895d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#elif defined (TYPE_ISO15693)
3905d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                            p_reader_mgmt_info->rf_gate_next_seq =
3915d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                                    ISO15693_PROP_PIPE_OPEN;
3925d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                            status = NFCSTATUS_PENDING;
3935d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/* end of #elif defined(TYPE_ISO15693) */
3945d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#elif defined(ENABLE_P2P)
3955d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                            p_reader_mgmt_info->rf_gate_next_seq =
3965d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                                    NFCIP1_INITIATOR_PIPE_OPEN;
3975d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                            status = NFCSTATUS_PENDING;
3985d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/* end of #ifdef ENABLE_P2P */
3995d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#else
4005d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                            p_reader_mgmt_info->rf_gate_next_seq =
4015d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                                            END_READER_SEQUENCE;
4025d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                            /* status = NFCSTATUS_PENDING; */
4035d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif /* #if !defined(ENABLE_P2P) && !defined(TYPE_B)*/
4045d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                        }
4055d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    }
4065d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    break;
4075d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                }
4085d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#ifdef TYPE_B
4095d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                /* Reader B pipe open sequence */
4105d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                case READERB_PIPE_OPEN:
4115d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                {
4125d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    p_pipe_info = ((phHciNfc_ReaderB_Info_t *)
4135d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                            psHciContext->p_reader_b_info)->p_pipe_info;
4145d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    if(NULL == p_pipe_info )
4155d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    {
4165d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                        status = PHNFCSTVAL(CID_NFC_HCI,
4175d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                        NFCSTATUS_INVALID_HCI_SEQUENCE);
4185d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    }
4195d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    else
4205d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    {
4215d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                        status = phHciNfc_Open_Pipe( psHciContext,
4225d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                                        pHwRef, p_pipe_info );
4235d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                        if(status == NFCSTATUS_SUCCESS)
4245d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                        {
4255d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#if defined(TYPE_FELICA)
4265d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                            p_reader_mgmt_info->rf_gate_next_seq =
4275d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                                        FELICA_PROP_PIPE_OPEN;
4285d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                            status = NFCSTATUS_PENDING;
4295d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/* end of #ifdef TYPE_FELICA */
4305d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#elif defined(TYPE_JEWEL)
4315d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                            p_reader_mgmt_info->rf_gate_next_seq =
4325d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                                        JEWEL_PROP_PIPE_OPEN;
4335d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                            status = NFCSTATUS_PENDING;
4345d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/* end of #elif defined(TYPE_JEWEL) */
4355d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#elif defined (TYPE_ISO15693)
4365d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                            p_reader_mgmt_info->rf_gate_next_seq =
4375d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                                    ISO15693_PROP_PIPE_OPEN;
4385d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                            status = NFCSTATUS_PENDING;
4395d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/* end of #elif defined(TYPE_ISO15693) */
4405d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#elif defined(ENABLE_P2P)
4415d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                            p_reader_mgmt_info->rf_gate_next_seq =
4425d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                                    NFCIP1_INITIATOR_PIPE_OPEN;
4435d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                            status = NFCSTATUS_PENDING;
4445d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/* end of #ifdef ENABLE_P2P */
4455d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#else
4465d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                            p_reader_mgmt_info->rf_gate_next_seq =
4475d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                                            END_READER_SEQUENCE;
4485d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                            /* status = NFCSTATUS_PENDING; */
4495d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif /* #if !defined(ENABLE_P2P) && !defined(TYPE_FELICA)*/
4505d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                        }
4515d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    }
4525d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    break;
4535d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                }
4545d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif /* #ifdef TYPE_B */
4555d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#ifdef TYPE_FELICA
4565d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                /* Felica Reader pipe open sequence */
4575d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                case FELICA_PROP_PIPE_OPEN:
4585d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                {
4595d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    p_pipe_info = ((phHciNfc_Felica_Info_t *)
4605d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                            psHciContext->p_felica_info)->p_pipe_info;
4615d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    if(NULL == p_pipe_info )
4625d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    {
4635d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                        status = PHNFCSTVAL(CID_NFC_HCI,
4645d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                        NFCSTATUS_INVALID_HCI_SEQUENCE);
4655d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    }
4665d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    else
4675d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    {
4685d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                        status = phHciNfc_Open_Pipe( psHciContext,
4695d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                                        pHwRef, p_pipe_info );
4705d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                        if(status == NFCSTATUS_SUCCESS)
4715d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                        {
4725d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#if defined(TYPE_JEWEL)
4735d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                            p_reader_mgmt_info->rf_gate_next_seq =
4745d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                                        JEWEL_PROP_PIPE_OPEN;
4755d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                            status = NFCSTATUS_PENDING;
4765d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/* end of #if defined(TYPE_JEWEL) */
4775d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#elif defined (TYPE_ISO15693)
4785d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                            p_reader_mgmt_info->rf_gate_next_seq =
4795d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                                    ISO15693_PROP_PIPE_OPEN;
4805d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                            status = NFCSTATUS_PENDING;
4815d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/* end of #elif defined(TYPE_ISO15693) */
4825d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#elif defined(ENABLE_P2P)
4835d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                            p_reader_mgmt_info->rf_gate_next_seq =
4845d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                                    NFCIP1_INITIATOR_PIPE_OPEN;
4855d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                            status = NFCSTATUS_PENDING;
4865d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* end of #ifdef ENABLE_P2P */
4875d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#else
4885d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                            p_reader_mgmt_info->rf_gate_next_seq =
4895d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                                            END_READER_SEQUENCE;
4905d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                            /* status = NFCSTATUS_PENDING; */
4915d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif /* #if !defined(ENABLE_P2P) */
4925d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                        }
4935d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    }
4945d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    break;
4955d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                }
4965d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif
4975d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#ifdef TYPE_JEWEL
4985d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                /* Jewel Reader pipe open sequence */
4995d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                case JEWEL_PROP_PIPE_OPEN:
5005d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                {
5015d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    p_pipe_info = ((phHciNfc_Jewel_Info_t *)
5025d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                            psHciContext->p_jewel_info)->p_pipe_info;
5035d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    if(NULL == p_pipe_info )
5045d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    {
5055d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                        status = PHNFCSTVAL(CID_NFC_HCI,
5065d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                        NFCSTATUS_INVALID_HCI_SEQUENCE);
5075d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    }
5085d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    else
5095d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    {
5105d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                        status = phHciNfc_Open_Pipe( psHciContext,
5115d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                                        pHwRef, p_pipe_info );
5125d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                        if(status == NFCSTATUS_SUCCESS)
5135d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                        {
5145d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#if defined (TYPE_ISO15693)
5155d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                            p_reader_mgmt_info->rf_gate_next_seq =
5165d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                                    ISO15693_PROP_PIPE_OPEN;
5175d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                            status = NFCSTATUS_PENDING;
5185d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/* end of #if defined(TYPE_ISO15693) */
5195d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#elif defined (ENABLE_P2P)
5205d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                            p_reader_mgmt_info->rf_gate_next_seq =
5215d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                                    NFCIP1_INITIATOR_PIPE_OPEN;
5225d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                            status = NFCSTATUS_PENDING;
5235d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* end of #ifdef ENABLE_P2P */
5245d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#else
5255d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                            p_reader_mgmt_info->rf_gate_next_seq =
5265d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                                            END_READER_SEQUENCE;
5275d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                            /* status = NFCSTATUS_PENDING; */
5285d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif /* #if !defined(ENABLE_P2P) */
5295d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                        }
5305d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    }
5315d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    break;
5325d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                }
5335d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif
5345d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
5355d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#ifdef TYPE_ISO15693
5365d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                /* ISO15693 Reader pipe open sequence */
5375d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                case ISO15693_PROP_PIPE_OPEN:
5385d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                {
5395d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    p_pipe_info = ((phHciNfc_ISO15693_Info_t *)
5405d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                        psHciContext->p_iso_15693_info)->ps_15693_pipe_info;
5415d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    if(NULL == p_pipe_info )
5425d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    {
5435d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                        status = PHNFCSTVAL(CID_NFC_HCI,
5445d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                        NFCSTATUS_INVALID_HCI_SEQUENCE);
5455d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    }
5465d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    else
5475d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    {
5485d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                        status = phHciNfc_Open_Pipe( psHciContext,
5495d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                                        pHwRef, p_pipe_info );
5505d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                        if(status == NFCSTATUS_SUCCESS)
5515d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                        {
5525d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#ifdef ENABLE_P2P
5535d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                            p_reader_mgmt_info->rf_gate_next_seq =
5545d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                                    NFCIP1_INITIATOR_PIPE_OPEN;
5555d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                            status = NFCSTATUS_PENDING;
5565d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* end of #ifdef ENABLE_P2P */
5575d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#else
5585d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                            p_reader_mgmt_info->rf_gate_next_seq =
5595d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                                            END_READER_SEQUENCE;
5605d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                            /* status = NFCSTATUS_PENDING; */
5615d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif /* #if !defined(ENABLE_P2P) */
5625d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                        }
5635d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    }
5645d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    break;
5655d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                }
5665d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
5675d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif
5685d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
5695d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#ifdef ENABLE_P2P
5705d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                /* NFC-IP1 Initiator pipe open sequence */
5715d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                case NFCIP1_INITIATOR_PIPE_OPEN:
5725d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                {
5735d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    p_pipe_info =
5745d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                        ((phHciNfc_NfcIP_Info_t *)psHciContext->
5755d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                    p_nfcip_info)->p_init_pipe_info;
5765d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    if(NULL == p_pipe_info )
5775d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    {
5785d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                        status = PHNFCSTVAL(CID_NFC_HCI,
5795d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                        NFCSTATUS_INVALID_HCI_SEQUENCE);
5805d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    }
5815d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    else
5825d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    {
5835d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                        status = phHciNfc_Open_Pipe( psHciContext,
5845d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                                        pHwRef, p_pipe_info );
5855d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                        if(status == NFCSTATUS_SUCCESS)
5865d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                        {
5875d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                            p_reader_mgmt_info->rf_gate_next_seq =
5885d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                                NFCIP1_INITIATOR_MODE_CONFIG;
5895d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                            status = NFCSTATUS_PENDING;
5905d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                        }
5915d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    }
5925d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    break;
5935d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                }
5945d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                case NFCIP1_INITIATOR_MODE_CONFIG:
5955d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                {
59600c98d516cac9dcdad6c22400267a2fd2bea3adfNick Pelly                    uint8_t mode = DEFAULT_NFCIP_INITIATOR_MODE_SUPPORT;
5975d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    status = phHciNfc_NfcIP_SetMode( psHciContext, pHwRef,
5985d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                                NFCIP_INITIATOR, mode);
5995d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    if(status == NFCSTATUS_PENDING )
6005d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    {
6015d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                        p_reader_mgmt_info->rf_gate_next_seq =
6025d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                            NFCIP1_INITIATOR_PSL1_CONFIG;
6035d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                        /* status = NFCSTATUS_SUCCESS; */
6045d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    }
6055d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    break;
6065d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                }
6075d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                case NFCIP1_INITIATOR_PSL1_CONFIG:
6085d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                {
6095d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    uint8_t psl_config = NXP_NFCIP_PSL_BRS_DEFAULT;
6105d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    status = phHciNfc_NfcIP_SetPSL1( psHciContext, pHwRef,
6115d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                                psl_config);
6125d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    if(status == NFCSTATUS_PENDING )
6135d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    {
6145d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                        p_reader_mgmt_info->rf_gate_next_seq =
6155d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                                        END_READER_SEQUENCE;
6165d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                        status = NFCSTATUS_SUCCESS;
6175d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    }
6185d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    break;
6195d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                }
6205d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif
6215d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                default:
6225d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                {
6235d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_INVALID_HCI_SEQUENCE);
6245d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    break;
6255d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                }
6265d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
6275d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            }/* End of the Sequence Switch */
6285d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
6295d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        }/* End of the Reader Info Memory Check */
6305d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
6315d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    } /* End of Null Context Check */
6325d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
6335d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    return status;
6345d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly}
6355d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
6365d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
6375d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/*!
6385d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * \brief Initiate the Discovery for the RF Reader .
6395d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly *
6405d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * This function starts the Polling Loop and initiates the discovery
6415d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * of the Target.
6425d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly *
6435d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly */
6445d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pellystatic
6455d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyNFCSTATUS
6465d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyphHciNfc_ReaderMgmt_Initiate_Discovery(
6475d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                phHciNfc_sContext_t     *psHciContext,
6485d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                void                    *pHwRef,
6495d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                uint8_t                 reader_pipe_id
6505d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                             )
6515d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly{
6525d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    NFCSTATUS                   status = NFCSTATUS_SUCCESS;
6535d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
6545d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    if( ( NULL == psHciContext )
6555d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        || ( NULL == pHwRef )
6565d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        || ( HCI_UNKNOWN_PIPE_ID == reader_pipe_id)
6575d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        )
6585d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    {
6595d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_INVALID_PARAMETER);
6605d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    }
6615d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    else
6625d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    {
6635d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
6645d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        status = phHciNfc_Send_RFReader_Event ( psHciContext, pHwRef,
6655d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    reader_pipe_id,(uint8_t) EVT_READER_REQUESTED );
6665d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        status = ( (status == NFCSTATUS_PENDING)?
6675d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                NFCSTATUS_SUCCESS : status);
6685d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    }
6695d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    return status;
6705d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly}
6715d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
6725d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
6735d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/*!
6745d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * \brief End the Discovery of the RF Reader .
6755d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly *
6765d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * This function stops the Polling Loop and ends the discovery
6775d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * of the Target.
6785d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly *
6795d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly */
6805d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pellystatic
6815d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyNFCSTATUS
6825d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyphHciNfc_ReaderMgmt_End_Discovery(
6835d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                phHciNfc_sContext_t     *psHciContext,
6845d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                void                    *pHwRef,
6855d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                uint8_t                 reader_pipe_id
6865d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                             )
6875d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly{
6885d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    NFCSTATUS                   status = NFCSTATUS_SUCCESS;
6895d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
6905d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    if( ( NULL == psHciContext )
6915d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        || ( NULL == pHwRef )
6925d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        || ( HCI_UNKNOWN_PIPE_ID == reader_pipe_id)
6935d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        )
6945d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    {
6955d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_INVALID_PARAMETER);
6965d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    }
6975d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    else
6985d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    {
6995d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
7005d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        status = phHciNfc_Send_RFReader_Event ( psHciContext, pHwRef,
7015d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    reader_pipe_id,(uint8_t) EVT_END_OPERATION );
7025d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        status = ( (status == NFCSTATUS_PENDING)?
7035d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                NFCSTATUS_SUCCESS : status);
7045d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    }
7055d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    return status;
7065d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly}
7075d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
7085d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
7095d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/*!
7105d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * \brief Enable the Discovery of RF Reader Managment Gate.
7115d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly *
7125d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * This function Enable the discovery of the RF Reader Management
7135d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * gate.
7145d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly *
7155d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly */
7165d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
7175d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
7185d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyNFCSTATUS
7195d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyphHciNfc_ReaderMgmt_Enable_Discovery(
7205d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                phHciNfc_sContext_t     *psHciContext,
7215d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                void                    *pHwRef
7225d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                             )
7235d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly{
7245d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    NFCSTATUS                   status = NFCSTATUS_SUCCESS;
7255d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    phHciNfc_ReaderMgmt_Info_t  *p_reader_mgmt_info=NULL;
7265d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    uint8_t                     reader_pipe_id = (uint8_t) HCI_UNKNOWN_PIPE_ID;
7275d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    /* phHal_sADD_Cfg_t    *p_poll_config = (phHal_sADD_Cfg_t * )
7285d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                            psHciContext->p_config_params; */
7295d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    PHNFC_UNUSED_VARIABLE(p_reader_mgmt_info);
7305d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    if( NULL != psHciContext->p_reader_mgmt_info )
7315d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    {
7325d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        uint8_t rdr_enable = FALSE;
7335d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        p_reader_mgmt_info = (phHciNfc_ReaderMgmt_Info_t *)
7345d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                            psHciContext->p_reader_mgmt_info ;
7355d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#ifdef TYPE_B
7365d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        if ( (NULL != psHciContext->p_reader_b_info )
7375d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly             /*   && (FALSE == rdr_enable) */
7385d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        )
7395d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        {
7405d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            /* Get the Reader B Pipe ID */
7415d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            status = phHciNfc_ReaderB_Get_PipeID
7425d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                    (psHciContext, &reader_pipe_id);
7435d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
7445d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            if( NFCSTATUS_SUCCESS == status )
7455d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            {
7465d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                rdr_enable = (uint8_t)TRUE;
7475d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                /* rdr_enable = (uint8_t)
7485d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                        p_poll_config->PollDevInfo.PollCfgInfo.EnableIso14443B; */
7495d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                status =    phHciNfc_ReaderB_Update_Info(psHciContext,
7505d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                        HCI_RDR_ENABLE_TYPE, &rdr_enable);
7515d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            }
7525d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        }
7535d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif
7545d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#ifdef TYPE_FELICA
7555d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        if ( (NULL != psHciContext->p_felica_info )
7565d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly               /* && (FALSE == rdr_enable) */
7575d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        )
7585d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        {
7595d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            /* Get the Reader F Pipe ID */
7605d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            status = phHciNfc_Felica_Get_PipeID
7615d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                    (psHciContext, &reader_pipe_id);
7625d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
7635d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            if( NFCSTATUS_SUCCESS == status )
7645d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            {
7655d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                rdr_enable = (uint8_t)TRUE;
7665d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly               /* rdr_enable = (uint8_t)
7675d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    ( p_poll_config->PollDevInfo.PollCfgInfo.EnableFelica212
7685d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                        || p_poll_config->PollDevInfo.PollCfgInfo.EnableFelica424 ); */
7695d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                status =    phHciNfc_Felica_Update_Info(psHciContext,
7705d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                        HCI_RDR_ENABLE_TYPE, &rdr_enable);
7715d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            }
7725d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        }
7735d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif
7745d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#ifdef TYPE_JEWEL
7755d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        if ( (NULL != psHciContext->p_jewel_info )
7765d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly               /* && (FALSE == rdr_enable) */
7775d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        )
7785d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        {
7795d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            /* Get the Reader F Pipe ID */
7805d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            status = phHciNfc_Jewel_Get_PipeID
7815d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                    (psHciContext, &reader_pipe_id);
7825d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
7835d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            if( NFCSTATUS_SUCCESS == status )
7845d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            {
7855d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                rdr_enable = (uint8_t)TRUE;
7865d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                status =    phHciNfc_Jewel_Update_Info(psHciContext,
7875d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                        HCI_RDR_ENABLE_TYPE, &rdr_enable);
7885d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            }
7895d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        }
7905d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif /* #ifdef TYPE_JEWEL */
7915d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#if defined(TYPE_ISO15693)
7925d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        if ( (NULL != psHciContext->p_iso_15693_info )
7935d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly               /* && (FALSE == rdr_enable) */
7945d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        )
7955d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        {
7965d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            /* Get the Reader F Pipe ID */
7975d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            status = phHciNfc_ISO15693_Get_PipeID
7985d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                    (psHciContext, &reader_pipe_id);
7995d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
8005d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            if( NFCSTATUS_SUCCESS == status )
8015d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            {
8025d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                rdr_enable = (uint8_t)TRUE;
8035d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                status =    phHciNfc_ISO15693_Update_Info(psHciContext,
8045d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                        HCI_RDR_ENABLE_TYPE, &rdr_enable);
8055d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            }
8065d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        }
8075d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
8085d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/* end of #elif defined(TYPE_ISO15693) */
8095d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif
8105d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
8115d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        if(NULL != psHciContext->p_reader_a_info)
8125d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        {
8135d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            /* Get the Reader A Pipe ID */
8145d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            status = phHciNfc_ReaderA_Get_PipeID
8155d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                    (psHciContext, &reader_pipe_id);
8165d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
8175d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            if( NFCSTATUS_SUCCESS == status )
8185d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            {
8195d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                rdr_enable = (uint8_t)TRUE;
8205d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                status =    phHciNfc_ReaderA_Update_Info(psHciContext,
8215d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                        HCI_RDR_ENABLE_TYPE, &rdr_enable);
8225d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            }
8235d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
8245d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        }
8255d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        if( ( NFCSTATUS_SUCCESS == status )
8265d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            && (reader_pipe_id != HCI_UNKNOWN_PIPE_ID )
8275d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly          )
8285d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        {
8295d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            status = phHciNfc_ReaderMgmt_Initiate_Discovery( psHciContext,
8305d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                         pHwRef, reader_pipe_id);
8315d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        }
8325d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
8335d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    }/* End of the Reader Info Memory Check */
8345d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
8355d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    return status;
8365d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly}
8375d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
8385d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/*!
8395d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * \brief Disable the Discovery of RF Reader Managment Gate.
8405d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly *
8415d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * This function Disable the discovery of the RF Reader Management
8425d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * gate.
8435d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly *
8445d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly */
8455d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
8465d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyNFCSTATUS
8475d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyphHciNfc_ReaderMgmt_Disable_Discovery(
8485d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                phHciNfc_sContext_t     *psHciContext,
8495d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                void                    *pHwRef
8505d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                             )
8515d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly{
8525d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    NFCSTATUS                   status = NFCSTATUS_FAILED;
8535d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    phHciNfc_ReaderMgmt_Info_t  *p_reader_mgmt_info=NULL;
8545d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    uint8_t                     reader_pipe_id = (uint8_t) HCI_UNKNOWN_PIPE_ID;
8555d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    /* phHal_sADD_Cfg_t         *p_poll_config = (phHal_sADD_Cfg_t * )
8565d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                            psHciContext->p_config_params; */
8575d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    PHNFC_UNUSED_VARIABLE(p_reader_mgmt_info);
8585d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    if( NULL != psHciContext->p_reader_mgmt_info )
8595d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    {
8605d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        p_reader_mgmt_info = (phHciNfc_ReaderMgmt_Info_t *)
8615d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                            psHciContext->p_reader_mgmt_info ;
8625d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        if(NULL != psHciContext->p_reader_a_info)
8635d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        {
8645d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            /* Get the Reader A Pipe ID */
8655d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            status = phHciNfc_ReaderA_Get_PipeID
8665d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                    (psHciContext, &reader_pipe_id);
8675d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#if 0
8685d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            if( NFCSTATUS_SUCCESS == status )
8695d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            {
8705d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                uint8_t rdr_enable = (uint8_t) FALSE;
8715d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                status =    phHciNfc_ReaderA_Update_Info(psHciContext,
8725d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                        HCI_RDR_ENABLE_TYPE, &rdr_enable);
8735d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            }
8745d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif
8755d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
8765d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        }
8775d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#ifdef TYPE_B
8785d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        else if((NULL != psHciContext->p_reader_b_info )
8795d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            /* && (NFCSTATUS_SUCCESS != status) */
8805d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            )
8815d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        {
8825d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            /* Get the Reader B Pipe ID */
8835d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            status = phHciNfc_ReaderB_Get_PipeID
8845d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                    (psHciContext, &reader_pipe_id);
8855d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        }
8865d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif
8875d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#ifdef TYPE_FELICA
8885d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        else if((NULL != psHciContext->p_felica_info )
8895d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            /* && (NFCSTATUS_SUCCESS != status) */
8905d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            )
8915d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        {
8925d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            /* Get the Reader B Pipe ID */
8935d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            status = phHciNfc_Felica_Get_PipeID
8945d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                    (psHciContext, &reader_pipe_id);
8955d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        }
8965d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif
8975d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#ifdef TYPE_JEWEL
8985d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        else if((NULL != psHciContext->p_jewel_info )
8995d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            /* && (NFCSTATUS_SUCCESS != status) */
9005d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            )
9015d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        {
9025d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            /* Get the Reader B Pipe ID */
9035d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            status = phHciNfc_Jewel_Get_PipeID
9045d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                    (psHciContext, &reader_pipe_id);
9055d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        }
9065d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif /* #ifdef TYPE_JEWEL */
9075d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#ifdef  TYPE_ISO15693
9085d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        else if((NULL != psHciContext->p_iso_15693_info )
9095d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            /* && (NFCSTATUS_SUCCESS != status) */
9105d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            )
9115d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        {
9125d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            /* Get the Reader B Pipe ID */
9135d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            status = phHciNfc_ISO15693_Get_PipeID
9145d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                    (psHciContext, &reader_pipe_id);
9155d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        }
9165d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif /* #ifdef    TYPE_ISO15693 */
9175d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
9185d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        else
9195d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        {
9205d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_NOT_ALLOWED);
9215d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        }
9225d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
9235d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        if( (NFCSTATUS_SUCCESS == status)
9245d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            && (reader_pipe_id != HCI_UNKNOWN_PIPE_ID )
9255d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            )
9265d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        {
9275d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            status = phHciNfc_ReaderMgmt_End_Discovery( psHciContext,
9285d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                         pHwRef, reader_pipe_id);
9295d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        }
9305d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
9315d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    }/* End of the Reader Info Memory Check */
9325d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
9335d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    return status;
9345d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly}
9355d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
9365d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
9375d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
9385d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
9395d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/*!
9405d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* \brief Updates the Sequence of RF Reader Managment Gate.
9415d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly*
9425d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* This function Resets/Updates the sequence of the RF Reader Management
9435d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* gate.
9445d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly*
9455d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly*/
9465d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
9475d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyNFCSTATUS
9485d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyphHciNfc_ReaderMgmt_Info_Sequence(
9495d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                   phHciNfc_sContext_t      *psHciContext,
9505d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                   void                     *pHwRef
9515d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                               )
9525d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly{
9535d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#if defined(NXP_NFCIP_ACTIVATE_DELAY)
9545d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    static uint8_t              nfc_atr_retry = 0;
9555d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif
9565d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    NFCSTATUS                   status = NFCSTATUS_SUCCESS;
9575d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    phHciNfc_ReaderMgmt_Info_t  *p_reader_mgmt_info=NULL;
9585d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#if 0
9595d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    uint8_t                     reader_pipe_id = (uint8_t) HCI_UNKNOWN_PIPE_ID;
9605d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    phHal_eRemDevType_t         target_type = phHal_eUnknown_DevType;
9615d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif
9625d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
9635d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
9645d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    PHNFC_UNUSED_VARIABLE(p_reader_mgmt_info);
9655d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    if( NULL == psHciContext )
9665d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    {
9675d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_INVALID_PARAMETER);
9685d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    }
9695d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    else
9705d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    {
9715d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        if( NULL != psHciContext->p_reader_mgmt_info )
9725d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        {
9735d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            p_reader_mgmt_info = (phHciNfc_ReaderMgmt_Info_t *)
9745d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                psHciContext->p_reader_mgmt_info ;
9755d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            switch( psHciContext->host_rf_type )
9765d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            {
9775d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
9785d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                case phHal_eISO14443_A_PCD:
9795d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                {
9805d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    /* If the Target Info is updated then the Target
9815d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                     * is connected.
9825d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                     */
9835d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    if(NULL == psHciContext->p_target_info)
9845d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    {
9855d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#if defined(NXP_NFCIP_ACTIVATE_DELAY)
9865d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                        nfc_atr_retry = 0;
9875d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif
9885d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                        status = phHciNfc_ReaderA_Info_Sequence(
9895d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                                    psHciContext, pHwRef );
9905d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    }
9915d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    else
9925d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    {
9935d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                            status = phHciNfc_ReaderA_App_Data(
9945d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                                psHciContext, pHwRef );
9955d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                            status = ((NFCSTATUS_PENDING == status )?
9965d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                        NFCSTATUS_SUCCESS : status);
9975d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    }
9985d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    break;
9995d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                }
10005d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#ifdef ENABLE_P2P
10015d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                case phHal_eNfcIP1_Initiator:
10025d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                {
10035d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    /* If the Target Info is updated then the Target
10045d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                     * is connected.
10055d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                     */
10065d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#ifdef NFCIP_CHECK
10075d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    if(NULL == psHciContext->p_target_info)
10085d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif
10095d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    {
10105d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                        status = phHciNfc_NfcIP_Info_Sequence(
10115d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                  psHciContext, pHwRef
10125d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#ifdef NOTIFY_REQD
10135d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                    ,(NULL == psHciContext->p_target_info)
10145d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif /* #ifdef NOTIFY_REQD */
10155d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                           );
10165d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    }
10175d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#ifdef NFCIP_CHECK
10185d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    else
10195d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    {
10205d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                        status = phHciNfc_NfcIP_GetATRInfo(
10215d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                            psHciContext, pHwRef, NFCIP_INITIATOR );
10225d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#if defined(NXP_NFCIP_ACTIVATE_DELAY)
10235d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                        if (
10245d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                            (NFCSTATUS_PENDING == status)
10255d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                            && ( NFCIP_ACTIVATE_DELAY <= nfc_atr_retry)
10265d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                            )
10275d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                        {
10285d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                            nfc_atr_retry = 0;
10295d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                            status = NFCSTATUS_SUCCESS;
10305d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                        }
10315d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                        else
10325d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                        {
10335d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                            nfc_atr_retry++;
10345d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                        }
10355d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#else
10365d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                        status = ((NFCSTATUS_PENDING == status )?
10375d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                        NFCSTATUS_SUCCESS : status);
10385d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif
10395d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    }
10405d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif
10415d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    break;
10425d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                }
10435d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif
10445d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#ifdef TYPE_B
10455d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                case phHal_eISO14443_B_PCD:
10465d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                {
10475d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    if(NULL == psHciContext->p_target_info)
10485d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    {
10495d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                        status = phHciNfc_ReaderB_Info_Sequence(
10505d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                                    psHciContext, pHwRef );
10515d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    }
10525d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    break;
10535d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                }
10545d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif /* #ifdef TYPE_B */
10555d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#ifdef TYPE_FELICA
10565d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                case phHal_eFelica_PCD:
10575d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                {
10585d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    if(NULL == psHciContext->p_target_info)
10595d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    {
10605d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#if defined(NXP_NFCIP_ACTIVATE_DELAY)
10615d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                        nfc_atr_retry = 0;
10625d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif
10635d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                        status = phHciNfc_Felica_Info_Sequence(
10645d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                                    psHciContext, pHwRef );
10655d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    }
10665d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    break;
10675d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                }
10685d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif /* #ifdef TYPE_FELICA */
10695d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#ifdef TYPE_JEWEL
10705d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                case phHal_eJewel_PCD:
10715d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                {
10725d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    if(NULL == psHciContext->p_target_info)
10735d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    {
10745d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                        status = phHciNfc_Jewel_Info_Sequence(
10755d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                                    psHciContext, pHwRef );
10765d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    }
10775d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    break;
10785d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                }
10795d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif /* #ifdef TYPE_JEWEL */
10805d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#if defined(TYPE_ISO15693)
10815d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                case phHal_eISO15693_PCD:
10825d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                {
10835d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    if(NULL == psHciContext->p_target_info)
10845d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    {
10855d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                        status = phHciNfc_ISO15693_Info_Sequence(
10865d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                                    psHciContext, pHwRef );
10875d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    }
10885d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    break;
10895d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                }
10905d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif
10915d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                default:
10925d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                {
10935d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    break;
10945d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                }
10955d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            }
10965d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
10975d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        }/* End of the Reader Info Memory Check */
10985d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
10995d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    } /* End of Null Context Check */
11005d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
11015d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    return status;
11025d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
11035d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly}
11045d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
11055d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
11065d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/*!
11075d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * \brief Connects the the selected tag via RF Reader Gates.
11085d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly *
11095d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * This function connects the selected tags via RF Reader Gate.
11105d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * This function uses the RF Reader gate based on the type of the
11115d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * tag specified.
11125d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly */
11135d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
11145d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
11155d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyNFCSTATUS
11165d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyphHciNfc_ReaderMgmt_Select(
11175d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                    phHciNfc_sContext_t     *psHciContext,
11185d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                    void                    *pHwRef,
11195d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                    phHal_eRemDevType_t     target_type
11205d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                )
11215d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly{
11225d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    NFCSTATUS                   status = NFCSTATUS_SUCCESS;
11235d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    uint8_t                     reader_pipe_id = (uint8_t) HCI_UNKNOWN_PIPE_ID;
11245d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
11255d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    if( (NULL == psHciContext) || (NULL == pHwRef) )
11265d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    {
11275d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly      status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_INVALID_PARAMETER);
11285d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    }
11295d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    else
11305d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    {
11315d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        switch (target_type)
11325d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        {
11335d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            case phHal_eMifare_PICC:
11345d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            case phHal_eISO14443_3A_PICC:
11355d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            {
11365d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                /* Get the Reader A Pipe ID */
11375d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                status = phHciNfc_ReaderA_Get_PipeID
11385d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                        (psHciContext, &reader_pipe_id);
11395d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
11405d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                if( (NFCSTATUS_SUCCESS == status)
11415d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    && (reader_pipe_id != HCI_UNKNOWN_PIPE_ID )
11425d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    )
11435d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                {
11445d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    status = phHciNfc_ReaderMgmt_Reactivate(
11455d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                            psHciContext, pHwRef, target_type );
11465d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                }
11475d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                break;
11485d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            }
11495d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            case phHal_eISO14443_A_PICC:
11505d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            case phHal_eISO14443_4A_PICC:
11515d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            {
11525d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#ifdef ENABLE_AUTO_ACTIVATE
11535d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                /* Get the Reader A Pipe ID */
11545d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                status = phHciNfc_ReaderA_Get_PipeID
11555d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                        (psHciContext, &reader_pipe_id);
11565d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
11575d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                if( (NFCSTATUS_SUCCESS == status)
11585d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    && (reader_pipe_id != HCI_UNKNOWN_PIPE_ID )
11595d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    )
11605d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                {
11615d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    status = phHciNfc_Send_RFReader_Command (psHciContext,
11625d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                    pHwRef, reader_pipe_id, NXP_WR_PRESCHECK );
11635d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                }
11645d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#else
11655d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                status = phHciNfc_ReaderA_Cont_Activate(
11665d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                                    psHciContext, pHwRef);
11675d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif /* #ifdef ENABLE_AUTO_ACTIVATE */
11685d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                break;
11695d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            }
11705d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#ifdef TYPE_B
11715d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            case phHal_eISO14443_B_PICC:
11725d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            case phHal_eISO14443_4B_PICC:
11735d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            {
11745d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                /* Get the Reader B Pipe ID */
11755d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                status = phHciNfc_ReaderB_Get_PipeID
11765d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                        (psHciContext, &reader_pipe_id);
11775d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
11785d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                if( (NFCSTATUS_SUCCESS == status)
11795d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    && (reader_pipe_id != HCI_UNKNOWN_PIPE_ID )
11805d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    )
11815d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                {
11825d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    status = phHciNfc_Send_RFReader_Command (psHciContext,
11835d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                    pHwRef, reader_pipe_id, NXP_WR_PRESCHECK );
11845d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    /* status = phHciNfc_ReaderA_Set_DataRateMax(
11855d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                        psHciContext, pHwRef,
11865d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                        DATA_RATE_MAX_DEFAULT_VALUE ); */
11875d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    /* status = phHciNfc_ReaderMgmt_Reactivate(
11885d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                            psHciContext, pHwRef, target_type ); */
11895d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                }
11905d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                break;
11915d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            }
11925d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif /* #ifdef TYPE_B */
11935d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#ifdef TYPE_FELICA
11945d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            case phHal_eFelica_PICC:
11955d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            {
11965d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                status = phHciNfc_Felica_Get_PipeID
11975d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                        (psHciContext, &reader_pipe_id);
11985d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
11995d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                if( (NFCSTATUS_SUCCESS == status)
12005d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    && (reader_pipe_id != HCI_UNKNOWN_PIPE_ID )
12015d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    )
12025d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                {
12035d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    /* Get the Reader Felica Pipe ID */
12045d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    /* status = phHciNfc_ReaderA_Set_DataRateMax(
12055d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                        psHciContext, pHwRef,
12065d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                        DATA_RATE_MAX_DEFAULT_VALUE ); */
12075d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    status = phHciNfc_ReaderMgmt_Reactivate(
12085d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                            psHciContext, pHwRef, target_type );
12095d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                }
12105d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                break;
12115d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            }
12125d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif /* #ifdef TYPE_FELICA */
12135d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#ifdef TYPE_JEWEL
12145d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            case phHal_eJewel_PICC:
12155d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            {
12165d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                /* Get the Reader jewel Pipe ID */
12175d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                status = phHciNfc_Jewel_Get_PipeID
12185d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                        (psHciContext, &reader_pipe_id);
12195d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
12205d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                if( (NFCSTATUS_SUCCESS == status)
12215d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    && (reader_pipe_id != HCI_UNKNOWN_PIPE_ID )
12225d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    )
12235d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                {
12245d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    status = phHciNfc_Jewel_GetRID(
12255d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                        psHciContext, pHwRef);
12265d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                }
12275d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                break;
12285d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            }
12295d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif /* #ifdef TYPE_JEWEL */
12305d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#ifdef  TYPE_ISO15693
12315d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            case phHal_eISO15693_PICC:
12325d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            {
12335d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                /* Get the Reader ISO 15693 Pipe ID */
12345d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                status = phHciNfc_ISO15693_Get_PipeID
12355d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                        (psHciContext, &reader_pipe_id);
12365d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
12375d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                if( (NFCSTATUS_SUCCESS == status)
12385d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    && (reader_pipe_id != HCI_UNKNOWN_PIPE_ID )
12395d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    )
12405d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                {
12415d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    /* TODO */
12425d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    status = phHciNfc_ReaderA_Set_DataRateMax(
12435d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                        psHciContext, pHwRef,
12445d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                        DATA_RATE_MAX_DEFAULT_VALUE );
12455d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                }
12465d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                break;
12475d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            }
12485d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif /* #ifdef    TYPE_ISO15693 */
12495d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#ifdef ENABLE_P2P
12505d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            case phHal_eNfcIP1_Target:
12515d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            {
12525d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                if ( (phHal_eISO14443_A_PCD ==
12535d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                            psHciContext->host_rf_type )
12545d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                   || (phHal_eFelica_PCD ==
12555d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                            psHciContext->host_rf_type )
12565d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                   )
12575d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                {
12585d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    status = phHciNfc_Initiator_Cont_Activate(
12595d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                                    psHciContext, pHwRef);
12605d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                }
12615d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                else
12625d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                {
12635d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    status = phHciNfc_NfcIP_Presence_Check (psHciContext, pHwRef);
12645d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                }
12655d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                break;
12665d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            }
12675d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif
12685d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#if 0
12695d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            case phHal_eNfcIP1_Initiator:
12705d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            {
12715d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
12725d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                break;
12735d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            }
12745d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif
12755d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            default:
12765d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            {
12775d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_FEATURE_NOT_SUPPORTED);
12785d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                break;
12795d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            }
12805d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
12815d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        } /* End of the tag_type Switch */
12825d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    }
12835d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
12845d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    return status;
12855d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly}
12865d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
12875d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyNFCSTATUS
12885d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyphHciNfc_ReaderMgmt_UICC_Dispatch(
12895d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                    phHciNfc_sContext_t     *psHciContext,
12905d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                    void                    *pHwRef,
12915d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                    phHal_eRemDevType_t     target_type
12925d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                )
12935d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly{
12945d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    NFCSTATUS                   status = NFCSTATUS_SUCCESS;
12955d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    uint8_t                     reader_pipe_id = (uint8_t) HCI_UNKNOWN_PIPE_ID;
12965d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    phHciNfc_Pipe_Info_t        *p_pipe_info = NULL;
12975d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
12985d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
12995d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    if( (NULL == psHciContext) || (NULL == pHwRef) )
13005d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    {
13015d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly      status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_INVALID_PARAMETER);
13025d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    }
13035d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    else if (NULL == psHciContext->p_target_info)
13045d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    {
13055d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_INVALID_HCI_INFORMATION);
13065d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    }
13075d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    else
13085d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    {
13095d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        switch (target_type)
13105d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        {
13115d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            case phHal_eISO14443_A_PICC:
13125d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            case phHal_eISO14443_4A_PICC:
13135d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            {
13145d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                /* Get the Reader A Pipe ID */
13155d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                status = phHciNfc_ReaderA_Get_PipeID(
13165d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                    psHciContext, &reader_pipe_id);
13175d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                p_pipe_info = psHciContext->p_pipe_list[reader_pipe_id];
13185d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                p_pipe_info->param_info = &psHciContext->p_target_info->
13195d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                    RemoteDevInfo.Iso14443A_Info.Uid;
13205d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                p_pipe_info->param_length = psHciContext->p_target_info->
13215d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                    RemoteDevInfo.Iso14443A_Info.UidLength;
13225d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
13235d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                break;
13245d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            }
13255d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#ifdef TYPE_B
13265d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            case phHal_eISO14443_B_PICC:
13275d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            case phHal_eISO14443_4B_PICC:
13285d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            {
13295d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                /* Get the Reader B Pipe ID */
13305d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                status = phHciNfc_ReaderB_Get_PipeID
13315d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    (psHciContext, &reader_pipe_id);
13325d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
13335d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                p_pipe_info = psHciContext->p_pipe_list[reader_pipe_id];
13345d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                p_pipe_info->param_info = &psHciContext->p_target_info->
13355d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                        RemoteDevInfo.Iso14443B_Info.AtqB.AtqResInfo.Pupi;
13365d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                p_pipe_info->param_length = PHHAL_PUPI_LENGTH;
13375d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                break;
13385d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            }
13395d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif /* #ifdef TYPE_B */
13405d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            case phHal_eMifare_PICC:
13415d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            case phHal_eISO14443_3A_PICC:
13425d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            default:
13435d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            {
13445d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_FEATURE_NOT_SUPPORTED);
13455d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                break;
13465d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            }
13475d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
13485d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        } /* End of the tag_type Switch */
13495d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    }
13505d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    if( (NFCSTATUS_SUCCESS == status)
13515d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        && (reader_pipe_id != HCI_UNKNOWN_PIPE_ID )
13525d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        )
13535d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    {
13545d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        status = phHciNfc_Send_RFReader_Command (psHciContext,
13555d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                        pHwRef, reader_pipe_id, NXP_WR_DISPATCH_TO_UICC );
13565d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    }
13575d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
13585d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    return status;
13595d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly}
13605d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
13615d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
13625d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyNFCSTATUS
13635d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyphHciNfc_ReaderMgmt_Reactivate(
13645d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                    phHciNfc_sContext_t     *psHciContext,
13655d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                    void                    *pHwRef,
13665d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                    phHal_eRemDevType_t     target_type
13675d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                )
13685d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly{
13695d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    NFCSTATUS                   status = NFCSTATUS_SUCCESS;
13705d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    uint8_t                     reader_pipe_id = (uint8_t) HCI_UNKNOWN_PIPE_ID;
13715d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    phHciNfc_Pipe_Info_t        *p_pipe_info = NULL;
13725d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
13735d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
13745d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    if( (NULL == psHciContext) || (NULL == pHwRef) )
13755d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    {
13765d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly      status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_INVALID_PARAMETER);
13775d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    }
13785d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    else if (NULL == psHciContext->p_target_info)
13795d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    {
13805d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_INVALID_HCI_INFORMATION);
13815d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    }
13825d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    else
13835d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    {
13845d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        switch (target_type)
13855d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        {
13865d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            case phHal_eISO14443_A_PICC:
13875d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            case phHal_eMifare_PICC:
13885d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            case phHal_eISO14443_4A_PICC:
13895d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            case phHal_eISO14443_3A_PICC:
13905d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            {
13915d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                /* Get the Reader A Pipe ID */
13925d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                status = phHciNfc_ReaderA_Get_PipeID(
13935d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                    psHciContext, &reader_pipe_id);
13945d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                p_pipe_info = psHciContext->p_pipe_list[reader_pipe_id];
13955d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                p_pipe_info->param_info = &psHciContext->p_target_info->
13965d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                    RemoteDevInfo.Iso14443A_Info.Uid;
13975d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                p_pipe_info->param_length = psHciContext->p_target_info->
13985d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                    RemoteDevInfo.Iso14443A_Info.UidLength;
13995d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
14005d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                break;
14015d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            }
14025d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#ifdef TYPE_B
14035d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            case phHal_eISO14443_B_PICC:
14045d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            case phHal_eISO14443_4B_PICC:
14055d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            {
14065d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                /* Get the Reader B Pipe ID */
14075d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                status = phHciNfc_ReaderB_Get_PipeID
14085d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    (psHciContext, &reader_pipe_id);
14095d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
14105d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                p_pipe_info = psHciContext->p_pipe_list[reader_pipe_id];
14115d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                p_pipe_info->param_info = &psHciContext->p_target_info->
14125d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                        RemoteDevInfo.Iso14443B_Info.AtqB.AtqResInfo.Pupi;
14135d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                p_pipe_info->param_length = PHHAL_PUPI_LENGTH;
14145d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                break;
14155d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            }
14165d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif /* #ifdef TYPE_B */
14175d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#ifdef TYPE_FELICA
14185d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            case phHal_eFelica_PICC:
14195d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            {
14205d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                /* Get the Felica Reader Pipe ID */
14215d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                status = phHciNfc_Felica_Get_PipeID
14225d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                        (psHciContext, &reader_pipe_id);
14235d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
14245d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                if( (NFCSTATUS_SUCCESS == status)
14255d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    && (reader_pipe_id != HCI_UNKNOWN_PIPE_ID )
14265d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    )
14275d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                {
14285d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                p_pipe_info = psHciContext->p_pipe_list[reader_pipe_id];
14295d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                p_pipe_info->param_info = &psHciContext->p_target_info->
14305d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    RemoteDevInfo.Felica_Info.IDm;
14315d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                p_pipe_info->param_length = PHHAL_FEL_ID_LEN;
14325d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                }
14335d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                break;
14345d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            }
14355d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif /* #ifdef TYPE_FELICA */
14365d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#ifdef ENABLE_P2P
14375d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            case phHal_eNfcIP1_Target:
14385d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            {
14395d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                /* Get the Initiator Pipe ID */
14405d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                status = phHciNfc_Initiator_Get_PipeID(
14415d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                    psHciContext, &reader_pipe_id);
14425d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                p_pipe_info = psHciContext->p_pipe_list[reader_pipe_id];
14435d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                p_pipe_info->param_info = &psHciContext->p_target_info->
14445d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                            RemoteDevInfo.NfcIP_Info.NFCID;
14455d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                p_pipe_info->param_length = psHciContext->p_target_info->
14465d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                        RemoteDevInfo.NfcIP_Info.NFCID_Length;
14475d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                break;
14485d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            }
14495d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            case phHal_eNfcIP1_Initiator:
14505d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            {
14515d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_FEATURE_NOT_SUPPORTED);
14525d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                break;
14535d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            }
14545d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif /* #ifdef ENABLE_P2P */
14555d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            default:
14565d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            {
14575d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_FEATURE_NOT_SUPPORTED);
14585d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                break;
14595d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            }
14605d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
14615d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        } /* End of the tag_type Switch */
14625d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    }
14635d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    if( (NFCSTATUS_SUCCESS == status)
14645d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        && (reader_pipe_id != HCI_UNKNOWN_PIPE_ID )
14655d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        )
14665d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    {
14675d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        status = phHciNfc_Send_RFReader_Command (psHciContext,
14685d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                        pHwRef, reader_pipe_id, NXP_WR_ACTIVATE_ID );
14695d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    }
14705d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
14715d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    return status;
14725d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly}
14735d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
14745d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
14755d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/*!
14765d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* \brief Activates the next Remote Target in the field.
14775d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly*
14785d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* This function selects and activates the next tag present in the field.
14795d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly*/
14805d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
14815d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
14825d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyNFCSTATUS
14835d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyphHciNfc_ReaderMgmt_Activate_Next(
14845d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                  phHciNfc_sContext_t       *psHciContext,
14855d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                  void                  *pHwRef
14865d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                  )
14875d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly{
14885d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    NFCSTATUS                   status = NFCSTATUS_SUCCESS;
14895d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    /* phHciNfc_Pipe_Info_t     *p_pipe_info = NULL; */
14905d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    uint8_t                     reader_pipe_id = (uint8_t) HCI_UNKNOWN_PIPE_ID;
14915d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
14925d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    if( (NULL == psHciContext) || (NULL == pHwRef) )
14935d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    {
14945d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_INVALID_PARAMETER);
14955d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    }
14965d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    else
14975d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    {
14985d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        switch ( psHciContext->host_rf_type )
14995d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        {
15005d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            case phHal_eISO14443_A_PCD:
15015d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            {
15025d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                /* Get the Reader A Pipe ID */
15035d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                status = phHciNfc_ReaderA_Get_PipeID
15045d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    (psHciContext, &reader_pipe_id);
15055d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
15065d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                break;
15075d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            }
15085d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#ifdef TYPE_B
15095d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            case phHal_eISO14443_B_PCD:
15105d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            {
15115d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                /* Get the Reader B Pipe ID */
15125d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                status = phHciNfc_ReaderB_Get_PipeID
15135d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    (psHciContext, &reader_pipe_id);
15145d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
15155d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                break;
15165d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            }
15175d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif /* #ifdef TYPE_B */
15185d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#ifdef TYPE_FELICA
15195d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            case phHal_eFelica_PCD:
15205d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            {
15215d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                /* Get the Felica Reader Pipe ID */
15225d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                status = phHciNfc_Felica_Get_PipeID
15235d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                        (psHciContext, &reader_pipe_id);
15245d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
15255d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                break;
15265d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            }
15275d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif /* #ifdef TYPE_FELICA */
1528e1b8bffcf9ff1a5c290c03be5a1d85be0c103223aferir#ifdef  TYPE_ISO15693
1529e1b8bffcf9ff1a5c290c03be5a1d85be0c103223aferir            case phHal_eISO15693_PCD:
1530e1b8bffcf9ff1a5c290c03be5a1d85be0c103223aferir            {
1531e1b8bffcf9ff1a5c290c03be5a1d85be0c103223aferir                /* Get the ISO 15693 Reader Pipe ID */
1532e1b8bffcf9ff1a5c290c03be5a1d85be0c103223aferir                status = phHciNfc_ISO15693_Get_PipeID
1533e1b8bffcf9ff1a5c290c03be5a1d85be0c103223aferir                                        (psHciContext, &reader_pipe_id);
1534e1b8bffcf9ff1a5c290c03be5a1d85be0c103223aferir
1535e1b8bffcf9ff1a5c290c03be5a1d85be0c103223aferir                break;
1536e1b8bffcf9ff1a5c290c03be5a1d85be0c103223aferir            }
1537e1b8bffcf9ff1a5c290c03be5a1d85be0c103223aferir#endif /* #ifdef TYPE_ISO15693 */
15385d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            default:
15395d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            {
15405d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_FEATURE_NOT_SUPPORTED);
15415d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                break;
15425d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            }
15435d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
15445d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        } /* End of the reader_type Switch */
15455d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        if( (NFCSTATUS_SUCCESS == status)
15465d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            && (reader_pipe_id != HCI_UNKNOWN_PIPE_ID )
15475d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly          )
15485d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        {
15495d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            status = phHciNfc_Send_RFReader_Command (psHciContext,
15505d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                pHwRef, reader_pipe_id, NXP_WR_ACTIVATE_NEXT );
15515d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        }
15525d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
15535d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    }
15545d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
15555d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    return status;
15565d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
15575d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly}
15585d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
15595d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/*!
15605d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* \brief Checks the presence of the Remote Target in the field.
15615d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly*
15625d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* This function checks the presence of the tag present in the field.
15635d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly*/
15645d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
15655d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
15665d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyNFCSTATUS
15675d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyphHciNfc_ReaderMgmt_Presence_Check(
15685d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                  phHciNfc_sContext_t       *psHciContext,
15695d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                  void                  *pHwRef
15705d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                  )
15715d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly{
15725d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    NFCSTATUS                   status = NFCSTATUS_SUCCESS;
15735d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    /* phHciNfc_Pipe_Info_t     *p_pipe_info = NULL; */
15745d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    uint8_t                     reader_pipe_id = (uint8_t) HCI_UNKNOWN_PIPE_ID;
15755d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    phHal_eRemDevType_t         target_type = phHal_eUnknown_DevType;
15765d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
15775d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    if( (NULL == psHciContext) || (NULL == pHwRef) )
15785d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    {
15795d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_INVALID_PARAMETER);
15805d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    }
15815d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    else
15825d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    {
15835d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        target_type = psHciContext->p_target_info->RemDevType;
15845d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        switch (target_type)
15855d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        {
15865d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            case phHal_eMifare_PICC:
15875d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            case phHal_eISO14443_3A_PICC:
15885d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            {
15895d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                /* Get the Reader A Pipe ID */
15905d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                status = phHciNfc_ReaderA_Get_PipeID
15915d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    (psHciContext, &reader_pipe_id);
15925d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
15935d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                if( (NFCSTATUS_SUCCESS == status)
15945d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    && (reader_pipe_id != HCI_UNKNOWN_PIPE_ID )
15955d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    )
15965d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                {
15975d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    status = phHciNfc_ReaderMgmt_Reactivate(
15985d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                            psHciContext, pHwRef, target_type );
15995d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                }
16005d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                break;
16015d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            }
16025d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            case phHal_eISO14443_A_PICC:
16035d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            case phHal_eISO14443_4A_PICC:
16045d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            {
16055d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                /* Get the Reader A Pipe ID */
16065d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                status = phHciNfc_ReaderA_Get_PipeID
16075d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    (psHciContext, &reader_pipe_id);
16085d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
16095d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                if( (NFCSTATUS_SUCCESS == status)
16105d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    && (reader_pipe_id != HCI_UNKNOWN_PIPE_ID )
16115d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    )
16125d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                {
16135d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    status = phHciNfc_Send_RFReader_Command (psHciContext,
16145d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                        pHwRef, reader_pipe_id, NXP_WR_PRESCHECK );
16155d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                }
16165d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                break;
16175d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            }
16185d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#ifdef ENABLE_P2P
16195d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            case phHal_eNfcIP1_Target:
16205d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            {
16215d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                status = phHciNfc_NfcIP_Presence_Check (psHciContext, pHwRef);
16225d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                break;
16235d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            }
16245d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif
16255d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#ifdef TYPE_B
16265d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            case phHal_eISO14443_B_PICC:
16275d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            case phHal_eISO14443_4B_PICC:
16285d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            {
16295d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                /* Get the Reader B Pipe ID */
16305d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                status = phHciNfc_ReaderB_Get_PipeID
16315d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    (psHciContext, &reader_pipe_id);
16325d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
16335d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                if( (NFCSTATUS_SUCCESS == status)
16345d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    && (reader_pipe_id != HCI_UNKNOWN_PIPE_ID )
16355d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    )
16365d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                {
16375d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    status = phHciNfc_Send_RFReader_Command (psHciContext,
16385d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                            pHwRef, reader_pipe_id, NXP_WR_PRESCHECK );
16395d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                }
16405d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                break;
16415d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            }
16425d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif /* #ifdef TYPE_B */
16435d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#ifdef TYPE_FELICA
16445d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            case phHal_eFelica_PICC:
16455d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            {
16465d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                /* Get the Felica Reader Pipe ID */
16475d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                status = phHciNfc_Felica_Get_PipeID
16485d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                        (psHciContext, &reader_pipe_id);
16495d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
16505d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                if( (NFCSTATUS_SUCCESS == status)
16515d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    && (reader_pipe_id != HCI_UNKNOWN_PIPE_ID )
16525d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    )
16535d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                {
16545d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    status = phHciNfc_Felica_Request_Mode(psHciContext, pHwRef);
16555d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                }
16565d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                break;
16575d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            }
16585d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif /* #ifdef TYPE_FELICA */
16595d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#ifdef TYPE_JEWEL
16605d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            case phHal_eJewel_PICC:
16615d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            {
16625d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                /* Get the Jewel Reader Pipe ID */
16635d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                status = phHciNfc_Jewel_Get_PipeID
16645d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                        (psHciContext, &reader_pipe_id);
16655d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
16665d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                if( (NFCSTATUS_SUCCESS == status)
16675d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    && (reader_pipe_id != HCI_UNKNOWN_PIPE_ID )
16685d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    )
16695d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                {
16705d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    /* status = PHNFCSTVAL(CID_NFC_HCI,
16715d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                    NFCSTATUS_FEATURE_NOT_SUPPORTED); */
16725d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                      status = phHciNfc_Jewel_GetRID(
16735d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                        psHciContext, pHwRef);
16745d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                }
16755d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                break;
16765d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            }
16775d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif /* #ifdef TYPE_JEWEL */
16785d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#ifdef  TYPE_ISO15693
16795d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            case phHal_eISO15693_PICC:
16805d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            {
16815d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                /* Get the Reader ISO 15693 Pipe ID */
16825d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                status = phHciNfc_ISO15693_Get_PipeID
16835d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                        (psHciContext, &reader_pipe_id);
16845d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
16855d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                if( (NFCSTATUS_SUCCESS == status)
16865d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    && (reader_pipe_id != HCI_UNKNOWN_PIPE_ID )
16875d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    )
16885d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                {
1689fa199fc046cb0bc698d564daaba669a180b7c6f4Martijn Coenen                    uint8_t cmd[11];
1690fa199fc046cb0bc698d564daaba669a180b7c6f4Martijn Coenen                    phHciNfc_Pipe_Info_t *p_pipe_info = NULL;
16915d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    p_pipe_info = psHciContext->p_pipe_list[reader_pipe_id];
1692fa199fc046cb0bc698d564daaba669a180b7c6f4Martijn Coenen                    p_pipe_info->param_info = &cmd;
1693fa199fc046cb0bc698d564daaba669a180b7c6f4Martijn Coenen                    p_pipe_info->param_length = 11;
1694fa199fc046cb0bc698d564daaba669a180b7c6f4Martijn Coenen                    // masked inventory command:
1695fa199fc046cb0bc698d564daaba669a180b7c6f4Martijn Coenen                    // set #slots to 1 to use mask without padding,
1696fa199fc046cb0bc698d564daaba669a180b7c6f4Martijn Coenen                    // need to set inventory flag to enable setting #slots
1697fa199fc046cb0bc698d564daaba669a180b7c6f4Martijn Coenen                    cmd[0] = 0x04 | 0x20; // FLAG_INVENTORY | FLAG_SLOTS
1698fa199fc046cb0bc698d564daaba669a180b7c6f4Martijn Coenen                    cmd[1] = 0x01; // CMD_INVENTORY
1699fa199fc046cb0bc698d564daaba669a180b7c6f4Martijn Coenen                    cmd[2] = 64; // mask bit-length
1700fa199fc046cb0bc698d564daaba669a180b7c6f4Martijn Coenen                    memcpy(cmd + 3, &(psHciContext->p_target_info->RemoteDevInfo.Iso15693_Info.Uid), 8);
17015d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    status = phHciNfc_Send_ISO15693_Command(
17025d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                        psHciContext,  pHwRef
17035d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                        ,reader_pipe_id, NXP_ISO15693_CMD );
17045d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
17055d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                }
17065d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                break;
17075d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            }
17085d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif /* #ifdef    TYPE_ISO15693 */
17095d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            default:
17105d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            {
17115d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                status = PHNFCSTVAL(CID_NFC_HCI,
17125d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                    NFCSTATUS_FEATURE_NOT_SUPPORTED);
17135d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                break;
17145d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            }
17155d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
17165d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        } /* End of the tag_type Switch */
17175d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    }
17185d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
17195d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    return status;
17205d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
17215d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly}
17225d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
17235d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
17245d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/*!
17255d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * \brief Disconnects the the selected tag.
17265d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly *
17275d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * This function disconnects the selected tags via RF Reader Gate.
17285d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * This function uses the RF Reader gate based on the type of the
17295d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * tag specified.
17305d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly */
17315d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
17325d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
17335d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyNFCSTATUS
17345d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyphHciNfc_ReaderMgmt_Deselect(
17355d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                    phHciNfc_sContext_t     *psHciContext,
17365d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                    void                    *pHwRef,
17375d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                    phHal_eRemDevType_t     target_type,
17385d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                    uint8_t                 re_poll
17395d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                )
17405d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly{
17415d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    static  uint8_t             rls_param = FALSE;
17425d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    NFCSTATUS                   status = NFCSTATUS_SUCCESS;
17435d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    uint8_t                     reader_pipe_id =
17445d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                    (uint8_t) HCI_UNKNOWN_PIPE_ID;
17455d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    phHciNfc_Pipe_Info_t        *p_pipe_info = NULL;
17465d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
17475d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
17485d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
17495d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    if( (NULL == psHciContext)
17505d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        || (NULL == pHwRef)
17515d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        )
17525d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    {
17535d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly      status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_INVALID_PARAMETER);
17545d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    }
17555d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    else
17565d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    {
17575d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        rls_param = re_poll;
17585d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
17595d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        switch (target_type)
17605d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        {
17615d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            case phHal_eMifare_PICC:
17625d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            case phHal_eISO14443_A_PICC:
17635d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            case phHal_eISO14443_3A_PICC:
17645d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            case phHal_eISO14443_4A_PICC:
17655d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            {
17665d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                /* Get the Reader A Pipe ID */
17675d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                status = phHciNfc_ReaderA_Get_PipeID
17685d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                        (psHciContext, &reader_pipe_id);
17695d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                break;
17705d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            }
17715d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#ifdef TYPE_B
17725d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            case phHal_eISO14443_B_PICC:
17735d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            case phHal_eISO14443_4B_PICC:
17745d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            {
17755d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                /* Get the Reader B Pipe ID */
17765d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                status = phHciNfc_ReaderB_Get_PipeID
17775d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    (psHciContext, &reader_pipe_id);
17785d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
17795d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                break;
17805d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            }
17815d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif /* #ifdef TYPE_B */
17825d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#ifdef TYPE_FELICA
17835d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            case phHal_eFelica_PICC:
17845d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            {
17855d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                /* Get the Felica Pipe ID */
17865d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                status = phHciNfc_Felica_Get_PipeID
17875d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    (psHciContext, &reader_pipe_id);
17885d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
17895d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                break;
17905d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            }
17915d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif /* #ifdef TYPE_FELICA */
17925d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#ifdef TYPE_JEWEL
17935d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            case phHal_eJewel_PICC:
17945d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            {
17955d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                /* Get the Jewel Pipe ID */
17965d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                status = phHciNfc_Jewel_Get_PipeID
17975d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    (psHciContext, &reader_pipe_id);
17985d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
17995d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                break;
18005d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            }
18015d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif /* #ifdef TYPE_JEWEL */
18025d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#ifdef  TYPE_ISO15693
18035d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            case phHal_eISO15693_PICC:
18045d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            {
18055d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                /* Get the ISO 15693 Pipe ID */
18065d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                status = phHciNfc_ISO15693_Get_PipeID
18075d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    (psHciContext, &reader_pipe_id);
18085d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
18095d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                break;
18105d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            }
18115d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif /* #ifdef    TYPE_ISO15693 */
18125d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#ifdef ENABLE_P2P
18135d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            case phHal_eNfcIP1_Target:
18145d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            {
18155d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                /* Get the Reader A Pipe ID */
18165d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                status = phHciNfc_Initiator_Get_PipeID
18175d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                        (psHciContext, &reader_pipe_id);
18185d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
18195d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                break;
18205d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            }
18215d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif
18225d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            default:
18235d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            {
18245d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                status = PHNFCSTVAL(CID_NFC_HCI,
18255d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                            NFCSTATUS_FEATURE_NOT_SUPPORTED);
18265d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                break;
18275d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            }
18285d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
18295d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        } /* End of the tag_type Switch */
18305d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        p_pipe_info = psHciContext->p_pipe_list[reader_pipe_id];
18315d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        if( (NFCSTATUS_SUCCESS == status)
18325d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            && (reader_pipe_id != HCI_UNKNOWN_PIPE_ID )
18335d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            && ( NULL != p_pipe_info ) )
18345d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        {
18355d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            if (TRUE == rls_param)
18365d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            {
18375d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                p_pipe_info->param_info = &rls_param;
18385d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                p_pipe_info->param_length = sizeof(rls_param);
18395d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            }
18405d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            status = phHciNfc_Send_RFReader_Event ( psHciContext, pHwRef,
18415d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                        reader_pipe_id,(uint8_t) NXP_EVT_RELEASE_TARGET );
18425d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        }
18435d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    }
18445d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
18455d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    return status;
18465d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly}
18475d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
18485d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
18495d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/*!
18505d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * \brief Exchanges the data to/from the selected tags via RF Reader Gates.
18515d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly *
18525d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * This function Exchanges the data to/from the selected tags
18535d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * via RF Reader Gates. This function uses the RF Reader gate based on the
18545d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * type of the selected tag and the type of the Reader gate specified.
18555d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly */
18565d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
18575d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
18585d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyNFCSTATUS
18595d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyphHciNfc_ReaderMgmt_Exchange_Data(
18605d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                    phHciNfc_sContext_t     *psHciContext,
18615d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                    void                    *pHwRef,
18625d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                    phHciNfc_XchgInfo_t     *p_xchg_info
18635d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                )
18645d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly{
18655d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    NFCSTATUS                   status = NFCSTATUS_SUCCESS;
18665d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    phHciNfc_Pipe_Info_t        *p_pipe_info = NULL;
18675d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    uint8_t                     reader_pipe_id = (uint8_t) HCI_UNKNOWN_PIPE_ID;
18685d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    phHal_eRemDevType_t         target_type = phHal_eUnknown_DevType;
18695d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
18705d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    if( (NULL == psHciContext) || (NULL == pHwRef) )
18715d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    {
18725d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly      status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_INVALID_PARAMETER);
18735d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    }
18745d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    else if (NULL == psHciContext->p_xchg_info)
18755d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    {
18765d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        status = PHNFCSTVAL(CID_NFC_HCI,
18775d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                NFCSTATUS_INVALID_HCI_INFORMATION);
18785d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
18795d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    }
18805d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    else
18815d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    {
18825d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        switch (psHciContext->host_rf_type)
18835d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        {
18845d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            case phHal_eISO14443_A_PCD:
18855d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            {
18865d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                /* Get the Reader A Pipe ID */
18875d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                status = phHciNfc_ReaderA_Get_PipeID
18885d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                        (psHciContext, &reader_pipe_id);
18895d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
18905d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                if( (NFCSTATUS_SUCCESS == status)
18915d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    && (reader_pipe_id != HCI_UNKNOWN_PIPE_ID )
18925d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    )
18935d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                {
18945d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    p_pipe_info = psHciContext->p_pipe_list[reader_pipe_id];
18955d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    p_pipe_info->param_info = p_xchg_info->tx_buffer;
18965d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    p_pipe_info->param_length = p_xchg_info->tx_length;
18975d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    target_type = psHciContext->p_target_info->RemDevType;
18985d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    switch (target_type)
18995d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    {
19005d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                        case phHal_eMifare_PICC:
19015d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                        case phHal_eISO14443_3A_PICC:
19025d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                        {
19035d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                            if ((uint8_t)phHal_eMifareRaw ==
19045d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                            p_xchg_info->params.tag_info.cmd_type)
19055d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                            {
19065d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                status = phHciNfc_Send_ReaderA_Command(
19075d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                    psHciContext,  pHwRef
19085d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                    ,reader_pipe_id, NXP_MIFARE_RAW );
19095d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                            }
19105d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                            else
19115d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                            {
19125d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                status = phHciNfc_Send_ReaderA_Command(
19135d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                    psHciContext, pHwRef,
19145d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                    reader_pipe_id, NXP_MIFARE_CMD );
19155d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                            }
19165d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                            break;
19175d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                        }
19185d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                        case phHal_eISO14443_A_PICC:
19195d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                        case phHal_eISO14443_4A_PICC:
19205d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                        {
19215d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                            status = phHciNfc_Send_RFReader_Command(
19225d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                        psHciContext, pHwRef,
19235d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                        reader_pipe_id, WR_XCHGDATA );
19245d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                            break;
19255d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                        }
19265d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                        default:
19275d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                        {
19285d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                            status = PHNFCSTVAL(CID_NFC_HCI,
19295d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                                NFCSTATUS_FEATURE_NOT_SUPPORTED);
19305d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                            break;
19315d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                        }
19325d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    } /* End of the tag_type Switch */
19335d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                } /* End of Pipe ID Check */
19345d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                break;
19355d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            }
19365d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#ifdef TYPE_B
19375d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            case phHal_eISO14443_B_PCD:
19385d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            {
19395d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                /* Get the Reader B Pipe ID */
19405d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                status = phHciNfc_ReaderB_Get_PipeID
19415d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                        (psHciContext, &reader_pipe_id);
19425d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
19435d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                if( (NFCSTATUS_SUCCESS == status)
19445d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    && (reader_pipe_id != HCI_UNKNOWN_PIPE_ID )
19455d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    )
19465d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                {
19475d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    p_pipe_info = psHciContext->p_pipe_list[reader_pipe_id];
19485d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    p_pipe_info->param_info = p_xchg_info->tx_buffer;
19495d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    p_pipe_info->param_length = p_xchg_info->tx_length;
19505d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    status = phHciNfc_Send_RFReader_Command(
19515d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                psHciContext, pHwRef,
19525d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                reader_pipe_id, WR_XCHGDATA );
19535d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                }
19545d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                break;
19555d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            }
19565d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif /* #ifdef TYPE_B */
19575d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#ifdef TYPE_FELICA
19585d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            case phHal_eFelica_PCD:
19595d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            {
19605d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                /* Get the Felica Reader Pipe ID */
19615d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                status = phHciNfc_Felica_Get_PipeID
19625d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                        (psHciContext, &reader_pipe_id);
19635d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
19645d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                if( (NFCSTATUS_SUCCESS == status)
19655d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    && (reader_pipe_id != HCI_UNKNOWN_PIPE_ID )
19665d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    )
19675d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                {
19685d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    p_pipe_info = psHciContext->p_pipe_list[reader_pipe_id];
19695d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    p_pipe_info->param_info = p_xchg_info->tx_buffer;
19705d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    p_pipe_info->param_length = p_xchg_info->tx_length;
19715d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    if ((uint8_t)phHal_eFelica_Raw ==
19725d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                    p_xchg_info->params.tag_info.cmd_type)
19735d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    {
19745d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                        status = phHciNfc_Send_Felica_Command(
19755d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                            psHciContext,  pHwRef
19765d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                            ,reader_pipe_id, NXP_FELICA_RAW );
19775d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    }
19785d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    else
19795d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    {
19805d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                        status = phHciNfc_Send_Felica_Command(
19815d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                            psHciContext, pHwRef,
19825d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                            reader_pipe_id, NXP_FELICA_CMD );
19835d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    }
19845d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                }
19855d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                break;
19865d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            }
19875d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif /* #ifdef TYPE_FELICA */
19885d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#if defined(TYPE_ISO15693)
19895d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            case phHal_eISO15693_PCD:
19905d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            {
19915d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                /* Get the ISO15693 Reader Pipe ID */
19925d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                status = phHciNfc_ISO15693_Get_PipeID
19935d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                        (psHciContext, &reader_pipe_id);
19945d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
19955d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                if( (NFCSTATUS_SUCCESS == status)
19965d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    && (reader_pipe_id != HCI_UNKNOWN_PIPE_ID )
19975d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    )
19985d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                {
19995d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    p_pipe_info = psHciContext->p_pipe_list[reader_pipe_id];
20005d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    p_pipe_info->param_info = p_xchg_info->tx_buffer;
20015d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    p_pipe_info->param_length = p_xchg_info->tx_length;
20025d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    if (((uint8_t)phHal_eIso15693_Cmd  ==
20035d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                    p_xchg_info->params.tag_info.cmd_type)
20045d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#if defined(SUPPORT_ISO15693_RAW)
20055d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                        || ((uint8_t) phHal_eIso15693_Raw ==
20065d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                    p_xchg_info->params.tag_info.cmd_type)
20075d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif
20085d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                     )
20095d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    {
20105d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                        status = phHciNfc_Send_ISO15693_Command(
20115d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                            psHciContext,  pHwRef
20125d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                            ,reader_pipe_id, NXP_ISO15693_CMD );
20135d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    }
20145d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    else
20155d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    {
20165d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                        status = PHNFCSTVAL(CID_NFC_HCI,
20175d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                    NFCSTATUS_INVALID_PARAMETER);
20185d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    }
20195d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                }
20205d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                break;
20215d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            }
20225d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif
20235d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#ifdef TYPE_JEWEL
20245d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            case phHal_eJewel_PCD:
20255d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            {
20265d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                /* Get the Jewel Reader Pipe ID */
20275d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                status = phHciNfc_Jewel_Get_PipeID
20285d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                        (psHciContext, &reader_pipe_id);
20295d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
20305d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                if( (NFCSTATUS_SUCCESS == status)
20315d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    && (reader_pipe_id != HCI_UNKNOWN_PIPE_ID )
20325d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    )
20335d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                {
20345d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    uint8_t         transact_type = 0;
20355d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    p_pipe_info = psHciContext->p_pipe_list[reader_pipe_id];
20365d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    p_pipe_info->param_info = p_xchg_info->tx_buffer;
20375d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    p_pipe_info->param_length = p_xchg_info->tx_length;
20385d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    switch(p_xchg_info->params.tag_info.cmd_type)
20395d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    {
20405d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                        case phHal_eJewel_Raw:
20415d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                        {
20425d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                            transact_type = NXP_JEWEL_RAW;
20435d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                            break;
20445d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                        }
20455d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                        case phHal_eJewel_Invalid:
20465d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                        default:
20475d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                        {
20485d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                            status = PHNFCSTVAL(CID_NFC_HCI,
20495d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                                NFCSTATUS_INVALID_PARAMETER);
20505d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                            break;
20515d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                        }
20525d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    }
20535d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    if(0 != transact_type)
20545d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    {
20555d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                        status = phHciNfc_Send_Jewel_Command(
20565d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                    psHciContext,  pHwRef,
20575d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                    reader_pipe_id, transact_type );
20585d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    }
20595d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                }
20605d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                break;
20615d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            }
20625d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif /* #ifdef TYPE_JEWEL */
20635d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            default:
20645d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            {
20655d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                status = PHNFCSTVAL(CID_NFC_HCI,
20665d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                                NFCSTATUS_FEATURE_NOT_SUPPORTED);
20675d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                break;
20685d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            }
20695d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        }/* End of Reader Type Switch */
20705d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    }
20715d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
20725d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    return status;
20735d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly}
20745d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
20755d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
20765d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
20775d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/*!
20785d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * \brief Releases the resources allocated the RF Reader Management.
20795d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly *
20805d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * This function Releases the resources allocated the RF Reader Management.
20815d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly */
20825d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
20835d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyNFCSTATUS
20845d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyphHciNfc_ReaderMgmt_Release(
20855d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                phHciNfc_sContext_t     *psHciContext,
20865d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                void                    *pHwRef
20875d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                             )
20885d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly{
20895d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    NFCSTATUS                           status = NFCSTATUS_SUCCESS;
20905d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    phHciNfc_Pipe_Info_t                *p_pipe_info = NULL;
20915d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    phHciNfc_ReaderMgmt_Info_t          *p_reader_mgmt_info=NULL;
20925d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
20935d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    if( (NULL == psHciContext) || (NULL == pHwRef) )
20945d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    {
20955d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly      status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_INVALID_PARAMETER);
20965d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    }
20975d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    else
20985d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    {
20995d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        if( NULL != psHciContext->p_reader_mgmt_info )
21005d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        {
21015d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            p_reader_mgmt_info = (phHciNfc_ReaderMgmt_Info_t *)
21025d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                psHciContext->p_reader_mgmt_info ;
21035d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            switch(p_reader_mgmt_info->rf_gate_cur_seq)
21045d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            {
21055d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                /* Reader A pipe close sequence */
21065d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                case READERA_PIPE_CLOSE:
21075d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                {
21085d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    p_pipe_info = ((phHciNfc_ReaderA_Info_t *)
21095d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                            psHciContext->p_reader_a_info)->p_pipe_info;
21105d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
21115d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    status = phHciNfc_Close_Pipe( psHciContext,
21125d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                                    pHwRef, p_pipe_info );
21135d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    if(status == NFCSTATUS_SUCCESS)
21145d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    {
21155d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                        p_reader_mgmt_info->rf_gate_next_seq =
21165d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                                    READERB_PIPE_CLOSE;
21175d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                        /* status = NFCSTATUS_PENDING; */
21185d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    }
21195d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    break;
21205d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                }
21215d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#ifdef TYPE_B
21225d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                /* Reader B pipe close sequence */
21235d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                case READERB_PIPE_CLOSE:
21245d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                {
21255d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    p_pipe_info = ((phHciNfc_ReaderB_Info_t *)
21265d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                            psHciContext->p_reader_b_info)->p_pipe_info;
21275d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
21285d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    status = phHciNfc_Close_Pipe( psHciContext,
21295d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                                        pHwRef, p_pipe_info );
21305d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    if(status == NFCSTATUS_SUCCESS)
21315d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    {
21325d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                        p_reader_mgmt_info->rf_gate_next_seq =
21335d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                                        FELICA_PROP_PIPE_CLOSE;
21345d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                        status = NFCSTATUS_PENDING;
21355d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    }
21365d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    break;
21375d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                }
21385d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif /* #ifdef TYPE_B */
21395d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#ifdef TYPE_FELICA
21405d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                /* Felica Reader pipe close sequence */
21415d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                case FELICA_PROP_PIPE_CLOSE:
21425d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                {
21435d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    p_pipe_info = ((phHciNfc_Felica_Info_t *)
21445d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                            psHciContext->p_felica_info)->p_pipe_info;
21455d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
21465d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    status = phHciNfc_Close_Pipe( psHciContext,
21475d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                                        pHwRef, p_pipe_info );
21485d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    if(status == NFCSTATUS_SUCCESS)
21495d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    {
21505d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                        p_reader_mgmt_info->rf_gate_next_seq =
21515d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                                NFCIP1_INITIATOR_PIPE_CLOSE;
21525d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                        /* status = NFCSTATUS_PENDING; */
21535d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    }
21545d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    break;
21555d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                }
21565d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif /* #ifdef TYPE_FELICA */
21575d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#ifdef ENABLE_P2P
21585d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                /* NFC-IP1 Initiator pipe Close sequence */
21595d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                case NFCIP1_INITIATOR_PIPE_CLOSE:
21605d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                {
21615d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    p_pipe_info =
21625d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                        ((phHciNfc_NfcIP_Info_t *)psHciContext->
21635d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                    p_nfcip_info)->p_init_pipe_info;
21645d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    if(NULL == p_pipe_info )
21655d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    {
21665d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                        status = PHNFCSTVAL(CID_NFC_HCI,
21675d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                        NFCSTATUS_INVALID_HCI_SEQUENCE);
21685d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    }
21695d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    else
21705d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    {
21715d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                        status = phHciNfc_Open_Pipe( psHciContext,
21725d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                                        pHwRef, p_pipe_info );
21735d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                        if(status == NFCSTATUS_SUCCESS)
21745d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                        {
21755d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                            p_reader_mgmt_info->rf_gate_next_seq = READERA_PIPE_CLOSE;
21765d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                            status = NFCSTATUS_PENDING;
21775d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                        }
21785d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    }
21795d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    break;
21805d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                }
21815d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif /* #ifdef ENABLE_P2P */
21825d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                default:
21835d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                {
21845d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_INVALID_HCI_SEQUENCE);
21855d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    break;
21865d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                }
21875d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
21885d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            }/* End of the Sequence Switch */
21895d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
21905d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        }/* End of the Reader Info Memory Check */
21915d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
21925d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    } /* End of Null Context Check */
21935d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
21945d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    return status;
21955d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly}
21965d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
21975d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
21985d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/*!
21995d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * \brief Sends the RF Reader HCI Events to the connected reader device.
22005d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly *
22015d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * This function Sends the RF Reader HCI Event frames in the HCP packet format to the
22025d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * connected reader device.
22035d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly */
22045d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
22055d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS
22065d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_Send_RFReader_Event (
22075d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                phHciNfc_sContext_t *psHciContext,
22085d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                void                *pHwRef,
22095d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                uint8_t             pipe_id,
22105d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                uint8_t             event
22115d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    )
22125d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly {
22135d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    phHciNfc_HCP_Packet_t   *hcp_packet = NULL;
22145d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    phHciNfc_HCP_Message_t  *hcp_message = NULL;
22155d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    phHciNfc_Pipe_Info_t    *p_pipe_info = NULL;
22165d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    uint8_t                 length = 0;
22175d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    uint8_t                 i = 0;
22185d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    NFCSTATUS               status = NFCSTATUS_SUCCESS;
22195d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
22205d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    if( (NULL == psHciContext)
22215d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        || ( pipe_id > PHHCINFC_MAX_PIPE)
22225d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        ||(NULL == psHciContext->p_pipe_list[pipe_id])
22235d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly      )
22245d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    {
22255d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_INVALID_PARAMETER);
22265d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        HCI_DEBUG("%s: Invalid Arguments passed \n",
22275d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                                "phHciNfc_Send_RFReader_Event");
22285d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    }
22295d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    else
22305d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    {
22315d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        p_pipe_info = (phHciNfc_Pipe_Info_t *)
22325d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                psHciContext->p_pipe_list[pipe_id];
22335d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        psHciContext->tx_total = 0 ;
22345d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        length +=  HCP_HEADER_LEN ;
22355d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        switch( event )
22365d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        {
22375d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            case EVT_READER_REQUESTED:
22385d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            case EVT_END_OPERATION:
22395d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            {
22405d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
22415d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                hcp_packet = (phHciNfc_HCP_Packet_t *) psHciContext->send_buffer;
22425d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                /* Construct the HCP Frame */
22435d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                phHciNfc_Build_HCPFrame(hcp_packet,HCP_CHAINBIT_DEFAULT,
22445d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                        (uint8_t) pipe_id, HCP_MSG_TYPE_EVENT, event);
22455d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                break;
22465d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            }
22475d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            case NXP_EVT_RELEASE_TARGET:
22485d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            {
22495d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                hcp_packet = (phHciNfc_HCP_Packet_t *) psHciContext->send_buffer;
22505d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                /* Construct the HCP Frame */
22515d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                phHciNfc_Build_HCPFrame(hcp_packet,HCP_CHAINBIT_DEFAULT,
22525d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                        (uint8_t) pipe_id, HCP_MSG_TYPE_EVENT, event);
22535d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                hcp_message = &(hcp_packet->msg.message);
22545d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                phHciNfc_Append_HCPFrame((uint8_t *)hcp_message->payload,
22555d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                            i, p_pipe_info->param_info,
22565d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                            p_pipe_info->param_length);
22571c7419cf7fd8913852433a02a0f16da8912fae6fJan Brands                length =(uint16_t)(length + i + p_pipe_info->param_length);
22585d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                break;
22595d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            }
22605d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            default:
22615d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            {
22625d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                status = PHNFCSTVAL( CID_NFC_HCI, NFCSTATUS_FEATURE_NOT_SUPPORTED );
22635d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                HCI_DEBUG("%s: Statement Should Not Occur \n",
22645d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                            "phHciNfc_Send_RFReader_Event");
22655d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                break;
22665d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            }
22675d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        }
22685d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        if( NFCSTATUS_SUCCESS == status )
22695d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        {
22705d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            p_pipe_info->sent_msg_type = HCP_MSG_TYPE_EVENT ;
22715d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            p_pipe_info->prev_msg = event ;
22725d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            psHciContext->tx_total = length;
22735d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
22745d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            /* Send the Constructed HCP packet to the lower layer */
22755d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            status = phHciNfc_Send_HCP( psHciContext, pHwRef );
22765d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            p_pipe_info->prev_status = NFCSTATUS_PENDING;
22775d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        }
22785d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    }
22795d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
22805d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    return status;
22815d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly}
22825d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
22835d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/*!
22845d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * \brief Sends the RF Reader HCI Additonal Commands to the connected
22855d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * reader device.
22865d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly *
22875d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * This function Sends the RF Reader HCI Command frames in the HCP packet
22885d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * format to the connected reader device.
22895d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly */
22905d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
22915d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS
22925d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_Send_RFReader_Command (
22935d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                phHciNfc_sContext_t *psHciContext,
22945d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                void                *pHwRef,
22955d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                uint8_t             pipe_id,
22965d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                uint8_t             cmd
22975d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    )
22985d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly {
22995d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    phHciNfc_HCP_Packet_t   *hcp_packet = NULL;
23005d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    phHciNfc_HCP_Message_t  *hcp_message = NULL;
23015d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    phHciNfc_Pipe_Info_t    *p_pipe_info = NULL;
23025d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    uint8_t                 i = 0;
23031c7419cf7fd8913852433a02a0f16da8912fae6fJan Brands    uint16_t                 length=0;
23045d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    NFCSTATUS               status = NFCSTATUS_SUCCESS;
23055d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
23065d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    if( (NULL == psHciContext)
23075d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        || ( pipe_id > PHHCINFC_MAX_PIPE)
23085d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        ||(NULL == psHciContext->p_pipe_list[pipe_id])
23095d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly      )
23105d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    {
23115d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_INVALID_PARAMETER);
23125d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        HCI_DEBUG("%s: Invalid Arguments passed \n",
23135d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                                "phHciNfc_Send_RFReader_Command");
23145d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    }
23155d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    else
23165d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    {
23175d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        p_pipe_info = (phHciNfc_Pipe_Info_t *)
23185d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                psHciContext->p_pipe_list[pipe_id];
23195d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        psHciContext->tx_total = 0 ;
23205d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        length +=  HCP_HEADER_LEN ;
23215d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        switch( cmd )
23225d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        {
23235d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            case WR_XCHGDATA:
23245d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            {
23255d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
23265d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                hcp_packet = (phHciNfc_HCP_Packet_t *) psHciContext->send_buffer;
23275d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                /* Construct the HCP Frame */
23285d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                phHciNfc_Build_HCPFrame(hcp_packet,HCP_CHAINBIT_DEFAULT,
23295d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                        (uint8_t) pipe_id, HCP_MSG_TYPE_COMMAND, cmd);
23305d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                hcp_message = &(hcp_packet->msg.message);
23315d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                /* Frame Wait Timeout */
233272854a2c28b99f9ab6aa60c906d5b3c1a36b04d7Martijn Coenen                hcp_message->payload[i++] = nxp_nfc_isoxchg_timeout ;
23335d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                phHciNfc_Append_HCPFrame((uint8_t *)hcp_message->payload,
23345d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                            i, p_pipe_info->param_info,
23355d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                            p_pipe_info->param_length);
23361c7419cf7fd8913852433a02a0f16da8912fae6fJan Brands                length =(uint16_t)(length + i + p_pipe_info->param_length);
23375d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                break;
23385d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            }
23395d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            case NXP_WR_PRESCHECK:
23405d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            case NXP_WR_ACTIVATE_NEXT:
23415d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            {
23425d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
23435d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                hcp_packet = (phHciNfc_HCP_Packet_t *) psHciContext->send_buffer;
23445d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                /* Construct the HCP Frame */
23455d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                phHciNfc_Build_HCPFrame(hcp_packet,HCP_CHAINBIT_DEFAULT,
23465d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                        (uint8_t) pipe_id, HCP_MSG_TYPE_COMMAND, cmd);
23475d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                break;
23485d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            }
23495d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            case NXP_WR_DISPATCH_TO_UICC:
23505d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            case NXP_WR_ACTIVATE_ID:
23515d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            {
23525d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
23535d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                hcp_packet = (phHciNfc_HCP_Packet_t *) psHciContext->send_buffer;
23545d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                /* Construct the HCP Frame */
23555d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                phHciNfc_Build_HCPFrame(hcp_packet,HCP_CHAINBIT_DEFAULT,
23565d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                        (uint8_t) pipe_id, HCP_MSG_TYPE_COMMAND, cmd);
23575d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                hcp_message = &(hcp_packet->msg.message);
23585d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                /* UID of the Card */
23595d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                phHciNfc_Append_HCPFrame((uint8_t *)hcp_message->payload,
23605d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                            i, p_pipe_info->param_info,
23615d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                            p_pipe_info->param_length);
23621c7419cf7fd8913852433a02a0f16da8912fae6fJan Brands                length =(uint16_t)(length + i + p_pipe_info->param_length);
23635d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                break;
23645d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            }
23655d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            default:
23665d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            {
23675d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                status = PHNFCSTVAL( CID_NFC_HCI, NFCSTATUS_FEATURE_NOT_SUPPORTED );
23685d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                HCI_DEBUG("%s: Statement Should Not Occur \n",
23695d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                                "phHciNfc_Send_RFReader_Command");
23705d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                break;
23715d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            }
23725d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        }
23735d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        if( NFCSTATUS_SUCCESS == status )
23745d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        {
23755d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            p_pipe_info->sent_msg_type = HCP_MSG_TYPE_COMMAND;
23765d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            p_pipe_info->prev_msg = cmd;
23775d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            psHciContext->tx_total = length;
23785d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            psHciContext->response_pending = TRUE ;
23795d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
23805d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            /* Send the Constructed HCP packet to the lower layer */
23815d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            status = phHciNfc_Send_HCP( psHciContext, pHwRef );
23825d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            p_pipe_info->prev_status = NFCSTATUS_PENDING;
23835d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        }
23845d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    }
23855d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
23865d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    return status;
23875d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly}
23885d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
23895d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
23905d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
2391