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