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