• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2010 NXP Semiconductors
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 /*!
18  * \file  phLibNfc_Internal.h
19  *
20  * Project: NFC-FRI 1.1
21  *
22  * $Workfile:: phLibNfc_Internal.h  $
23  * $Modtime::         $
24  * $Author: ing07385 $
25  * $Revision: 1.26 $
26  *
27  */
28 #ifndef PHLIBNFC_IN_H
29 #define PHLIBNFC_IN_H
30 #include <phNfcStatus.h>
31 #include <phNfcCompId.h>
32 #include <phNfcHalTypes.h>
33 #include <phNfcInterface.h>
34 #include <phNfcConfig.h>
35 #include <phDbgTrace.h>
36 #include <phHal4Nfc.h>
37 #include <phFriNfc_NdefMap.h>
38 #include <phFriNfc_OvrHal.h>
39 #include <phFriNfc_SmtCrdFmt.h>
40 #include <phFriNfc_Llcp.h>
41 #include <phFriNfc_LlcpTransport.h>
42 #include <phOsalNfc_Timer.h>
43 #include <phLibNfc_SE.h>
44 #include <phFriNfc_NdefReg.h>
45 #include <phLibNfc.h>
46 #include <phLibNfc_initiator.h>
47 #include <phLibNfc_ndef_raw.h>
48 #include <phNfcLlcpTypes.h>
49 
50 /**Maximum number of Records.Presently set to a realistic value of 128
51    Configurable upto 1K*/
52 #define    MAX_NO_OF_RECORDS    128U
53 #define    CHK_NDEF_NOT_DONE   0x02U
54 
55 typedef struct phLibNfc_status
56 {
57     unsigned                    RlsCb_status : 1;
58     unsigned                    DiscEnbl_status : 1;
59     unsigned                    Connect_status : 1;
60     unsigned                    TransProg_status : 1;
61     unsigned                    RelsProg_status : 1;
62     unsigned                    GenCb_pending_status : 1;
63     unsigned                    Shutdown_pending_status : 1;
64     unsigned                    Discovery_pending_status : 1;
65 
66 }Status_t;
67 typedef enum phLibNfc_State{
68     eLibNfcHalStateShutdown   = 0x00,  /**< closed*/
69     eLibNfcHalInitInProgress,
70     eLibNfcHalInited,
71     eLibNfcHalShutdownInProgress,
72     eLibNfcHalStateInitandIdle,
73     eLibNfcHalStateConfigReady ,
74     eLibNfcHalStateConnect,
75     eLibNfcHalStateTransaction,
76     eLibNfcHalStatePresenceChk,
77     eLibNfcHalStateRelease,
78     eLibNfcHalStateInvalid
79 } phLibNfc_State_t;
80 
81 
82 
83 
84 typedef struct phLibNfc_Hal_CB_Info
85 {
86     /*Init call back & its context*/
87     pphLibNfc_RspCb_t              pClientInitCb;
88     void                           *pClientInitCntx;
89     /*Shutdown call back & its context*/
90     pphLibNfc_RspCb_t              pClientShutdownCb;
91     void                           *pClientShtdwnCntx;
92     /*Connect call back & its context*/
93     pphLibNfc_ConnectCallback_t    pClientConnectCb;
94     void                           *pClientConCntx;
95     /*DisConnect call back & its context*/
96     pphLibNfc_DisconnectCallback_t pClientDisConnectCb;
97     void                           *pClientDConCntx;
98 
99     /*Transceive Call back & it's context*/
100     pphLibNfc_TransceiveCallback_t pClientTransceiveCb;
101     void                           *pClientTranseCntx;
102     /*Check Ndef Call back & it's context*/
103     pphLibNfc_ChkNdefRspCb_t       pClientCkNdefCb;
104     void                           *pClientCkNdefCntx;
105     /*Read Ndef Call back & it's context*/
106     pphLibNfc_RspCb_t              pClientRdNdefCb;
107     void                           *pClientRdNdefCntx;
108     /*Write Ndef Call back & it's context*/
109     pphLibNfc_RspCb_t              pClientWrNdefCb;
110     void                           *pClientWrNdefCntx;
111 
112 
113     /*Discover Call back & it's context*/
114     pphLibNfc_RspCb_t              pClientDisConfigCb;
115     void                           *pClientDisCfgCntx;
116 
117     /*Presence check Call back & it's context*/
118     pphLibNfc_RspCb_t              pClientPresChkCb;
119     void                           *pClientPresChkCntx;
120 
121     /*Register notification Call back & it's context*/
122     phLibNfc_NtfRegister_RspCb_t   pClientNtfRegRespCB;
123     void                           *pClientNtfRegRespCntx;
124 
125     /*Ndef Notification CB*/
126     pphLibNfc_Ndef_Search_RspCb_t   pClientNdefNtfRespCb;
127     void                           *pClientNdefNtfRespCntx;
128 
129     /*LLCP Check CB*/
130     pphLibNfc_ChkLlcpRspCb_t       pClientLlcpCheckRespCb;
131     void                           *pClientLlcpCheckRespCntx;
132 
133     /*LLCP Link CB*/
134     pphLibNfc_LlcpLinkStatusCb_t   pClientLlcpLinkCb;
135     void                           *pClientLlcpLinkCntx;
136 
137 }phLibNfc_Hal_CB_Info_t;
138 
139 typedef struct phLibNfc_NdefInfo
140 {
141     bool_t                       NdefContinueRead;
142     uint32_t                     NdefActualSize,
143                                  AppWrLength;
144     phFriNfc_NdefMap_t           *psNdefMap;
145     uint16_t                     NdefSendRecvLen;
146     uint16_t                     NdefDataCount;
147     phNfc_sData_t                *psUpperNdefMsg;
148     uint32_t                     NdefReadTimerId,
149                                  NdefLength;
150     uint8_t                      is_ndef ;
151     phFriNfc_sNdefSmtCrdFmt_t    *ndef_fmt ;
152     phLibNfc_Last_Call_t         eLast_Call;
153     uint32_t                     Chk_Ndef_Timer_Id;
154 
155 
156     /*Format Ndef Call back & it's context*/
157     pphLibNfc_RspCb_t            pClientNdefFmtCb;
158     void                        *pClientNdefFmtCntx;
159     phLibNfc_Ndef_SrchType_t    *pNdef_NtfSrch_Type;
160 
161 }phLibNfc_NdefInfo_t;
162 
163 typedef struct phLibNfc_NdefRecInfo
164 {
165     phFriNfc_NdefReg_CbParam_t  CbParam;
166     phFriNfc_NdefReg_t          NdefReg;
167     uint8_t                     *NdefTypes_array[100];
168     phFriNfc_NdefRecord_t       RecordsExtracted;
169     uint8_t                     ChunkedRecordsarray[MAX_NO_OF_RECORDS];
170     uint32_t                    NumberOfRecords;
171     uint8_t                     IsChunked[MAX_NO_OF_RECORDS];
172     uint32_t                    NumberOfRawRecords;
173     uint8_t                     *RawRecords[MAX_NO_OF_RECORDS];
174     phFriNfc_NdefReg_Cb_t       *NdefCb;
175     phNfc_sData_t               ndef_message;
176 }phLibNfc_NdefRecInfo_t;
177 
178 typedef struct phLibNfc_LlcpInfo
179 {
180    /* Local parameters for LLC, given upon config
181     * and used upon detection.
182     */
183    phLibNfc_Llcp_sLinkParameters_t sLocalParams;
184 
185    /* LLCP compliance flag */
186    bool_t bIsLlcp;
187 
188    /* Monitor structure for LLCP Transport */
189    phFriNfc_LlcpTransport_t sLlcpTransportContext;
190 
191    /* Monitor structure for LLCP LLC */
192    phFriNfc_Llcp_t sLlcpContext;
193 
194    /* LLC Rx buffer */
195    uint8_t pRxBuffer[1024];
196 
197    /* LLC Tx buffer */
198    uint8_t pTxBuffer[1024];
199 
200 } phLibNfc_LlcpInfo_t;
201 
202 typedef struct phLibNfc_LibContext
203 {
204     phHal_sHwReference_t         *psHwReference;
205     Status_t                     status;
206     phHal_sEmulationCfg_t        sCardEmulCfg;
207     phLibNfc_SeCtxt_t            sSeContext;
208     phNfc_sState_t               LibNfcState;
209 
210     phHal_sDevInputParam_t       *psDevInputParam;
211 
212     phLibNfc_NdefInfo_t          ndef_cntx;
213     phLibNfc_NfcIpInfo_t         sNfcIp_Context;
214 
215     phFriNfc_OvrHal_t            *psOverHalCtxt;
216     phLibNfc_Registry_Info_t     RegNtfType;
217     uint8_t                      dev_cnt;
218 
219     /*To re configure the discovery wheel*/
220     phLibNfc_sADD_Cfg_t          sADDconfig;
221     uint32_t                     Connected_handle,
222                                  Discov_handle[MAX_REMOTE_DEVICES];
223 
224     /* To store the previous connected handle in case of Multiple protocol tags */
225     uint32_t Prev_Connected_handle;
226 
227     /*Call back function pointers */
228 
229     phLibNfc_eDiscoveryConfigMode_t        eLibNfcCfgMode;
230 
231     phHal4Nfc_DiscoveryInfo_t      *psDiscInfo;
232 
233     phLibNfc_eReleaseType_t        ReleaseType;
234     /**Transaction Related Info */
235     phLibNfc_sTransceiveInfo_t     *psTransInfo;
236     phLibNfc_sTransceiveInfo_t     *psBufferedAuth;
237     uint8_t                        LastTrancvSuccess;
238     phLibNfc_RemoteDevList_t       psRemoteDevList[MAX_REMOTE_DEVICES];
239     /*To Call back function pointers & Client context*/
240     phLibNfc_Hal_CB_Info_t           CBInfo;
241 
242     /*Ndef RTD search Info*/
243     phLibNfc_NdefRecInfo_t    phLib_NdefRecCntx;
244 
245     /*LLCP Info*/
246     phLibNfc_LlcpInfo_t          llcp_cntx;
247 
248     /* Pointer to Lib context */
249 } phLibNfc_LibContext_t,*pphLibNfc_LibContext_t;
250 
251 extern void phLibNfc_Pending_Shutdown(void);
252 extern pphLibNfc_LibContext_t gpphLibContext;
253 extern NFCSTATUS
254 phLibNfc_UpdateNextState(
255                          pphLibNfc_LibContext_t psNfcHalCtxt,
256                          phLibNfc_State_t        next_state
257                          );
258 
259 extern void
260 phLibNfc_UpdateCurState(
261                         NFCSTATUS      status,
262                         pphLibNfc_LibContext_t psNfcHalCtxt
263                         );
264 
265 extern void
266 phLibNfc_Reconnect_Mifare_Cb (
267                     void                            *pContext,
268                     phHal_sRemoteDevInformation_t   *psRemoteDevInfo,
269                     NFCSTATUS                       status);
270 
271 
272 #endif
273 
274 
275