• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /******************************************************************************
2  *
3  *  Copyright (C) 2010-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 is the public interface file for NFA, Broadcom's NFC application
22  *  layer for mobile phones.
23  *
24  ******************************************************************************/
25 #ifndef NFA_API_H
26 #define NFA_API_H
27 
28 #include "gki.h"
29 #include "nci_defs.h"
30 #include "nfc_api.h"
31 #include "nfc_hal_api.h"
32 #include "nfc_target.h"
33 #include "rw_api.h"
34 #include "tags_defs.h"
35 
36 /*****************************************************************************
37 **  Constants and data types
38 *****************************************************************************/
39 
40 /* Max length of Appliction ID in 7816-4 */
41 #define NFA_MAX_AID_LEN NFC_MAX_AID_LEN
42 #define NFA_MIN_AID_LEN 5 /* per NCI specification */
43 
44 /* Command succeeded    */
45 #define NFA_STATUS_OK NCI_STATUS_OK
46 /* Command is rejected. */
47 #define NFA_STATUS_REJECTED NCI_STATUS_REJECTED
48 /* buffer full          */
49 #define NFA_STATUS_BUFFER_FULL NCI_STATUS_BUFFER_FULL
50 /* failed               */
51 #define NFA_STATUS_FAILED NCI_STATUS_FAILED
52 /* Optional feature of NCI Spec not supported */
53 #define NFA_STATUS_NOT_SUPPORTED NCI_STATUS_NOT_SUPPORTED
54 /* Semantic error       */
55 #define NFA_STATUS_SEMANTIC_ERROR NCI_STATUS_SEMANTIC_ERROR
56 /* Unknown NCI Group ID */
57 #define NFA_STATUS_UNKNOWN_GID NCI_STATUS_UNKNOWN_GID
58 /* Invalid Parameter    */
59 #define NFA_STATUS_INVALID_PARAM NCI_STATUS_INVALID_PARAM
60 /* Already started      */
61 #define NFA_STATUS_ALREADY_STARTED NCI_STATUS_ALREADY_STARTED
62 /* RF frame error       */
63 #define NFA_STATUS_RF_FRAME_CORRUPTED NCI_STATUS_RF_FRAME_CORRUPTED
64 /* RF protocol error    */
65 #define NFA_STATUS_RF_PROTOCOL_ERR NCI_STATUS_RF_PROTOCOL_ERR
66 /* RF Timeout           */
67 #define NFA_STATUS_TIMEOUT NCI_STATUS_TIMEOUT
68 
69 #define NFA_STATUS_CONTINUE NFC_STATUS_CONTINUE
70 /* Out of GKI buffers */
71 #define NFA_STATUS_NO_BUFFERS NFC_STATUS_NO_BUFFERS
72 /* Protocol mismatch between API and activated one */
73 #define NFA_STATUS_WRONG_PROTOCOL NFC_STATUS_WRONG_PROTOCOL
74 /* Another Tag command is already in progress */
75 #define NFA_STATUS_BUSY NFC_STATUS_BUSY
76 
77 /* data len exceeds MIU                             */
78 #define NFA_STATUS_BAD_LENGTH NFC_STATUS_BAD_LENGTH
79 /* invalid handle                                   */
80 #define NFA_STATUS_BAD_HANDLE NFC_STATUS_BAD_HANDLE
81 /* congested                                        */
82 #define NFA_STATUS_CONGESTED NFC_STATUS_CONGESTED
83 typedef uint8_t tNFA_STATUS;
84 
85 /* Handle for NFA registrations and connections */
86 typedef uint16_t tNFA_HANDLE;
87 #define NFA_HANDLE_INVALID (0xFFFF)
88 /* NFA Handle definitions */
89 
90 /* The upper byte of NFA_HANDLE signifies the handle group */
91 /* NDEF Type Handler handles    */
92 #define NFA_HANDLE_GROUP_NDEF_HANDLER 0x0200
93 /* DH Card Emulation handles    */
94 #define NFA_HANDLE_GROUP_CE 0x0300
95 /* Handles to identify NFCEE    */
96 #define NFA_HANDLE_GROUP_EE 0x0400
97 /* P2P handles                  */
98 #define NFA_HANDLE_GROUP_P2P 0x0500
99 /* HCI handles                  */
100 #define NFA_HANDLE_GROUP_HCI 0x0800
101 /* Local NDEF message handle    */
102 #define NFA_HANDLE_GROUP_MASK 0xFF00
103 #define NFA_HANDLE_MASK 0x00FF
104 
105 /* NCI Parameter IDs */
106 typedef uint8_t tNFA_PMID;
107 
108 /* Definitions for tNFA_TECHNOLOGY_MASK */
109 #define NFA_TECHNOLOGY_MASK_A 0x01        /* NFC Technology A             */
110 #define NFA_TECHNOLOGY_MASK_B 0x02        /* NFC Technology B             */
111 #define NFA_TECHNOLOGY_MASK_F 0x04        /* NFC Technology F             */
112 /* TECHNOLOGY_MASK_V in NCI2.0 and TECHNOLOGY_MASK_15693 proprietary in NCI1.0*/
113 #define NFA_TECHNOLOGY_MASK_V 0x08
114 #define NFA_TECHNOLOGY_MASK_B_PRIME 0x10  /* Proprietary Technology       */
115 #define NFA_TECHNOLOGY_MASK_KOVIO 0x20    /* Proprietary Technology       */
116 /* NFC technology NFC-DEP protocol active mode */
117 #define NFA_TECHNOLOGY_MASK_ACTIVE 0x40
118 /* NFC Technology A active mode */
119 #define NFA_TECHNOLOGY_MASK_A_ACTIVE 0x40
120 /* NFC Technology F active mode */
121 #define NFA_TECHNOLOGY_MASK_F_ACTIVE 0x80
122 /* All supported technologies   */
123 typedef uint8_t tNFA_TECHNOLOGY_MASK;
124 
125 /* Definitions for NFC protocol for RW, CE and P2P APIs */
126 /* Type1Tag - NFC-A */
127 #define NFA_PROTOCOL_T1T NFC_PROTOCOL_T1T
128 /* MIFARE/Type2Tag - NFC-A */
129 #define NFA_PROTOCOL_T2T NFC_PROTOCOL_T2T
130 /* Felica/Type3Tag - NFC-F */
131 #define NFA_PROTOCOL_T3T NFC_PROTOCOL_T3T
132 /* Type 4A,4B - NFC-A or NFC-B */
133 #define NFA_PROTOCOL_ISO_DEP NFC_PROTOCOL_ISO_DEP
134 /* NFCDEP/LLCP - NFC-A or NFC-F */
135 #define NFA_PROTOCOL_NFC_DEP NFC_PROTOCOL_NFC_DEP
136 /* NFC_PROTOCOL_T5T in NCI2.0 and NFC_PROTOCOL_ISO15693 proprietary in NCI1.0*/
137 #define NFA_PROTOCOL_T5T NFC_PROTOCOL_T5T
138 #define NFA_PROTOCOL_INVALID 0xFF
139 typedef uint8_t tNFA_NFC_PROTOCOL;
140 
141 /* Definitions for tNFA_PROTOCOL_MASK */
142 #define NFA_PROTOCOL_MASK_T1T 0x01     /* Type 1 tag          */
143 #define NFA_PROTOCOL_MASK_T2T 0x02     /* MIFARE / Type 2 tag */
144 #define NFA_PROTOCOL_MASK_T3T 0x04     /* FeliCa / Type 3 tag */
145 #define NFA_PROTOCOL_MASK_ISO_DEP 0x08 /* ISODEP/4A,4B        */
146 #define NFA_PROTOCOL_MASK_NFC_DEP 0x10 /* NFCDEP/LLCP         */
147 typedef uint8_t tNFA_PROTOCOL_MASK;
148 
149 /* NFA_DM callback events */
150 /* Result of NFA_Enable             */
151 #define NFA_DM_ENABLE_EVT 0
152 /* Result of NFA_Disable            */
153 #define NFA_DM_DISABLE_EVT 1
154 /* Result of NFA_SetConfig          */
155 #define NFA_DM_SET_CONFIG_EVT 2
156 /* Result of NFA_GetConfig          */
157 #define NFA_DM_GET_CONFIG_EVT 3
158 /* Result of NFA_PowerOffSleepMode  */
159 #define NFA_DM_PWR_MODE_CHANGE_EVT 4
160 #define NFA_DM_RF_FIELD_EVT 5 /* Status of RF Field               */
161 /* NFCC is not responding           */
162 #define NFA_DM_NFCC_TIMEOUT_EVT 6
163 /* NCI Tranport error               */
164 #define NFA_DM_NFCC_TRANSPORT_ERR_EVT 7
165 /* Result of NFA_SetPowerSubStateForScreenState */
166 #define NFA_DM_SET_POWER_SUB_STATE_EVT 11
167 /* T1T HR length            */
168 #define NFA_T1T_HR_LEN T1T_HR_LEN
169 /* Max UID length of T1/T2  */
170 #define NFA_MAX_UID_LEN TAG_MAX_UID_LEN
171 /* UID len for T1T cmds     */
172 #define NFA_T1T_CMD_UID_LEN T1T_CMD_UID_LEN
173 /* T2T UID length           */
174 
175 /* Tag formated for NDEF */
176 #define NFA_RW_NDEF_FL_FORMATED RW_NDEF_FL_FORMATED
177 /* NDEF supported by the tag */
178 #define NFA_RW_NDEF_FL_SUPPORTED RW_NDEF_FL_SUPPORTED
179 /* Unable to find if tag is ndef capable/formated/read only */
180 #define NFA_RW_NDEF_FL_UNKNOWN RW_NDEF_FL_UNKNOWN
181 /* Tag supports format operation */
182 #define NFA_RW_NDEF_FL_FORMATABLE RW_NDEF_FL_FORMATABLE
183 
184 typedef uint8_t tNFA_RW_NDEF_FLAG;
185 
186 /* Data for NFA_DM_SET_CONFIG_EVT */
187 typedef struct {
188   tNFA_STATUS status;                   /* NFA_STATUS_OK if successful  */
189   uint8_t num_param_id;                 /* Number of rejected Param ID  */
190   tNFA_PMID param_ids[NFC_MAX_NUM_IDS]; /* Rejected Param ID            */
191 } tNFA_SET_CONFIG;
192 
193 /* Data for NFA_DM_GET_CONFIG_EVT */
194 typedef struct {
195   tNFA_STATUS status;    /* NFA_STATUS_OK if successful              */
196   uint16_t tlv_size;     /* The length of TLV                        */
197   uint8_t* param_tlvs;   /* TLV (Parameter ID-Len-Value byte stream) */
198 } tNFA_GET_CONFIG;
199 
200 /* Structure to store screen state */
201 typedef enum screen_state {
202   NFA_SCREEN_STATE_UNKNOWN = 0x00,
203   NFA_SCREEN_STATE_OFF_UNLOCKED = 0x01,
204   NFA_SCREEN_STATE_OFF_LOCKED = 0x02,
205   NFA_SCREEN_STATE_ON_LOCKED = 0x04,
206   NFA_SCREEN_STATE_ON_UNLOCKED = 0x08
207 } eScreenState_t;
208 
209 typedef enum power_substate {
210   SCREEN_STATE_ON_UNLOCKED = 0x00,
211   SCREEN_STATE_OFF_UNLOCKED,
212   SCREEN_STATE_ON_LOCKED,
213   SCREEN_STATE_OFF_LOCKED,
214   SCREEN_STATE_INVALID = 0xFF
215 } epower_substate_t;
216 
217 #define NFA_SCREEN_STATE_MASK 0x0F
218 
219 /* CONN_DISCOVER_PARAM */
220 #define NFA_DM_PWR_MODE_FULL 0x04
221 #define NFA_DM_PWR_MODE_OFF_SLEEP 0x00
222 
223 typedef uint8_t tNFA_DM_PWR_MODE;
224 
225 /* Data for NFA_DM_PWR_MODE_CHANGE_EVT */
226 typedef struct {
227   tNFA_STATUS status; /* NFA_STATUS_OK if successful */
228   /* NFA_DM_PWR_MODE_FULL or NFA_DM_PWR_MODE_OFF_SLEEP */
229   tNFA_DM_PWR_MODE power_mode;
230 } tNFA_DM_PWR_MODE_CHANGE;
231 
232 /* Data for NFA_DM_RF_FIELD_EVT */
233 #define NFA_DM_RF_FIELD_OFF 0x00
234 #define NFA_DM_RF_FIELD_ON 0x01
235 
236 typedef struct {
237   tNFA_STATUS status; /* NFA_STATUS_OK if successful  */
238   /* NFA_DM_RF_FIELD_ON if operating field generated by remote */
239   uint8_t rf_field_status;
240 } tNFA_DM_RF_FIELD;
241 
242 typedef struct {
243   tNFA_STATUS status;  /* NFA_STATUS_OK if successful  */
244   uint8_t power_state; /* current screen/power state */
245 } tNFA_DM_POWER_STATE;
246 
247 /* Union of all DM callback structures */
248 typedef union {
249   tNFA_STATUS status;                 /* NFA_DM_ENABLE_EVT        */
250   tNFA_SET_CONFIG set_config;         /* NFA_DM_SET_CONFIG_EVT    */
251   tNFA_GET_CONFIG get_config;         /* NFA_DM_GET_CONFIG_EVT    */
252   tNFA_DM_PWR_MODE_CHANGE power_mode; /* NFA_DM_PWR_MODE_CHANGE_EVT   */
253   tNFA_DM_RF_FIELD rf_field;          /* NFA_DM_RF_FIELD_EVT      */
254   void* p_vs_evt_data;                /* Vendor-specific evt data */
255   tNFA_DM_POWER_STATE power_sub_state; /* power sub state */
256 } tNFA_DM_CBACK_DATA;
257 
258 /* NFA_DM callback */
259 typedef void(tNFA_DM_CBACK)(uint8_t event, tNFA_DM_CBACK_DATA* p_data);
260 
261 /* NFA Enable DTA Type Mode */
262 typedef enum {
263   NFA_DTA_DEFAULT_MODE = 0x00000001,
264   NFA_DTA_LLCP_MODE = 0x00000002,
265   NFA_DTA_HCEF_MODE = 0x00000004,
266   NFA_DTA_CR8 = 0x00000080,
267 } tNFA_eDtaModes;
268 
269 /* NFA Connection Callback Events */
270 #define NFA_POLL_ENABLED_EVT 0  /* Polling enabled event */
271 #define NFA_POLL_DISABLED_EVT 1 /* Polling disabled event */
272 /* NFC link/protocol discovery notificaiton */
273 #define NFA_DISC_RESULT_EVT 2
274 /* NFC link/protocol discovery select response */
275 #define NFA_SELECT_RESULT_EVT 3
276 #define NFA_DEACTIVATE_FAIL_EVT 4 /* NFA_Deactivate failure */
277 /* NFC link/protocol activated */
278 #define NFA_ACTIVATED_EVT 5
279 /* NFC link/protocol deactivated */
280 #define NFA_DEACTIVATED_EVT 6
281 #define NFA_TLV_DETECT_EVT 7 /* TLV Detection complete */
282 /* NDEF Detection complete */
283 #define NFA_NDEF_DETECT_EVT 8
284 #define NFA_DATA_EVT 9            /* Data message received */
285 #define NFA_SELECT_CPLT_EVT 10    /* Select completed */
286 #define NFA_READ_CPLT_EVT 11      /* Read completed */
287 #define NFA_WRITE_CPLT_EVT 12     /* Write completed */
288 #define NFA_LLCP_ACTIVATED_EVT 13 /* LLCP link is activated */
289 /* LLCP link is deactivated */
290 #define NFA_LLCP_DEACTIVATED_EVT 14
291 /* Response to NFA_RwPresenceCheck */
292 #define NFA_PRESENCE_CHECK_EVT 15
293 /* Tag Formating completed */
294 #define NFA_FORMAT_CPLT_EVT 16
295 /* ISO 15693 command completed */
296 #define NFA_I93_CMD_CPLT_EVT 17
297 #define NFA_SET_TAG_RO_EVT 18 /* Tag set as Read only */
298 /* Result for NFA_RequestExclusiveRfControl */
299 #define NFA_EXCLUSIVE_RF_CONTROL_STARTED_EVT 19
300 /* Result for NFA_ReleaseExclusiveRfControl */
301 #define NFA_EXCLUSIVE_RF_CONTROL_STOPPED_EVT 20
302 /* DH Card emulation: AID or System code reg'd  */
303 #define NFA_CE_REGISTERED_EVT 21
304 /* DH Card emulation: AID or System code dereg'd */
305 #define NFA_CE_DEREGISTERED_EVT 22
306 /* DH Card emulation: data received event */
307 #define NFA_CE_DATA_EVT 23
308 /* DH Card emulation: activation event */
309 #define NFA_CE_ACTIVATED_EVT 24
310 /* DH Card emulation: deactivation event */
311 #define NFA_CE_DEACTIVATED_EVT 25
312 /* DH Card emulation: local NDEF configured */
313 #define NFA_CE_LOCAL_TAG_CONFIGURED_EVT 26
314 /* DH Card emulation: NDEF write started */
315 #define NFA_CE_NDEF_WRITE_START_EVT 27
316 /* DH Card emulation: NDEF write completed */
317 #define NFA_CE_NDEF_WRITE_CPLT_EVT 28
318 #define NFA_CE_UICC_LISTEN_CONFIGURED_EVT 29 /* UICC Listen configured */
319 /* RF Discovery started event */
320 #define NFA_RF_DISCOVERY_STARTED_EVT 30
321 /* RF Discovery stopped event */
322 #define NFA_RF_DISCOVERY_STOPPED_EVT 31
323 /* status of updating RF communication paramters */
324 #define NFA_UPDATE_RF_PARAM_RESULT_EVT 32
325 /* RF Interface error event */
326 #define NFA_RW_INTF_ERROR_EVT 34
327 /* status of setting P2P listen technologies */
328 #define NFA_SET_P2P_LISTEN_TECH_EVT 33
329 /* First packet received over LLCP link */
330 #define NFA_LLCP_FIRST_PACKET_RECEIVED_EVT 35
331 /* Listening enabled event */
332 #define NFA_LISTEN_ENABLED_EVT 36
333 /* Listening disabled event */
334 #define NFA_LISTEN_DISABLED_EVT 37
335 /* P2P services paused event */
336 #define NFA_P2P_PAUSED_EVT 38
337 /* P2P services resumed event */
338 #define NFA_P2P_RESUMED_EVT 39
339 /* T2T command completed */
340 #define NFA_T2T_CMD_CPLT_EVT 40
341 
342 /* NFC deactivation type */
343 #define NFA_DEACTIVATE_TYPE_IDLE NFC_DEACTIVATE_TYPE_IDLE
344 #define NFA_DEACTIVATE_TYPE_SLEEP NFC_DEACTIVATE_TYPE_SLEEP
345 #define NFA_DEACTIVATE_TYPE_DISCOVERY NFC_DEACTIVATE_TYPE_DISCOVERY
346 
347 typedef uint8_t tNFA_DEACTIVATE_TYPE;
348 
349 /* Data for NFA_DISC_RESULT_EVT */
350 typedef struct {
351   tNFA_STATUS status;             /* NFA_STATUS_OK if successful       */
352   tNFC_RESULT_DEVT discovery_ntf; /* RF discovery notification details */
353 } tNFA_DISC_RESULT;
354 
355 /* Data for NFA_ACTIVATED_EVT */
356 typedef struct {
357   uint8_t hr[NFA_T1T_HR_LEN];       /* HR of Type 1 tag         */
358   uint8_t uid[NFA_T1T_CMD_UID_LEN]; /* UID used in T1T Commands */
359 } tNFA_T1T_PARAMS;
360 
361 typedef struct {
362   uint8_t uid[NFA_MAX_UID_LEN]; /* UID of T2T tag           */
363 } tNFA_T2T_PARAMS;
364 
365 typedef struct {
366   uint8_t num_system_codes; /* Number of system codes supporte by tag   */
367   uint16_t* p_system_codes; /* Pointer to list of system codes          */
368 } tNFA_T3T_PARAMS;
369 
370 typedef struct {
371   uint8_t uid[I93_UID_BYTE_LEN]; /* UID[0]:MSB, ... UID[7]:LSB */
372   uint8_t info_flags;   /* information flags                            */
373   uint8_t dsfid;        /* DSFID if I93_INFO_FLAG_DSFID                 */
374   uint8_t afi;          /* AFI if I93_INFO_FLAG_AFI                     */
375   uint16_t num_block;   /* number of blocks if I93_INFO_FLAG_MEM_SIZE   */
376   uint8_t block_size;   /* block size in byte if I93_INFO_FLAG_MEM_SIZE */
377   uint8_t IC_reference; /* IC Reference if I93_INFO_FLAG_IC_REF         */
378 } tNFA_I93_PARAMS;
379 
380 typedef union {
381   tNFA_T1T_PARAMS t1t; /* HR and UID of T1T                */
382   tNFA_T2T_PARAMS t2t; /* UID of T2T                       */
383   tNFA_T3T_PARAMS t3t; /* System codes                     */
384   tNFA_I93_PARAMS i93; /* System Information of ISO 15693  */
385 } tNFA_TAG_PARAMS;
386 
387 typedef struct {
388   tNFC_ACTIVATE_DEVT activate_ntf; /* RF discovery activation details */
389   tNFA_TAG_PARAMS params;          /* additional informaiton of tag   */
390 } tNFA_ACTIVATED;
391 
392 /* Data for NFA_DEACTIVATED_EVT */
393 typedef struct {
394   /* NFA_DEACTIVATE_TYPE_IDLE or NFA_DEACTIVATE_TYPE_SLEEP */
395   tNFA_DEACTIVATE_TYPE type;
396 } tNFA_DEACTIVATED;
397 
398 /* Structure for NFA_NDEF_DETECT_EVT event data */
399 typedef struct {
400   tNFA_STATUS status;         /* Status of the ndef detecton */
401   tNFA_NFC_PROTOCOL protocol; /* protocol used to detect NDEF */
402   uint32_t max_size;          /* max number of bytes available for NDEF data */
403   uint32_t cur_size;          /* current size of stored NDEF data (in bytes) */
404   /* Flags to indicate NDEF capability, is formated, soft/hard lockable,
405    * formatable, otp and read only */
406   tNFA_RW_NDEF_FLAG flags;
407 } tNFA_NDEF_DETECT;
408 
409 /* Structure for NFA_TLV_DETECT_EVT event data */
410 typedef struct {
411   tNFA_STATUS status;         /* Status of the tlv detecton        */
412   tNFA_NFC_PROTOCOL protocol; /* protocol used to detect TLV       */
413   uint8_t num_tlvs;           /* number of tlvs present in the tag */
414   uint8_t num_bytes;          /* number of lock/reserved bytes     */
415 } tNFA_TLV_DETECT;
416 
417 /* Structure for NFA_DATA_EVT data */
418 typedef struct {
419   tNFA_STATUS status; /* Status of Data received          */
420   uint8_t* p_data;    /* Data buffer                      */
421   uint16_t len;       /* Length of data                   */
422 } tNFA_RX_DATA;
423 
424 /* Structure for NFA_CE_NDEF_WRITE_CPLT_EVT data */
425 typedef struct {
426   tNFA_STATUS status; /* Status of the ndef write op      */
427   uint32_t len;       /* Update length of NDEF data       */
428   uint8_t* p_data;    /* data buffer                      */
429 } tNFA_CE_NDEF_WRITE_CPLT;
430 
431 /* Data for NFA_LLCP_ACTIVATED_EVT */
432 typedef struct {
433   bool is_initiator;        /* TRUE if initiator                */
434   uint16_t remote_wks;      /* Well-Known service mask of peer  */
435   uint8_t remote_lsc;       /* Link Service Class of peer       */
436   uint16_t remote_link_miu; /* Link MIU of peer                 */
437   uint16_t local_link_miu;  /* Link MIU of local                */
438   uint8_t remote_version;   /* LLCP version of remote           */
439 } tNFA_LLCP_ACTIVATED;
440 
441 /* Data for NFA_LLCP_DEACTIVATED_EVT */
442 typedef struct {
443   uint8_t reason; /* reason of deactivation           */
444 } tNFA_LLCP_DEACTIVATED;
445 
446 /* Data for NFA_I93_CMD_CPLT_EVT */
447 typedef struct {
448   uint8_t dsfid;                 /* DSFID                       */
449   uint8_t uid[I93_UID_BYTE_LEN]; /* UID[0]:MSB, ... UID[7]:LSB  */
450 } tNFA_I93_INVENTORY;
451 
452 typedef struct /* RW_I93_SYS_INFO_EVT                          */
453 {
454   uint8_t info_flags; /* information flags                            */
455   uint8_t uid[I93_UID_BYTE_LEN]; /* UID */
456   uint8_t dsfid;        /* DSFID if I93_INFO_FLAG_DSFID                 */
457   uint8_t afi;          /* AFI if I93_INFO_FLAG_AFI                     */
458   uint16_t num_block;   /* number of blocks if I93_INFO_FLAG_MEM_SIZE   */
459   uint8_t block_size;   /* block size in byte if I93_INFO_FLAG_MEM_SIZE */
460   uint8_t IC_reference; /* IC Reference if I93_INFO_FLAG_IC_REF         */
461 } tNFA_I93_SYS_INFO;
462 
463 typedef struct {
464   tNFA_STATUS status;   /* Status of sending command       */
465   uint8_t sent_command; /* sent command to tag             */
466   union {
467     uint8_t error_code;           /* error code defined in ISO 15693 */
468     tNFA_I93_INVENTORY inventory; /* inventory response              */
469     tNFA_I93_SYS_INFO sys_info;   /* system information              */
470   } params;
471 } tNFA_I93_CMD_CPLT;
472 
473 /* Data for NFA_CE_REGISTERED_EVT */
474 typedef struct {
475   tNFA_STATUS status; /* NFA_STATUS_OK if successful                      */
476   tNFA_HANDLE handle; /* handle for NFA_CeRegisterFelicaSystemCodeOnDH () */
477                       /*            NFA_CeRegisterT4tAidOnDH ()           */
478 } tNFA_CE_REGISTERED;
479 
480 /* Data for NFA_CE_DEREGISTERED_EVT */
481 typedef struct {
482   tNFA_HANDLE handle; /* handle from NFA_CE_REGISTERED_EVT   */
483 } tNFA_CE_DEREGISTERED;
484 
485 /* Data for NFA_CE_ACTIVATED_EVT */
486 typedef struct {
487   tNFA_STATUS status; /* NFA_STATUS_OK if successful              */
488   tNFA_HANDLE handle; /* handle from NFA_CE_REGISTERED_EVT        */
489   tNFC_ACTIVATE_DEVT activate_ntf; /* RF discovery activation details */
490 } tNFA_CE_ACTIVATED;
491 
492 /* Data for NFA_CE_DEACTIVATED_EVT */
493 typedef struct {
494   tNFA_HANDLE handle; /* handle from NFA_CE_REGISTERED_EVT   */
495   /* NFA_DEACTIVATE_TYPE_IDLE or NFA_DEACTIVATE_TYPE_SLEEP */
496   tNFA_DEACTIVATE_TYPE type;
497 } tNFA_CE_DEACTIVATED;
498 
499 /* Structure for NFA_CE_DATA_EVT data */
500 typedef struct {
501   tNFA_STATUS status; /* NFA_STATUS_OK if complete packet     */
502   tNFA_HANDLE handle; /* handle from NFA_CE_REGISTERED_EVT    */
503   uint8_t* p_data;    /* Data buffer                          */
504   uint16_t len;       /* Length of data                       */
505 } tNFA_CE_DATA;
506 
507 /* Union of all connection callback structures */
508 typedef union {
509   tNFA_STATUS status;           /* NFA_POLL_ENABLED_EVT                 */
510   tNFA_DISC_RESULT disc_result; /* NFA_DISC_RESULT_EVT                  */
511   tNFA_ACTIVATED activated;     /* NFA_ACTIVATED_EVT                    */
512   tNFA_DEACTIVATED deactivated; /* NFA_DEACTIVATED_EVT                  */
513   tNFA_NDEF_DETECT ndef_detect; /* NFA_NDEF_DETECT_EVT                  */
514   tNFA_TLV_DETECT tlv_detect;   /* NFA_TLV_DETECT_EVT                   */
515   tNFA_RX_DATA data;            /* NFA_DATA_EVT                         */
516   tNFA_CE_NDEF_WRITE_CPLT ndef_write_cplt; /* NFA_CE_NDEF_WRITE_CPLT_EVT */
517   tNFA_LLCP_ACTIVATED llcp_activated; /* NFA_LLCP_ACTIVATED_EVT               */
518   tNFA_LLCP_DEACTIVATED llcp_deactivated; /* NFA_LLCP_DEACTIVATED_EVT */
519   tNFA_I93_CMD_CPLT i93_cmd_cplt;   /* NFA_I93_CMD_CPLT_EVT                 */
520   tNFA_CE_REGISTERED ce_registered; /* NFA_CE_REGISTERED_EVT                */
521   tNFA_CE_DEREGISTERED ce_deregistered; /* NFA_CE_DEREGISTERED_EVT */
522   tNFA_CE_ACTIVATED ce_activated;     /* NFA_CE_ACTIVATED_EVT                 */
523   tNFA_CE_DEACTIVATED ce_deactivated; /* NFA_CE_DEACTIVATED_EVT               */
524   tNFA_CE_DATA ce_data;               /* NFA_CE_DATA_EVT                      */
525 
526 } tNFA_CONN_EVT_DATA;
527 
528 /* NFA Connection Callback */
529 typedef void(tNFA_CONN_CBACK)(uint8_t event, tNFA_CONN_EVT_DATA* p_data);
530 
531 #ifndef NFA_DM_NUM_INTERFACE_MAP
532 #define NFA_DM_NUM_INTERFACE_MAP 3
533 #endif
534 
535 /* compile-time configuration structure for the RF Discovery Frequency for each
536  * technology */
537 typedef struct {
538   uint8_t pa;   /* Frequency for NFC Technology A               */
539   uint8_t pb;   /* Frequency for NFC Technology B               */
540   uint8_t pf;   /* Frequency for NFC Technology F               */
541   uint8_t pi93; /* Frequency for Proprietary Technology/15693   */
542   uint8_t pbp;  /* Frequency for Proprietary Technology/B-Prime */
543   uint8_t pk;   /* Frequency for Proprietary Technology/Kovio   */
544   uint8_t paa;  /* Frequency for NFC Technology A active mode   */
545   uint8_t pfa;  /* Frequency for NFC Technology F active mode   */
546   uint8_t pacm; /* Frequency for NFC Technology active mode     */
547 } tNFA_DM_DISC_FREQ_CFG;
548 
549 /* definitions for tNFA_DM_CFG.presence_check_option */
550 /* if NDEF is not supported by the tag, use sleep/wake(last interface) */
551 #define NFA_DM_PCO_ISO_SLEEP_WAKE 0x01
552 /* NFA_SendRawFrame() has been used, use empty I block for presence check
553  * if this bit is not set, use read-binary on channel 3 for presence check */
554 #define NFA_DM_PCO_EMPTY_I_BLOCK 0x02
555 
556 /* compile-time configuration structure */
557 typedef struct {
558   /* Automatic NDEF detection (when not in exclusive RF mode) */
559   bool auto_detect_ndef;
560   /* Automatic NDEF read (when not in exclusive RF mode)      */
561   bool auto_read_ndef;
562   /* Automatic presence check                                 */
563   bool auto_presence_check;
564   /* Use sleep/wake(last interface) for ISODEP presence check */
565   uint8_t presence_check_option;
566   /* Maximum time to wait for presence check response         */
567   uint16_t presence_check_timeout;
568 } tNFA_DM_CFG;
569 
570 /* compile-time configuration structure for HCI */
571 typedef struct {
572   /* Maximum idle(no HCP Pkt) time to wait for EE DISC REQ Ntf(s) */
573   uint16_t hci_netwk_enable_timeout;
574   /* Maximum time to wait for EE DISC REQ NTF(s) after HOT PLUG EVT(s) */
575   uint16_t hcp_response_timeout;
576   /* Number of host in the whitelist of Terminal host */
577   uint8_t num_whitelist_host;
578   /* Whitelist of Terminal Host */
579   uint8_t* p_whitelist;
580 } tNFA_HCI_CFG;
581 
582 /*
583 ** Exclusive RF mode listen configuration
584 */
585 
586 #define NFA_LB_MAX_NFCID0_LEN 4
587 #define NFA_LF_MAX_SC_NFCID2 1
588 #define NFA_LA_MAX_HIST_BYTES 15
589 #define NFA_LB_MAX_H_INFO_LEN 15
590 
591 typedef struct {
592   /*
593   ** Discovery Configuration Parameters for Listen A
594   */
595   bool la_enable;             /* TRUE if listening A                      */
596   uint8_t la_bit_frame_sdd;   /* Bit Frame SDD in Byte 1 of SENS_RES      */
597   uint8_t la_platform_config; /* Platform Config in Byte 2 of SENS_RES    */
598   uint8_t la_sel_info;        /* Byte of SEL_RES                          */
599   uint8_t la_nfcid1_len;      /* NFCID1 (0, 4, 7 or 10 bytes)             */
600   uint8_t la_nfcid1[NCI_NFCID1_MAX_LEN]; /*        if empty, NFCC will decide */
601 
602   /*
603   ** Discovery Configuration Parameters for Listen B
604   */
605   bool lb_enable;        /* TRUE if listening B                      */
606   uint8_t lb_sensb_info; /* Byte 2 of Protocol Info within SENSB_RES */
607   uint8_t lb_nfcid0_len; /* NFCID0 (0, 1 or 4 bytes)                 */
608   uint8_t
609       lb_nfcid0[NFA_LB_MAX_NFCID0_LEN]; /*         if empty, NFCC will decide */
610   uint8_t lb_app_data[NCI_PARAM_LEN_LB_APPDATA]; /* Bytes 6 - 9 in SENSB_RES */
611   uint8_t lb_sfgi;   /* Start-Up Frame Guard Time                */
612   uint8_t lb_adc_fo; /* Byte 12 in SENSB_RES                     */
613 
614   /*
615   ** Discovery Configuration Parameters for Listen F
616   */
617   bool lf_enable;           /* TRUE if listening F          */
618   uint8_t lf_con_bitr_f;    /* bit rate to listen           */
619   uint8_t lf_protocol_type; /* Supported Protocols          */
620   /* bit field indicating which lf_t3t_identifier are enabled */
621   uint16_t lf_t3t_flags;
622   uint8_t lf_t3t_identifier[NFA_LF_MAX_SC_NFCID2]
623                            [NCI_SYSTEMCODE_LEN + NCI_NFCID2_LEN];
624   /* System Code and NFCID2       */
625   uint8_t lf_t3t_pmm[NCI_T3T_PMM_LEN]; /* Bytes 10 - 17 in SENSF_RES   */
626 
627   /*
628   ** Discovery Configuration Parameters for Listen ISO-DEP
629   */
630   bool li_enable;            /* TRUE if listening ISO-DEP            */
631   uint8_t li_fwi;            /* Frame Waiting Time Integer           */
632   uint8_t la_hist_bytes_len; /* historical bytes for Listen-A        */
633   uint8_t la_hist_bytes[NFA_LA_MAX_HIST_BYTES];
634   uint8_t lb_h_info_resp_len; /* higher layer response for Listen-B   */
635   uint8_t lb_h_info_resp[NFA_LB_MAX_H_INFO_LEN];
636 
637   /*
638   ** Discovery Configuration Parameters for Listen NFC-DEP
639   */
640   bool ln_enable;                   /* TRUE if listening NFC-DEP            */
641   uint8_t ln_wt;                    /* Waiting Time Integer                 */
642   uint8_t ln_atr_res_gen_bytes_len; /* General bytes in ATR_RES             */
643   uint8_t ln_atr_res_gen_bytes[NCI_MAX_GEN_BYTES_LEN];
644   uint8_t ln_atr_res_config; /* Optional parameters (PPt) in ATR_RES */
645 } tNFA_LISTEN_CFG;
646 
647 /* Data for NFA_UpdateRFCommParams () */
648 typedef tNFC_RF_COMM_PARAMS tNFA_RF_COMM_PARAMS;
649 
650 /* RF Interface type */
651 #define NFA_INTERFACE_FRAME NFC_INTERFACE_FRAME
652 #define NFA_INTERFACE_ISO_DEP NFC_INTERFACE_ISO_DEP
653 #define NFA_INTERFACE_NFC_DEP NFC_INTERFACE_NFC_DEP
654 #define NFA_INTERFACE_MIFARE NFC_INTERFACE_MIFARE
655 typedef tNFC_INTF_TYPE tNFA_INTF_TYPE;
656 
657 /*******************************************************************************
658 ** NDEF Definitions
659 *******************************************************************************/
660 
661 /* Definitions for tNFA_TNF (NDEF type name format ID) */
662 /* Empty or no type specified                       */
663 #define NFA_TNF_EMPTY NDEF_TNF_EMPTY
664 /* NFC Forum well-known type [NFC RTD]              */
665 #define NFA_TNF_WKT NDEF_TNF_WKT
666 /* Media-type as defined in RFC 2046 [RFC 2046]     */
667 #define NFA_TNF_RFC2046_MEDIA NDEF_TNF_MEDIA
668 /* Absolute URI as defined in RFC 3986 [RFC 3986]   */
669 #define NFA_TNF_RFC3986_URI NDEF_TNF_URI
670 /* NFC Forum external type [NFC RTD]                */
671 #define NFA_TNF_EXTERNAL NDEF_TNF_EXT
672 /* Unknown                                          */
673 #define NFA_TNF_UNKNOWN NDEF_TNF_UNKNOWN
674 /* Unchanged                                        */
675 #define NFA_TNF_UNCHANGED NDEF_TNF_UNCHANGED
676 /* Reserved                                         */
677 #define NFA_TNF_RESERVED NDEF_TNF_RESERVED
678 /* Used to register default NDEF type handler       */
679 #define NFA_TNF_DEFAULT 0xFF
680 typedef uint8_t tNFA_TNF;
681 
682 /* Definitions for tNFA_NDEF_URI_ID (Frequently used prefixes. For additional
683  * values, see [NFC RTD URI] */
684 #define NFA_NDEF_URI_ID_ABSOLUTE 0x00 /* Unabridged URI.  */
685 #define NFA_NDEF_URI_ID_HTTP 0x03     /* http://          */
686 #define NFA_NDEF_URI_ID_HTTPS 0x04    /* https://         */
687 #define NFA_NDEF_URI_ID_TEL 0x05      /* tel:             */
688 #define NFA_NDEF_URI_ID_MAILTO 0x06   /* mailto:          */
689 #define NFA_NDEF_URI_ID_FTP 0x0D      /* ftp://           */
690 #define NFA_NDEF_URI_ID_FILE 0x1D     /* file://          */
691 
692 typedef uint8_t tNFA_NDEF_URI_ID;
693 
694 /* Events for tNFA_NDEF_CBACK */
695 /* NDEF record type registered. (In response to NFA_RegisterNDefTypeHandler) */
696 #define NFA_NDEF_REGISTER_EVT 0
697 /* Received an NDEF message with the registered type. See [tNFA_NDEF_DATA] */
698 #define NFA_NDEF_DATA_EVT 1
699 typedef uint8_t tNFA_NDEF_EVT;
700 
701 /* Structure for NFA_NDEF_REGISTER_EVT event data */
702 typedef struct {
703   tNFA_STATUS status;           /* Status of the registration               */
704   tNFA_HANDLE ndef_type_handle; /* Handle for this NDEF type registration.  */
705 } tNFA_NDEF_REGISTER;
706 
707 /* Structure for NFA_NDEF_DATA_EVT event data */
708 typedef struct {
709   tNFA_HANDLE ndef_type_handle; /* Handle for NDEF type registration.   */
710   uint8_t* p_data;              /* Data buffer                          */
711   uint32_t len;                 /* Length of data                       */
712 } tNFA_NDEF_DATA;
713 
714 /* Union of all NDEF callback structures */
715 typedef union {
716   /* Structure for NFA_NDEF_REGISTER_EVT event data */
717   tNFA_NDEF_REGISTER ndef_reg;
718   /* Structure for NFA_NDEF_DATA_EVT event data */
719   tNFA_NDEF_DATA ndef_data;
720 } tNFA_NDEF_EVT_DATA;
721 
722 /* NFA_NDEF callback */
723 typedef void(tNFA_NDEF_CBACK)(tNFA_NDEF_EVT event, tNFA_NDEF_EVT_DATA* p_data);
724 
725 /* NFA VSC Callback */
726 typedef void(tNFA_VSC_CBACK)(uint8_t event, uint16_t param_len,
727                              uint8_t* p_param);
728 
729 /*****************************************************************************
730 **  External Function Declarations
731 *****************************************************************************/
732 
733 /*******************************************************************************
734 **
735 ** Function         NFA_Init
736 **
737 ** Description      This function initializes control blocks for NFA
738 **
739 **                  p_hal_entry_tbl points to a table of HAL entry points
740 **
741 **                  NOTE: the buffer that p_hal_entry_tbl points must be
742 **                  persistent until NFA is disabled.
743 **
744 **
745 ** Returns          none
746 **
747 *******************************************************************************/
748 extern void NFA_Init(tHAL_NFC_ENTRY* p_hal_entry_tbl);
749 
750 /*******************************************************************************
751 **
752 ** Function         NFA_Enable
753 **
754 ** Description      This function enables NFC. Prior to calling NFA_Enable,
755 **                  the NFCC must be powered up, and ready to receive commands.
756 **                  This function enables the tasks needed by NFC, opens the NCI
757 **                  transport, resets the NFC controller, downloads patches to
758 **                  the NFCC (if necessary), and initializes the NFC subsystems.
759 **
760 **                  This function should only be called once - typically when
761 **                  NFC is enabled during boot-up, or when NFC is enabled from a
762 **                  settings UI. Subsequent calls to NFA_Enable while NFA is
763 **                  enabling or enabled will be ignored. When the NFC startup
764 **                  procedure is completed, an NFA_DM_ENABLE_EVT is returned to
765 **                  the application using the tNFA_DM_CBACK.
766 **
767 **                  The tNFA_CONN_CBACK parameter is used to register a callback
768 **                  for polling, p2p and card emulation events.
769 **
770 **
771 ** Returns          NFA_STATUS_OK if successfully initiated
772 **                  NFA_STATUS_FAILED otherwise
773 **
774 *******************************************************************************/
775 extern tNFA_STATUS NFA_Enable(tNFA_DM_CBACK* p_dm_cback,
776                               tNFA_CONN_CBACK* p_conn_cback);
777 
778 /*******************************************************************************
779 **
780 ** Function         NFA_Disable
781 **
782 ** Description      This function is called to shutdown NFC. The tasks for NFC
783 **                  are terminated, and clean up routines are performed. This
784 **                  function is typically called during platform shut-down, or
785 **                  when NFC is disabled from a settings UI. When the NFC
786 **                  shutdown procedure is completed, an NFA_DM_DISABLE_EVT is
787 **                  returned to the application using the tNFA_DM_CBACK.
788 **
789 **                  The platform should wait until the NFC_DISABLE_REVT is
790 **                  received before powering down the NFC chip and NCI
791 **                  transport. This is required to so that NFA can gracefully
792 **                  shut down any open connections.
793 **
794 ** Returns          NFA_STATUS_OK if successfully initiated
795 **                  NFA_STATUS_FAILED otherwise
796 **
797 *******************************************************************************/
798 extern tNFA_STATUS NFA_Disable(bool graceful);
799 
800 /*******************************************************************************
801 **
802 ** Function         NFA_SetConfig
803 **
804 ** Description      Set the configuration parameters to NFCC. The result is
805 **                  reported with an NFA_DM_SET_CONFIG_EVT in the tNFA_DM_CBACK
806 **                  callback.
807 **
808 ** Note:            If RF discovery is started,
809 **                  NFA_StopRfDiscovery()/NFA_RF_DISCOVERY_STOPPED_EVT should
810 **                  happen before calling this function. Most Configuration
811 **                  parameters are related to RF discovery.
812 **
813 ** Returns          NFA_STATUS_OK if successfully initiated
814 **                  NFA_STATUS_BUSY if previous setting is on-going
815 **                  NFA_STATUS_FAILED otherwise
816 **
817 *******************************************************************************/
818 extern tNFA_STATUS NFA_SetConfig(tNFA_PMID param_id, uint8_t length,
819                                  uint8_t* p_data);
820 
821 /*******************************************************************************
822 **
823 ** Function         NFA_GetConfig
824 **
825 ** Description      Get the configuration parameters from NFCC. The result is
826 **                  reported with an NFA_DM_GET_CONFIG_EVT in the tNFA_DM_CBACK
827 **                  callback.
828 **
829 ** Returns          NFA_STATUS_OK if successfully initiated
830 **                  NFA_STATUS_FAILED otherwise
831 **
832 *******************************************************************************/
833 extern tNFA_STATUS NFA_GetConfig(uint8_t num_ids, tNFA_PMID* p_param_ids);
834 
835 /*******************************************************************************
836 **
837 ** Function         NFA_RequestExclusiveRfControl
838 **
839 ** Description      Request exclusive control of NFC.
840 **                  - Previous behavior (polling/tag reading, DH card emulation)
841 **                    will be suspended .
842 **                  - Polling and listening will be done based on the specified
843 **                    params
844 **
845 **                  The NFA_EXCLUSIVE_RF_CONTROL_STARTED_EVT event of
846 **                  tNFA_CONN_CBACK indicates the status of the operation.
847 **
848 **                  NFA_ACTIVATED_EVT and NFA_DEACTIVATED_EVT indicates link
849 **                  activation/deactivation.
850 **
851 **                  NFA_SendRawFrame is used to send data to the peer.
852 **                  NFA_DATA_EVT indicates data from the peer.
853 **
854 **                  If a tag is activated, then the NFA_RW APIs may be used to
855 **                  send commands to the tag. Incoming NDEF messages are sent to
856 **                  the NDEF callback.
857 **
858 **                  Once exclusive RF control has started, NFA will not activate
859 **                  LLCP internally. The application has exclusive control of
860 **                  the link.
861 **
862 ** Note:            If RF discovery is started,
863 **                  NFA_StopRfDiscovery()/NFA_RF_DISCOVERY_STOPPED_EVT should
864 **                  happen before calling this function
865 **
866 ** Returns          NFA_STATUS_OK if successfully initiated
867 **                  NFA_STATUS_FAILED otherwise
868 **
869 *******************************************************************************/
870 extern tNFA_STATUS NFA_RequestExclusiveRfControl(tNFA_TECHNOLOGY_MASK poll_mask,
871                                                  tNFA_LISTEN_CFG* p_listen_cfg,
872                                                  tNFA_CONN_CBACK* p_conn_cback,
873                                                  tNFA_NDEF_CBACK* p_ndef_cback);
874 
875 /*******************************************************************************
876 **
877 ** Function         NFA_ReleaseExclusiveRfControl
878 **
879 ** Description      Release exclusive control of NFC. Once released, behavior
880 **                  prior to obtaining exclusive RF control will resume.
881 **
882 Note??
883 ** Returns          NFA_STATUS_OK if successfully initiated
884 **                  NFA_STATUS_FAILED otherwise
885 **
886 *******************************************************************************/
887 extern tNFA_STATUS NFA_ReleaseExclusiveRfControl(void);
888 
889 /*******************************************************************************
890 **
891 ** Function         NFA_EnablePolling
892 **
893 ** Description      Enable polling for technologies specified by poll_mask.
894 **
895 **                  The following events (notified using the connection
896 **                  callback registered with NFA_Enable) are generated during
897 **                  polling:
898 **
899 **                  - NFA_POLL_ENABLED_EVT indicates whether or not polling
900 **                    successfully enabled.
901 **                  - NFA_DISC_RESULT_EVT indicates there are more than one
902 **                    devices, so application must select one of tags by calling
903 **                    NFA_Select().
904 **                  - NFA_SELECT_RESULT_EVT indicates whether previous selection
905 **                    was successful or not. If it was failed then application
906 **                    must select again or deactivate by calling
907 **                    NFA_Deactivate().
908 **                  - NFA_ACTIVATED_EVT is generated when an NFC link is
909 **                    activated.
910 **                  - NFA_NDEF_DETECT_EVT is generated if tag is activated
911 **                  - NFA_LLCP_ACTIVATED_EVT/NFA_LLCP_DEACTIVATED_EVT is
912 **                    generated if NFC-DEP is activated
913 **                  - NFA_DEACTIVATED_EVT will be returned after deactivating
914 **                    NFC link.
915 **
916 ** Note:            If RF discovery is started,
917 **                  NFA_StopRfDiscovery()/NFA_RF_DISCOVERY_STOPPED_EVT should
918 **                  happen before calling this function
919 **
920 ** Returns          NFA_STATUS_OK if successfully initiated
921 **                  NFA_STATUS_FAILED otherwise
922 **
923 *******************************************************************************/
924 extern tNFA_STATUS NFA_EnablePolling(tNFA_TECHNOLOGY_MASK poll_mask);
925 
926 /*******************************************************************************
927 **
928 ** Function         NFA_DisablePolling
929 **
930 ** Description      Disable polling
931 **                  NFA_POLL_DISABLED_EVT will be returned after stopping
932 **                  polling.
933 **
934 ** Note:            If RF discovery is started,
935 **                  NFA_StopRfDiscovery()/NFA_RF_DISCOVERY_STOPPED_EVT should
936 **                  happen before calling this function
937 **
938 ** Returns          NFA_STATUS_OK if successfully initiated
939 **                  NFA_STATUS_FAILED otherwise
940 **
941 *******************************************************************************/
942 extern tNFA_STATUS NFA_DisablePolling(void);
943 
944 /*******************************************************************************
945 **
946 ** Function         NFA_EnableListening
947 **
948 ** Description      Enable listening.
949 **                  NFA_LISTEN_ENABLED_EVT will be returned after listening is
950 **                  allowed.
951 **
952 **                  The actual listening technologies are specified by other NFA
953 **                  API functions. Such functions include (but not limited to)
954 **                  NFA_CeConfigureUiccListenTech.
955 **                  If NFA_DisableListening () is called to ignore the listening
956 **                  technologies, NFA_EnableListening () is called to restore
957 **                  the listening technologies set by these functions.
958 **
959 ** Note:            If RF discovery is started,
960 **                  NFA_StopRfDiscovery()/NFA_RF_DISCOVERY_STOPPED_EVT should
961 **                  happen before calling this function
962 **
963 ** Returns          NFA_STATUS_OK if successfully initiated
964 **                  NFA_STATUS_FAILED otherwise
965 **
966 *******************************************************************************/
967 extern tNFA_STATUS NFA_EnableListening(void);
968 
969 /*******************************************************************************
970 **
971 ** Function         NFA_DisableListening
972 **
973 ** Description      Disable listening
974 **                  NFA_LISTEN_DISABLED_EVT will be returned after stopping
975 **                  listening. This function is called to exclude listen at RF
976 **                  discovery.
977 **
978 ** Note:            If RF discovery is started,
979 **                  NFA_StopRfDiscovery()/NFA_RF_DISCOVERY_STOPPED_EVT should
980 **                  happen before calling this function
981 **
982 ** Returns          NFA_STATUS_OK if successfully initiated
983 **                  NFA_STATUS_FAILED otherwise
984 **
985 *******************************************************************************/
986 extern tNFA_STATUS NFA_DisableListening(void);
987 
988 /*******************************************************************************
989 **
990 ** Function         NFA_PauseP2p
991 **
992 ** Description      Pause P2P services.
993 **                  NFA_P2P_PAUSED_EVT will be returned after P2P services are
994 **                  disabled.
995 **
996 **                  The P2P services enabled by NFA_P2p* API functions are not
997 **                  available. NFA_ResumeP2p() is called to resume the P2P
998 **                  services.
999 **
1000 ** Note:            If RF discovery is started,
1001 **                  NFA_StopRfDiscovery()/NFA_RF_DISCOVERY_STOPPED_EVT should
1002 **                  happen before calling this function
1003 **
1004 ** Returns          NFA_STATUS_OK if successfully initiated
1005 **                  NFA_STATUS_FAILED otherwise
1006 **
1007 *******************************************************************************/
1008 extern tNFA_STATUS NFA_PauseP2p(void);
1009 
1010 /*******************************************************************************
1011 **
1012 ** Function         NFA_ResumeP2p
1013 **
1014 ** Description      Resume P2P services.
1015 **                  NFA_P2P_RESUMED_EVT will be returned after P2P services are.
1016 **                  enables again.
1017 **
1018 ** Note:            If RF discovery is started,
1019 **                  NFA_StopRfDiscovery()/NFA_RF_DISCOVERY_STOPPED_EVT should
1020 **                  happen before calling this function
1021 **
1022 ** Returns          NFA_STATUS_OK if successfully initiated
1023 **                  NFA_STATUS_FAILED otherwise
1024 **
1025 *******************************************************************************/
1026 extern tNFA_STATUS NFA_ResumeP2p(void);
1027 
1028 /*******************************************************************************
1029 **
1030 ** Function         NFA_SetP2pListenTech
1031 **
1032 ** Description      This function is called to set listen technology for
1033 **                  NFC-DEP. This funtion may be called before or after starting
1034 **                  any server on NFA P2P/CHO/SNEP.
1035 **                  If there is no technology for NFC-DEP, P2P listening will be
1036 **                  stopped.
1037 **
1038 **                  NFA_SET_P2P_LISTEN_TECH_EVT without data will be returned.
1039 **
1040 ** Note:            If RF discovery is started,
1041 **                  NFA_StopRfDiscovery()/NFA_RF_DISCOVERY_STOPPED_EVT should
1042 **                  happen before calling this function
1043 **
1044 ** Returns          NFA_STATUS_OK if successfully initiated
1045 **                  NFA_STATUS_FAILED otherwise
1046 **
1047 *******************************************************************************/
1048 extern tNFA_STATUS NFA_SetP2pListenTech(tNFA_TECHNOLOGY_MASK tech_mask);
1049 
1050 /*******************************************************************************
1051 **
1052 ** Function         NFA_StartRfDiscovery
1053 **
1054 ** Description      Start RF discovery
1055 **                  RF discovery parameters shall be set by other APIs.
1056 **
1057 **                  An NFA_RF_DISCOVERY_STARTED_EVT indicates whether starting
1058 **                  was successful or not.
1059 **
1060 ** Returns          NFA_STATUS_OK if successfully initiated
1061 **                  NFA_STATUS_FAILED otherwise
1062 **
1063 *******************************************************************************/
1064 extern tNFA_STATUS NFA_StartRfDiscovery(void);
1065 
1066 /*******************************************************************************
1067 **
1068 ** Function         NFA_StopRfDiscovery
1069 **
1070 ** Description      Stop RF discovery
1071 **
1072 **                  An NFA_RF_DISCOVERY_STOPPED_EVT indicates whether stopping
1073 **                  was successful or not.
1074 **
1075 ** Returns          NFA_STATUS_OK if successfully initiated
1076 **                  NFA_STATUS_FAILED otherwise
1077 **
1078 *******************************************************************************/
1079 extern tNFA_STATUS NFA_StopRfDiscovery(void);
1080 
1081 /*******************************************************************************
1082 **
1083 ** Function         NFA_SetRfDiscoveryDuration
1084 **
1085 ** Description      Set the duration of the single discovery period in [ms].
1086 **                  Allowable range: 0 ms to 0xFFFF ms.
1087 **
1088 ** Note:            If discovery is already started, the application should
1089 **                  call NFA_StopRfDiscovery prior to calling
1090 **                  NFA_SetRfDiscoveryDuration, and then call
1091 **                  NFA_StartRfDiscovery afterwards to restart discovery using
1092 **                  the new duration.
1093 **
1094 ** Returns:
1095 **                  NFA_STATUS_OK, if command accepted
1096 **                  NFA_STATUS_FAILED: otherwise
1097 **
1098 *******************************************************************************/
1099 extern tNFA_STATUS NFA_SetRfDiscoveryDuration(uint16_t discovery_period_ms);
1100 
1101 /*******************************************************************************
1102 **
1103 ** Function         NFA_Select
1104 **
1105 ** Description      Select one from detected devices by NFA_DISC_RESULT_EVT
1106 **                  after the last discovery result is received.
1107 **                  An NFA_SELECT_RESULT_EVT indicates whether selection was
1108 **                  successful or not. If failed then application must select
1109 **                  again or deactivate by NFA_Deactivate ().
1110 **
1111 ** Returns          NFA_STATUS_OK if successfully initiated
1112 **                  NFA_STATUS_INVALID_PARAM if RF interface is not matched
1113 **                  protocol
1114 **                  NFA_STATUS_FAILED otherwise
1115 **
1116 *******************************************************************************/
1117 extern tNFA_STATUS NFA_Select(uint8_t rf_disc_id, tNFA_NFC_PROTOCOL protocol,
1118                               tNFA_INTF_TYPE rf_interface);
1119 
1120 /*******************************************************************************
1121 **
1122 ** Function         NFA_UpdateRFCommParams
1123 **
1124 ** Description      This function is called to update RF Communication
1125 **                  parameters once the Frame RF Interface has been activated.
1126 **
1127 **                  An NFA_UPDATE_RF_PARAM_RESULT_EVT indicates whether updating
1128 **                  was successful or not.
1129 **
1130 ** Returns          NFA_STATUS_OK if successfully initiated
1131 **                  NFA_STATUS_FAILED otherwise
1132 **
1133 *******************************************************************************/
1134 extern tNFA_STATUS NFA_UpdateRFCommParams(tNFA_RF_COMM_PARAMS* p_params);
1135 
1136 /*******************************************************************************
1137 **
1138 ** Function         NFA_Deactivate
1139 **
1140 ** Description
1141 **                  If sleep_mode=TRUE:
1142 **                      Deselect the activated device by deactivating into sleep
1143 **                      mode.
1144 **
1145 **                      An NFA_DEACTIVATE_FAIL_EVT indicates that selection was
1146 **                      not successful. Application can select another
1147 **                      discovered device or deactivate by NFA_Deactivate ()
1148 **                      after receiving NFA_DEACTIVATED_EVT.
1149 **
1150 **                      Deactivating to sleep mode is not allowed when NFCC is
1151 **                      in wait-for-host-select mode, or in listen-sleep states;
1152 **                      NFA will deactivate to idle or discovery state for these
1153 **                      cases respectively.
1154 **
1155 **
1156 **                  If sleep_mode=FALSE:
1157 **                      Deactivate the connection (e.g. as a result of presence
1158 **                      check failure) NFA_DEACTIVATED_EVT will indicate that
1159 **                      link is deactivated. Polling/listening will resume
1160 **                      (unless the nfcc is in wait_for-all-discoveries state)
1161 **
1162 **
1163 ** Returns          NFA_STATUS_OK if successfully initiated
1164 **                  NFA_STATUS_FAILED otherwise
1165 **
1166 *******************************************************************************/
1167 extern tNFA_STATUS NFA_Deactivate(bool sleep_mode);
1168 
1169 /*******************************************************************************
1170 **
1171 ** Function         NFA_SendRawFrame
1172 **
1173 ** Description      Send a raw frame over the activated interface with the NFCC.
1174 **                  This function can only be called after NFC link is
1175 **                  activated.
1176 **
1177 **                  If the activated interface is a tag and auto-presence check
1178 **                  is enabled then presence_check_start_delay can be used to
1179 **                  indicate the delay in msec after which the next auto
1180 **                  presence check command can be sent.
1181 **                  NFA_DM_DEFAULT_PRESENCE_CHECK_START_DELAY can be used as the
1182 **                  default value for the delay.
1183 **
1184 ** Returns          NFA_STATUS_OK if successfully initiated
1185 **                  NFA_STATUS_FAILED otherwise
1186 **
1187 *******************************************************************************/
1188 extern tNFA_STATUS NFA_SendRawFrame(uint8_t* p_raw_data, uint16_t data_len,
1189                                     uint16_t presence_check_start_delay);
1190 
1191 /*******************************************************************************
1192 ** NDEF APIs
1193 *******************************************************************************/
1194 
1195 /*******************************************************************************
1196 **
1197 ** Function         NFA_RegisterNDefTypeHandler
1198 **
1199 ** Description      This function allows the applications to register for
1200 **                  specific types of NDEF records. When NDEF records are
1201 **                  received, NFA will parse the record-type field, and pass
1202 **                  the record to the registered tNFA_NDEF_CBACK.
1203 **
1204 **                  For records types which were not registered, the record will
1205 **                  be sent to the default handler. A default type-handler may
1206 **                  be registered by calling this NFA_RegisterNDefTypeHandler
1207 **                  with tnf=NFA_TNF_DEFAULT. In this case, all un-registered
1208 **                  record types will be sent to the callback. Only one default
1209 **                  handler may be registered at a time.
1210 **
1211 **                  An NFA_NDEF_REGISTER_EVT will be sent to the tNFA_NDEF_CBACK
1212 **                  to indicate that registration was successful, and provide a
1213 **                  handle for this record type.
1214 **
1215 **
1216 ** Returns          NFA_STATUS_OK if successfully initiated
1217 **                  NFA_STATUS_FAILED otherwise
1218 **
1219 *******************************************************************************/
1220 extern tNFA_STATUS NFA_RegisterNDefTypeHandler(bool handle_whole_message,
1221                                                tNFA_TNF tnf,
1222                                                uint8_t* p_type_name,
1223                                                uint8_t type_name_len,
1224                                                tNFA_NDEF_CBACK* p_ndef_cback);
1225 
1226 /*******************************************************************************
1227 **
1228 ** Function         NFA_RegisterNDefUriHandler
1229 **
1230 ** Description      This API is a special-case of NFA_RegisterNDefTypeHandler
1231 **                  with TNF=NFA_TNF_WKT, and type_name='U' (URI record); and
1232 **                  allows registering for specific URI types (e.g. 'tel:' or
1233 **                  'mailto:').
1234 **
1235 **                  An NFA_NDEF_REGISTER_EVT will be sent to the tNFA_NDEF_CBACK
1236 **                  to indicate that registration was successful, and provide a
1237 **                  handle for this registration.
1238 **
1239 **                  If uri_id=NFA_NDEF_URI_ID_ABSOLUTE, then p_abs_uri contains
1240 **                  the unabridged URI. For all other uri_id values, the
1241 **                  p_abs_uri parameter is ignored (i.e the URI prefix is
1242 **                  implied by uri_id).
1243 **
1244 **                  See [NFC RTD URI] for more information.
1245 **
1246 ** Returns          NFA_STATUS_OK if successfully initiated
1247 **                  NFA_STATUS_FAILED otherwise
1248 **
1249 *******************************************************************************/
1250 extern tNFA_STATUS NFA_RegisterNDefUriHandler(bool handle_whole_message,
1251                                               tNFA_NDEF_URI_ID uri_id,
1252                                               uint8_t* p_abs_uri,
1253                                               uint8_t uri_id_len,
1254                                               tNFA_NDEF_CBACK* p_ndef_cback);
1255 
1256 /*******************************************************************************
1257 **
1258 ** Function         NFA_DeregisterNDefTypeHandler
1259 **
1260 ** Description      Deregister NDEF record type handler.
1261 **
1262 ** Returns          NFA_STATUS_OK if successfully initiated
1263 **                  NFA_STATUS_FAILED otherwise
1264 **
1265 *******************************************************************************/
1266 extern tNFA_STATUS NFA_DeregisterNDefTypeHandler(tNFA_HANDLE ndef_type_handle);
1267 
1268 /*******************************************************************************
1269 **
1270 ** Function         NFA_PowerOffSleepMode
1271 **
1272 ** Description      This function is called to enter or leave NFCC Power Off
1273 **                  Sleep mode
1274 **                  NFA_DM_PWR_MODE_CHANGE_EVT will be sent to indicate status.
1275 **
1276 **                  start_stop : TRUE if entering Power Off Sleep mode
1277 **                               FALSE if leaving Power Off Sleep mode
1278 **
1279 Note??
1280 ** Returns          NFA_STATUS_OK if successfully initiated
1281 **                  NFA_STATUS_FAILED otherwise
1282 **
1283 *******************************************************************************/
1284 extern tNFA_STATUS NFA_PowerOffSleepMode(bool start_stop);
1285 
1286 /*******************************************************************************
1287 **
1288 ** Function         NFA_RegVSCback
1289 **
1290 ** Description      This function is called to register or de-register a
1291 **                  callback function to receive Proprietary NCI response and
1292 **                  notification events.
1293 **                  The maximum number of callback functions allowed is
1294 **                  NFC_NUM_VS_CBACKS
1295 **
1296 ** Returns          tNFC_STATUS
1297 **
1298 *******************************************************************************/
1299 extern tNFC_STATUS NFA_RegVSCback(bool is_register, tNFA_VSC_CBACK* p_cback);
1300 
1301 /*******************************************************************************
1302 **
1303 ** Function         NFA_SendVsCommand
1304 **
1305 ** Description      This function is called to send an NCI Vendor Specific
1306 **                  command to NFCC.
1307 **
1308 **                  oid             - The opcode of the VS command.
1309 **                  cmd_params_len  - The command parameter len
1310 **                  p_cmd_params    - The command parameter
1311 **                  p_cback         - The callback function to receive the
1312 **                                    command status
1313 **
1314 ** Returns          NFA_STATUS_OK if successfully initiated
1315 **                  NFA_STATUS_FAILED otherwise
1316 **
1317 *******************************************************************************/
1318 extern tNFA_STATUS NFA_SendVsCommand(uint8_t oid, uint8_t cmd_params_len,
1319                                      uint8_t* p_cmd_params,
1320                                      tNFA_VSC_CBACK* p_cback);
1321 
1322 /*******************************************************************************
1323 **
1324 ** Function         NFA_SendRawVsCommand
1325 **
1326 ** Description      This function is called to send raw vendor specific
1327 **                  command to NFCC.
1328 **
1329 **                  cmd_params_len  - The command parameter len
1330 **                  p_cmd_params    - The command parameter
1331 **                  p_cback         - The callback function to receive the
1332 **                                    command
1333 **
1334 ** Returns          NFA_STATUS_OK if successfully initiated
1335 **                  NFA_STATUS_FAILED otherwise
1336 **
1337 *******************************************************************************/
1338 
1339 extern tNFA_STATUS NFA_SendRawVsCommand(uint8_t cmd_params_len,
1340                                         uint8_t* p_cmd_params,
1341                                         tNFA_VSC_CBACK* p_cback);
1342 
1343 /*******************************************************************************
1344 ** Function:        NFA_EnableDTA_TypeMode
1345 **
1346 ** Description:     Initialize and get global DTA type mode from .conf
1347 **
1348 ** Returns:         none:
1349 **
1350 *******************************************************************************/
1351 extern void NFA_EnableDtamode(tNFA_eDtaModes eDtaMode);
1352 
1353 /*******************************************************************************
1354 ** Function         NFA_GetNCIVersion
1355 **
1356 ** Description      Called by higher layer to get the current nci
1357 **                  version of nfc.
1358 **
1359 ** Returns          NCI version NCI2.0 / NCI1.0
1360 **
1361 *******************************************************************************/
1362 extern uint8_t NFA_GetNCIVersion();
1363 
1364 /*******************************************************************************
1365 ** Function:        NFA_SetPowerSubStateForScreenState
1366 **
1367 ** Description:     This function send the current screen state
1368 **
1369 ** Returns:        NFA_STATUS_OK if successfully initiated
1370 **                  NFA_STATUS_FAILED otherwise
1371 *******************************************************************************/
1372 extern tNFA_STATUS NFA_SetPowerSubStateForScreenState(uint8_t ScreenState);
1373 
1374 #endif /* NFA_API_H */
1375