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