• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /******************************************************************************
2  *
3  *  Copyright (C) 2009-2012 Broadcom Corporation
4  *
5  *  Licensed under the Apache License, Version 2.0 (the "License");
6  *  you may not use this file except in compliance with the License.
7  *  You may obtain a copy of the License at:
8  *
9  *  http://www.apache.org/licenses/LICENSE-2.0
10  *
11  *  Unless required by applicable law or agreed to in writing, software
12  *  distributed under the License is distributed on an "AS IS" BASIS,
13  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  *  See the License for the specific language governing permissions and
15  *  limitations under the License.
16  *
17  ******************************************************************************/
18 
19 /******************************************************************************
20  *
21  *  This file contains the Near Field Communication (NFC) API function
22  *  external definitions.
23  *
24  ******************************************************************************/
25 
26 #ifndef NFC_API_H
27 #define NFC_API_H
28 
29 #include "nfc_target.h"
30 #include "nci_defs.h"
31 #include "nfc_hal_api.h"
32 #include "gki.h"
33 
34 /* NFC application return status codes */
35 #define NFC_STATUS_OK                   NCI_STATUS_OK                   /* Command succeeded    */
36 #define NFC_STATUS_REJECTED             NCI_STATUS_REJECTED             /* Command is rejected. */
37 #define NFC_STATUS_MSG_CORRUPTED        NCI_STATUS_MESSAGE_CORRUPTED    /* Message is corrupted */
38 #define NFC_STATUS_BUFFER_FULL          NCI_STATUS_BUFFER_FULL          /* buffer full          */
39 #define NFC_STATUS_FAILED               NCI_STATUS_FAILED               /* failed               */
40 #define NFC_STATUS_NOT_INITIALIZED      NCI_STATUS_NOT_INITIALIZED      /* not initialized      */
41 #define NFC_STATUS_SYNTAX_ERROR         NCI_STATUS_SYNTAX_ERROR         /* Syntax error         */
42 #define NFC_STATUS_SEMANTIC_ERROR       NCI_STATUS_SEMANTIC_ERROR       /* Semantic error       */
43 #define NFC_STATUS_UNKNOWN_GID          NCI_STATUS_UNKNOWN_GID          /* Unknown NCI Group ID */
44 #define NFC_STATUS_UNKNOWN_OID          NCI_STATUS_UNKNOWN_OID          /* Unknown NCI Opcode   */
45 #define NFC_STATUS_INVALID_PARAM        NCI_STATUS_INVALID_PARAM        /* Invalid Parameter    */
46 #define NFC_STATUS_MSG_SIZE_TOO_BIG     NCI_STATUS_MSG_SIZE_TOO_BIG     /* Message size too big */
47 #define NFC_STATUS_ALREADY_STARTED      NCI_STATUS_ALREADY_STARTED      /* Already started      */
48 #define NFC_STATUS_ACTIVATION_FAILED    NCI_STATUS_ACTIVATION_FAILED    /* Activation Failed    */
49 #define NFC_STATUS_TEAR_DOWN            NCI_STATUS_TEAR_DOWN            /* Tear Down Error      */
50 #define NFC_STATUS_RF_TRANSMISSION_ERR  NCI_STATUS_RF_TRANSMISSION_ERR  /* RF transmission error*/
51 #define NFC_STATUS_RF_PROTOCOL_ERR      NCI_STATUS_RF_PROTOCOL_ERR      /* RF protocol error    */
52 #define NFC_STATUS_TIMEOUT              NCI_STATUS_TIMEOUT              /* RF Timeout           */
53 #define NFC_STATUS_EE_INTF_ACTIVE_FAIL  NCI_STATUS_EE_INTF_ACTIVE_FAIL  /* EE Intf activate err */
54 #define NFC_STATUS_EE_TRANSMISSION_ERR  NCI_STATUS_EE_TRANSMISSION_ERR  /* EE transmission error*/
55 #define NFC_STATUS_EE_PROTOCOL_ERR      NCI_STATUS_EE_PROTOCOL_ERR      /* EE protocol error    */
56 #define NFC_STATUS_EE_TIMEOUT           NCI_STATUS_EE_TIMEOUT           /* EE Timeout           */
57 
58 /* 0xE0 ~0xFF are proprietary status codes */
59 #define NFC_STATUS_CMD_STARTED          0xE3/* Command started successfully                     */
60 #define NFC_STATUS_HW_TIMEOUT           0xE4/* NFCC Timeout in responding to an NCI command     */
61 #define NFC_STATUS_CONTINUE             0xE5/* More (same) event to follow                      */
62 #define NFC_STATUS_REFUSED              0xE6/* API is called to perform illegal function        */
63 #define NFC_STATUS_BAD_RESP             0xE7/* Wrong format of R-APDU, CC file or NDEF file     */
64 #define NFC_STATUS_CMD_NOT_CMPLTD       0xE8/* 7816 Status Word is not command complete(0x9000) */
65 #define NFC_STATUS_NO_BUFFERS           0xE9/* Out of GKI buffers                               */
66 #define NFC_STATUS_WRONG_PROTOCOL       0xEA/* Protocol mismatch between API and activated one  */
67 #define NFC_STATUS_BUSY                 0xEB/* Another Tag command is already in progress       */
68 
69 #define NFC_STATUS_LINK_LOSS            0xFC                      /* Link Loss                  */
70 #define NFC_STATUS_BAD_LENGTH           0xFD                      /* data len exceeds MIU       */
71 #define NFC_STATUS_BAD_HANDLE           0xFE                      /* invalid handle             */
72 #define NFC_STATUS_CONGESTED            0xFF                      /* congested                  */
73 typedef UINT8 tNFC_STATUS;
74 
75 
76 
77 /**********************************************
78  * NFC Config Parameter IDs defined by NCI
79  **********************************************/
80 #define NFC_PMID_TOTAL_DURATION     NCI_PARAM_ID_TOTAL_DURATION
81 #define NFC_PMID_CON_DEVICES_LIMIT  NCI_PARAM_ID_CON_DEVICES_LIMIT
82 #define NFC_PMID_PA_BAILOUT         NCI_PARAM_ID_PA_BAILOUT
83 #define NFC_PMID_PB_AFI             NCI_PARAM_ID_PB_AFI
84 #define NFC_PMID_PB_BAILOUT         NCI_PARAM_ID_PB_BAILOUT
85 #define NFC_PMID_PB_ATTRIB_PARAM1   NCI_PARAM_ID_PB_ATTRIB_PARAM1
86 #define NFC_PMID_PF_BIT_RATE        NCI_PARAM_ID_PF_BIT_RATE
87 #define NFC_PMID_PB_H_INFO          NCI_PARAM_ID_PB_H_INFO
88 #define NFC_PMID_BITR_NFC_DEP       NCI_PARAM_ID_BITR_NFC_DEP
89 #define NFC_PMID_ATR_REQ_GEN_BYTES  NCI_PARAM_ID_ATR_REQ_GEN_BYTES
90 #define NFC_PMID_ATR_REQ_CONFIG     NCI_PARAM_ID_ATR_REQ_CONFIG
91 #define NFC_PMID_LA_HIST_BY         NCI_PARAM_ID_LA_HIST_BY
92 #define NFC_PMID_LA_NFCID1          NCI_PARAM_ID_LA_NFCID1
93 #define NFC_PMID_PI_BIT_RATE        NCI_PARAM_ID_PI_BIT_RATE
94 #define NFC_PMID_LA_BIT_FRAME_SDD   NCI_PARAM_ID_LA_BIT_FRAME_SDD
95 #define NFC_PMID_LA_PLATFORM_CONFIG NCI_PARAM_ID_LA_PLATFORM_CONFIG
96 #define NFC_PMID_LA_SEL_INFO        NCI_PARAM_ID_LA_SEL_INFO
97 #define NFC_PMID_LI_BIT_RATE        NCI_PARAM_ID_LI_BIT_RATE
98 #define NFC_PMID_LB_SENSB_INFO      NCI_PARAM_ID_LB_SENSB_INFO
99 #define NFC_PMID_LB_PROTOCOL        NCI_PARAM_ID_LB_PROTOCOL
100 #define NFC_PMID_LB_H_INFO          NCI_PARAM_ID_LB_H_INFO_RSP
101 #define NFC_PMID_LB_NFCID0          NCI_PARAM_ID_LB_NFCID0
102 #define NFC_PMID_LB_APPDATA         NCI_PARAM_ID_LB_APPDATA
103 #define NFC_PMID_LB_SFGI            NCI_PARAM_ID_LB_SFGI
104 #define NFC_PMID_LB_ADC_FO          NCI_PARAM_ID_LB_ADC_FO
105 #define NFC_PMID_LF_T3T_ID1         NCI_PARAM_ID_LF_T3T_ID1
106 #define NFC_PMID_LF_T3T_ID2         NCI_PARAM_ID_LF_T3T_ID2
107 #define NFC_PMID_LF_T3T_ID3         NCI_PARAM_ID_LF_T3T_ID3
108 #define NFC_PMID_LF_T3T_ID4         NCI_PARAM_ID_LF_T3T_ID4
109 #define NFC_PMID_LF_T3T_ID5         NCI_PARAM_ID_LF_T3T_ID5
110 #define NFC_PMID_LF_T3T_ID6         NCI_PARAM_ID_LF_T3T_ID6
111 #define NFC_PMID_LF_T3T_ID7         NCI_PARAM_ID_LF_T3T_ID7
112 #define NFC_PMID_LF_T3T_ID8         NCI_PARAM_ID_LF_T3T_ID8
113 #define NFC_PMID_LF_T3T_ID9         NCI_PARAM_ID_LF_T3T_ID9
114 #define NFC_PMID_LF_T3T_ID10        NCI_PARAM_ID_LF_T3T_ID10
115 #define NFC_PMID_LF_T3T_ID11        NCI_PARAM_ID_LF_T3T_ID11
116 #define NFC_PMID_LF_T3T_ID12        NCI_PARAM_ID_LF_T3T_ID12
117 #define NFC_PMID_LF_T3T_ID13        NCI_PARAM_ID_LF_T3T_ID13
118 #define NFC_PMID_LF_T3T_ID14        NCI_PARAM_ID_LF_T3T_ID14
119 #define NFC_PMID_LF_T3T_ID15        NCI_PARAM_ID_LF_T3T_ID15
120 #define NFC_PMID_LF_T3T_ID16        NCI_PARAM_ID_LF_T3T_ID16
121 #define NFC_PMID_LF_PROTOCOL        NCI_PARAM_ID_LF_PROTOCOL
122 #define NFC_PMID_LF_T3T_PMM         NCI_PARAM_ID_LF_T3T_PMM
123 #define NFC_PMID_LF_T3T_MAX         NCI_PARAM_ID_LF_T3T_MAX
124 #define NFC_PMID_LF_T3T_FLAGS2      NCI_PARAM_ID_LF_T3T_FLAGS2
125 #define NFC_PMID_FWI                NCI_PARAM_ID_FWI
126 #define NFC_PMID_LF_CON_BITR_F      NCI_PARAM_ID_LF_CON_BITR_F
127 #define NFC_PMID_WT                 NCI_PARAM_ID_WT
128 #define NFC_PMID_ATR_RES_GEN_BYTES  NCI_PARAM_ID_ATR_RES_GEN_BYTES
129 #define NFC_PMID_ATR_RSP_CONFIG     NCI_PARAM_ID_ATR_RSP_CONFIG
130 #define NFC_PMID_RF_FIELD_INFO      NCI_PARAM_ID_RF_FIELD_INFO
131 #define NFC_PMID_NFC_DEP_OP         NCI_PARAM_ID_NFC_DEP_OP
132 #define NFC_PARAM_ID_RF_EE_ACTION   NCI_PARAM_ID_RF_EE_ACTION
133 #define NFC_PARAM_ID_ISO_DEP_OP     NCI_PARAM_ID_ISO_DEP_OP
134 
135 #define NFC_ROUTE_TAG_TECH           NCI_ROUTE_TAG_TECH      /* Technology based routing  */
136 #define NFC_ROUTE_TAG_PROTO          NCI_ROUTE_TAG_PROTO     /* Protocol based routing  */
137 #define NFC_ROUTE_TAG_AID            NCI_ROUTE_TAG_AID       /* AID routing */
138 #define NFC_ROUTE_TLV_ENTRY_SIZE     4 /* tag, len, 2 byte value for technology/protocol based routing */
139 
140 /* For routing */
141 #define NFC_DH_ID                NCI_DH_ID   /* for DH */
142 /* To identify the loopback test */
143 #define NFC_TEST_ID              NCI_TEST_ID            /* use a proprietary range */
144 
145 typedef UINT8 tNFC_PMID;
146 #define NFC_TL_SIZE                     2
147 #define NFC_SAVED_CMD_SIZE              2
148 
149 typedef tNCI_DISCOVER_MAPS   tNFC_DISCOVER_MAPS;
150 typedef tNCI_DISCOVER_PARAMS tNFC_DISCOVER_PARAMS;
151 
152 /* all NFC Manager Callback functions have prototype like void (cback) (UINT8 event, void *p_data)
153  * tNFC_DATA_CBACK uses connection id as the first parameter; range 0x00-0x0F.
154  * tNFC_DISCOVER_CBACK uses tNFC_DISCOVER_EVT; range  0x4000 ~
155  * tNFC_RESPONSE_CBACK uses tNFC_RESPONSE_EVT; range  0x5000 ~
156  */
157 
158 #define NFC_FIRST_DEVT      0x4000
159 #define NFC_FIRST_REVT      0x5000
160 #define NFC_FIRST_CEVT      0x6000
161 #define NFC_FIRST_TEVT      0x8000
162 
163 /* the events reported on tNFC_RESPONSE_CBACK */
164 enum
165 {
166     NFC_ENABLE_REVT = NFC_FIRST_REVT,       /* 0  Enable event                  */
167     NFC_DISABLE_REVT,                       /* 1  Disable event                 */
168     NFC_SET_CONFIG_REVT,                    /* 2  Set Config Response           */
169     NFC_GET_CONFIG_REVT,                    /* 3  Get Config Response           */
170     NFC_NFCEE_DISCOVER_REVT,                /* 4  Discover NFCEE response       */
171     NFC_NFCEE_INFO_REVT,                    /* 5  Discover NFCEE Notification   */
172     NFC_NFCEE_MODE_SET_REVT,                /* 6  NFCEE Mode Set response       */
173     NFC_RF_FIELD_REVT,                      /* 7  RF Field information          */
174     NFC_EE_ACTION_REVT,                     /* 8  EE Action notification        */
175     NFC_EE_DISCOVER_REQ_REVT,               /* 9  EE Discover Req notification  */
176     NFC_SET_ROUTING_REVT,                   /* 10 Configure Routing response    */
177     NFC_GET_ROUTING_REVT,                   /* 11 Retrieve Routing response     */
178     NFC_RF_COMM_PARAMS_UPDATE_REVT,         /* 12 RF Communication Param Update */
179     NFC_GEN_ERROR_REVT,                     /* 13 generic error notification    */
180     NFC_NFCC_RESTART_REVT,                  /* 14 NFCC has been re-initialized  */
181     NFC_NFCC_TIMEOUT_REVT,                  /* 15 NFCC is not responding        */
182     NFC_NFCC_TRANSPORT_ERR_REVT,            /* 16 NCI Tranport error            */
183     NFC_NFCC_POWER_OFF_REVT,                /* 17 NFCC turned off               */
184 
185     NFC_FIRST_VS_REVT                       /* First vendor-specific rsp event  */
186 };
187 typedef UINT16 tNFC_RESPONSE_EVT;
188 
189 enum
190 {
191     NFC_CONN_CREATE_CEVT = NFC_FIRST_CEVT,  /* 0  Conn Create Response          */
192     NFC_CONN_CLOSE_CEVT,                    /* 1  Conn Close Response           */
193     NFC_DEACTIVATE_CEVT,                    /* 2  Deactivate response/notificatn*/
194     NFC_DATA_CEVT,                          /* 3  Data                          */
195     NFC_ERROR_CEVT                          /* 4  generic or interface error    */
196 };
197 typedef UINT16 tNFC_CONN_EVT;
198 
199 #define NFC_NFCC_INFO_LEN       4
200 #ifndef NFC_NFCC_MAX_NUM_VS_INTERFACE
201 #define NFC_NFCC_MAX_NUM_VS_INTERFACE   4
202 #endif
203 typedef struct
204 {
205     tNFC_STATUS             status;         /* The event status.                */
206     UINT8                   nci_version;    /* the NCI version of NFCC          */
207     UINT8                   max_conn;       /* max number of connections by NFCC*/
208     UINT32                  nci_features;   /* the NCI features of NFCC         */
209     UINT16                  nci_interfaces; /* the NCI interfaces of NFCC       */
210     UINT16                  max_ce_table;   /* the max routing table size       */
211     UINT16                  max_param_size; /* Max Size for Large Parameters    */
212     UINT8                   manufacture_id; /* the Manufacture ID for NFCC      */
213     UINT8                   nfcc_info[NFC_NFCC_INFO_LEN];/* the Manufacture Info for NFCC      */
214     UINT8                   vs_interface[NFC_NFCC_MAX_NUM_VS_INTERFACE];  /* the NCI VS interfaces of NFCC    */
215 } tNFC_ENABLE_REVT;
216 
217 #define NFC_MAX_NUM_IDS     125
218 /* the data type associated with NFC_SET_CONFIG_REVT */
219 typedef struct
220 {
221     tNFC_STATUS             status;         /* The event status.                */
222     UINT8                   num_param_id;   /* Number of rejected NCI Param ID  */
223     UINT8                   param_ids[NFC_MAX_NUM_IDS];/* NCI Param ID          */
224 } tNFC_SET_CONFIG_REVT;
225 
226 /* the data type associated with NFC_GET_CONFIG_REVT */
227 typedef struct
228 {
229     tNFC_STATUS             status;         /* The event status.    */
230     UINT16                  tlv_size;       /* The length of TLV    */
231     UINT8                   *p_param_tlvs;  /* TLV                  */
232 } tNFC_GET_CONFIG_REVT;
233 
234 /* the data type associated with NFC_NFCEE_DISCOVER_REVT */
235 typedef struct
236 {
237     tNFC_STATUS             status;         /* The event status.    */
238     UINT8                   num_nfcee;      /* The number of NFCEE  */
239 } tNFC_NFCEE_DISCOVER_REVT;
240 
241 #define NFC_NFCEE_INTERFACE_APDU         NCI_NFCEE_INTERFACE_APDU
242 #define NFC_NFCEE_INTERFACE_HCI_ACCESS   NCI_NFCEE_INTERFACE_HCI_ACCESS
243 #define NFC_NFCEE_INTERFACE_T3T          NCI_NFCEE_INTERFACE_T3T
244 #define NFC_NFCEE_INTERFACE_TRANSPARENT  NCI_NFCEE_INTERFACE_TRANSPARENT
245 #define NFC_NFCEE_INTERFACE_PROPRIETARY  NCI_NFCEE_INTERFACE_PROPRIETARY
246 typedef UINT8 tNFC_NFCEE_INTERFACE;
247 
248 #define NFC_NFCEE_TAG_HW_ID             NCI_NFCEE_TAG_HW_ID
249 #define NFC_NFCEE_TAG_ATR_BYTES         NCI_NFCEE_TAG_ATR_BYTES
250 #define NFC_NFCEE_TAG_T3T_INFO          NCI_NFCEE_TAG_T3T_INFO
251 #define NFC_NFCEE_TAG_HCI_HOST_ID       NCI_NFCEE_TAG_HCI_HOST_ID
252 typedef UINT8 tNFC_NFCEE_TAG;
253 /* additional NFCEE Info */
254 typedef struct
255 {
256     tNFC_NFCEE_TAG          tag;
257     UINT8                   len;
258     UINT8                   info[NFC_MAX_EE_INFO];
259 } tNFC_NFCEE_TLV;
260 
261 #define NFC_NFCEE_STATUS_INACTIVE       NCI_NFCEE_STS_CONN_INACTIVE/* NFCEE connected and inactive */
262 #define NFC_NFCEE_STATUS_ACTIVE         NCI_NFCEE_STS_CONN_ACTIVE  /* NFCEE connected and active   */
263 #define NFC_NFCEE_STATUS_REMOVED        NCI_NFCEE_STS_REMOVED      /* NFCEE removed                */
264 /* the data type associated with NFC_NFCEE_INFO_REVT */
265 typedef struct
266 {
267     tNFC_STATUS             status;                 /* The event status - place holder  */
268     UINT8                   nfcee_id;               /* NFCEE ID                         */
269     UINT8                   ee_status;              /* The NFCEE status.                */
270     UINT8                   num_interface;          /* number of NFCEE interfaces       */
271     UINT8                   ee_interface[NFC_MAX_EE_INTERFACE];/* NFCEE interface       */
272     UINT8                   num_tlvs;               /* number of TLVs                   */
273     tNFC_NFCEE_TLV          ee_tlv[NFC_MAX_EE_TLVS];/* The TLVs associated with NFCEE   */
274 } tNFC_NFCEE_INFO_REVT;
275 
276 #define NFC_MODE_ACTIVATE          NCI_NFCEE_MD_ACTIVATE
277 #define NFC_MODE_DEACTIVATE        NCI_NFCEE_MD_DEACTIVATE
278 typedef UINT8 tNFC_NFCEE_MODE;
279 /* the data type associated with NFC_NFCEE_MODE_SET_REVT */
280 typedef struct
281 {
282     tNFC_STATUS             status;                 /* The event status.*/
283     UINT8                   nfcee_id;               /* NFCEE ID         */
284     tNFC_NFCEE_MODE         mode;                   /* NFCEE mode       */
285 } tNFC_NFCEE_MODE_SET_REVT;
286 
287 #define NFC_MAX_AID_LEN     NCI_MAX_AID_LEN     /* 16 */
288 
289 /* the data type associated with NFC_CE_GET_ROUTING_REVT */
290 typedef struct
291 {
292     tNFC_STATUS             status;         /* The event status                 */
293     UINT8                   nfcee_id;       /* NFCEE ID                         */
294     UINT8                   num_tlvs;       /* number of TLVs                   */
295     UINT8                   tlv_size;       /* the total len of all TLVs        */
296     UINT8                   param_tlvs[NFC_MAX_EE_TLV_SIZE];/* the TLVs         */
297 } tNFC_GET_ROUTING_REVT;
298 
299 
300 /* the data type associated with NFC_CONN_CREATE_CEVT */
301 typedef struct
302 {
303     tNFC_STATUS             status;         /* The event status                 */
304     UINT8                   dest_type;      /* the destination type             */
305     UINT8                   id;             /* NFCEE ID  or RF Discovery ID     */
306     UINT8                   buff_size;      /* The max buffer size              */
307     UINT8                   num_buffs;      /* The number of buffers            */
308 } tNFC_CONN_CREATE_CEVT;
309 
310 /* the data type associated with NFC_CONN_CLOSE_CEVT */
311 typedef struct
312 {
313     tNFC_STATUS             status;         /* The event status                 */
314 } tNFC_CONN_CLOSE_CEVT;
315 
316 /* the data type associated with NFC_DATA_CEVT */
317 typedef struct
318 {
319     tNFC_STATUS             status;         /* The event status                 */
320     BT_HDR                  *p_data;        /* The received Data                */
321 } tNFC_DATA_CEVT;
322 
323 /* RF Field Status */
324 #define NFC_RF_STS_NO_REMOTE    NCI_RF_STS_NO_REMOTE    /* No field generated by remote device  */
325 #define NFC_RF_STS_REMOTE       NCI_RF_STS_REMOTE       /* field generated by remote device     */
326 typedef UINT8 tNFC_RF_STS;
327 
328 /* RF Field Technologies */
329 #define NFC_RF_TECHNOLOGY_A     NCI_RF_TECHNOLOGY_A
330 #define NFC_RF_TECHNOLOGY_B     NCI_RF_TECHNOLOGY_B
331 #define NFC_RF_TECHNOLOGY_F     NCI_RF_TECHNOLOGY_F
332 #define NFC_RF_TECHNOLOGY_15693 NCI_RF_TECHNOLOGY_15693
333 typedef UINT8 tNFC_RF_TECH;
334 
335 
336 /* Supported Protocols */
337 #define NFC_PROTOCOL_UNKNOWN    NCI_PROTOCOL_UNKNOWN  /* Unknown */
338 #define NFC_PROTOCOL_T1T        NCI_PROTOCOL_T1T      /* Type1Tag    - NFC-A            */
339 #define NFC_PROTOCOL_T2T        NCI_PROTOCOL_T2T      /* Type2Tag    - NFC-A            */
340 #define NFC_PROTOCOL_T3T        NCI_PROTOCOL_T3T      /* Type3Tag    - NFC-F            */
341 #define NFC_PROTOCOL_ISO_DEP    NCI_PROTOCOL_ISO_DEP  /* Type 4A,4B  - NFC-A or NFC-B   */
342 #define NFC_PROTOCOL_NFC_DEP    NCI_PROTOCOL_NFC_DEP  /* NFCDEP/LLCP - NFC-A or NFC-F       */
343 #define NFC_PROTOCOL_B_PRIME    NCI_PROTOCOL_B_PRIME
344 #define NFC_PROTOCOL_15693      NCI_PROTOCOL_15693
345 #define NFC_PROTOCOL_KOVIO      NCI_PROTOCOL_KOVIO
346 typedef UINT8 tNFC_PROTOCOL;
347 
348 /* Discovery Types/Detected Technology and Mode */
349 #define NFC_DISCOVERY_TYPE_POLL_A           NCI_DISCOVERY_TYPE_POLL_A
350 #define NFC_DISCOVERY_TYPE_POLL_B           NCI_DISCOVERY_TYPE_POLL_B
351 #define NFC_DISCOVERY_TYPE_POLL_F           NCI_DISCOVERY_TYPE_POLL_F
352 #define NFC_DISCOVERY_TYPE_POLL_A_ACTIVE    NCI_DISCOVERY_TYPE_POLL_A_ACTIVE
353 #define NFC_DISCOVERY_TYPE_POLL_F_ACTIVE    NCI_DISCOVERY_TYPE_POLL_F_ACTIVE
354 #define NFC_DISCOVERY_TYPE_POLL_ISO15693    NCI_DISCOVERY_TYPE_POLL_ISO15693
355 #define NFC_DISCOVERY_TYPE_POLL_B_PRIME     NCI_DISCOVERY_TYPE_POLL_B_PRIME
356 #define NFC_DISCOVERY_TYPE_POLL_KOVIO       NCI_DISCOVERY_TYPE_POLL_KOVIO
357 #define NFC_DISCOVERY_TYPE_LISTEN_A         NCI_DISCOVERY_TYPE_LISTEN_A
358 #define NFC_DISCOVERY_TYPE_LISTEN_B         NCI_DISCOVERY_TYPE_LISTEN_B
359 #define NFC_DISCOVERY_TYPE_LISTEN_F         NCI_DISCOVERY_TYPE_LISTEN_F
360 #define NFC_DISCOVERY_TYPE_LISTEN_A_ACTIVE  NCI_DISCOVERY_TYPE_LISTEN_A_ACTIVE
361 #define NFC_DISCOVERY_TYPE_LISTEN_F_ACTIVE  NCI_DISCOVERY_TYPE_LISTEN_F_ACTIVE
362 #define NFC_DISCOVERY_TYPE_LISTEN_ISO15693  NCI_DISCOVERY_TYPE_LISTEN_ISO15693
363 #define NFC_DISCOVERY_TYPE_LISTEN_B_PRIME   NCI_DISCOVERY_TYPE_LISTEN_B_PRIME
364 typedef UINT8 tNFC_DISCOVERY_TYPE;
365 typedef UINT8 tNFC_RF_TECH_N_MODE;
366 
367 /* Select Response codes */
368 #define NFC_SEL_RES_NFC_FORUM_T2T           0x00
369 #define NFC_SEL_RES_MF_CLASSIC              0x08
370 
371 /* Bit Rates */
372 #define NFC_BIT_RATE_106        NCI_BIT_RATE_106    /* 106 kbit/s */
373 #define NFC_BIT_RATE_212        NCI_BIT_RATE_212    /* 212 kbit/s */
374 #define NFC_BIT_RATE_424        NCI_BIT_RATE_424    /* 424 kbit/s */
375 #define NFC_BIT_RATE_848        NCI_BIT_RATE_848    /* 848 Kbit/s */
376 #define NFC_BIT_RATE_1696       NCI_BIT_RATE_1696   /* 1696 Kbit/s*/
377 #define NFC_BIT_RATE_3392       NCI_BIT_RATE_3392   /* 3392 Kbit/s*/
378 #define NFC_BIT_RATE_6784       NCI_BIT_RATE_6784   /* 6784 Kbit/s*/
379 typedef UINT8 tNFC_BIT_RATE;
380 
381 /**********************************************
382  * Interface Types
383  **********************************************/
384 #define NFC_INTERFACE_EE_DIRECT_RF  NCI_INTERFACE_EE_DIRECT_RF
385 #define NFC_INTERFACE_FRAME         NCI_INTERFACE_FRAME
386 #define NFC_INTERFACE_ISO_DEP       NCI_INTERFACE_ISO_DEP
387 #define NFC_INTERFACE_NDEF          NCI_INTERFACE_NDEF
388 #define NFC_INTERFACE_NFC_DEP       NCI_INTERFACE_NFC_DEP
389 #define NFC_INTERFACE_LLCP_LOW      NCI_INTERFACE_LLCP_LOW
390 #define NFC_INTERFACE_LLCP_HIGH     NCI_INTERFACE_LLCP_HIGH
391 #define NFC_INTERFACE_VS_T2T_CE     NCI_INTERFACE_VS_T2T_CE
392 typedef tNCI_INTF_TYPE tNFC_INTF_TYPE;
393 
394 /**********************************************
395  *  Deactivation Type
396  **********************************************/
397 #define NFC_DEACTIVATE_TYPE_IDLE        NCI_DEACTIVATE_TYPE_IDLE
398 #define NFC_DEACTIVATE_TYPE_SLEEP       NCI_DEACTIVATE_TYPE_SLEEP
399 #define NFC_DEACTIVATE_TYPE_SLEEP_AF    NCI_DEACTIVATE_TYPE_SLEEP_AF
400 #define NFC_DEACTIVATE_TYPE_DISCOVERY   NCI_DEACTIVATE_TYPE_DISCOVERY
401 typedef UINT8 tNFC_DEACT_TYPE;
402 
403 /**********************************************
404  *  Deactivation Reasons
405  **********************************************/
406 #define NFC_DEACTIVATE_REASON_DH_REQ        NCI_DEACTIVATE_REASON_DH_REQ
407 #define NFC_DEACTIVATE_REASON_ENDPOINT_REQ  NCI_DEACTIVATE_REASON_ENDPOINT_REQ
408 #define NFC_DEACTIVATE_REASON_RF_LINK_LOSS  NCI_DEACTIVATE_REASON_RF_LINK_LOSS
409 #define NFC_DEACTIVATE_REASON_NFCB_BAD_AFI  NCI_DEACTIVATE_REASON_NFCB_BAD_AFI
410 typedef UINT8 tNFC_DEACT_REASON;
411 
412 /* the data type associated with NFC_RF_FIELD_REVT */
413 typedef struct
414 {
415     tNFC_STATUS             status;     /* The event status - place holder. */
416     tNFC_RF_STS             rf_field;   /* RF Field Status                  */
417 } tNFC_RF_FIELD_REVT;
418 
419 #define NFC_MAX_APP_DATA_LEN    40
420 typedef struct
421 {
422     UINT8                   len_aid;                /* length of application id */
423     UINT8                   aid[NFC_MAX_AID_LEN];   /* application id           */
424 } tNFC_AID;
425 typedef struct
426 {
427     UINT8                   len_aid;                /* length of application id */
428     UINT8                   aid[NFC_MAX_AID_LEN];   /* application id           */
429     UINT8                   len_data;               /* len of application data  */
430     UINT8                   data[NFC_MAX_APP_DATA_LEN];  /* application data    */
431 } tNFC_APP_INIT;
432 
433 #define NFC_EE_TRIG_SELECT              NCI_EE_TRIG_7816_SELECT  /* ISO 7816-4 SELECT command */
434 #define NFC_EE_TRIG_RF_PROTOCOL         NCI_EE_TRIG_RF_PROTOCOL  /* RF Protocol changed       */
435 #define NFC_EE_TRIG_RF_TECHNOLOGY       NCI_EE_TRIG_RF_TECHNOLOGY/* RF Technology changed     */
436 #define NFC_EE_TRIG_APP_INIT            NCI_EE_TRIG_APP_INIT     /* Application initiation    */
437 typedef UINT8 tNFC_EE_TRIGGER;
438 typedef struct
439 {
440     tNFC_EE_TRIGGER         trigger;        /* the trigger of this event        */
441     union
442     {
443         tNFC_PROTOCOL       protocol;
444         tNFC_RF_TECH        technology;
445         tNFC_AID            aid;
446         tNFC_APP_INIT       app_init;
447     } param; /* Discovery Type specific parameters */
448 } tNFC_ACTION_DATA;
449 
450 /* the data type associated with NFC_EE_ACTION_REVT */
451 typedef struct
452 {
453     tNFC_STATUS             status;         /* The event status - place holder  */
454     UINT8                   nfcee_id;       /* NFCEE ID                         */
455     tNFC_ACTION_DATA        act_data;       /* data associated /w the action    */
456 } tNFC_EE_ACTION_REVT;
457 
458 #define NFC_EE_DISC_OP_ADD      0
459 #define NFC_EE_DISC_OP_REMOVE   1
460 typedef UINT8 tNFC_EE_DISC_OP;
461 typedef struct
462 {
463     tNFC_EE_DISC_OP         op;             /* add or remove this entry         */
464     UINT8                   nfcee_id;       /* NFCEE ID                         */
465     tNFC_RF_TECH_N_MODE     tech_n_mode;    /* Discovery Technology and Mode    */
466     tNFC_PROTOCOL           protocol;       /* NFC protocol                     */
467 } tNFC_EE_DISCOVER_INFO;
468 
469 #ifndef NFC_MAX_EE_DISC_ENTRIES
470 #define NFC_MAX_EE_DISC_ENTRIES     6
471 #endif
472 #define NFC_EE_DISCOVER_ENTRY_LEN   5 /* T, L, V(NFCEE ID, TechnMode, Protocol) */
473 #define NFC_EE_DISCOVER_INFO_LEN    3 /* NFCEE ID, TechnMode, Protocol */
474 /* the data type associated with NFC_EE_DISCOVER_REQ_REVT */
475 typedef struct
476 {
477     tNFC_STATUS             status;         /* The event status - place holder  */
478     UINT8                   num_info;       /* number of entries in info[]      */
479     tNFC_EE_DISCOVER_INFO   info[NFC_MAX_EE_DISC_ENTRIES];  /* discovery request from NFCEE */
480 } tNFC_EE_DISCOVER_REQ_REVT;
481 
482 typedef union
483 {
484     tNFC_STATUS                 status;     /* The event status. */
485     tNFC_ENABLE_REVT            enable;
486     tNFC_SET_CONFIG_REVT        set_config;
487     tNFC_GET_CONFIG_REVT        get_config;
488     tNFC_NFCEE_DISCOVER_REVT    nfcee_discover;
489     tNFC_NFCEE_INFO_REVT        nfcee_info;
490     tNFC_NFCEE_MODE_SET_REVT    mode_set;
491     tNFC_RF_FIELD_REVT          rf_field;
492     tNFC_STATUS                 cfg_routing;
493     tNFC_GET_ROUTING_REVT       get_routing;
494     tNFC_EE_ACTION_REVT         ee_action;
495     tNFC_EE_DISCOVER_REQ_REVT   ee_discover_req;
496     void                        *p_vs_evt_data;
497 } tNFC_RESPONSE;
498 
499 /*************************************
500 **  RESPONSE Callback Functions
501 **************************************/
502 typedef void (tNFC_RESPONSE_CBACK) (tNFC_RESPONSE_EVT event, tNFC_RESPONSE *p_data);
503 
504 /* The events reported on tNFC_VS_CBACK */
505 /* The event is (NCI_RSP_BIT|oid) for response and (NCI_NTF_BIT|oid) for notification*/
506 
507 typedef UINT8 tNFC_VS_EVT;
508 
509 /*************************************
510 **  Proprietary (Vendor Specific) Callback Functions
511 **************************************/
512 typedef void (tNFC_VS_CBACK) (tNFC_VS_EVT event, UINT16 data_len, UINT8 *p_data);
513 
514 /* the events reported on tNFC_DISCOVER_CBACK */
515 enum
516 {
517     NFC_START_DEVT = NFC_FIRST_DEVT,    /* Status of NFC_DiscoveryStart     */
518     NFC_MAP_DEVT,                       /* Status of NFC_DiscoveryMap       */
519     NFC_RESULT_DEVT,                    /* The responses from remote device */
520     NFC_SELECT_DEVT,                    /* Status of NFC_DiscoverySelect    */
521     NFC_ACTIVATE_DEVT,                  /* RF interface is activated        */
522     NFC_DEACTIVATE_DEVT                 /* Status of RF deactivation        */
523 };
524 typedef UINT16 tNFC_DISCOVER_EVT;
525 
526 /* the data type associated with NFC_START_DEVT */
527 typedef tNFC_STATUS tNFC_START_DEVT;
528 
529 typedef tNCI_RF_PA_PARAMS tNFC_RF_PA_PARAMS;
530 #define NFC_MAX_SENSB_RES_LEN         NCI_MAX_SENSB_RES_LEN
531 #define NFC_NFCID0_MAX_LEN          4
532 typedef struct
533 {
534     UINT8       sensb_res_len;/* Length of SENSB_RES Response (Byte 2 - Byte 12 or 13) Available after Technology Detection */
535     UINT8       sensb_res[NFC_MAX_SENSB_RES_LEN]; /* SENSB_RES Response (ATQ) */
536     UINT8       nfcid0[NFC_NFCID0_MAX_LEN];
537 } tNFC_RF_PB_PARAMS;
538 
539 #define NFC_MAX_SENSF_RES_LEN       NCI_MAX_SENSF_RES_LEN
540 #define NFC_NFCID2_LEN              NCI_NFCID2_LEN
541 typedef struct
542 {
543     UINT8       bit_rate;/* NFC_BIT_RATE_212 or NFC_BIT_RATE_424 */
544     UINT8       sensf_res_len;/* Length of SENSF_RES Response (Byte 2 - Byte 17 or 19) Available after Technology Detection */
545     UINT8       sensf_res[NFC_MAX_SENSF_RES_LEN]; /* SENSB_RES Response */
546     UINT8       nfcid2[NFC_NFCID2_LEN];  /* NFCID2 generated by the Local NFCC for NFC-DEP Protocol.Available for Frame Interface  */
547     UINT8       mrti_check;
548     UINT8       mrti_update;
549 } tNFC_RF_PF_PARAMS;
550 
551 typedef tNCI_RF_LF_PARAMS tNFC_RF_LF_PARAMS;
552 
553 #define NFC_ISO15693_UID_LEN        8
554 typedef struct
555 {
556     UINT8       flag;
557     UINT8       dsfid;
558     UINT8       uid[NFC_ISO15693_UID_LEN];
559 } tNFC_RF_PISO15693_PARAMS;
560 
561 #define NFC_KOVIO_MAX_LEN       16
562 typedef struct
563 {
564     UINT8       uid_len;
565     UINT8       uid[NFC_KOVIO_MAX_LEN];
566 } tNFC_RF_PKOVIO_PARAMS;
567 
568 typedef struct
569 {
570     tNFC_DISCOVERY_TYPE     mode;
571     union
572     {
573         tNFC_RF_PA_PARAMS   pa;
574         tNFC_RF_PB_PARAMS   pb;
575         tNFC_RF_PF_PARAMS   pf;
576         tNFC_RF_LF_PARAMS   lf;
577         tNFC_RF_PISO15693_PARAMS pi93;
578         tNFC_RF_PKOVIO_PARAMS pk;
579     } param; /* Discovery Type specific parameters */
580 } tNFC_RF_TECH_PARAMS;
581 
582 /* the data type associated with NFC_RESULT_DEVT */
583 typedef struct
584 {
585     tNFC_STATUS             status;         /* The event status - place holder. */
586     UINT8                   rf_disc_id;     /* RF Discovery ID                  */
587     UINT8                   protocol;       /* supported protocol               */
588     tNFC_RF_TECH_PARAMS     rf_tech_param;  /* RF technology parameters         */
589     BOOLEAN                 more;           /* 0: last notification             */
590 } tNFC_RESULT_DEVT;
591 
592 /* the data type associated with NFC_SELECT_DEVT */
593 typedef tNFC_STATUS tNFC_SELECT_DEVT;
594 
595 /* the data type associated with NFC_STOP_DEVT */
596 typedef tNFC_STATUS tNFC_STOP_DEVT;
597 
598 #define NFC_MAX_ATS_LEN             NCI_MAX_ATS_LEN
599 #define NFC_MAX_HIS_BYTES_LEN       NCI_MAX_HIS_BYTES_LEN
600 #define NFC_MAX_GEN_BYTES_LEN       NCI_MAX_GEN_BYTES_LEN
601 
602 
603 typedef struct
604 {
605     UINT8       ats_res_len;                /* Length of ATS RES                */
606     UINT8       ats_res[NFC_MAX_ATS_LEN];   /* ATS RES                          */
607     BOOLEAN     nad_used;                   /* NAD is used or not               */
608     UINT8       fwi;                        /* Frame Waiting time Integer       */
609     UINT8       sfgi;                       /* Start-up Frame Guard time Integer*/
610     UINT8       his_byte_len;               /* len of historical bytes          */
611     UINT8       his_byte[NFC_MAX_HIS_BYTES_LEN];/* historical bytes             */
612 } tNFC_INTF_PA_ISO_DEP;
613 
614 typedef struct
615 {
616     UINT8       rats;  /* RATS */
617 } tNFC_INTF_LA_ISO_DEP;
618 
619 
620 typedef struct
621 {
622     UINT8       atr_res_len;                /* Length of ATR_RES            */
623     UINT8       atr_res[NFC_MAX_ATS_LEN];   /* ATR_RES (Byte 3 - Byte 17+n) */
624     UINT8       max_payload_size;           /* 64, 128, 192 or 254          */
625     UINT8       gen_bytes_len;              /* len of general bytes         */
626     UINT8       gen_bytes[NFC_MAX_GEN_BYTES_LEN];/* general bytes           */
627     UINT8       waiting_time;               /* WT -> Response Waiting Time RWT = (256 x 16/fC) x 2WT */
628 } tNFC_INTF_PA_NFC_DEP;
629 
630 /* Note: keep tNFC_INTF_PA_NFC_DEP data member in the same order as tNFC_INTF_LA_NFC_DEP */
631 typedef struct
632 {
633     UINT8       atr_req_len;                /* Length of ATR_REQ            */
634     UINT8       atr_req[NFC_MAX_ATS_LEN];   /* ATR_REQ (Byte 3 - Byte 18+n) */
635     UINT8       max_payload_size;           /* 64, 128, 192 or 254          */
636     UINT8       gen_bytes_len;              /* len of general bytes         */
637     UINT8       gen_bytes[NFC_MAX_GEN_BYTES_LEN];/* general bytes           */
638 } tNFC_INTF_LA_NFC_DEP;
639 typedef tNFC_INTF_LA_NFC_DEP tNFC_INTF_LF_NFC_DEP;
640 typedef tNFC_INTF_PA_NFC_DEP tNFC_INTF_PF_NFC_DEP;
641 
642 #define NFC_MAX_ATTRIB_LEN      NCI_MAX_ATTRIB_LEN
643 
644 typedef struct
645 {
646     UINT8       attrib_res_len;                /* Length of ATTRIB RES      */
647     UINT8       attrib_res[NFC_MAX_ATTRIB_LEN];/* ATTRIB RES                */
648     UINT8       hi_info_len;                   /* len of Higher layer Info  */
649     UINT8       hi_info[NFC_MAX_GEN_BYTES_LEN];/* Higher layer Info         */
650     UINT8       mbli;                          /* Maximum buffer length.    */
651 } tNFC_INTF_PB_ISO_DEP;
652 
653 typedef struct
654 {
655     UINT8       attrib_req_len;                /* Length of ATTRIB REQ      */
656     UINT8       attrib_req[NFC_MAX_ATTRIB_LEN];/* ATTRIB REQ (Byte 2 - 10+k)*/
657     UINT8       hi_info_len;                   /* len of Higher layer Info  */
658     UINT8       hi_info[NFC_MAX_GEN_BYTES_LEN];/* Higher layer Info         */
659     UINT8       nfcid0[NFC_NFCID0_MAX_LEN];    /* NFCID0                    */
660 } tNFC_INTF_LB_ISO_DEP;
661 
662 
663 #ifndef NFC_MAX_RAW_PARAMS
664 #define NFC_MAX_RAW_PARAMS      16
665 #endif
666 #define NFC_MAX_RAW_PARAMS       16
667 typedef struct
668 {
669     UINT8       param_len;
670     UINT8       param[NFC_MAX_RAW_PARAMS];
671 } tNFC_INTF_FRAME;
672 
673 typedef struct
674 {
675     tNFC_INTF_TYPE      type;  /* Interface Type  1 Byte  See Table 67 */
676     union
677     {
678         tNFC_INTF_LA_ISO_DEP    la_iso;
679         tNFC_INTF_PA_ISO_DEP    pa_iso;
680         tNFC_INTF_LB_ISO_DEP    lb_iso;
681         tNFC_INTF_PB_ISO_DEP    pb_iso;
682         tNFC_INTF_LA_NFC_DEP    la_nfc;
683         tNFC_INTF_PA_NFC_DEP    pa_nfc;
684         tNFC_INTF_LF_NFC_DEP    lf_nfc;
685         tNFC_INTF_PF_NFC_DEP    pf_nfc;
686         tNFC_INTF_FRAME         frame;
687     } intf_param;       /* Activation Parameters   0 - n Bytes */
688 } tNFC_INTF_PARAMS;
689 
690 /* the data type associated with NFC_ACTIVATE_DEVT */
691 typedef struct
692 {
693     UINT8                   rf_disc_id;     /* RF Discovery ID          */
694     tNFC_PROTOCOL           protocol;       /* supported protocol       */
695     tNFC_RF_TECH_PARAMS     rf_tech_param;  /* RF technology parameters */
696     tNFC_BIT_RATE           tx_bitrate;     /* Data Exchange Tx Bitrate */
697     tNFC_BIT_RATE           rx_bitrate;     /* Data Exchange Rx Bitrate */
698     tNFC_INTF_PARAMS        intf_param;     /* interface type and params*/
699 } tNFC_ACTIVATE_DEVT;
700 
701 /* the data type associated with NFC_DEACTIVATE_DEVT and NFC_DEACTIVATE_CEVT */
702 typedef struct
703 {
704     tNFC_STATUS             status;         /* The event status.        */
705     tNFC_DEACT_TYPE         type;           /* De-activate type         */
706     BOOLEAN                 is_ntf;         /* TRUE, if deactivate notif*/
707 } tNFC_DEACTIVATE_DEVT;
708 
709 typedef union
710 {
711     tNFC_STATUS             status;         /* The event status.        */
712     tNFC_START_DEVT         start;
713     tNFC_RESULT_DEVT        result;
714     tNFC_SELECT_DEVT        select;
715     tNFC_STOP_DEVT          stop;
716     tNFC_ACTIVATE_DEVT      activate;
717     tNFC_DEACTIVATE_DEVT    deactivate;
718 } tNFC_DISCOVER;
719 
720 /* Min TR0 indicates to tag the min delay before responding after the end of command */
721 #define NFC_RF_PARAM_MIN_TR0_DEFAULT    0x00
722 #define NFC_RF_PARAM_MIN_TR0_48X        0x01    /* 48 x 16/fc */
723 #define NFC_RF_PARAM_MIN_TR0_16X        0x02    /* 16 x 16/fc */
724 
725 /* Min TR1 indicates to tag the min delay between subcarrier modulation and data transmission */
726 #define NFC_RF_PARAM_MIN_TR1_DEFAULT    0x00
727 #define NFC_RF_PARAM_MIN_TR1_64X        0x01    /* 64 x 16/fc */
728 #define NFC_RF_PARAM_MIN_TR1_16X        0x02    /* 16 x 16/fc */
729 
730 /* Min TR2 indicates to RW the min delay between EoS of tag and SoS of RW */
731 #define NFC_RF_PARAM_MIN_TR2_1792       0x00    /* 1792/fc (10etu + 32/fc) */
732 #define NFC_RF_PARAM_MIN_TR2_3328       0x01    /* 3328/fc (10etu + 128/fc) */
733 #define NFC_RF_PARAM_MIN_TR2_5376       0x02    /* 5376/fc (10etu + 256/fc) */
734 #define NFC_RF_PARAM_MIN_TR2_9472       0x03    /* 9472/fc (10etu + 512/fc) */
735 
736 #define NFC_RF_PARAM_EOS_REQUIRED       0x00    /* EoS required */
737 #define NFC_RF_PARAM_EOS_NOT_REQUIRED   0x01    /* EoS not required */
738 
739 #define NFC_RF_PARAM_SOS_REQUIRED       0x00    /* SoS required */
740 #define NFC_RF_PARAM_SOS_NOT_REQUIRED   0x01    /* SoS not required */
741 
742 typedef struct
743 {
744     BOOLEAN                 include_rf_tech_mode;   /* TRUE if including RF Tech and Mode update    */
745     tNFC_RF_TECH_N_MODE     rf_tech_n_mode;         /* RF tech and mode                             */
746     BOOLEAN                 include_tx_bit_rate;    /* TRUE if including Tx bit rate update         */
747     tNFC_BIT_RATE           tx_bit_rate;            /* Transmit Bit Rate                            */
748     BOOLEAN                 include_rx_bit_rate;    /* TRUE if including Rx bit rate update         */
749     tNFC_BIT_RATE           rx_bit_rate;            /* Receive Bit Rate                             */
750     BOOLEAN                 include_nfc_b_config;   /* TRUE if including NFC-B data exchange config */
751     UINT8                   min_tr0;                /* Minimun TR0                                  */
752     UINT8                   min_tr1;                /* Minimun TR1                                  */
753     UINT8                   suppression_eos;        /* Suppression of EoS                           */
754     UINT8                   suppression_sos;        /* Suppression of SoS                           */
755     UINT8                   min_tr2;                /* Minimun TR1                                  */
756 } tNFC_RF_COMM_PARAMS;
757 
758 /*************************************
759 **  DISCOVER Callback Functions
760 **************************************/
761 typedef void (tNFC_DISCOVER_CBACK) (tNFC_DISCOVER_EVT event, tNFC_DISCOVER *p_data);
762 
763 /* the events reported on tNFC_TEST_CBACK */
764 enum
765 {
766     NFC_LOOPBACK_TEVT = NFC_FIRST_TEVT, /* 0  Loopback test             */
767     NFC_RF_CONTROL_TEVT,                /* 1  RF control Test response  */
768     NFC_RF_FIELD_DONE_TEVT              /* 1  RF control Test notificatn*/
769 };
770 typedef UINT16 tNFC_TEST_EVT;
771 
772 /* the data type associated with NFC_LOOPBACK_TEVT */
773 typedef struct
774 {
775     tNFC_STATUS             status;     /* The event status.            */
776     BT_HDR                  *p_data;    /* The loop back data from NFCC */
777 } tNFC_LOOPBACK_TEVT;
778 
779 /* the data type associated with NFC_RF_CONTROL_TEVT */
780 typedef tNFC_STATUS tNFC_RF_CONTROL_TEVT;
781 
782 typedef union
783 {
784     tNFC_STATUS             status;     /* The event status.            */
785     tNFC_LOOPBACK_TEVT      loop_back;
786     tNFC_RF_CONTROL_TEVT    rf_control;
787 } tNFC_TEST;
788 
789 /*************************************
790 **  TEST Callback Functions
791 **************************************/
792 typedef void (tNFC_TEST_CBACK) (tNFC_TEST_EVT event, tNFC_TEST *p_data);
793 
794 
795 typedef tNFC_DEACTIVATE_DEVT tNFC_DEACTIVATE_CEVT;
796 typedef union
797 {
798     tNFC_STATUS             status;     /* The event status. */
799     tNFC_CONN_CREATE_CEVT   conn_create;
800     tNFC_CONN_CLOSE_CEVT    conn_close;
801     tNFC_DEACTIVATE_CEVT    deactivate;
802     tNFC_DATA_CEVT          data;
803 } tNFC_CONN;
804 
805 /*************************************
806 **  Data Callback Functions
807 **************************************/
808 typedef void (tNFC_CONN_CBACK) (UINT8 conn_id, tNFC_CONN_EVT event, tNFC_CONN *p_data);
809 #define NFC_MAX_CONN_ID                15
810 #define NFC_ILLEGAL_CONN_ID            0xFF
811 #define NFC_RF_CONN_ID                 0    /* the static connection ID for RF traffic */
812 
813 
814 
815 /*************************************
816 **  Status callback function
817 **************************************/
818 typedef void (tNFC_STATUS_CBACK) (tNFC_STATUS status);
819 
820 /*****************************************************************************
821 **  EXTERNAL FUNCTION DECLARATIONS
822 *****************************************************************************/
823 #ifdef __cplusplus
824 extern "C" {
825 #endif
826 
827 /*******************************************************************************
828 **
829 ** Function         NFC_Enable
830 **
831 ** Description      This function enables NFC. Prior to calling NFC_Enable:
832 **                  - the NFCC must be powered up, and ready to receive commands.
833 **                  - GKI must be enabled
834 **                  - NFC_TASK must be started
835 **                  - NCIT_TASK must be started (if using dedicated NCI transport)
836 **
837 **                  This function opens the NCI transport (if applicable),
838 **                  resets the NFC controller, and initializes the NFC subsystems.
839 **
840 **                  When the NFC startup procedure is completed, an
841 **                  NFC_ENABLE_REVT is returned to the application using the
842 **                  tNFC_RESPONSE_CBACK.
843 **
844 ** Returns          tNFC_STATUS
845 **
846 *******************************************************************************/
847 NFC_API extern tNFC_STATUS NFC_Enable (tNFC_RESPONSE_CBACK *p_cback);
848 
849 /*******************************************************************************
850 **
851 ** Function         NFC_Disable
852 **
853 ** Description      This function performs clean up routines for shutting down
854 **                  NFC and closes the NCI transport (if using dedicated NCI
855 **                  transport).
856 **
857 **                  When the NFC shutdown procedure is completed, an
858 **                  NFC_DISABLED_REVT is returned to the application using the
859 **                  tNFC_RESPONSE_CBACK.
860 **
861 ** Returns          nothing
862 **
863 *******************************************************************************/
864 NFC_API extern void NFC_Disable (void);
865 
866 /*******************************************************************************
867 **
868 ** Function         NFC_Init
869 **
870 ** Description      This function initializes control blocks for NFC
871 **
872 ** Returns          nothing
873 **
874 *******************************************************************************/
875 NFC_API extern void NFC_Init(tHAL_NFC_ENTRY *p_hal_entry_tbl);
876 
877 /*******************************************************************************
878 **
879 ** Function         NFC_GetLmrtSize
880 **
881 ** Description      Called by application wto query the Listen Mode Routing
882 **                  Table size supported by NFCC
883 **
884 ** Returns          Listen Mode Routing Table size
885 **
886 *******************************************************************************/
887 NFC_API extern UINT16 NFC_GetLmrtSize(void);
888 
889 /*******************************************************************************
890 **
891 ** Function         NFC_SetConfig
892 **
893 ** Description      This function is called to send the configuration parameter
894 **                  TLV to NFCC. The response from NFCC is reported by
895 **                  tNFC_RESPONSE_CBACK as NFC_SET_CONFIG_REVT.
896 **
897 ** Parameters       tlv_size - the length of p_param_tlvs.
898 **                  p_param_tlvs - the parameter ID/Len/Value list
899 **
900 ** Returns          tNFC_STATUS
901 **
902 *******************************************************************************/
903 NFC_API extern tNFC_STATUS NFC_SetConfig (UINT8     tlv_size,
904                                           UINT8    *p_param_tlvs);
905 
906 /*******************************************************************************
907 **
908 ** Function         NFC_GetConfig
909 **
910 ** Description      This function is called to retrieve the parameter TLV from NFCC.
911 **                  The response from NFCC is reported by tNFC_RESPONSE_CBACK
912 **                  as NFC_GET_CONFIG_REVT.
913 **
914 ** Parameters       num_ids - the number of parameter IDs
915 **                  p_param_ids - the parameter ID list.
916 **
917 ** Returns          tNFC_STATUS
918 **
919 *******************************************************************************/
920 NFC_API extern tNFC_STATUS NFC_GetConfig (UINT8     num_ids,
921                                           UINT8    *p_param_ids);
922 
923 /*******************************************************************************
924 **
925 ** Function         NFC_NfceeDiscover
926 **
927 ** Description      This function is called to enable or disable NFCEE Discovery.
928 **                  The response from NFCC is reported by tNFC_RESPONSE_CBACK
929 **                  as NFC_NFCEE_DISCOVER_REVT.
930 **                  The notification from NFCC is reported by tNFC_RESPONSE_CBACK
931 **                  as NFC_NFCEE_INFO_REVT.
932 **
933 ** Parameters       discover - 1 to enable discover, 0 to disable.
934 **
935 ** Returns          tNFC_STATUS
936 **
937 *******************************************************************************/
938 NFC_API extern tNFC_STATUS NFC_NfceeDiscover (BOOLEAN discover);
939 
940 /*******************************************************************************
941 **
942 ** Function         NFC_NfceeModeSet
943 **
944 ** Description      This function is called to activate or de-activate an NFCEE
945 **                  connected to the NFCC.
946 **                  The response from NFCC is reported by tNFC_RESPONSE_CBACK
947 **                  as NFC_NFCEE_MODE_SET_REVT.
948 **
949 ** Parameters       nfcee_id - the NFCEE to activate or de-activate.
950 **                  mode - 0 to activate NFCEE, 1 to de-activate.
951 **
952 ** Returns          tNFC_STATUS
953 **
954 *******************************************************************************/
955 NFC_API extern tNFC_STATUS NFC_NfceeModeSet (UINT8              nfcee_id,
956                                              tNFC_NFCEE_MODE    mode);
957 /*******************************************************************************
958 **
959 ** Function         NFC_DiscoveryMap
960 **
961 ** Description      This function is called to set the discovery interface mapping.
962 **                  The response from NFCC is reported by tNFC_DISCOVER_CBACK as.
963 **                  NFC_MAP_DEVT.
964 **
965 ** Parameters       num - the number of items in p_params.
966 **                  p_maps - the discovery interface mappings
967 **                  p_cback - the discovery callback function
968 **
969 ** Returns          tNFC_STATUS
970 **
971 *******************************************************************************/
972 NFC_API extern tNFC_STATUS NFC_DiscoveryMap(UINT8 num, tNFC_DISCOVER_MAPS *p_maps,
973                                         tNFC_DISCOVER_CBACK *p_cback);
974 
975 /*******************************************************************************
976 **
977 ** Function         NFC_DiscoveryStart
978 **
979 ** Description      This function is called to start Polling and/or Listening.
980 **                  The response from NFCC is reported by tNFC_DISCOVER_CBACK as.
981 **                  NFC_START_DEVT. The notification from NFCC is reported by
982 **                  tNFC_DISCOVER_CBACK as NFC_RESULT_DEVT.
983 **
984 ** Parameters       num_params - the number of items in p_params.
985 **                  p_params - the discovery parameters
986 **                  p_cback - the discovery callback function
987 **
988 ** Returns          tNFC_STATUS
989 **
990 *******************************************************************************/
991 NFC_API extern tNFC_STATUS NFC_DiscoveryStart(UINT8                 num_params,
992                                               tNFC_DISCOVER_PARAMS *p_params,
993                                               tNFC_DISCOVER_CBACK  *p_cback);
994 
995 /*******************************************************************************
996 **
997 ** Function         NFC_DiscoverySelect
998 **
999 ** Description      If tNFC_DISCOVER_CBACK reports status=NFC_MULTIPLE_PROT,
1000 **                  the application needs to use this function to select the
1001 **                  the logical endpoint to continue. The response from NFCC is
1002 **                  reported by tNFC_DISCOVER_CBACK as NFC_SELECT_DEVT.
1003 **
1004 ** Parameters       rf_disc_id - The ID identifies the remote device.
1005 **                  protocol - the logical endpoint on the remote devide
1006 **                  rf_interface - the RF interface to communicate with NFCC
1007 **
1008 ** Returns          tNFC_STATUS
1009 **
1010 *******************************************************************************/
1011 NFC_API extern tNFC_STATUS NFC_DiscoverySelect (UINT8    rf_disc_id,
1012                                                 UINT8    protocol,
1013                                                 UINT8    rf_interface);
1014 
1015 /*******************************************************************************
1016 **
1017 ** Function         NFC_ConnCreate
1018 **
1019 ** Description      This function is called to create a logical connection with
1020 **                  NFCC for data exchange.
1021 **                  The response from NFCC is reported in tNFC_CONN_CBACK
1022 **                  as NFC_CONN_CREATE_CEVT.
1023 **
1024 ** Parameters       dest_type - the destination type
1025 **                  id   - the NFCEE ID or RF Discovery ID .
1026 **                  protocol - the protocol
1027 **                  p_cback - the data callback function to receive data fron NFCC
1028 **
1029 ** Returns          tNFC_STATUS
1030 **
1031 *******************************************************************************/
1032 NFC_API extern tNFC_STATUS NFC_ConnCreate(UINT8             dest_type,
1033                                           UINT8             id,
1034                                           UINT8             protocol,
1035                                           tNFC_CONN_CBACK  *p_cback);
1036 
1037 /*******************************************************************************
1038 **
1039 ** Function         NFC_ConnClose
1040 **
1041 ** Description      This function is called to close a logical connection with
1042 **                  NFCC.
1043 **                  The response from NFCC is reported in tNFC_CONN_CBACK
1044 **                  as NFC_CONN_CLOSE_CEVT.
1045 **
1046 ** Parameters       conn_id - the connection id.
1047 **
1048 ** Returns          tNFC_STATUS
1049 **
1050 *******************************************************************************/
1051 NFC_API extern tNFC_STATUS NFC_ConnClose(UINT8 conn_id);
1052 
1053 /*******************************************************************************
1054 **
1055 ** Function         NFC_SetStaticRfCback
1056 **
1057 ** Description      This function is called to update the data callback function
1058 **                  to receive the data for the given connection id.
1059 **
1060 ** Parameters       p_cback - the connection callback function
1061 **
1062 ** Returns          Nothing
1063 **
1064 *******************************************************************************/
1065 NFC_API extern void NFC_SetStaticRfCback(tNFC_CONN_CBACK    *p_cback);
1066 
1067 /*******************************************************************************
1068 **
1069 ** Function         NFC_SendData
1070 **
1071 ** Description      This function is called to send the given data packet
1072 **                  to the connection identified by the given connection id.
1073 **
1074 ** Parameters       conn_id - the connection id.
1075 **                  p_data - the data packet
1076 **
1077 ** Returns          tNFC_STATUS
1078 **
1079 *******************************************************************************/
1080 NFC_API extern tNFC_STATUS NFC_SendData(UINT8       conn_id,
1081                                         BT_HDR     *p_data);
1082 
1083 /*******************************************************************************
1084 **
1085 ** Function         NFC_FlushData
1086 **
1087 ** Description      This function is called to discard the tx data queue of
1088 **                  the given connection id.
1089 **
1090 ** Parameters       conn_id - the connection id.
1091 **
1092 ** Returns          tNFC_STATUS
1093 **
1094 *******************************************************************************/
1095 NFC_API extern tNFC_STATUS NFC_FlushData (UINT8       conn_id);
1096 
1097 /*******************************************************************************
1098 **
1099 ** Function         NFC_Deactivate
1100 **
1101 ** Description      This function is called to stop the discovery process or
1102 **                  put the listen device in sleep mode or terminate the NFC link.
1103 **
1104 **                  The response from NFCC is reported by tNFC_DISCOVER_CBACK
1105 **                  as NFC_DEACTIVATE_DEVT.
1106 **
1107 ** Parameters       deactivate_type - NFC_DEACTIVATE_TYPE_IDLE, to IDLE mode.
1108 **                                    NFC_DEACTIVATE_TYPE_SLEEP to SLEEP mode.
1109 **                                    NFC_DEACTIVATE_TYPE_SLEEP_AF to SLEEP_AF mode.
1110 **
1111 ** Returns          tNFC_STATUS
1112 **
1113 *******************************************************************************/
1114 NFC_API extern tNFC_STATUS NFC_Deactivate(tNFC_DEACT_TYPE deactivate_type);
1115 
1116 /*******************************************************************************
1117 **
1118 ** Function         NFC_UpdateRFCommParams
1119 **
1120 ** Description      This function is called to update RF Communication parameters
1121 **                  once the Frame RF Interface has been activated.
1122 **
1123 **                  The response from NFCC is reported by tNFC_RESPONSE_CBACK
1124 **                  as NFC_RF_COMM_PARAMS_UPDATE_REVT.
1125 **
1126 ** Returns          tNFC_STATUS
1127 **
1128 *******************************************************************************/
1129 NFC_API extern tNFC_STATUS NFC_UpdateRFCommParams (tNFC_RF_COMM_PARAMS *p_params);
1130 
1131 /*******************************************************************************
1132 **
1133 ** Function         NFC_SetPowerOffSleep
1134 **
1135 ** Description      This function closes/opens transport and turns off/on NFCC.
1136 **
1137 ** Returns          tNFC_STATUS
1138 **
1139 *******************************************************************************/
1140 NFC_API extern tNFC_STATUS NFC_SetPowerOffSleep (BOOLEAN enable);
1141 
1142 /*******************************************************************************
1143 **
1144 ** Function         NFC_PowerCycleNFCC
1145 **
1146 ** Description      This function turns off and then on NFCC.
1147 **
1148 ** Returns          tNFC_STATUS
1149 **
1150 *******************************************************************************/
1151 NFC_API extern tNFC_STATUS NFC_PowerCycleNFCC (void);
1152 
1153 /*******************************************************************************
1154 **
1155 ** Function         NFC_SetRouting
1156 **
1157 ** Description      This function is called to configure the CE routing table.
1158 **                  The response from NFCC is reported by tNFC_RESPONSE_CBACK
1159 **                  as NFC_SET_ROUTING_REVT.
1160 **
1161 ** Parameters
1162 **
1163 ** Returns          tNFC_STATUS
1164 **
1165 *******************************************************************************/
1166 NFC_API extern tNFC_STATUS NFC_SetRouting(BOOLEAN     more,
1167                                             UINT8       nfcee_id,
1168                                             UINT8       num_tlv,
1169                                             UINT8       tlv_size,
1170                                             UINT8      *p_param_tlvs);
1171 
1172 /*******************************************************************************
1173 **
1174 ** Function         NFC_GetRouting
1175 **
1176 ** Description      This function is called to retrieve the CE routing table from
1177 **                  NFCC. The response from NFCC is reported by tNFC_RESPONSE_CBACK
1178 **                  as NFC_GET_ROUTING_REVT.
1179 **
1180 ** Returns          tNFC_STATUS
1181 **
1182 *******************************************************************************/
1183 NFC_API extern tNFC_STATUS NFC_GetRouting(void);
1184 
1185 /*******************************************************************************
1186 **
1187 ** Function         NFC_RegVSCback
1188 **
1189 ** Description      This function is called to register or de-register a callback
1190 **                  function to receive Proprietary NCI response and notification
1191 **                  events.
1192 **                  The maximum number of callback functions allowed is NFC_NUM_VS_CBACKS
1193 **
1194 ** Returns          tNFC_STATUS
1195 **
1196 *******************************************************************************/
1197 NFC_API extern tNFC_STATUS NFC_RegVSCback (BOOLEAN          is_register,
1198                                            tNFC_VS_CBACK   *p_cback);
1199 
1200 /*******************************************************************************
1201 **
1202 ** Function         NFC_SendVsCommand
1203 **
1204 ** Description      This function is called to send the given vendor specific
1205 **                  command to NFCC. The response from NFCC is reported to the
1206 **                  given tNFC_VS_CBACK as (oid).
1207 **
1208 ** Parameters       oid - The opcode of the VS command.
1209 **                  p_data - The parameters for the VS command
1210 **
1211 ** Returns          tNFC_STATUS
1212 **
1213 *******************************************************************************/
1214 NFC_API extern tNFC_STATUS NFC_SendVsCommand(UINT8          oid,
1215                                              BT_HDR        *p_data,
1216                                              tNFC_VS_CBACK *p_cback);
1217 
1218 /*******************************************************************************
1219 **
1220 ** Function         NFC_TestLoopback
1221 **
1222 ** Description      This function is called to send the given data packet
1223 **                  to NFCC for loopback test.
1224 **                  When loopback data is received from NFCC, tNFC_TEST_CBACK .
1225 **                  reports a NFC_LOOPBACK_TEVT.
1226 **
1227 ** Parameters       p_data - the data packet
1228 **
1229 ** Returns          tNFC_STATUS
1230 **
1231 *******************************************************************************/
1232 NFC_API extern tNFC_STATUS NFC_TestLoopback(BT_HDR *p_data);
1233 
1234 
1235 /*******************************************************************************
1236 **
1237 ** Function         NFC_SetTraceLevel
1238 **
1239 ** Description      This function sets the trace level for NFC.  If called with
1240 **                  a value of 0xFF, it simply returns the current trace level.
1241 **
1242 ** Returns          The new or current trace level
1243 **
1244 *******************************************************************************/
1245 NFC_API extern UINT8 NFC_SetTraceLevel (UINT8 new_level);
1246 
1247 #ifdef __cplusplus
1248 }
1249 #endif
1250 
1251 #endif /* NFC_API_H */
1252