2 * Copyright (C) 2010 NXP Semiconductors
\r
4 * Licensed under the Apache License, Version 2.0 (the "License");
\r
5 * you may not use this file except in compliance with the License.
\r
6 * You may obtain a copy of the License at
\r
8 * http://www.apache.org/licenses/LICENSE-2.0
\r
10 * Unless required by applicable law or agreed to in writing, software
\r
11 * distributed under the License is distributed on an "AS IS" BASIS,
\r
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
13 * See the License for the specific language governing permissions and
\r
14 * limitations under the License.
\r
19 * =============================================================================
\r
20 * \file phNfcInterface.h
\r
21 * \brief Generic Interface Layer Function Definitions.
\r
23 * Project: NFC-FRI-1.1
\r
25 * $Date: Thu Feb 11 19:01:36 2010 $
\r
26 * $Author: ing04880 $
\r
28 * $Aliases: NFC_FRI1.1_WK1007_R33_1,NFC_FRI1.1_WK1007_R33_4,NFC_FRI1.1_WK1017_PREP1,NFC_FRI1.1_WK1017_R34_1,NFC_FRI1.1_WK1017_R34_2,NFC_FRI1.1_WK1023_R35_1 $
\r
30 * =============================================================================
\r
33 #ifndef PHNFCINTERFACE_H /* */
\r
34 #define PHNFCINTERFACE_H /* */
\r
37 * \name NFC Inteface
\r
39 * File: \ref phNfcInterface.h
\r
44 #define PHNFCINTERFACE_FILEREVISION "$Revision: 1.42 $" /**< \ingroup grp_file_attributes */
\r
45 #define PHNFCINTERFACE_FILEALIASES "$Aliases: NFC_FRI1.1_WK1007_R33_1,NFC_FRI1.1_WK1007_R33_4,NFC_FRI1.1_WK1017_PREP1,NFC_FRI1.1_WK1017_R34_1,NFC_FRI1.1_WK1017_R34_2,NFC_FRI1.1_WK1023_R35_1 $" /**< \ingroup grp_file_attributes */
\r
49 ################################################################################
\r
50 ***************************** Header File Inclusion ****************************
\r
51 ################################################################################
\r
54 #include <phNfcTypes.h>
\r
55 #include <phNfcHalTypes.h>
\r
59 ################################################################################
\r
60 ****************************** Macro Definitions *******************************
\r
61 ################################################################################
\r
64 #define NFC_FSM_IN_PROGRESS 0x01U
\r
65 #define NFC_FSM_COMPLETE 0x00U
\r
67 #define NFC_FSM_CURRENT 0x00U
\r
68 #define NFC_FSM_NEXT 0x01U
\r
70 /* NFC Notification Types */
\r
72 #define NFC_NOTIFY_INIT_COMPLETED 0x01
\r
73 #define NFC_NOTIFY_INIT_FAILED 0xF1
\r
75 #define NFC_NOTIFY_DEINIT_COMPLETED 0x02
\r
76 #define NFC_NOTIFY_DEINIT_FAILED 0xF2
\r
78 #define NFC_NOTIFY_EVENT 0x70
\r
80 #define NFC_NOTIFY_DEVICE_ACTIVATED 0x82
\r
81 #define NFC_NOTIFY_DEVICE_DEACTIVATED 0x83
\r
83 #define NFC_NOTIFY_SEND_COMPLETED 0x03
\r
84 #define NFC_NOTIFY_SEND_ERROR 0xF3
\r
86 #define NFC_NOTIFY_RECV_COMPLETED 0x04
\r
87 #define NFC_NOTIFY_RECV_ERROR 0xF4
\r
88 #define NFC_NOTIFY_RECV_EVENT 0x74
\r
89 #define NFC_NOTIFY_RECV_CANCELLED 0x34
\r
91 #define NFC_NOTIFY_TRANSCEIVE_COMPLETED 0x05
\r
92 #define NFC_NOTIFY_TRANSCEIVE_ERROR 0xF5
\r
94 #define NFC_NOTIFY_POLL_ENABLED 0x06
\r
95 #define NFC_NOTIFY_POLL_RESTARTED 0x16
\r
96 #define NFC_NOTIFY_POLL_DISABLED 0x26
\r
97 #define NFC_NOTIFY_CONFIG_SUCCESS 0x36
\r
98 #define NFC_NOTIFY_CONFIG_ERROR 0xF6
\r
100 #define NFC_NOTIFY_TARGET_DISCOVERED 0x10
\r
101 #define NFC_NOTIFY_DISCOVERY_ERROR 0xFA
\r
102 #define NFC_NOTIFY_TARGET_RELEASED 0x11
\r
103 #define NFC_NOTIFY_TARGET_CONNECTED 0x12
\r
104 #define NFC_NOTIFY_TARGET_PRESENT 0x13
\r
105 #define NFC_NOTIFY_TARGET_REACTIVATED 0x14
\r
106 #define NFC_NOTIFY_CONNECT_FAILED 0xFC
\r
107 #define NFC_NOTIFY_TARGET_DISCONNECTED 0x15
\r
108 #define NFC_NOTIFY_DISCONNECT_FAILED 0xFD
\r
110 #define NFC_NOTIFY_TRANSACTION 0x07
\r
112 #define NFC_NOTIFY_RESULT 0x08
\r
114 #define NFC_NOTIFY_DEVICE_ERROR 0xFEU
\r
115 #define NFC_NOTIFY_ERROR 0xFFU
\r
118 #define BYTE_SIZE 0x08U
\r
119 #define BYTE_MASK 0xFFU
\r
120 /* HCI GET and SET BITS Macros */
\r
121 #define MASK_BITS8(p,l) \
\r
122 ( ( (((uint8_t)(p))+((uint8_t)(l)))<=BYTE_SIZE )? \
\r
123 (~(0xFFU<<((p)+(l))) & (0xFFU<<(p))):(0U) )
\r
125 #define GET_BITS8(num,p,l) \
\r
126 ( ((((uint8_t)(p))+((uint8_t)(l)))<=BYTE_SIZE)? \
\r
127 (((num)& (MASK_BITS8(p,l)))>>(p)):(0U) )
\r
129 #define GET_BITS8(num,p,l) \
\r
130 ( ((((p)+(l))<=BYTE_SIZE))? \
\r
131 (((num)>>(p))& (~(0xFFU<<(l)))):(0U) )
\r
133 #define SET_BITS8(num,p,l,val) \
\r
134 ( ((((uint8_t)(p))+((uint8_t)(l)))<=BYTE_SIZE)? \
\r
135 (((num)& (~MASK_BITS8(p,l)))|((val)<<(p))):(0U))
\r
138 ################################################################################
\r
139 ******************** Enumeration and Structure Definition **********************
\r
140 ################################################################################
\r
144 enum phNfcIF_eExecution{
\r
145 NFC_EXEC_NORMAL = 0x00, /**< Normal Execution Sequence */
\r
146 NFC_EXEC_CALLBACK = 0x01, /**< Callback Execution Sequence */
\r
147 NFC_EXEC_UNKNOWN = 0xFF /**< Callback Execution Sequence */
\r
151 typedef enum phNfc_eModeType{
\r
152 MODE_ON = 0x00U, /**< Switches the particular feature ON*/
\r
153 MODE_OFF /**< Switches the particular feature OFF*/
\r
154 }phNfc_eModeType_t;
\r
157 * State Structure to hold the State Information
\r
159 * This structure holds the state Information of a specified
\r
164 typedef struct phNfc_sState
\r
167 uint8_t transition;
\r
168 uint8_t next_state;
\r
169 /* uint8_t event; */
\r
176 * Transaction Completion Information Structure
\r
178 * This structure holds the completion callback information of the
\r
179 * transaction passed from the lower layer to the upper layer
\r
180 * along with the completion callback.
\r
183 typedef struct phNfc_sTransactionInfo
\r
185 /* Returns the status of the Transaction Completion routine */
\r
187 /* Indicates the Type of the Transaction */
\r
189 /* To contain more Transaction Notification specific info */
\r
191 /* The data response from the Transaction */
\r
193 /* The size of the data response from the Transaction */
\r
195 }phNfc_sTransactionInfo_t;
\r
198 * Notification Information Structure
\r
200 * This structure holds the notification callback information passed from
\r
201 * the lower layer to the upper layer along with the notification callback.
\r
204 typedef struct phNfc_sCompletionInfo
\r
206 /* Returns the status of the completion routine */
\r
209 /* Indicates the Type of the Information
\r
210 * associated with the completion
\r
214 /* To contain more completion specific info */
\r
217 }phNfc_sCompletionInfo_t;
\r
221 * Notification Information
\r
224 typedef struct phNfc_sNotificationInfo
\r
226 /* Returns the status of the Notification routine */
\r
228 /* Indicates the Type of the Notification */
\r
229 phHal_eNotificationType_t type;
\r
230 /* To contain more Notification specific info */
\r
233 }phNfc_sNotificationInfo_t;
\r
237 ################################################################################
\r
238 ********************* Callback Function Type Definition ************************
\r
239 ################################################################################
\r
243 * Interface Notification Callback
\r
245 * This callback notifies the occurrance of an event in the Lower Interface.
\r
247 * \param [in] pContext Context for the Callback Function
\r
248 * \param [in] pHwRef Pointer to the Hardware Reference
\r
249 * \param [in] type Type of the Notification sent
\r
250 * \param [out] pInfo Pointer to the Transaction Information Structure
\r
251 * which contains the Status of the operation, data
\r
252 * obtained or sent and size of the data sent or received
\r
255 typedef void (*pphNfcIF_Notification_CB_t) (
\r
263 * asynchronous Interface Transaction Completion callback
\r
265 * This callback signals the completion of the asynchronous send or receive
\r
266 * operation. The number of bytes sent or recieved is returned back.
\r
268 * \param [in] pContext Context for the Callback Function
\r
269 * \param [in] pHwRef Pointer to the Hardware Reference
\r
270 * \param [out] pInfo Pointer to the Transaction Information Structure
\r
271 * which contains the Status of the operation, data
\r
272 * obtained or sent and size of the data sent or received
\r
275 typedef void (*pphNfcIF_Transact_Completion_CB_t) (
\r
278 phNfc_sTransactionInfo_t *pInfo
\r
282 ################################################################################
\r
283 ********************** Generic Interface Function Prototype ********************
\r
284 ################################################################################
\r
288 * Generic NFC Interface Function Type .
\r
290 * \param [in] pContext Context pointer for the Generic Interface.
\r
291 * \param [in] pHwRef pointer for the device interface link information.
\r
294 typedef NFCSTATUS (*pphNfcIF_Interface_t) (
\r
299 * Data Transaction between the lower layer interface
\r
301 * Sends or Receives the given amount of data to the lower layer.
\r
302 * The call returns immediately and the registered callback is
\r
303 * called when all data has been written.
\r
306 * @note If the interface is not initialized the function does nothing.
\r
308 * \param [in] pContext Context pointer for sending the data.
\r
309 * \param [in] pHwRef pointer for the device interface link information.
\r
310 * \param[in] data pointer to data buffer containing the data to be sent or
\r
311 * to be received. The data pointer is valid at least until
\r
312 * the registered callback is called.
\r
313 * \param[in] length length of the data to be sent or to be received.
\r
316 typedef NFCSTATUS (*pphNfcIF_Transact_t) (
\r
325 * Generic Interface structure with the Lower Layer
\r
327 * This structure holds the context and function pointers of all functions
\r
328 * required to interface with the Lower Layers.
\r
331 typedef struct phNfc_sLowerIF
\r
334 pphNfcIF_Interface_t init;
\r
335 pphNfcIF_Interface_t release;
\r
336 pphNfcIF_Transact_t send;
\r
337 pphNfcIF_Transact_t receive;
\r
338 pphNfcIF_Transact_t receive_wait;
\r
339 pphNfcIF_Interface_t transact_abort;
\r
340 pphNfcIF_Interface_t unregister;
\r
341 } phNfc_sLowerIF_t,*pphNfc_sLowerIF_t;
\r
345 * Generic Callback interface structure for the Lower layer.
\r
347 * This structure holds the callback function pointers of the functions that
\r
348 * performs the completion of a particular operation. These functions are used
\r
349 * by the Lower Layer interface to convey the completion of an operation.
\r
352 typedef struct phNfcIF_sCallBack
\r
354 /**<Holds context info to be sent to lower layer*/
\r
356 /**<Callback notifies occurrance of event in Lower Interface*/
\r
357 pphNfcIF_Notification_CB_t notify;
\r
358 /**<asynchronous Interface Transaction Completion callback*/
\r
359 pphNfcIF_Transact_Completion_CB_t send_complete;
\r
360 pphNfcIF_Transact_Completion_CB_t receive_complete;
\r
362 } phNfcIF_sCallBack_t ,*pphNfcIF_sCallBack_t ;
\r
366 * Interface Reference structure.
\r
368 * This structure holds the reference parameters, callback function pointers and
\r
369 * lower interface functions .
\r
372 typedef struct phNfcIF_sReference
\r
374 /**<Generic Interface structure with the Lower Layer*/
\r
375 phNfc_sLowerIF_t *plower_if;
\r
376 /**<pointer to the data to be sent*/
\r
378 /**<pointer to the data to be received*/
\r
380 }phNfcIF_sReference_t, *pphNfcIF_sReference_t;
\r
384 ################################################################################
\r
385 ********************** Register Function Type Definition ***********************
\r
386 ################################################################################
\r
390 * Registers the interface functions and passes the callback functions to the
\r
393 * This function passes the callback functions of the interface to the
\r
394 * lower interface and the lower interface registers its functions.
\r
397 typedef NFCSTATUS ( *pphNfcIF_Register_t) (
\r
398 phNfcIF_sReference_t *psReference,
\r
399 phNfcIF_sCallBack_t if_callback,
\r
405 * Layer Specific Configuration structure.
\r
407 * This structure holds the Lower Layer Name and the registry function for registering
\r
408 * the lower layer interface functions .
\r
412 typedef struct phNfcLayer_sCfg
\r
414 uint8_t layer_index;
\r
415 uint8_t *layer_name;
\r
416 pphNfcIF_Register_t layer_registry;
\r
417 struct phNfcLayer_sCfg *layer_next;
\r
418 }phNfcLayer_sCfg_t, *pphNfcLayer_sCfg_t;
\r
421 #endif /* PHNFCINTERFACE_H */
\r