1 /****************************************************************************** 2 * 3 * Copyright (C) 1999-2014 Broadcom Corporation 4 * 5 * Licensed under the Apache License, Version 2.0 (the "License"); 6 * you may not use this file except in compliance with the License. 7 * You may obtain a copy of the License at: 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 * 17 ******************************************************************************/ 18 19 /****************************************************************************** 20 * 21 * This file contains the definition from NCI specification 22 * 23 ******************************************************************************/ 24 25 #ifndef NFC_NCI_DEFS_H 26 #define NFC_NCI_DEFS_H 27 28 #include <stdint.h> 29 30 #ifdef __cplusplus 31 extern "C" { 32 #endif 33 34 #define NCI_BRCM_CO_ID 0x2E 35 36 /* Define the message header size for all NCI Commands and Notifications. 37 */ 38 #define NCI_MSG_HDR_SIZE 3 /* per NCI spec */ 39 #define NCI_DATA_HDR_SIZE 3 /* per NCI spec */ 40 #define NCI_MAX_PAYLOAD_SIZE 0xFE 41 #define NCI_MAX_CTRL_SIZE 0xFF /* max control message size */ 42 #define NCI_CTRL_INIT_SIZE 32 /* initial NFCC control payload size */ 43 #define NCI_MAX_VSC_SIZE 0xFF 44 /* NCI header (3) + callback function pointer(8; use 8 to be safe) + HCIT (1 45 * byte) */ 46 #define NCI_VSC_MSG_HDR_SIZE 12 47 #define NCI_TL_SIZE 2 48 49 /* Max frame size (256) - Prologue (1) - Epilogue (2) in ISO-DEP, CID and NAD 50 * are not used*/ 51 #define NCI_ISO_DEP_MAX_INFO 253 52 /* Max payload (254) - Protocol Header (3) in NFC-DEP, DID and NAD are not used 53 */ 54 #define NCI_NFC_DEP_MAX_DATA 251 55 56 /* NCI Command and Notification Format: 57 * 3 byte message header: 58 * byte 0: MT PBF GID 59 * byte 1: OID 60 * byte 2: Message Length */ 61 /* MT: Message Type (byte 0) */ 62 #define NCI_MT_MASK 0xE0 63 #define NCI_MT_SHIFT 5 64 #define NCI_MT_DATA 0x00 65 #define NCI_MT_CMD 1 /* (NCI_MT_CMD << NCI_MT_SHIFT) = 0x20 */ 66 #define NCI_MT_RSP 2 /* (NCI_MT_RSP << NCI_MT_SHIFT) = 0x40 */ 67 #define NCI_MT_NTF 3 /* (NCI_MT_NTF << NCI_MT_SHIFT) = 0x60 */ 68 #define NCI_MT_CFG 4 /* (NCI_MT_CFG << NCI_MT_SHIFT) = 0x80 */ 69 70 #define NCI_MTS_CMD 0x20 71 #define NCI_MTS_RSP 0x40 72 #define NCI_MTS_NTF 0x60 73 #define NCI_MTS_CFG 0x80 74 75 #define NCI_NTF_BIT 0x80 /* the tNFC_VS_EVT is a notification */ 76 #define NCI_RSP_BIT 0x40 /* the tNFC_VS_EVT is a response */ 77 78 /* for internal use only; not from specification */ 79 /* the following 2 flags are used in layer_specific for fragmentation/reassembly 80 * of data packets */ 81 #define NCI_LS_DATA 0x00 82 #define NCI_LS_DATA_PBF 0x01 83 84 /* PBF: Packet Boundary Flag (byte 0) */ 85 #define NCI_PBF_MASK 0x10 86 #define NCI_PBF_SHIFT 4 87 #define NCI_PBF_NO_OR_LAST 0x00 /* not fragmented or last fragment */ 88 #define NCI_PBF_ST_CONT 0x10 /* start or continuing fragment */ 89 90 /* GID: Group Identifier (byte 0) */ 91 #define NCI_GID_MASK 0x0F 92 #define NCI_GID_SHIFT 0 93 #define NCI_GID_CORE 0x00 /* 0000b NCI Core group */ 94 #define NCI_GID_RF_MANAGE 0x01 /* 0001b RF Management group */ 95 #define NCI_GID_EE_MANAGE 0x02 /* 0010b NFCEE Management group */ 96 #define NCI_GID_PROP 0x0F /* 1111b Proprietary */ 97 /* 0111b - 1110b RFU */ 98 99 /* OID: Opcode Identifier (byte 1) */ 100 #define NCI_OID_MASK 0x3F 101 #define NCI_OID_SHIFT 0 102 103 /* For routing */ 104 #define NCI_DH_ID 0 /* for DH */ 105 /* To identify the loopback test */ 106 #define NCI_TEST_ID 0xFE /* for loopback test */ 107 108 /* Destination Type */ 109 #define NCI_DEST_TYPE_NFCC 1 /* NFCC - loopback */ 110 #define NCI_DEST_TYPE_REMOTE 2 /* Remote NFC Endpoint */ 111 #define NCI_DEST_TYPE_NFCEE 3 /* NFCEE */ 112 113 /* builds byte0 of NCI Command and Notification packet */ 114 #define NCI_MSG_BLD_HDR0(p, mt, gid) \ 115 *(p)++ = (uint8_t)(((mt) << NCI_MT_SHIFT) | (gid)); 116 117 #define NCI_MSG_PBLD_HDR0(p, mt, pbf, gid) \ 118 *(p)++ = (uint8_t)(((mt) << NCI_MT_SHIFT) | ((pbf) << NCI_PBF_SHIFT) | (gid)); 119 120 /* builds byte1 of NCI Command and Notification packet */ 121 #define NCI_MSG_BLD_HDR1(p, oid) *(p)++ = (uint8_t)(((oid) << NCI_OID_SHIFT)); 122 123 /* parse byte0 of NCI packet */ 124 #define NCI_MSG_PRS_HDR0(p, mt, pbf, gid) \ 125 mt = (*(p)&NCI_MT_MASK) >> NCI_MT_SHIFT; \ 126 pbf = (*(p)&NCI_PBF_MASK) >> NCI_PBF_SHIFT; \ 127 gid = *(p)++ & NCI_GID_MASK; 128 129 /* parse MT and PBF bits of NCI packet */ 130 #define NCI_MSG_PRS_MT_PBF(p, mt, pbf) \ 131 mt = (*(p)&NCI_MT_MASK) >> NCI_MT_SHIFT; \ 132 pbf = (*(p)&NCI_PBF_MASK) >> NCI_PBF_SHIFT; 133 134 /* parse byte1 of NCI Cmd/Ntf */ 135 #define NCI_MSG_PRS_HDR1(p, oid) \ 136 oid = (*(p)&NCI_OID_MASK); \ 137 (p)++; 138 139 /* NCI Data Format: 140 * byte 0: MT(0) PBF CID 141 * byte 1: RFU 142 * byte 2: Data Length */ 143 /* CID: Connection Identifier (byte 0) 1-0xF Dynamically assigned (by NFCC), 0 144 * is predefined */ 145 #define NCI_CID_MASK 0x0F 146 147 /* builds 3-byte message header of NCI Data packet */ 148 #define NCI_DATA_BLD_HDR(p, cid, len) \ 149 *(p)++ = (uint8_t)(cid); \ 150 *(p)++ = 0; \ 151 *(p)++ = (uint8_t)(len); 152 153 #define NCI_DATA_PBLD_HDR(p, pbf, cid, len) \ 154 *(p)++ = (uint8_t)(((pbf) << NCI_PBF_SHIFT) | (cid)); \ 155 *(p)++ = 0; \ 156 *(p)++ = (len); 157 158 #define NCI_DATA_PRS_HDR(p, pbf, cid, len) \ 159 (pbf) = (*(p)&NCI_PBF_MASK) >> NCI_PBF_SHIFT; \ 160 (cid) = (*(p)&NCI_CID_MASK); \ 161 p++; \ 162 p++; \ 163 (len) = *(p)++; 164 165 /* Logical target ID 0x01-0xFE */ 166 167 /* Status Codes */ 168 #define NCI_STATUS_OK 0x00 169 #define NCI_STATUS_REJECTED 0x01 170 #define NCI_STATUS_MESSAGE_CORRUPTED 0x02 171 #define NCI_STATUS_BUFFER_FULL 0xE0 172 #define NCI_STATUS_FAILED 0x03 173 #define NCI_STATUS_NOT_INITIALIZED 0x04 174 #define NCI_STATUS_SYNTAX_ERROR 0x05 175 #define NCI_STATUS_SEMANTIC_ERROR 0x06 176 #define NCI_STATUS_UNKNOWN_GID 0x07 177 #define NCI_STATUS_UNKNOWN_OID 0x08 178 #define NCI_STATUS_INVALID_PARAM 0x09 179 #define NCI_STATUS_MSG_SIZE_TOO_BIG 0x0A 180 /* discovery */ 181 #define NCI_STATUS_ALREADY_STARTED 0xA0 182 #define NCI_STATUS_ACTIVATION_FAILED 0xA1 183 #define NCI_STATUS_TEAR_DOWN 0xA2 184 /* RF Interface */ 185 #define NCI_STATUS_RF_TRANSMISSION_ERR 0xB0 186 #define NCI_STATUS_RF_PROTOCOL_ERR 0xB1 187 #define NCI_STATUS_TIMEOUT 0xB2 188 /* NFCEE Interface */ 189 #define NCI_STATUS_EE_INTF_ACTIVE_FAIL 0xC0 190 #define NCI_STATUS_EE_TRANSMISSION_ERR 0xC1 191 #define NCI_STATUS_EE_PROTOCOL_ERR 0xC2 192 #define NCI_STATUS_EE_TIMEOUT 0xC3 193 194 typedef uint8_t tNCI_STATUS; 195 196 /* RF Technologies */ 197 #define NCI_RF_TECHNOLOGY_A 0x00 198 #define NCI_RF_TECHNOLOGY_B 0x01 199 #define NCI_RF_TECHNOLOGY_F 0x02 200 #define NCI_RF_TECHNOLOGY_15693 0x03 201 202 /* Bit Rates */ 203 #define NCI_BIT_RATE_106 0x00 /* 106 kbit/s */ 204 #define NCI_BIT_RATE_212 0x01 /* 212 kbit/s */ 205 #define NCI_BIT_RATE_424 0x02 /* 424 kbit/s */ 206 #define NCI_BIT_RATE_848 0x03 /* 848 Kbit/s */ 207 #define NCI_BIT_RATE_1696 0x04 /* 1696 Kbit/s*/ 208 #define NCI_BIT_RATE_3392 0x05 /* 3392 Kbit/s*/ 209 #define NCI_BIT_RATE_6784 0x06 /* 6784 Kbit/s*/ 210 211 /********************************************** 212 * NCI Core Group Opcode - 0 213 **********************************************/ 214 #define NCI_MSG_CORE_RESET 0 215 #define NCI_MSG_CORE_INIT 1 216 #define NCI_MSG_CORE_SET_CONFIG 2 217 #define NCI_MSG_CORE_GET_CONFIG 3 218 #define NCI_MSG_CORE_CONN_CREATE 4 219 #define NCI_MSG_CORE_CONN_CLOSE 5 220 #define NCI_MSG_CORE_CONN_CREDITS 6 221 #define NCI_MSG_CORE_GEN_ERR_STATUS 7 222 #define NCI_MSG_CORE_INTF_ERR_STATUS 8 223 224 /********************************************** 225 * RF MANAGEMENT Group Opcode - 1 226 **********************************************/ 227 #define NCI_MSG_RF_DISCOVER_MAP 0 228 #define NCI_MSG_RF_SET_ROUTING 1 229 #define NCI_MSG_RF_GET_ROUTING 2 230 #define NCI_MSG_RF_DISCOVER 3 231 #define NCI_MSG_RF_DISCOVER_SELECT 4 232 #define NCI_MSG_RF_INTF_ACTIVATED 5 233 #define NCI_MSG_RF_DEACTIVATE 6 234 #define NCI_MSG_RF_FIELD 7 235 #define NCI_MSG_RF_T3T_POLLING 8 236 #define NCI_MSG_RF_EE_ACTION 9 237 #define NCI_MSG_RF_EE_DISCOVERY_REQ 10 238 #define NCI_MSG_RF_PARAMETER_UPDATE 11 239 240 /********************************************** 241 * NFCEE MANAGEMENT Group Opcode - 2 242 **********************************************/ 243 #define NCI_MSG_NFCEE_DISCOVER 0 244 #define NCI_MSG_NFCEE_MODE_SET 1 245 246 /********************************************** 247 * NCI Proprietary Group - F 248 **********************************************/ 249 250 /********************************************** 251 * NCI Core Group Params 252 **********************************************/ 253 #define NCI_CORE_PARAM_SIZE_RESET 0x01 254 #define NCI_CORE_PARAM_SIZE_RESET_RSP 0x03 255 #define NCI_CORE_PARAM_SIZE_RESET_NTF 0x02 256 257 #define NCI_CORE_PARAM_SIZE_INIT 0x00 /* no payload */ 258 #define NCI_CORE_PARAM_SIZE_INIT_RSP 0x11 259 #define NCI_CORE_INIT_RSP_OFFSET_NUM_INTF 0x05 260 261 /* Status (1 octet) and number of params */ 262 #define NCI_CORE_PARAM_SIZE_SET_CONFIG_RSP 0x02 263 264 /* octet 0 */ 265 #define NCI_FEAT_DISCOVERY_FREG 0x00000001 266 #define NCI_FEAT_DISCOVERY_CFGM 0x00000006 267 /* octet 1 */ 268 #define NCI_FEAT_TECHNOLOGY_ROUTING 0x00000200 269 #define NCI_FEAT_PROTOCOL_ROUTING 0x00000400 270 #define NCI_FEAT_AID_ROUTING 0x00000800 271 /* octet 2 */ 272 #define NCI_FEAT_BATTERY_OFF_MD 0x00010000 273 #define NCI_FEAT_SWITCH_OFF_MD 0x00020000 274 275 /* supported Interfaces */ 276 #define NCI_SUP_INTF_FRAME 0x0001 277 #define NCI_SUP_INTF_ISO_DEP 0x0002 278 #define NCI_SUP_INTF_NFC_DEP 0x0004 279 280 #define NCI_CORE_PARAM_SIZE_CON_CREATE 0x02 /* handle, num_tlv, (tlv) */ 281 /* status, size, credits, conn_id */ 282 #define NCI_CORE_PARAM_SIZE_CON_CREATE_RSP 0x04 283 #define NCI_CON_CREATE_TAG_EE_INTF 0x00 /* old */ 284 #define NCI_CON_CREATE_TAG_RF_DISC_ID 0x00 285 #define NCI_CON_CREATE_TAG_NFCEE_VAL 0x01 286 287 #define NCI_CORE_PARAM_SIZE_CON_CLOSE 0x01 /* Conn ID (1 octet) */ 288 #define NCI_CORE_PARAM_SIZE_CON_CLOSE_RSP 0x01 /* Status (1 octet) */ 289 290 /* RF Field Status (1 octet) */ 291 #define NCI_CORE_PARAM_SIZE_RF_FIELD_NTF 0x01 292 293 /* Keep the NCI configuration (if possible) and perform NCI initialization. */ 294 #define NCI_RESET_TYPE_KEEP_CFG 0x00 295 /* Reset the NCI configuration, and perform NCI initialization. */ 296 #define NCI_RESET_TYPE_RESET_CFG 0x01 297 298 /* NCI Configuration has been kept */ 299 #define NCI_RESET_STATUS_KEPT_CFG 0x00 300 /* NCI Configuration has been reset */ 301 #define NCI_RESET_STATUS_RESET_CFG 0x01 302 303 /* No operating field generated by remote device */ 304 #define NCI_RF_STS_NO_REMOTE 0x00 305 /* Operating field generated by remote device */ 306 #define NCI_RF_STS_REMOTE 0x01 307 308 #define NCI_PARAM_SIZE_DISCOVER_NFCEE 0x01 /* Discovery Action (1 octet) */ 309 /* Status (1 octet)Number of NFCEEs (1 octet) */ 310 #define NCI_PARAM_SIZE_DISCOVER_NFCEE_RSP 0x02 311 312 #define NCI_DISCOVER_ACTION_DISABLE 0 313 #define NCI_DISCOVER_ACTION_ENABLE 1 314 315 #define NCI_EE_DISCOVER_REQ_TYPE_LISTEN 0x01 316 #define NCI_EE_DISCOVER_REQ_TYPE_POLL 0x02 317 318 #define NCI_RF_PARAM_ID_TECH_N_MODE 0x00 /* RF Technology and Mode */ 319 #define NCI_RF_PARAM_ID_TX_BIT_RATE 0x01 /* Transmit Bit Rate */ 320 #define NCI_RF_PARAM_ID_RX_BIT_RATE 0x02 /* Receive Bit Rate */ 321 #define NCI_RF_PARAM_ID_B_DATA_EX_PARAM \ 322 0x03 /* B Data Exchange config param \ 323 */ 324 325 #define NCI_NFCEE_INTERFACE_APDU 0x00 326 #define NCI_NFCEE_INTERFACE_HCI_ACCESS 0x01 327 #define NCI_NFCEE_INTERFACE_T3T 0x02 328 #define NCI_NFCEE_INTERFACE_TRANSPARENT 0x03 329 #define NCI_NFCEE_INTERFACE_PROPRIETARY 0x80 330 331 #define NCI_NFCEE_STS_CONN_ACTIVE 0x00 332 #define NCI_NFCEE_STS_CONN_INACTIVE 0x01 333 #define NCI_NFCEE_STS_REMOVED 0x02 334 #define NCI_NUM_NFCEE_STS 3 335 336 /* Logical Target ID (1 octet)NFCEE Mode (1 octet) */ 337 #define NCI_CORE_PARAM_SIZE_NFCEE_MODE_SET 0x02 338 #define NCI_CORE_PARAM_SIZE_NFCEE_MODE_SET_RSP 0x01 /* Status (1 octet) */ 339 340 /* Deactivate the connected NFCEE */ 341 #define NCI_NFCEE_MD_DEACTIVATE 0x00 342 /* Activate the connected NFCEE */ 343 #define NCI_NFCEE_MD_ACTIVATE 0x01 344 #define NCI_NUM_NFCEE_MODE 2 345 346 /********************************************** 347 * NCI Deactivation Type 348 **********************************************/ 349 #define NCI_DEACTIVATE_TYPE_IDLE 0 /* Idle Mode */ 350 #define NCI_DEACTIVATE_TYPE_SLEEP 1 /* Sleep Mode */ 351 #define NCI_DEACTIVATE_TYPE_SLEEP_AF 2 /* Sleep_AF Mode */ 352 #define NCI_DEACTIVATE_TYPE_DISCOVERY 3 /* Discovery */ 353 354 /********************************************** 355 * NCI Deactivation Reasons 356 **********************************************/ 357 #define NCI_DEACTIVATE_REASON_DH_REQ 0 /* DH Request */ 358 #define NCI_DEACTIVATE_REASON_ENDPOINT_REQ 1 /* Endpoint Request */ 359 #define NCI_DEACTIVATE_REASON_RF_LINK_LOSS 2 /* RF Link Loss */ 360 #define NCI_DEACTIVATE_REASON_NFCB_BAD_AFI 3 /* NFC-B Bad AFI */ 361 362 /********************************************** 363 * NCI Interface Mode 364 **********************************************/ 365 #define NCI_INTERFACE_MODE_POLL 1 366 #define NCI_INTERFACE_MODE_LISTEN 2 367 #define NCI_INTERFACE_MODE_POLL_N_LISTEN 3 368 369 /********************************************** 370 * NCI Interface Types 371 **********************************************/ 372 #define NCI_INTERFACE_EE_DIRECT_RF 0 373 #define NCI_INTERFACE_FRAME 1 374 #define NCI_INTERFACE_ISO_DEP 2 375 #define NCI_INTERFACE_NFC_DEP 3 376 #define NCI_INTERFACE_MAX NCI_INTERFACE_NFC_DEP 377 #define NCI_INTERFACE_FIRST_VS 0x80 378 typedef uint8_t tNCI_INTF_TYPE; 379 380 /********************************************** 381 * NCI RF Management / DISCOVERY Group Params 382 **********************************************/ 383 #define NCI_DISCOVER_PARAM_SIZE_RSP 0x01 384 385 #define NCI_DISCOVER_PARAM_SIZE_SELECT 0x03 /* ID, protocol, interface */ 386 #define NCI_DISCOVER_PARAM_SIZE_SELECT_RSP 0x01 /* Status (1 octet) */ 387 #define NCI_DISCOVER_PARAM_SIZE_STOP 0x00 /* */ 388 #define NCI_DISCOVER_PARAM_SIZE_STOP_RSP 0x01 /* Status (1 octet) */ 389 #define NCI_DISCOVER_PARAM_SIZE_DEACT 0x01 /* type */ 390 #define NCI_DISCOVER_PARAM_SIZE_DEACT_RSP 0x01 /* Status (1 octet) */ 391 #define NCI_DISCOVER_PARAM_SIZE_DEACT_NTF 0x01 /* type */ 392 393 /********************************************** 394 * Supported Protocols 395 **********************************************/ 396 #define NCI_PROTOCOL_UNKNOWN 0x00 397 #define NCI_PROTOCOL_T1T 0x01 398 #define NCI_PROTOCOL_T2T 0x02 399 #define NCI_PROTOCOL_T3T 0x03 400 #define NCI_PROTOCOL_ISO_DEP 0x04 401 #define NCI_PROTOCOL_NFC_DEP 0x05 402 403 /* Discovery Types/Detected Technology and Mode */ 404 #define NCI_DISCOVERY_TYPE_POLL_A 0x00 405 #define NCI_DISCOVERY_TYPE_POLL_B 0x01 406 #define NCI_DISCOVERY_TYPE_POLL_F 0x02 407 #define NCI_DISCOVERY_TYPE_POLL_A_ACTIVE 0x03 408 #define NCI_DISCOVERY_TYPE_POLL_F_ACTIVE 0x05 409 #define NCI_DISCOVERY_TYPE_LISTEN_A 0x80 410 #define NCI_DISCOVERY_TYPE_LISTEN_B 0x81 411 #define NCI_DISCOVERY_TYPE_LISTEN_F 0x82 412 #define NCI_DISCOVERY_TYPE_LISTEN_A_ACTIVE 0x83 413 #define NCI_DISCOVERY_TYPE_LISTEN_F_ACTIVE 0x85 414 #define NCI_DISCOVERY_TYPE_POLL_ISO15693 0x06 415 #define NCI_DISCOVERY_TYPE_LISTEN_ISO15693 0x86 416 #define NCI_DISCOVERY_TYPE_MAX NCI_DISCOVERY_TYPE_LISTEN_ISO15693 417 418 typedef uint8_t tNCI_DISCOVERY_TYPE; 419 420 #define NCI_EE_TRIG_7816_SELECT 0x00 421 #define NCI_EE_TRIG_RF_PROTOCOL 0x01 422 #define NCI_EE_TRIG_RF_TECHNOLOGY 0x02 423 #define NCI_EE_TRIG_APP_INIT 0x10 424 425 #define NCI_EE_ACT_TAG_AID 0xC0 /* AID */ 426 #define NCI_EE_ACT_TAG_PROTO 0xC1 /* RF protocol */ 427 #define NCI_EE_ACT_TAG_TECH 0xC2 /* RF technology */ 428 #define NCI_EE_ACT_TAG_DATA 0xC3 /* hex data for app */ 429 #define NCI_EE_ACT_TAG_DEBUG 0xC4 /* debug trace */ 430 431 /* Technology based routing */ 432 #define NCI_ROUTE_TAG_TECH 0x00 433 /* Protocol based routing */ 434 #define NCI_ROUTE_TAG_PROTO 0x01 435 #define NCI_ROUTE_TAG_AID 0x02 /* AID routing */ 436 437 #define NCI_ROUTE_PWR_STATE_ON 0x01 /* The device is on */ 438 /* The device is switched off */ 439 #define NCI_ROUTE_PWR_STATE_SWITCH_OFF 0x02 440 /* The device's battery is removed */ 441 #define NCI_ROUTE_PWR_STATE_BATT_OFF 0x04 442 443 /* Hardware / Registration Identification */ 444 #define NCI_NFCEE_TAG_HW_ID 0x00 445 #define NCI_NFCEE_TAG_ATR_BYTES 0x01 /* ATR Bytes */ 446 /* T3T Command Set Interface Supplementary Info */ 447 #define NCI_NFCEE_TAG_T3T_INFO 0x02 448 #define NCI_NFCEE_TAG_HCI_HOST_ID 0xA0 /* HCI host ID */ 449 450 #define NCI_DISCOVER_NTF_LAST 0x00 451 #define NCI_DISCOVER_NTF_LAST_ABORT 0x01 452 #define NCI_DISCOVER_NTF_MORE 0x02 453 454 /* NCI RF Management Group Params */ 455 #define NCI_RF_PARAM_SIZE_T3T_POLLING 0x04 /* System Code, RC, TSN */ 456 457 /********************************************** 458 * NCI Parameter IDs 459 **********************************************/ 460 461 #define NCI_PARAM_ID_TOTAL_DURATION 0x00 462 #define NCI_PARAM_ID_CON_DEVICES_LIMIT 0x01 463 #define NCI_PARAM_ID_PA_BAILOUT 0x08 464 #define NCI_PARAM_ID_PB_AFI 0x10 465 #define NCI_PARAM_ID_PB_BAILOUT 0x11 466 #define NCI_PARAM_ID_PB_ATTRIB_PARAM1 0x12 467 #define NCI_PARAM_ID_PF_BIT_RATE 0x18 468 #define NCI_PARAM_ID_PF_RC 0x19 469 #define NCI_PARAM_ID_PB_H_INFO 0x20 470 #define NCI_PARAM_ID_PI_BIT_RATE 0x21 471 472 #define NCI_PARAM_ID_BITR_NFC_DEP 0x28 473 #define NCI_PARAM_ID_ATR_REQ_GEN_BYTES 0x29 474 #define NCI_PARAM_ID_ATR_REQ_CONFIG 0x2A 475 476 #define NCI_PARAM_ID_LA_BIT_FRAME_SDD 0x30 477 #define NCI_PARAM_ID_LA_PLATFORM_CONFIG 0x31 478 #define NCI_PARAM_ID_LA_SEL_INFO 0x32 479 #define NCI_PARAM_ID_LA_NFCID1 0x33 480 #define NCI_PARAM_ID_LB_SENSB_INFO 0x38 481 #define NCI_PARAM_ID_LB_NFCID0 0x39 482 #define NCI_PARAM_ID_LB_APPDATA 0x3A 483 #define NCI_PARAM_ID_LB_SFGI 0x3B 484 #define NCI_PARAM_ID_LB_ADC_FO 0x3C 485 #define NCI_PARAM_ID_LB_PROTOCOL NCI_PARAM_ID_LB_SENSB_INFO 486 487 #define NCI_PARAM_ID_LF_T3T_ID1 0x40 488 #define NCI_PARAM_ID_LF_T3T_ID2 0x41 489 #define NCI_PARAM_ID_LF_T3T_ID3 0x42 490 #define NCI_PARAM_ID_LF_T3T_ID4 0x43 491 #define NCI_PARAM_ID_LF_T3T_ID5 0x44 492 #define NCI_PARAM_ID_LF_T3T_ID6 0x45 493 #define NCI_PARAM_ID_LF_T3T_ID7 0x46 494 #define NCI_PARAM_ID_LF_T3T_ID8 0x47 495 #define NCI_PARAM_ID_LF_T3T_ID9 0x48 496 #define NCI_PARAM_ID_LF_T3T_ID10 0x49 497 #define NCI_PARAM_ID_LF_T3T_ID11 0x4A 498 #define NCI_PARAM_ID_LF_T3T_ID12 0x4B 499 #define NCI_PARAM_ID_LF_T3T_ID13 0x4C 500 #define NCI_PARAM_ID_LF_T3T_ID14 0x4D 501 #define NCI_PARAM_ID_LF_T3T_ID15 0x4E 502 #define NCI_PARAM_ID_LF_T3T_ID16 0x4F 503 #define NCI_PARAM_ID_LF_PROTOCOL 0x50 504 #define NCI_PARAM_ID_LF_T3T_PMM 0x51 505 /* max num of LF_T3T_ID supported by NFCC (1 for now) */ 506 #define NCI_PARAM_ID_LF_T3T_MAX 0x52 507 #define NCI_PARAM_ID_LF_T3T_FLAGS2 0x53 508 #define NCI_PARAM_ID_LF_CON_BITR_F 0x54 509 #define NCI_PARAM_ID_FWI 0x58 510 #define NCI_PARAM_ID_LA_HIST_BY 0x59 511 #define NCI_PARAM_ID_LB_H_INFO_RSP 0x5A 512 #define NCI_PARAM_ID_LI_BIT_RATE 0x5B 513 514 #define NCI_PARAM_ID_WT 0x60 515 #define NCI_PARAM_ID_ATR_RES_GEN_BYTES 0x61 516 #define NCI_PARAM_ID_ATR_RSP_CONFIG 0x62 517 518 #define NCI_PARAM_ID_RF_FIELD_INFO 0x80 519 #define NCI_PARAM_ID_RF_NFCEE_ACTION 0x81 520 #define NCI_PARAM_ID_NFC_DEP_OP 0x82 521 522 /* NCI_PARAM_ID_HOST_LISTEN_MASK (byte1 for DH, byte2 for UICC) */ 523 /* (0x01 << (NCI_DISCOVERY_TYPE_LISTEN_A_PASSIVE & 0x0F)) */ 524 #define NCI_LISTEN_MASK_A 0x01 525 /* (0x01 << (NCI_DISCOVERY_TYPE_LISTEN_B_PASSIVE & 0x0F)) */ 526 #define NCI_LISTEN_MASK_B 0x02 527 /* (0x01 << (NCI_DISCOVERY_TYPE_LISTEN_F_PASSIVE & 0x0F)) */ 528 #define NCI_LISTEN_MASK_F 0x04 529 /* (0x01 << (NCI_DISCOVERY_TYPE_LISTEN_A_ACTIVE & 0x0F)) */ 530 #define NCI_LISTEN_MASK_A_ACTIVE 0x08 531 /* (0x01 << (NCI_DISCOVERY_TYPE_LISTEN_B_PRIME & 0x0F)) */ 532 #define NCI_LISTEN_MASK_B_PRIME 0x10 533 /* (0x01 << (NCI_DISCOVERY_TYPE_LISTEN_F_ACTIVE & 0x0F)) */ 534 #define NCI_LISTEN_MASK_F_ACTIVE 0x20 535 /* (0x01 << (NCI_DISCOVERY_TYPE_LISTEN_ISO15693 & 0x0F)) */ 536 #define NCI_LISTEN_MASK_ISO15693 0x40 537 538 /* Type A Parameters */ 539 #define NCI_PARAM_PLATFORM_T1T 0x0C 540 #define NCI_PARAM_SEL_INFO_ISODEP 0x20 541 #define NCI_PARAM_SEL_INFO_NFCDEP 0x40 542 /********************************************** 543 * NCI Parameter ID Lens 544 **********************************************/ 545 #define NCI_PARAM_LEN_TOTAL_DURATION 2 546 547 #define NCI_PARAM_LEN_PA_FSDI 1 548 549 #define NCI_PARAM_LEN_PF_RC 1 550 551 #define NCI_PARAM_LEN_LA_BIT_FRAME_SDD 1 552 #define NCI_PARAM_LEN_LA_PLATFORM_CONFIG 1 553 #define NCI_PARAM_LEN_LA_SEL_INFO 1 554 555 #define NCI_PARAM_LEN_LB_SENSB_INFO 1 556 #define NCI_PARAM_LEN_LB_NFCID0 4 557 #define NCI_PARAM_LEN_LB_APPDATA 4 558 #define NCI_PARAM_LEN_LB_ADC_FO 1 559 560 #define NCI_PARAM_LEN_LF_PROTOCOL 1 561 #define NCI_PARAM_LEN_LF_T3T_FLAGS2 2 562 #define NCI_PARAM_LEN_LF_T3T_PMM 8 563 #define NCI_PARAM_LEN_LF_T3T_ID 10 564 565 #define NCI_PARAM_LEN_FWI 1 566 #define NCI_PARAM_LEN_WT 1 567 /* GEN_BYTES - variable */ 568 569 /* Listen protocol bits - NCI_PARAM_ID_LF_PROTOCOL and 570 * NCI_PARAM_ID_LB_SENSB_INFO */ 571 #define NCI_LISTEN_PROTOCOL_ISO_DEP 0x01 572 #define NCI_LISTEN_PROTOCOL_NFC_DEP 0x02 573 574 #define NCI_DISCOVER_PARAM_SIZE_TEST_RF 0x06 575 576 /* LF_T3T_FLAGS2 listen bits all-disabled definition */ 577 #define NCI_LF_T3T_FLAGS2_ALL_DISABLED 0x0000 578 #define NCI_LF_T3T_FLAGS2_ID1_ENABLED 0x0001 579 580 typedef struct { 581 uint16_t addr; 582 uint8_t len; 583 uint8_t* data; 584 } NCIP_T1T_SETMEM_CMD_t; 585 586 typedef struct { uint8_t status; } NCIP_T1T_SETMEM_RSP_t; 587 588 typedef struct { uint16_t addr; } NCIP_T1T_GETMEM_CMD_t; 589 590 typedef struct { 591 uint8_t status; 592 uint8_t* data; 593 } NCIP_T1T_GETMEM_RSP_t; 594 595 typedef struct { 596 uint8_t hr0; 597 uint8_t hr1; 598 } NCIP_T1T_SETHR_CMD_t; 599 600 typedef struct { uint8_t status; } NCIP_T1T_SETHR_RSP_t; 601 602 #ifndef NCI_GET_CMD_BUF 603 #if (HCI_USE_VARIABLE_SIZE_CMD_BUF == FALSE) 604 /* Allocate fixed-size buffer from HCI_CMD_POOL (default case) */ 605 #define NCI_GET_CMD_BUF(paramlen) ((NFC_HDR*)GKI_getpoolbuf(NFC_NCI_POOL_ID)) 606 #else 607 /* Allocate smallest possible buffer (for platforms with limited RAM) */ 608 #define NCI_GET_CMD_BUF(paramlen) \ 609 ((NFC_HDR*)GKI_getbuf((uint16_t)(NFC_HDR_SIZE + NCI_MSG_HDR_SIZE + \ 610 NCI_MSG_OFFSET_SIZE + (paramlen)))) 611 #endif 612 #endif /* NCI_GET_CMD_BUF */ 613 614 #define NCI_MAX_AID_LEN 16 615 616 typedef struct { 617 uint8_t type; 618 uint8_t frequency; 619 } tNCI_DISCOVER_PARAMS; 620 621 typedef struct { 622 uint8_t protocol; 623 uint8_t mode; 624 uint8_t intf_type; 625 } tNCI_DISCOVER_MAPS; 626 627 #define NCI_NFCID1_MAX_LEN 10 628 #define NCI_T1T_HR_LEN 2 629 typedef struct { 630 uint8_t sens_res[2]; /* SENS_RES Response (ATQA). Available after Technology 631 Detection */ 632 uint8_t nfcid1_len; /* 4, 7 or 10 */ 633 uint8_t nfcid1[NCI_NFCID1_MAX_LEN]; /* AKA NFCID1 */ 634 uint8_t sel_rsp; /* SEL_RSP (SAK) Available after Collision Resolution */ 635 uint8_t hr_len; /* 2, if T1T HR0/HR1 is reported */ 636 uint8_t hr[NCI_T1T_HR_LEN]; /* T1T HR0 is in hr[0], HR1 is in hr[1] */ 637 } tNCI_RF_PA_PARAMS; 638 639 #define NCI_MAX_SENSB_RES_LEN 12 640 typedef struct { 641 uint8_t sensb_res_len; /* Length of SENSB_RES Response (Byte 2 - Byte 12 or 642 13) Available after Technology Detection */ 643 uint8_t sensb_res[NCI_MAX_SENSB_RES_LEN]; /* SENSB_RES Response (ATQ) */ 644 } tNCI_RF_PB_PARAMS; 645 646 #define NCI_MAX_SENSF_RES_LEN 18 647 #define NCI_SENSF_RES_OFFSET_PAD0 8 648 #define NCI_SENSF_RES_OFFSET_RD 16 649 #define NCI_NFCID2_LEN 8 650 #define NCI_T3T_PMM_LEN 8 651 #define NCI_SYSTEMCODE_LEN 2 652 #define NCI_RF_F_UID_LEN NCI_NFCID2_LEN 653 #define NCI_MRTI_CHECK_INDEX 13 654 #define NCI_MRTI_UPDATE_INDEX 14 655 typedef struct { 656 uint8_t bit_rate; /* NFC_BIT_RATE_212 or NFC_BIT_RATE_424 */ 657 uint8_t sensf_res_len; /* Length of SENSF_RES Response (Byte 2 - Byte 17 or 658 19) Available after Technology Detection */ 659 uint8_t sensf_res[NCI_MAX_SENSF_RES_LEN]; /* SENSB_RES Response */ 660 } tNCI_RF_PF_PARAMS; 661 662 typedef struct { 663 uint8_t nfcid2[NCI_NFCID2_LEN]; /* NFCID2 generated by the Local NFCC for 664 NFC-DEP Protocol.Available for Frame 665 Interface */ 666 } tNCI_RF_LF_PARAMS; 667 668 typedef struct { 669 tNCI_DISCOVERY_TYPE mode; 670 union { 671 tNCI_RF_PA_PARAMS pa; 672 tNCI_RF_PB_PARAMS pb; 673 tNCI_RF_PF_PARAMS pf; 674 tNCI_RF_LF_PARAMS lf; 675 } param; /* Discovery Type specific parameters */ 676 } tNCI_RF_TECH_PARAMS; 677 678 #ifndef NCI_MAX_ATS_LEN 679 #define NCI_MAX_ATS_LEN 60 680 #endif 681 #ifndef NCI_MAX_HIS_BYTES_LEN 682 #define NCI_MAX_HIS_BYTES_LEN 50 683 #endif 684 #ifndef NCI_MAX_GEN_BYTES_LEN 685 #define NCI_MAX_GEN_BYTES_LEN 48 686 #endif 687 688 #define NCI_ATS_T0_INDEX 0 689 #define NCI_ATS_TC_MASK 0x40 690 #define NCI_ATS_TB_MASK 0x20 691 #define NCI_ATS_TA_MASK 0x10 692 #define NCI_ATS_FSCI_MASK 0x0F 693 typedef struct { 694 uint8_t ats_res_len; /* Length of ATS RES */ 695 uint8_t ats_res[NCI_MAX_ATS_LEN]; /* ATS RES defined in [DIGPROT] */ 696 } tNCI_INTF_PA_ISO_DEP; 697 698 typedef struct { uint8_t rats; /* RATS */ } tNCI_INTF_LA_ISO_DEP; 699 700 #define NCI_P_GEN_BYTE_INDEX 15 701 #define NCI_L_GEN_BYTE_INDEX 14 702 #define NCI_L_NFC_DEP_TO_INDEX 13 703 typedef struct { 704 uint8_t atr_res_len; /* Length of ATR_RES */ 705 uint8_t atr_res[NCI_MAX_ATS_LEN]; /* ATR_RES (Byte 3 - Byte 17+n) as defined 706 in [DIGPROT] */ 707 } tNCI_INTF_PA_NFC_DEP; 708 709 /* Note: keep tNCI_INTF_PA_NFC_DEP data member in the same order as 710 * tNCI_INTF_LA_NFC_DEP */ 711 typedef struct { 712 uint8_t atr_req_len; /* Length of ATR_REQ */ 713 uint8_t atr_req[NCI_MAX_ATS_LEN]; /* ATR_REQ (Byte 3 - Byte 18+n) as defined 714 in [DIGPROT] */ 715 } tNCI_INTF_LA_NFC_DEP; 716 typedef tNCI_INTF_LA_NFC_DEP tNCI_INTF_LF_NFC_DEP; 717 typedef tNCI_INTF_PA_NFC_DEP tNCI_INTF_PF_NFC_DEP; 718 719 #define NCI_MAX_ATTRIB_LEN (10 + NCI_MAX_GEN_BYTES_LEN) 720 721 typedef struct { 722 uint8_t attrib_res_len; /* Length of ATTRIB RES */ 723 uint8_t 724 attrib_res[NCI_MAX_ATTRIB_LEN]; /* ATTRIB RES as defined in [DIGPROT] */ 725 } tNCI_INTF_PB_ISO_DEP; 726 727 typedef struct { 728 uint8_t attrib_req_len; /* Length of ATTRIB REQ */ 729 uint8_t attrib_req[NCI_MAX_ATTRIB_LEN]; /* ATTRIB REQ (Byte 2 - Byte 10+k) as 730 defined in [DIGPROT] */ 731 } tNCI_INTF_LB_ISO_DEP; 732 733 typedef struct { 734 tNCI_INTF_TYPE type; /* Interface Type 1 Byte See Table 67 */ 735 union { 736 tNCI_INTF_LA_ISO_DEP la_iso; 737 tNCI_INTF_PA_ISO_DEP pa_iso; 738 tNCI_INTF_LB_ISO_DEP lb_iso; 739 tNCI_INTF_PB_ISO_DEP pb_iso; 740 tNCI_INTF_LA_NFC_DEP la_nfc; 741 tNCI_INTF_PA_NFC_DEP pa_nfc; 742 tNCI_INTF_LF_NFC_DEP lf_nfc; 743 tNCI_INTF_PF_NFC_DEP pf_nfc; 744 } intf_param; /* Activation Parameters 0 - n Bytes */ 745 } tNCI_INTF_PARAMS; 746 747 #ifdef __cplusplus 748 } 749 #endif 750 751 #endif /* NFC_NCI_DEFS_H */ 752