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 /** 19 * \file phHal4Nfc_Internal.h 20 * \brief HAL callback Function Prototypes 21 * 22 * The HAL4.0 Internal header file 23 * 24 * Project: NFC-FRI-1.1 / HAL4.0 25 * 26 * $Date: Mon May 31 11:43:42 2010 $ 27 * $Author: ing07385 $ 28 * $Revision: 1.40 $ 29 * $Aliases: NFC_FRI1.1_WK1023_R35_1 $ 30 * 31 */ 32 33 /*@{*/ 34 #ifndef PHHAL4NFC_INTERNAL_H 35 #define PHHAL4NFC_INTERNAL_H 36 /*@}*/ 37 38 #include <phHciNfc.h> 39 40 /** 41 * \name HAL4 42 * 43 * File: \ref phHal4Nfc_Internal.h 44 * 45 */ 46 47 /*@{*/ 48 #define PH_HAL4NFC_INTERNAL_FILEREVISION "$Revision: 1.40 $" /**< \ingroup grp_file_attributes */ 49 #define PH_HAL4NFC_INTERNAL_FILEALIASES "$Aliases: NFC_FRI1.1_WK1023_R35_1 $" /**< \ingroup grp_file_attributes */ 50 /*@}*/ 51 52 /* -----------------Include files ---------------------------------------*/ 53 54 /* ---------------- Macros ----------------------------------------------*/ 55 #define PH_HAL4NFC_TRANSCEIVE_TIMEOUT 30000 /**<Transceive operation 56 on any target should be 57 completed within this 58 interval.Else the 59 operation is timed out*/ 60 61 #define PH_HAL4NFC_TGT_MERGE_ADDRESS 0x988BU 62 #define PH_HAL4NFC_TGT_MERGE_SAK 0x00U 63 64 65 /*---------------- Hal4 Internal Data Structures -------------------------*/ 66 /**HAL4 states*/ 67 typedef enum{ 68 eHal4StateClosed = 0x00, /**<closed state*/ 69 eHal4StateSelfTestMode, /**<Self test mode*/ 70 eHal4StateOpenAndReady ,/**<Fully initialised*/ 71 eHal4StateConfiguring , /**<configuration ongoing,transient state*/ 72 eHal4StateTargetDiscovered,/**<target discovered*/ 73 eHal4StateTargetActivate,/**<state during a select or reactivate*/ 74 eHal4StateEmulation,/**<Emulation state*/ 75 eHal4StateTargetConnected,/**<Connected state*/ 76 eHal4StateTransaction,/**<configuration ongoing,transient state*/ 77 eHal4StatePresenceCheck,/**<Presence Check state*/ 78 eHal4StateInvalid 79 } phHal4Nfc_Hal4state_t; 80 81 82 /**Global Pointer to hardware reference used in timer callbacks to get the 83 context pointer*/ 84 extern phHal_sHwReference_t *gpphHal4Nfc_Hwref; 85 86 /**Context info for HAL4 transceive*/ 87 typedef struct phHal4Nfc_TrcvCtxtInfo{ 88 /*Upper layer's Transceive callback*/ 89 pphHal4Nfc_TransceiveCallback_t pUpperTranceiveCb; 90 /*Upper layer's Send callback*/ 91 pphHal4Nfc_SendCallback_t pP2PSendCb; 92 /*Upper layer's receive callback*/ 93 pphHal4Nfc_ReceiveCallback_t pP2PRecvCb; 94 /**Flag to check if a P2P Send is ongoing when target release is issued by 95 the upper layer.If this flag is set ,then a remote device disconnect call 96 will be deferred*/ 97 uint8_t P2P_Send_In_Progress; 98 /*Data structure to provide transceive info to Hci*/ 99 phHciNfc_XchgInfo_t XchangeInfo; 100 /*sData pointer to point to upper layer's send data*/ 101 phNfc_sData_t *psUpperSendData; 102 /*Maintains the offset of number of bytes sent in one go ,so that the 103 remaining bytes can be sent during the next transceive*/ 104 uint32_t NumberOfBytesSent; 105 /*Number of bytes received during a P2p receive*/ 106 uint32_t P2PRecvLength; 107 /*sData pointer to point to upper layer's recv data*/ 108 phNfc_sData_t *psUpperRecvData; 109 /*structure to hold data received from lower layer*/ 110 phNfc_sData_t sLowerRecvData; 111 /*Offset for Lower Recv Data buffer*/ 112 uint32_t LowerRecvBufferOffset; 113 /*Holds the status of the RecvDataBuffer: 114 NFCSTATUS_SUCCESS:Receive data buffer is complete with data & P2P receive has 115 not yet been called 116 NFCSTATUS_PENDING:RecvDataBuffer is yet to receive the data from lower layer 117 */ 118 NFCSTATUS RecvDataBufferStatus; 119 /*Transaction timer ,currently used only for P2P receive on target*/ 120 uint32_t TransactionTimerId; 121 }phHal4Nfc_TrcvCtxtInfo_t,*pphHal4Nfc_TrcvCtxtInfo_t; 122 123 124 /**Context info for HAL4 Device discovery feature*/ 125 typedef struct phHal4Nfc_ADDCtxtInfo{ 126 /*total number of devices discovered*/ 127 uint8_t nbr_of_devices; 128 /*smx_discovery*/ 129 uint8_t smx_discovery; 130 /*Most recently used ADD configuration*/ 131 phHal_sADD_Cfg_t sADDCfg; 132 /*Most recently used Poll configuration*/ 133 phHal_sPollDevInfo_t sCurrentPollConfig; 134 /*Set when Poll Configured and reset when polling is disabled.*/ 135 uint8_t IsPollConfigured; 136 }phHal4Nfc_ADDCtxtInfo_t,*pphHal4Nfc_ADDCtxtInfo_t; 137 138 /**Context info for HAL4 connect/disconnect*/ 139 typedef struct phHal4Nfc_TargetConnectInfo{ 140 /*connect callback*/ 141 pphHal4Nfc_ConnectCallback_t pUpperConnectCb; 142 /*Disconnect callback*/ 143 pphHal4Nfc_DiscntCallback_t pUpperDisconnectCb; 144 /*used when a release call is pending in HAL*/ 145 phHal_eReleaseType_t ReleaseType; 146 /*Points to Remote device info of a connected device*/ 147 phHal_sRemoteDevInformation_t *psConnectedDevice; 148 /*Emulation state Activated/Deactivated*/ 149 phHal_Event_t EmulationState; 150 /*Presence check callback*/ 151 pphHal4Nfc_GenCallback_t pPresenceChkCb; 152 }phHal4Nfc_TargetConnectInfo_t,*pphHal4Nfc_TargetConnectInfo_t; 153 154 /**Context info for HAL4 connect & disconnect*/ 155 typedef struct phHal4Nfc_UpperLayerInfo{ 156 /*Upper layer Context for discovery call*/ 157 void *DiscoveryCtxt; 158 /*Upper layer Context for P2P discovery call*/ 159 void *P2PDiscoveryCtxt; 160 /**Context and function pointer for default event handler registered 161 by upper layer during initialization*/ 162 void *DefaultListenerCtxt; 163 /*Default event handler*/ 164 pphHal4Nfc_Notification_t pDefaultEventHandler; 165 /**Upper layer has to register this listener for receiving info about 166 discovered tags*/ 167 pphHal4Nfc_Notification_t pTagDiscoveryNotification; 168 /**Upper layer has to register this listener for receiving info about 169 discovered P2P devices*/ 170 pphHal4Nfc_Notification_t pP2PNotification; 171 /*Event Notification Context*/ 172 void *EventNotificationCtxt; 173 /**Notification handler for emulation and other events*/ 174 pphHal4Nfc_Notification_t pEventNotification; 175 /**Upper layer's Config discovery/Emulation callback registry*/ 176 pphHal4Nfc_GenCallback_t pConfigCallback; 177 void *psUpperLayerCtxt; 178 void *psUpperLayerDisconnectCtxt; 179 /**Upper layer's Open Callback registry*/ 180 pphHal4Nfc_GenCallback_t pUpperOpenCb; 181 /**Upper layer's Close Callback registry */ 182 pphHal4Nfc_GenCallback_t pUpperCloseCb; 183 /*Ioctl out param pointer ,points to buffer provided by upper layer during 184 a ioctl call*/ 185 phNfc_sData_t *pIoctlOutParam; 186 /*Ioctl callback*/ 187 pphHal4Nfc_IoctlCallback_t pUpperIoctlCb; 188 }phHal4Nfc_UpperLayerInfo_t; 189 190 /**Context structure for HAL4.0*/ 191 typedef struct phHal4Nfc_Hal4Ctxt{ 192 /**Hci handle obtained in Hci_Init*/ 193 void *psHciHandle; 194 /**Layer configuration*/ 195 pphNfcLayer_sCfg_t pHal4Nfc_LayerCfg; 196 /**Device capabilities*/ 197 phHal_sDeviceCapabilities_t Hal4Nfc_DevCaps; 198 /*Current state of HAL4.Updated generally in callbacks*/ 199 phHal4Nfc_Hal4state_t Hal4CurrentState; 200 /*Next state of HAL.Updated during calls*/ 201 phHal4Nfc_Hal4state_t Hal4NextState; 202 /**Info related to upper layer*/ 203 phHal4Nfc_UpperLayerInfo_t sUpperLayerInfo; 204 /*ADD context info*/ 205 pphHal4Nfc_ADDCtxtInfo_t psADDCtxtInfo; 206 /*union for different configurations ,used in a config_parameters()call*/ 207 phHal_uConfig_t uConfig; 208 /*Event info*/ 209 phHal_sEventInfo_t *psEventInfo; 210 /*Select sector flag*/ 211 uint8_t SelectSectorFlag; 212 /**List of pointers to remote device information for all discovered 213 targets*/ 214 phHal_sRemoteDevInformation_t *rem_dev_list[MAX_REMOTE_DEVICES]; 215 /*Transceive context info*/ 216 pphHal4Nfc_TrcvCtxtInfo_t psTrcvCtxtInfo; 217 /*Connect context info*/ 218 phHal4Nfc_TargetConnectInfo_t sTgtConnectInfo; 219 /*Last called Ioctl_type*/ 220 uint32_t Ioctl_Type; 221 #ifdef IGNORE_EVT_PROTECTED 222 /*used to ignore multiple Protected events*/ 223 uint8_t Ignore_Event_Protected; 224 #endif/*#ifdef IGNORE_EVT_PROTECTED*/ 225 }phHal4Nfc_Hal4Ctxt_t; 226 227 228 /*---------------- Function Prototypes ----------------------------------------------*/ 229 230 /*Callback completion routine for Connect*/ 231 extern void phHal4Nfc_ConnectComplete( 232 phHal4Nfc_Hal4Ctxt_t *Hal4Ctxt, 233 void *pInfo 234 ); 235 236 /*Callback completion routine for Disconnect*/ 237 extern void phHal4Nfc_DisconnectComplete( 238 phHal4Nfc_Hal4Ctxt_t *Hal4Ctxt, 239 void *pInfo 240 ); 241 242 /*Callback completion routine for Transceive*/ 243 extern void phHal4Nfc_TransceiveComplete( 244 phHal4Nfc_Hal4Ctxt_t *Hal4Ctxt, 245 void *pInfo 246 ); 247 248 /*Callback completion routine for Presence check*/ 249 extern void phHal4Nfc_PresenceChkComplete( 250 phHal4Nfc_Hal4Ctxt_t *Hal4Ctxt, 251 void *pInfo 252 ); 253 254 /*Configuration completion routine*/ 255 extern void phHal4Nfc_ConfigureComplete( 256 phHal4Nfc_Hal4Ctxt_t *Hal4Ctxt, 257 void *pInfo, 258 uint8_t type 259 ); 260 261 262 /*Callback completion routine for ADD*/ 263 extern void phHal4Nfc_TargetDiscoveryComplete( 264 phHal4Nfc_Hal4Ctxt_t *Hal4Ctxt, 265 void *pInfo 266 ); 267 268 /*Event handler routine for Emulation*/ 269 extern void phHal4Nfc_HandleEmulationEvent( 270 phHal4Nfc_Hal4Ctxt_t *Hal4Ctxt, 271 void *pInfo 272 ); 273 274 /*Callback completion routine for NFCIP1 Receive*/ 275 extern void phHal4Nfc_RecvCompleteHandler(phHal4Nfc_Hal4Ctxt_t *Hal4Ctxt,void *pInfo); 276 277 /*Callback completion routine for Send*/ 278 extern void phHal4Nfc_SendCompleteHandler(phHal4Nfc_Hal4Ctxt_t *Hal4Ctxt,void *pInfo); 279 280 /*Callback completion routine for P2P Activate Event received from HCI*/ 281 extern void phHal4Nfc_P2PActivateComplete( 282 phHal4Nfc_Hal4Ctxt_t *Hal4Ctxt, 283 void *pInfo 284 ); 285 /*Callback completion routine for P2P Deactivate Event received from HCI*/ 286 extern void phHal4Nfc_HandleP2PDeActivate( 287 phHal4Nfc_Hal4Ctxt_t *Hal4Ctxt, 288 void *pInfo 289 ); 290 291 /*Callback completion routine for reactivate target*/ 292 extern void phHal4Nfc_ReactivationComplete( 293 phHal4Nfc_Hal4Ctxt_t *Hal4Ctxt, 294 void *pInfo 295 ); 296 297 /**Execute Hal4 Disconnect*/ 298 extern NFCSTATUS phHal4Nfc_Disconnect_Execute( 299 phHal_sHwReference_t *psHwReference 300 ); 301 302 /**Handle transceive timeout*/ 303 #ifdef TRANSACTION_TIMER 304 extern void phHal4Nfc_TrcvTimeoutHandler(uint32_t TrcvTimerId); 305 #endif /*TRANSACTION_TIMER*/ 306 307 #endif/*PHHAL4NFC_INTERNAL_H*/ 308 309 310