2 * Copyright (C) 2010 NXP Semiconductors
\r
4 * Licensed under the Apache License, Version 2.0 (the "License");
\r
5 * you may not use this file except in compliance with the License.
\r
6 * You may obtain a copy of the License at
\r
8 * http://www.apache.org/licenses/LICENSE-2.0
\r
10 * Unless required by applicable law or agreed to in writing, software
\r
11 * distributed under the License is distributed on an "AS IS" BASIS,
\r
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
13 * See the License for the specific language governing permissions and
\r
14 * limitations under the License.
\r
18 * \file phFriNfc_LlcpMac.c
\r
19 * \brief NFC LLCP MAC Mappings For Different RF Technologies.
\r
27 #include <phFriNfc_LlcpMac.h>
\r
28 #include <phFriNfc_LlcpMacNfcip.h>
\r
29 #include <phLibNfcStatus.h>
\r
30 #include <phLibNfc.h>
\r
31 #include <phLibNfc_Internal.h>
\r
33 NFCSTATUS phFriNfc_LlcpMac_Reset (phFriNfc_LlcpMac_t *LlcpMac,
\r
35 phFriNfc_LlcpMac_LinkStatus_CB_t LinkStatus_Cb,
\r
38 NFCSTATUS status = NFCSTATUS_SUCCESS;
\r
39 /* Store the Linkstatus callback function of the upper layer */
\r
40 LlcpMac->LinkStatus_Cb = LinkStatus_Cb;
\r
42 /* Store a pointer to the upper layer context */
\r
43 LlcpMac->LinkStatus_Context = pContext;
\r
45 /* Set the LinkStatus variable to the default state */
\r
46 LlcpMac->LinkState = phFriNfc_LlcpMac_eLinkDefault;
\r
48 /* Store a pointer to the lower layer */
\r
49 LlcpMac->LowerDevice = LowerDevice;
\r
51 LlcpMac->psRemoteDevInfo = NULL;
\r
52 LlcpMac->PeerRemoteDevType = 0;
\r
53 LlcpMac->MacType = 0;
\r
54 LlcpMac->MacReceive_Cb = NULL;
\r
55 LlcpMac->MacSend_Cb = NULL;
\r
56 LlcpMac->psSendBuffer = NULL;
\r
57 LlcpMac->RecvPending = 0;
\r
58 LlcpMac->SendPending = 0;
\r
63 NFCSTATUS phFriNfc_LlcpMac_ChkLlcp (phFriNfc_LlcpMac_t *LlcpMac,
\r
64 phHal_sRemoteDevInformation_t *psRemoteDevInfo,
\r
65 phFriNfc_LlcpMac_Chk_CB_t ChkLlcpMac_Cb,
\r
68 NFCSTATUS status = NFCSTATUS_SUCCESS;
\r
69 if (NULL == LlcpMac || NULL == psRemoteDevInfo)
\r
71 status = PHNFCSTVAL(CID_FRI_NFC_LLCP_MAC, NFCSTATUS_INVALID_PARAMETER);
\r
75 /* Store the Remote Device info received from Device Discovery */
\r
76 LlcpMac->psRemoteDevInfo = psRemoteDevInfo;
\r
78 if(LlcpMac->psRemoteDevInfo->RemDevType == phHal_eNfcIP1_Initiator)
\r
80 /* Set the PeerRemoteDevType variable to the Target type */
\r
81 LlcpMac->PeerRemoteDevType = phFriNfc_LlcpMac_ePeerTypeTarget;
\r
83 else if(LlcpMac->psRemoteDevInfo->RemDevType == phHal_eNfcIP1_Target)
\r
85 /* Set the PeerRemoteDevType variable to the Initiator type */
\r
86 LlcpMac->PeerRemoteDevType = phFriNfc_LlcpMac_ePeerTypeInitiator;
\r
89 switch(LlcpMac->psRemoteDevInfo->RemDevType)
\r
91 case phHal_eNfcIP1_Initiator:
\r
92 case phHal_eNfcIP1_Target:
\r
94 /* Set the MAC mapping type detected */
\r
95 LlcpMac->MacType = phFriNfc_LlcpMac_eTypeNfcip;
\r
97 /* Register the lower layer to the MAC mapping component */
\r
98 status = phFriNfc_LlcpMac_Nfcip_Register (LlcpMac);
\r
99 if(status == NFCSTATUS_SUCCESS)
\r
101 status = LlcpMac->LlcpMacInterface.chk(LlcpMac,ChkLlcpMac_Cb,pContext);
\r
105 status = PHNFCSTVAL(CID_FRI_NFC_LLCP_MAC, NFCSTATUS_FAILED);
\r
110 status = PHNFCSTVAL(CID_FRI_NFC_LLCP_MAC, NFCSTATUS_INVALID_DEVICE);
\r
118 NFCSTATUS phFriNfc_LlcpMac_Activate (phFriNfc_LlcpMac_t *LlcpMac)
\r
120 NFCSTATUS status = NFCSTATUS_SUCCESS;
\r
122 if(LlcpMac->LlcpMacInterface.activate == NULL)
\r
124 status = PHNFCSTVAL(CID_FRI_NFC_LLCP_MAC, NFCSTATUS_INVALID_PARAMETER);
\r
128 status = LlcpMac->LlcpMacInterface.activate(LlcpMac);
\r
133 NFCSTATUS phFriNfc_LlcpMac_Deactivate (phFriNfc_LlcpMac_t *LlcpMac)
\r
135 NFCSTATUS status = NFCSTATUS_SUCCESS;
\r
136 if(LlcpMac->LlcpMacInterface.deactivate == NULL)
\r
138 status = PHNFCSTVAL(CID_FRI_NFC_LLCP_MAC, NFCSTATUS_INVALID_PARAMETER);
\r
142 status = LlcpMac->LlcpMacInterface.deactivate(LlcpMac);
\r
147 NFCSTATUS phFriNfc_LlcpMac_Send (phFriNfc_LlcpMac_t *LlcpMac,
\r
148 phNfc_sData_t *psData,
\r
149 phFriNfc_LlcpMac_Send_CB_t LlcpMacSend_Cb,
\r
152 NFCSTATUS status = NFCSTATUS_SUCCESS;
\r
154 if(NULL== LlcpMac->LlcpMacInterface.send || NULL==psData || NULL==LlcpMacSend_Cb || NULL==pContext)
\r
156 status = PHNFCSTVAL(CID_FRI_NFC_LLCP_MAC, NFCSTATUS_INVALID_PARAMETER);
\r
160 status = LlcpMac->LlcpMacInterface.send(LlcpMac,psData,LlcpMacSend_Cb,pContext);
\r
165 NFCSTATUS phFriNfc_LlcpMac_Receive (phFriNfc_LlcpMac_t *LlcpMac,
\r
166 phNfc_sData_t *psData,
\r
167 phFriNfc_LlcpMac_Reveive_CB_t ReceiveLlcpMac_Cb,
\r
170 NFCSTATUS status = NFCSTATUS_SUCCESS;
\r
172 if(LlcpMac->LlcpMacInterface.receive == NULL || NULL==psData || NULL==ReceiveLlcpMac_Cb || NULL==pContext)
\r
174 status = PHNFCSTVAL(CID_FRI_NFC_LLCP_MAC, NFCSTATUS_INVALID_PARAMETER);
\r
178 status = LlcpMac->LlcpMacInterface.receive(LlcpMac,psData,ReceiveLlcpMac_Cb,pContext);
\r