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