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