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 /*LLCP service discovery*/ 138 pphLibNfc_RspCb_t pClientLlcpDiscoveryCb; 139 void *pClientLlcpDiscoveryCntx; 140 141 }phLibNfc_Hal_CB_Info_t; 142 143 typedef struct phLibNfc_NdefInfo 144 { 145 bool_t NdefContinueRead; 146 uint32_t NdefActualSize, 147 AppWrLength; 148 phFriNfc_NdefMap_t *psNdefMap; 149 uint16_t NdefSendRecvLen; 150 uint16_t NdefDataCount; 151 phNfc_sData_t *psUpperNdefMsg; 152 uint32_t NdefReadTimerId, 153 NdefLength; 154 uint8_t is_ndef ; 155 phFriNfc_sNdefSmtCrdFmt_t *ndef_fmt ; 156 phLibNfc_Last_Call_t eLast_Call; 157 uint32_t Chk_Ndef_Timer_Id; 158 159 160 /*Format Ndef Call back & it's context*/ 161 pphLibNfc_RspCb_t pClientNdefFmtCb; 162 void *pClientNdefFmtCntx; 163 phLibNfc_Ndef_SrchType_t *pNdef_NtfSrch_Type; 164 165 }phLibNfc_NdefInfo_t; 166 167 typedef struct phLibNfc_NdefRecInfo 168 { 169 phFriNfc_NdefReg_CbParam_t CbParam; 170 phFriNfc_NdefReg_t NdefReg; 171 uint8_t *NdefTypes_array[100]; 172 phFriNfc_NdefRecord_t RecordsExtracted; 173 uint8_t ChunkedRecordsarray[MAX_NO_OF_RECORDS]; 174 uint32_t NumberOfRecords; 175 uint8_t IsChunked[MAX_NO_OF_RECORDS]; 176 uint32_t NumberOfRawRecords; 177 uint8_t *RawRecords[MAX_NO_OF_RECORDS]; 178 phFriNfc_NdefReg_Cb_t *NdefCb; 179 phNfc_sData_t ndef_message; 180 }phLibNfc_NdefRecInfo_t; 181 182 typedef struct phLibNfc_LlcpInfo 183 { 184 /* Local parameters for LLC, given upon config 185 * and used upon detection. 186 */ 187 phLibNfc_Llcp_sLinkParameters_t sLocalParams; 188 189 /* LLCP compliance flag */ 190 bool_t bIsLlcp; 191 192 /* Monitor structure for LLCP Transport */ 193 phFriNfc_LlcpTransport_t sLlcpTransportContext; 194 195 /* Monitor structure for LLCP LLC */ 196 phFriNfc_Llcp_t sLlcpContext; 197 198 /* LLC Rx buffer */ 199 uint8_t pRxBuffer[PHFRINFC_LLCP_PDU_HEADER_MAX + PHFRINFC_LLCP_MIU_DEFAULT + PHFRINFC_LLCP_MIUX_MAX]; 200 201 /* LLC Tx buffer */ 202 uint8_t pTxBuffer[PHFRINFC_LLCP_PDU_HEADER_MAX + PHFRINFC_LLCP_MIU_DEFAULT + PHFRINFC_LLCP_MIUX_MAX]; 203 204 } phLibNfc_LlcpInfo_t; 205 206 typedef struct phLibNfc_LibContext 207 { 208 phHal_sHwReference_t *psHwReference; 209 Status_t status; 210 phHal_sEmulationCfg_t sCardEmulCfg; 211 phLibNfc_SeCtxt_t sSeContext; 212 phNfc_sState_t LibNfcState; 213 214 phHal_sDevInputParam_t *psDevInputParam; 215 216 phLibNfc_NdefInfo_t ndef_cntx; 217 phLibNfc_NfcIpInfo_t sNfcIp_Context; 218 219 phFriNfc_OvrHal_t *psOverHalCtxt; 220 phLibNfc_Registry_Info_t RegNtfType; 221 uint8_t dev_cnt; 222 223 /*To re configure the discovery wheel*/ 224 phLibNfc_sADD_Cfg_t sADDconfig; 225 uintptr_t Connected_handle, 226 Discov_handle[MAX_REMOTE_DEVICES]; 227 228 /* To store the previous connected handle in case of Multiple protocol tags */ 229 uintptr_t Prev_Connected_handle; 230 231 /*Call back function pointers */ 232 233 phLibNfc_eDiscoveryConfigMode_t eLibNfcCfgMode; 234 235 phHal4Nfc_DiscoveryInfo_t *psDiscInfo; 236 237 phLibNfc_eReleaseType_t ReleaseType; 238 /**Transaction Related Info */ 239 phLibNfc_sTransceiveInfo_t *psTransInfo; 240 phLibNfc_sTransceiveInfo_t *psBufferedAuth; 241 uint8_t LastTrancvSuccess; 242 phLibNfc_RemoteDevList_t psRemoteDevList[MAX_REMOTE_DEVICES]; 243 /*To Call back function pointers & Client context*/ 244 phLibNfc_Hal_CB_Info_t CBInfo; 245 246 /*Ndef RTD search Info*/ 247 phLibNfc_NdefRecInfo_t phLib_NdefRecCntx; 248 249 /*LLCP Info*/ 250 phLibNfc_LlcpInfo_t llcp_cntx; 251 252 /* Pointer to Lib context */ 253 } phLibNfc_LibContext_t,*pphLibNfc_LibContext_t; 254 255 extern void phLibNfc_Pending_Shutdown(void); 256 extern pphLibNfc_LibContext_t gpphLibContext; 257 extern NFCSTATUS 258 phLibNfc_UpdateNextState( 259 pphLibNfc_LibContext_t psNfcHalCtxt, 260 phLibNfc_State_t next_state 261 ); 262 263 extern void 264 phLibNfc_UpdateCurState( 265 NFCSTATUS status, 266 pphLibNfc_LibContext_t psNfcHalCtxt 267 ); 268 269 extern void 270 phLibNfc_Reconnect_Mifare_Cb ( 271 void *pContext, 272 phHal_sRemoteDevInformation_t *psRemoteDevInfo, 273 NFCSTATUS status); 274 275 276 #endif 277 278 279