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