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