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