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