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