Home | History | Annotate | Download | only in include
      1 /******************************************************************************
      2  *
      3  *  Copyright (C) 2010-2012 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 "nfc_target.h"
     29 #include "nci_defs.h"
     30 #include "tags_defs.h"
     31 #include "nfc_api.h"
     32 #include "nfc_hal_api.h"
     33 #include "gki.h"
     34 
     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 /* NFA API return status codes */
     45 #define NFA_STATUS_OK                   NCI_STATUS_OK                   /* Command succeeded    */
     46 #define NFA_STATUS_REJECTED             NCI_STATUS_REJECTED             /* Command is rejected. */
     47 #define NFA_STATUS_MSG_CORRUPTED        NCI_STATUS_MESSAGE_CORRUPTED    /* Message is corrupted */
     48 #define NFA_STATUS_BUFFER_FULL          NCI_STATUS_BUFFER_FULL          /* buffer full          */
     49 #define NFA_STATUS_FAILED               NCI_STATUS_FAILED               /* failed               */
     50 #define NFA_STATUS_NOT_INITIALIZED      NCI_STATUS_NOT_INITIALIZED      /* not initialized      */
     51 #define NFA_STATUS_SYNTAX_ERROR         NCI_STATUS_SYNTAX_ERROR         /* Syntax error         */
     52 #define NFA_STATUS_SEMANTIC_ERROR       NCI_STATUS_SEMANTIC_ERROR       /* Semantic error       */
     53 #define NFA_STATUS_UNKNOWN_GID          NCI_STATUS_UNKNOWN_GID          /* Unknown NCI Group ID */
     54 #define NFA_STATUS_UNKNOWN_OID          NCI_STATUS_UNKNOWN_OID          /* Unknown NCI Opcode   */
     55 #define NFA_STATUS_INVALID_PARAM        NCI_STATUS_INVALID_PARAM        /* Invalid Parameter    */
     56 #define NFA_STATUS_MSG_SIZE_TOO_BIG     NCI_STATUS_MSG_SIZE_TOO_BIG     /* Message size too big */
     57 #define NFA_STATUS_ALREADY_STARTED      NCI_STATUS_ALREADY_STARTED      /* Already started      */
     58 #define NFA_STATUS_ACTIVATION_FAILED    NCI_STATUS_ACTIVATION_FAILED    /* Activation Failed    */
     59 #define NFA_STATUS_TEAR_DOWN            NCI_STATUS_TEAR_DOWN            /* Tear Down Error      */
     60 #define NFA_STATUS_RF_TRANSMISSION_ERR  NCI_STATUS_RF_TRANSMISSION_ERR  /* RF transmission error*/
     61 #define NFA_STATUS_RF_PROTOCOL_ERR      NCI_STATUS_RF_PROTOCOL_ERR      /* RF protocol error    */
     62 #define NFA_STATUS_TIMEOUT              NCI_STATUS_TIMEOUT              /* RF Timeout           */
     63 #define NFA_STATUS_EE_INTF_ACTIVE_FAIL  NCI_STATUS_EE_INTF_ACTIVE_FAIL  /* EE Intf activate err */
     64 #define NFA_STATUS_EE_TRANSMISSION_ERR  NCI_STATUS_EE_TRANSMISSION_ERR  /* EE transmission error*/
     65 #define NFA_STATUS_EE_PROTOCOL_ERR      NCI_STATUS_EE_PROTOCOL_ERR      /* EE protocol error    */
     66 #define NFA_STATUS_EE_TIMEOUT           NCI_STATUS_EE_TIMEOUT           /* EE Timeout           */
     67 
     68 #define NFA_STATUS_CMD_STARTED          NFC_STATUS_CMD_STARTED    /* Command started successfully                     */
     69 #define NFA_STATUS_HW_TIMEOUT           NFC_STATUS_HW_TIMEOUT     /* NFCC Timeout in responding to an NCI command     */
     70 #define NFA_STATUS_CONTINUE             NFC_STATUS_CONTINUE       /* More NFA_CE_GET_ROUTING_REVT to follow           */
     71 #define NFA_STATUS_REFUSED              NFC_STATUS_REFUSED        /* API is called to perform illegal function        */
     72 #define NFA_STATUS_BAD_RESP             NFC_STATUS_BAD_RESP       /* Wrong format of R-APDU, CC file or NDEF file     */
     73 #define NFA_STATUS_CMD_NOT_CMPLTD       NFC_STATUS_CMD_NOT_CMPLTD /* 7816 Status Word is not command complete(0x9000) */
     74 #define NFA_STATUS_NO_BUFFERS           NFC_STATUS_NO_BUFFERS     /* Out of GKI buffers                               */
     75 #define NFA_STATUS_WRONG_PROTOCOL       NFC_STATUS_WRONG_PROTOCOL /* Protocol mismatch between API and activated one  */
     76 #define NFA_STATUS_BUSY                 NFC_STATUS_BUSY           /* Another Tag command is already in progress       */
     77 
     78 #define NFA_STATUS_BAD_LENGTH           NFC_STATUS_BAD_LENGTH     /* data len exceeds MIU                             */
     79 #define NFA_STATUS_BAD_HANDLE           NFC_STATUS_BAD_HANDLE     /* invalid handle                                   */
     80 #define NFA_STATUS_CONGESTED            NFC_STATUS_CONGESTED      /* congested                                        */
     81 typedef UINT8 tNFA_STATUS;
     82 
     83 /* Handle for NFA registrations and connections */
     84 typedef UINT16 tNFA_HANDLE;
     85 #define NFA_HANDLE_INVALID              (0xFFFF)
     86 /* NFA Handle definitions */
     87 
     88 /* The upper byte of NFA_HANDLE signifies the handle group */
     89 #define NFA_HANDLE_GROUP_CONNECTION     0x0100      /* Connection handles           */
     90 #define NFA_HANDLE_GROUP_NDEF_HANDLER   0x0200      /* NDEF Type Handler handles    */
     91 #define NFA_HANDLE_GROUP_CE             0x0300      /* DH Card Emulation handles    */
     92 #define NFA_HANDLE_GROUP_EE             0x0400      /* Handles to identify NFCEE    */
     93 #define NFA_HANDLE_GROUP_P2P            0x0500      /* P2P handles                  */
     94 #define NFA_HANDLE_GROUP_CHO            0x0600      /* Connection Handvoer handles  */
     95 #define NFA_HANDLE_GROUP_SNEP           0x0700      /* SNEP handles                 */
     96 #define NFA_HANDLE_GROUP_HCI            0x0800      /* HCI handles                  */
     97 #define NFA_HANDLE_GROUP_LOCAL_NDEF     0x0900      /* Local NDEF message handle    */
     98 #define NFA_HANDLE_GROUP_MASK           0xFF00
     99 #define NFA_HANDLE_MASK                 0x00FF
    100 
    101 /* NCI Parameter IDs */
    102 typedef UINT8 tNFA_PMID;
    103 
    104 /* Definitions for tNFA_TECHNOLOGY_MASK */
    105 #define NFA_TECHNOLOGY_MASK_A	        0x01    /* NFC Technology A             */
    106 #define NFA_TECHNOLOGY_MASK_B	        0x02    /* NFC Technology B             */
    107 #define NFA_TECHNOLOGY_MASK_F	        0x04    /* NFC Technology F             */
    108 #define NFA_TECHNOLOGY_MASK_ISO15693	0x08    /* Proprietary Technology       */
    109 #define NFA_TECHNOLOGY_MASK_B_PRIME	    0x10    /* Proprietary Technology       */
    110 #define NFA_TECHNOLOGY_MASK_KOVIO	    0x20    /* Proprietary Technology       */
    111 #define NFA_TECHNOLOGY_MASK_A_ACTIVE    0x40    /* NFC Technology A active mode */
    112 #define NFA_TECHNOLOGY_MASK_F_ACTIVE    0x80    /* NFC Technology F active mode */
    113 #define NFA_TECHNOLOGY_MASK_ALL         0xFF    /* All supported technologies   */
    114 typedef UINT8 tNFA_TECHNOLOGY_MASK;
    115 
    116 /* Definitions for NFC protocol for RW, CE and P2P APIs */
    117 #define NFA_PROTOCOL_T1T        NFC_PROTOCOL_T1T        /* Type1Tag         - NFC-A             */
    118 #define NFA_PROTOCOL_T2T        NFC_PROTOCOL_T2T        /* MIFARE/Type2Tag  - NFC-A             */
    119 #define NFA_PROTOCOL_T3T        NFC_PROTOCOL_T3T        /* Felica/Type3Tag  - NFC-F             */
    120 #define NFA_PROTOCOL_ISO_DEP    NFC_PROTOCOL_ISO_DEP    /* Type 4A,4B       - NFC-A or NFC-B    */
    121 #define NFA_PROTOCOL_NFC_DEP    NFC_PROTOCOL_NFC_DEP    /* NFCDEP/LLCP      - NFC-A or NFC-F    */
    122 #define NFA_PROTOCOL_ISO15693   NFC_PROTOCOL_15693
    123 #define NFA_PROTOCOL_B_PRIME    NFC_PROTOCOL_B_PRIME
    124 #define NFA_PROTOCOL_KOVIO      NFC_PROTOCOL_KOVIO
    125 #define NFA_PROTOCOL_INVALID    0xFF
    126 #define NFA_MAX_NUM_PROTOCOLS   8
    127 typedef UINT8 tNFA_NFC_PROTOCOL;
    128 
    129 /* Definitions for tNFA_PROTOCOL_MASK */
    130 #define NFA_PROTOCOL_MASK_T1T       0x01    /* Type 1 tag          */
    131 #define NFA_PROTOCOL_MASK_T2T       0x02    /* MIFARE / Type 2 tag */
    132 #define NFA_PROTOCOL_MASK_T3T       0x04    /* FeliCa / Type 3 tag */
    133 #define NFA_PROTOCOL_MASK_ISO_DEP   0x08    /* ISODEP/4A,4B        */
    134 #define NFA_PROTOCOL_MASK_NFC_DEP   0x10    /* NFCDEP/LLCP         */
    135 typedef UINT8 tNFA_PROTOCOL_MASK;
    136 
    137 
    138 /* NFA_DM callback events */
    139 #define NFA_DM_ENABLE_EVT               0   /* Result of NFA_Enable             */
    140 #define NFA_DM_DISABLE_EVT              1   /* Result of NFA_Disable            */
    141 #define NFA_DM_SET_CONFIG_EVT           2   /* Result of NFA_SetConfig          */
    142 #define NFA_DM_GET_CONFIG_EVT           3   /* Result of NFA_GetConfig          */
    143 #define NFA_DM_PWR_MODE_CHANGE_EVT      4   /* Result of NFA_PowerOffSleepMode  */
    144 #define NFA_DM_RF_FIELD_EVT	            5   /* Status of RF Field               */
    145 #define NFA_DM_NFCC_TIMEOUT_EVT         6   /* NFCC is not responding           */
    146 #define NFA_DM_NFCC_TRANSPORT_ERR_EVT   7   /* NCI Tranport error               */
    147 
    148 #define NFA_DM_MAX_UICC                 2   /* Max number of UICC               */
    149 
    150 #define NFA_T1T_HR_LEN              T1T_HR_LEN      /* T1T HR length            */
    151 #define NFA_MAX_UID_LEN             TAG_MAX_UID_LEN /* Max UID length of T1/T2  */
    152 #define NFA_T1T_UID_LEN             T1T_UID_LEN     /* T1T UID length           */
    153 #define NFA_T1T_CMD_UID_LEN         T1T_CMD_UID_LEN /* UID len for T1T cmds     */
    154 #define NFA_T2T_UID_LEN             T2T_UID_LEN     /* T2T UID length           */
    155 
    156 /* Data for NFA_DM_SET_CONFIG_EVT */
    157 typedef struct
    158 {
    159     tNFA_STATUS     status;                     /* NFA_STATUS_OK if successful  */
    160     UINT8           num_param_id;               /* Number of rejected Param ID  */
    161     tNFA_PMID       param_ids[NFC_MAX_NUM_IDS]; /* Rejected Param ID            */
    162 } tNFA_SET_CONFIG;
    163 
    164 /* Data for NFA_DM_GET_CONFIG_EVT */
    165 typedef struct
    166 {
    167     tNFA_STATUS status;     /* NFA_STATUS_OK if successful              */
    168     UINT16 tlv_size;        /* The length of TLV                        */
    169     UINT8 param_tlvs[1];    /* TLV (Parameter ID-Len-Value byte stream) */
    170 } tNFA_GET_CONFIG;
    171 
    172 #define NFA_DM_PWR_MODE_FULL        0x04
    173 #define NFA_DM_PWR_MODE_OFF_SLEEP   0x00
    174 
    175 typedef UINT8 tNFA_DM_PWR_MODE;
    176 
    177 /* Data for NFA_DM_PWR_MODE_CHANGE_EVT */
    178 typedef struct
    179 {
    180     tNFA_STATUS         status;        /* NFA_STATUS_OK if successful                       */
    181     tNFA_DM_PWR_MODE    power_mode;    /* NFA_DM_PWR_MODE_FULL or NFA_DM_PWR_MODE_OFF_SLEEP */
    182 } tNFA_DM_PWR_MODE_CHANGE;
    183 
    184 /* Data for NFA_DM_RF_FIELD_EVT */
    185 #define NFA_DM_RF_FIELD_OFF     0x00
    186 #define NFA_DM_RF_FIELD_ON      0x01
    187 
    188 typedef struct
    189 {
    190     tNFA_STATUS     status;         /* NFA_STATUS_OK if successful  */
    191     UINT8           rf_field_status;/* NFA_DM_RF_FIELD_ON if operating field generated by remote */
    192 } tNFA_DM_RF_FIELD;
    193 
    194 /* Union of all DM callback structures */
    195 typedef union
    196 {
    197     tNFA_STATUS             status;         /* NFA_DM_ENABLE_EVT        */
    198     tNFA_SET_CONFIG         set_config;     /* NFA_DM_SET_CONFIG_EVT    */
    199     tNFA_GET_CONFIG         get_config;     /* NFA_DM_GET_CONFIG_EVT    */
    200     tNFA_DM_PWR_MODE_CHANGE power_mode;     /* NFA_DM_PWR_MODE_CHANGE_EVT   */
    201     tNFA_DM_RF_FIELD        rf_field;       /* NFA_DM_RF_FIELD_EVT      */
    202     void                    *p_vs_evt_data; /* Vendor-specific evt data */
    203 } tNFA_DM_CBACK_DATA;
    204 
    205 /* NFA_DM callback */
    206 typedef void (tNFA_DM_CBACK) (UINT8 event, tNFA_DM_CBACK_DATA *p_data);
    207 
    208 /* Data for data events */
    209 typedef struct
    210 {
    211     tNFA_HANDLE handle;     /* Connection handle */
    212     UINT16      len;        /* Length of data    */
    213     UINT8       *p_buf;     /* Data buffer       */
    214 } tNFA_DATA;
    215 
    216 
    217 /* NFA Connection Callback Events */
    218 #define NFA_POLL_ENABLED_EVT                    0   /* Polling enabled event                        */
    219 #define NFA_POLL_DISABLED_EVT                   1   /* Polling disabled event                       */
    220 #define NFA_DISC_RESULT_EVT                     2   /* NFC link/protocol discovery notificaiton     */
    221 #define NFA_SELECT_RESULT_EVT                   3   /* NFC link/protocol discovery select response  */
    222 #define NFA_DEACTIVATE_FAIL_EVT                 4   /* NFA_Deactivate failure                       */
    223 #define NFA_ACTIVATED_EVT                       5   /* NFC link/protocol activated                  */
    224 #define NFA_DEACTIVATED_EVT                     6   /* NFC link/protocol deactivated                */
    225 #define NFA_TLV_DETECT_EVT                      7   /* TLV Detection complete                       */
    226 #define NFA_NDEF_DETECT_EVT                     8   /* NDEF Detection complete                      */
    227 #define NFA_DATA_EVT                            9   /* Data message received                        */
    228 #define NFA_SELECT_CPLT_EVT                     10  /* Select completed                             */
    229 #define NFA_READ_CPLT_EVT                       11  /* Read completed                               */
    230 #define NFA_WRITE_CPLT_EVT                      12  /* Write completed                              */
    231 #define NFA_LLCP_ACTIVATED_EVT                  13  /* LLCP link is activated                       */
    232 #define NFA_LLCP_DEACTIVATED_EVT                14  /* LLCP link is deactivated                     */
    233 #define NFA_PRESENCE_CHECK_EVT                  15  /* Response to NFA_RwPresenceCheck              */
    234 #define NFA_FORMAT_CPLT_EVT                     16  /* Tag Formating completed                      */
    235 #define NFA_I93_CMD_CPLT_EVT                    17  /* ISO 15693 command completed                  */
    236 #define NFA_SET_TAG_RO_EVT                      18  /* Tag set as Read only                         */
    237 #define NFA_EXCLUSIVE_RF_CONTROL_STARTED_EVT    19  /* Result for NFA_RequestExclusiveRfControl     */
    238 #define NFA_EXCLUSIVE_RF_CONTROL_STOPPED_EVT    20  /* Result for NFA_ReleaseExclusiveRfControl     */
    239 #define NFA_CE_REGISTERED_EVT                   21  /* DH Card emulation: AID or System code reg'd  */
    240 #define NFA_CE_DEREGISTERED_EVT                 22  /* DH Card emulation: AID or System code dereg'd*/
    241 #define NFA_CE_DATA_EVT                         23  /* DH Card emulation: data received event       */
    242 #define NFA_CE_ACTIVATED_EVT                    24  /* DH Card emulation: activation event          */
    243 #define NFA_CE_DEACTIVATED_EVT                  25  /* DH Card emulation: deactivation event        */
    244 #define NFA_CE_LOCAL_TAG_CONFIGURED_EVT         26  /* DH Card emulation: local NDEF configured     */
    245 #define NFA_CE_NDEF_WRITE_START_EVT             27  /* DH Card emulation: NDEF write started        */
    246 #define NFA_CE_NDEF_WRITE_CPLT_EVT              28  /* DH Card emulation: NDEF write completed      */
    247 #define NFA_CE_UICC_LISTEN_CONFIGURED_EVT       29  /* UICC Listen configured                       */
    248 #define NFA_RF_DISCOVERY_STARTED_EVT            30  /* RF Discovery started event                   */
    249 #define NFA_RF_DISCOVERY_STOPPED_EVT            31  /* RF Discovery stopped event                   */
    250 #define NFA_UPDATE_RF_PARAM_RESULT_EVT          32  /* status of updating RF communication paramters*/
    251 #define NFA_SET_P2P_LISTEN_TECH_EVT             33  /* status of setting P2P listen technologies    */
    252 #define NFA_RW_INTF_ERROR_EVT                   34  /* RF Interface error event                     */
    253 
    254 /* NFC deactivation type */
    255 #define NFA_DEACTIVATE_TYPE_IDLE        NFC_DEACTIVATE_TYPE_IDLE
    256 #define NFA_DEACTIVATE_TYPE_SLEEP       NFC_DEACTIVATE_TYPE_SLEEP
    257 #define NFA_DEACTIVATE_TYPE_DISCOVERY   NFC_DEACTIVATE_TYPE_DISCOVERY
    258 
    259 typedef UINT8   tNFA_DEACTIVATE_TYPE;
    260 
    261 /* Data for NFA_DISC_RESULT_EVT */
    262 typedef struct
    263 {
    264     tNFA_STATUS	        status;         /* NFA_STATUS_OK if successful       */
    265     tNFC_RESULT_DEVT    discovery_ntf;  /* RF discovery notification details */
    266 } tNFA_DISC_RESULT;
    267 
    268 /* Data for NFA_ACTIVATED_EVT */
    269 typedef struct
    270 {
    271     UINT8               hr[NFA_T1T_HR_LEN];       /* HR of Type 1 tag         */
    272     UINT8               uid[NFA_T1T_CMD_UID_LEN]; /* UID used in T1T Commands */
    273 } tNFA_T1T_PARAMS;
    274 
    275 typedef struct
    276 {
    277     UINT8               uid[NFA_MAX_UID_LEN];     /* UID of T2T tag           */
    278 } tNFA_T2T_PARAMS;
    279 
    280 typedef struct
    281 {
    282     UINT8               num_system_codes;       /* Number of system codes supporte by tag   */
    283     UINT16              *p_system_codes;        /* Pointer to list of system codes          */
    284 } tNFA_T3T_PARAMS;
    285 
    286 typedef struct
    287 {
    288     UINT8               uid[I93_UID_BYTE_LEN];  /* UID[0]:MSB, ... UID[7]:LSB                   */
    289     UINT8               info_flags;             /* information flags                            */
    290     UINT8               dsfid;                  /* DSFID if I93_INFO_FLAG_DSFID                 */
    291     UINT8               afi;                    /* AFI if I93_INFO_FLAG_AFI                     */
    292     UINT16              num_block;              /* number of blocks if I93_INFO_FLAG_MEM_SIZE   */
    293     UINT8               block_size;             /* block size in byte if I93_INFO_FLAG_MEM_SIZE */
    294     UINT8               IC_reference;           /* IC Reference if I93_INFO_FLAG_IC_REF         */
    295 } tNFA_I93_PARAMS;
    296 
    297 typedef union
    298 {
    299     tNFA_T1T_PARAMS     t1t;            /* HR and UID of T1T                */
    300     tNFA_T2T_PARAMS     t2t;            /* UID of T2T                       */
    301     tNFA_T3T_PARAMS     t3t;            /* System codes                     */
    302     tNFA_I93_PARAMS     i93;            /* System Information of ISO 15693  */
    303 } tNFA_TAG_PARAMS;
    304 
    305 typedef struct
    306 {
    307     tNFC_ACTIVATE_DEVT  activate_ntf;   /* RF discovery activation details */
    308     tNFA_TAG_PARAMS     params;         /* additional informaiton of tag   */
    309 } tNFA_ACTIVATED;
    310 
    311 /* Data for NFA_DEACTIVATED_EVT */
    312 typedef struct
    313 {
    314     tNFA_DEACTIVATE_TYPE type;          /* NFA_DEACTIVATE_TYPE_IDLE or NFA_DEACTIVATE_TYPE_SLEEP */
    315 } tNFA_DEACTIVATED;
    316 
    317 /* Structure for NFA_NDEF_DETECT_EVT event data */
    318 typedef struct
    319 {
    320     tNFA_STATUS         status;             /* Status of the ndef detecton                              */
    321     tNFA_NFC_PROTOCOL   protocol;           /* protocol used to detect NDEF                             */
    322     UINT32              max_size;           /* max number of bytes available for NDEF data              */
    323     UINT32              cur_size;           /* current size of stored NDEF data (in bytes)              */
    324     UINT8               flags;              /* Flags to indicate NDEF capability,formated,formatable and read only */
    325 } tNFA_NDEF_DETECT;
    326 
    327 
    328 /* Structure for NFA_TLV_DETECT_EVT event data */
    329 typedef struct
    330 {
    331     tNFA_STATUS         status;     /* Status of the tlv detecton        */
    332     tNFA_NFC_PROTOCOL   protocol;   /* protocol used to detect TLV       */
    333     UINT8               num_tlvs;   /* number of tlvs present in the tag */
    334     UINT8               num_bytes;  /* number of lock/reserved bytes     */
    335 } tNFA_TLV_DETECT;
    336 
    337 /* Structure for NFA_DATA_EVT data */
    338 typedef struct
    339 {
    340     UINT8               *p_data;        /* Data buffer                      */
    341     UINT16              len;            /* Length of data                   */
    342 } tNFA_RX_DATA;
    343 
    344 /* Structure for NFA_CE_NDEF_WRITE_CPLT_EVT data */
    345 typedef struct
    346 {
    347     tNFA_STATUS         status;         /* Status of the ndef write op      */
    348     UINT32              len;            /* Update length of NDEF data       */
    349     UINT8               *p_data;        /* data buffer                      */
    350 } tNFA_CE_NDEF_WRITE_CPLT;
    351 
    352 /* Data for NFA_LLCP_ACTIVATED_EVT */
    353 typedef struct
    354 {
    355     BOOLEAN             is_initiator;   /* TRUE if initiator                */
    356     UINT16              remote_wks;     /* Well-Known service mask of peer  */
    357     UINT8               remote_lsc;     /* Link Service Class of peer       */
    358     UINT16              remote_link_miu;/* Link MIU of peer                 */
    359     UINT16              local_link_miu; /* Link MIU of local                */
    360 } tNFA_LLCP_ACTIVATED;
    361 
    362 /* Data for NFA_LLCP_DEACTIVATED_EVT */
    363 typedef struct
    364 {
    365     UINT8               reason;         /* reason of deactivation           */
    366 } tNFA_LLCP_DEACTIVATED;
    367 
    368 /* Data for NFA_I93_CMD_CPLT_EVT */
    369 typedef struct
    370 {
    371     UINT8           dsfid;                  /* DSFID                       */
    372     UINT8           uid[I93_UID_BYTE_LEN];  /* UID[0]:MSB, ... UID[7]:LSB  */
    373 } tNFA_I93_INVENTORY;
    374 
    375 typedef struct                              /* RW_I93_SYS_INFO_EVT                          */
    376 {
    377     UINT8           info_flags;             /* information flags                            */
    378     UINT8           uid[I93_UID_BYTE_LEN];  /* UID                                          */
    379     UINT8           dsfid;                  /* DSFID if I93_INFO_FLAG_DSFID                 */
    380     UINT8           afi;                    /* AFI if I93_INFO_FLAG_AFI                     */
    381     UINT16          num_block;              /* number of blocks if I93_INFO_FLAG_MEM_SIZE   */
    382     UINT8           block_size;             /* block size in byte if I93_INFO_FLAG_MEM_SIZE */
    383     UINT8           IC_reference;           /* IC Reference if I93_INFO_FLAG_IC_REF         */
    384 } tNFA_I93_SYS_INFO;
    385 
    386 typedef struct
    387 {
    388     tNFA_STATUS         status;         /* Status of sending command       */
    389     UINT8               sent_command;   /* sent command to tag             */
    390     union
    391     {
    392         UINT8               error_code; /* error code defined in ISO 15693 */
    393         tNFA_I93_INVENTORY  inventory;  /* inventory response              */
    394         tNFA_I93_SYS_INFO   sys_info;   /* system information              */
    395     } params;
    396 } tNFA_I93_CMD_CPLT;
    397 
    398 /* Data for NFA_CE_REGISTERED_EVT */
    399 typedef struct
    400 {
    401     tNFA_STATUS         status;         /* NFA_STATUS_OK if successful                      */
    402     tNFA_HANDLE         handle;         /* handle for NFA_CeRegisterFelicaSystemCodeOnDH () */
    403                                         /*            NFA_CeRegisterT4tAidOnDH ()           */
    404 } tNFA_CE_REGISTERED;
    405 
    406 /* Data for NFA_CE_DEREGISTERED_EVT */
    407 typedef struct
    408 {
    409     tNFA_HANDLE         handle;         /* handle from NFA_CE_REGISTERED_EVT   */
    410 } tNFA_CE_DEREGISTERED;
    411 
    412 /* Data for NFA_CE_ACTIVATED_EVT */
    413 typedef struct
    414 {
    415     tNFA_STATUS         status;         /* NFA_STATUS_OK if successful              */
    416     tNFA_HANDLE         handle;         /* handle from NFA_CE_REGISTERED_EVT        */
    417     tNFC_ACTIVATE_DEVT  activate_ntf;   /* RF discovery activation details          */
    418 } tNFA_CE_ACTIVATED;
    419 
    420 /* Data for NFA_CE_DEACTIVATED_EVT */
    421 typedef struct
    422 {
    423     tNFA_HANDLE         handle;         /* handle from NFA_CE_REGISTERED_EVT   */
    424     tNFA_DEACTIVATE_TYPE type;          /* NFA_DEACTIVATE_TYPE_IDLE or NFA_DEACTIVATE_TYPE_SLEEP */
    425 } tNFA_CE_DEACTIVATED;
    426 
    427 /* Structure for NFA_CE_DATA_EVT data */
    428 typedef struct
    429 {
    430     tNFA_HANDLE         handle;         /* handle from NFA_CE_REGISTERED_EVT    */
    431     UINT8               *p_data;        /* Data buffer                          */
    432     UINT16              len;            /* Length of data                       */
    433 } tNFA_CE_DATA;
    434 
    435 
    436 /* Union of all connection callback structures */
    437 typedef union
    438 {
    439     tNFA_STATUS             status;             /* NFA_POLL_ENABLED_EVT                 */
    440                                                 /* NFA_POLL_DISABLED_EVT                */
    441                                                 /* NFA_CE_UICC_LISTEN_CONFIGURED_EVT    */
    442                                                 /* NFA_EXCLUSIVE_RF_CONTROL_STARTED_EVT */
    443                                                 /* NFA_EXCLUSIVE_RF_CONTROL_STOPPED_EVT */
    444                                                 /* NFA_SELECT_RESULT_EVT                */
    445                                                 /* NFA_DEACTIVATE_FAIL_EVT              */
    446                                                 /* NFA_CE_NDEF_WRITE_START_EVT          */
    447                                                 /* NFA_SELECT_CPLT_EVT                  */
    448                                                 /* NFA_READ_CPLT_EVT                    */
    449                                                 /* NFA_WRITE_CPLT_EVT                   */
    450                                                 /* NFA_PRESENCE_CHECK_EVT               */
    451                                                 /* NFA_FORMAT_CPLT_EVT                  */
    452                                                 /* NFA_SET_TAG_RO_EVT                   */
    453                                                 /* NFA_UPDATE_RF_PARAM_RESULT_EVT       */
    454                                                 /* NFA_RW_INTF_ERROR_EVT                */
    455     tNFA_DISC_RESULT         disc_result;       /* NFA_DISC_RESULT_EVT                  */
    456     tNFA_ACTIVATED           activated;         /* NFA_ACTIVATED_EVT                    */
    457     tNFA_DEACTIVATED         deactivated;       /* NFA_DEACTIVATED_EVT                  */
    458     tNFA_NDEF_DETECT         ndef_detect;       /* NFA_NDEF_DETECT_EVT                  */
    459     tNFA_TLV_DETECT          tlv_detect;        /* NFA_TLV_DETECT_EVT                   */
    460     tNFA_RX_DATA             data;              /* NFA_DATA_EVT                         */
    461     tNFA_CE_NDEF_WRITE_CPLT  ndef_write_cplt;   /* NFA_CE_NDEF_WRITE_CPLT_EVT           */
    462     tNFA_LLCP_ACTIVATED      llcp_activated;    /* NFA_LLCP_ACTIVATED_EVT               */
    463     tNFA_LLCP_DEACTIVATED    llcp_deactivated;  /* NFA_LLCP_DEACTIVATED_EVT             */
    464     tNFA_I93_CMD_CPLT        i93_cmd_cplt;      /* NFA_I93_CMD_CPLT_EVT                 */
    465     tNFA_CE_REGISTERED       ce_registered;     /* NFA_CE_REGISTERED_EVT                */
    466     tNFA_CE_DEREGISTERED     ce_deregistered;   /* NFA_CE_DEREGISTERED_EVT              */
    467     tNFA_CE_ACTIVATED        ce_activated;      /* NFA_CE_ACTIVATED_EVT                 */
    468     tNFA_CE_DEACTIVATED      ce_deactivated;    /* NFA_CE_DEACTIVATED_EVT               */
    469     tNFA_CE_DATA             ce_data;           /* NFA_CE_DATA_EVT                      */
    470 
    471 } tNFA_CONN_EVT_DATA;
    472 
    473 /* NFA Connection Callback */
    474 typedef void (tNFA_CONN_CBACK) (UINT8 event, tNFA_CONN_EVT_DATA *p_data);
    475 
    476 #ifndef NFA_DM_NUM_INTERFACE_MAP
    477 #define NFA_DM_NUM_INTERFACE_MAP    3
    478 #endif
    479 
    480 /* compile-time configuration structure */
    481 typedef struct
    482 {
    483     BOOLEAN auto_detect_ndef;           /* Automatic NDEF detection (when not in exclusive RF mode) */
    484     BOOLEAN auto_read_ndef;             /* Automatic NDEF read (when not in exclusive RF mode)      */
    485 } tNFA_DM_CFG;
    486 
    487 /*
    488 ** Exclusive RF mode listen configuration
    489 */
    490 
    491 #define NFA_LB_MAX_NFCID0_LEN           4
    492 #define NFA_LF_MAX_SC_NFCID2            1
    493 #define NFA_LA_MAX_HIST_BYTES           15
    494 #define NFA_LB_MAX_H_INFO_LEN           15
    495 
    496 typedef struct
    497 {
    498     /*
    499     ** Discovery Configuration Parameters for Listen A
    500     */
    501     BOOLEAN la_enable;                          /* TRUE if listening A                      */
    502     UINT8   la_bit_frame_sdd;                   /* Bit Frame SDD in Byte 1 of SENS_RES      */
    503     UINT8   la_platform_config;                 /* Platform Config in Byte 2 of SENS_RES    */
    504     UINT8   la_sel_info;                        /* Byte of SEL_RES                          */
    505     UINT8   la_nfcid1_len;                      /* NFCID1 (0, 4, 7 or 10 bytes)             */
    506     UINT8   la_nfcid1[NCI_NFCID1_MAX_LEN];      /*        if empty, NFCC will decide        */
    507 
    508     /*
    509     ** Discovery Configuration Parameters for Listen B
    510     */
    511     BOOLEAN lb_enable;                          /* TRUE if listening B                      */
    512     UINT8   lb_sensb_info;                      /* Byte 2 of Protocol Info within SENSB_RES */
    513     UINT8   lb_nfcid0_len;                      /* NFCID0 (0, 1 or 4 bytes)                 */
    514     UINT8   lb_nfcid0[NFA_LB_MAX_NFCID0_LEN];   /*         if empty, NFCC will decide       */
    515     UINT8   lb_app_data[NCI_PARAM_LEN_LB_APPDATA];/* Bytes 6 - 9 in SENSB_RES               */
    516     UINT8   lb_sfgi;                            /* Start-Up Frame Guard Time                */
    517     UINT8   lb_adc_fo;                          /* Byte 12 in SENSB_RES                     */
    518 
    519     /*
    520     ** Discovery Configuration Parameters for Listen F
    521     */
    522     BOOLEAN lf_enable;                          /* TRUE if listening F          */
    523     UINT8   lf_con_bitr_f;                      /* bit rate to listen           */
    524     UINT8   lf_protocol_type;                   /* Supported Protocols          */
    525     UINT16  lf_t3t_flags;                       /* bit field indicating which lf_t3t_identifier are enabled */
    526     UINT8   lf_t3t_identifier[NFA_LF_MAX_SC_NFCID2][NCI_SYSTEMCODE_LEN + NCI_NFCID2_LEN];
    527                                                 /* System Code and NFCID2       */
    528     UINT8   lf_t3t_pmm[NCI_T3T_PMM_LEN];        /* Bytes 10 - 17 in SENSF_RES   */
    529 
    530     /*
    531     ** Discovery Configuration Parameters for Listen ISO-DEP
    532     */
    533     BOOLEAN li_enable;                          /* TRUE if listening ISO-DEP            */
    534     UINT8   li_fwi;                             /* Frame Waiting Time Integer           */
    535     UINT8   la_hist_bytes_len;                  /* historical bytes for Listen-A        */
    536     UINT8   la_hist_bytes[NFA_LA_MAX_HIST_BYTES];
    537     UINT8   lb_h_info_resp_len;                 /* higher layer response for Listen-B   */
    538     UINT8   lb_h_info_resp[NFA_LB_MAX_H_INFO_LEN];
    539 
    540     /*
    541     ** Discovery Configuration Parameters for Listen NFC-DEP
    542     */
    543     BOOLEAN ln_enable;                          /* TRUE if listening NFC-DEP            */
    544     UINT8   ln_wt;                              /* Waiting Time Integer                 */
    545     UINT8   ln_atr_res_gen_bytes_len;           /* General bytes in ATR_RES             */
    546     UINT8   ln_atr_res_gen_bytes[NCI_MAX_GEN_BYTES_LEN];
    547     UINT8   ln_atr_res_config;                  /* Optional parameters (PPt) in ATR_RES */
    548 } tNFA_LISTEN_CFG;
    549 
    550 /* Data for NFA_UpdateRFCommParams () */
    551 typedef tNFC_RF_COMM_PARAMS tNFA_RF_COMM_PARAMS;
    552 
    553 /* RF Interface type */
    554 #define NFA_INTERFACE_FRAME         NFC_INTERFACE_FRAME
    555 #define NFA_INTERFACE_ISO_DEP       NFC_INTERFACE_ISO_DEP
    556 #define NFA_INTERFACE_NFC_DEP       NFC_INTERFACE_NFC_DEP
    557 typedef tNFC_INTF_TYPE tNFA_INTF_TYPE;
    558 
    559 /*******************************************************************************
    560 ** NDEF Definitions
    561 *******************************************************************************/
    562 
    563 /* Definitions for tNFA_TNF (NDEF type name format ID) */
    564 #define NFA_TNF_EMPTY           NDEF_TNF_EMPTY      /* Empty or no type specified                       */
    565 #define NFA_TNF_WKT             NDEF_TNF_WKT        /* NFC Forum well-known type [NFC RTD]              */
    566 #define NFA_TNF_RFC2046_MEDIA   NDEF_TNF_MEDIA      /* Media-type as defined in RFC 2046 [RFC 2046]     */
    567 #define NFA_TNF_RFC3986_URI     NDEF_TNF_URI        /* Absolute URI as defined in RFC 3986 [RFC 3986]   */
    568 #define NFA_TNF_EXTERNAL        NDEF_TNF_EXT        /* NFC Forum external type [NFC RTD]                */
    569 #define NFA_TNF_UNKNOWN	        NDEF_TNF_UNKNOWN    /* Unknown                                          */
    570 #define NFA_TNF_UNCHANGED       NDEF_TNF_UNCHANGED  /* Unchanged                                        */
    571 #define NFA_TNF_RESERVED        NDEF_TNF_RESERVED   /* Reserved                                         */
    572 #define NFA_TNF_DEFAULT	        0xFF                /* Used to register default NDEF type handler       */
    573 typedef UINT8 tNFA_TNF;
    574 
    575 /* Definitions for tNFA_NDEF_URI_ID (Frequently used prefixes. For additional values, see [NFC RTD URI] */
    576 #define NFA_NDEF_URI_ID_ABSOLUTE    0x00            /* Unabridged URI.  */
    577 #define NFA_NDEF_URI_ID_HTTP        0x03            /* http://          */
    578 #define NFA_NDEF_URI_ID_HTTPS       0x04            /* https://         */
    579 #define NFA_NDEF_URI_ID_TEL         0x05            /* tel:             */
    580 #define NFA_NDEF_URI_ID_MAILTO      0x06            /* mailto:          */
    581 #define NFA_NDEF_URI_ID_FTP         0x0D            /* ftp://           */
    582 #define NFA_NDEF_URI_ID_FILE        0x1D            /* file://          */
    583 
    584 typedef UINT8 tNFA_NDEF_URI_ID;
    585 
    586 /* Events for tNFA_NDEF_CBACK */
    587 #define NFA_NDEF_REGISTER_EVT   0   /* NDEF record type registered. (In response to NFA_RegisterNDefTypeHandler)    */
    588 #define NFA_NDEF_DATA_EVT	    1   /* Received an NDEF message with the registered type. See [tNFA_DATA]       */
    589 typedef UINT8 tNFA_NDEF_EVT;
    590 
    591 /* Structure for NFA_NDEF_REGISTER_EVT event data */
    592 typedef struct
    593 {
    594     tNFA_STATUS status;             /* Status of the registration               */
    595     tNFA_HANDLE ndef_type_handle;   /* Handle for this NDEF type registration.  */
    596 } tNFA_NDEF_REGISTER;
    597 
    598 /* Structure for NFA_NDEF_DATA_EVT event data */
    599 typedef struct
    600 {
    601     tNFA_HANDLE ndef_type_handle;   /* Handle for NDEF type registration.   */
    602     UINT8       *p_data;            /* Data buffer                          */
    603     UINT32      len;                /* Length of data                       */
    604 } tNFA_NDEF_DATA;
    605 
    606 /* Union of all NDEF callback structures */
    607 typedef union
    608 {
    609     tNFA_NDEF_REGISTER  ndef_reg;       /* Structure for NFA_NDEF_REGISTER_EVT event data   */
    610     tNFA_NDEF_DATA      ndef_data;      /* Structure for NFA_NDEF_DATA_EVT event data       */
    611 } tNFA_NDEF_EVT_DATA;
    612 
    613 /* NFA_NDEF callback */
    614 typedef void (tNFA_NDEF_CBACK) (tNFA_NDEF_EVT event, tNFA_NDEF_EVT_DATA *p_data);
    615 
    616 /* NFA VSC Callback */
    617 typedef void (tNFA_VSC_CBACK)(UINT8 event, UINT16 param_len, UINT8 *p_param);
    618 
    619 
    620 /*****************************************************************************
    621 **  External Function Declarations
    622 *****************************************************************************/
    623 #ifdef __cplusplus
    624 extern "C"
    625 {
    626 #endif
    627 
    628 /*******************************************************************************
    629 **
    630 ** Function         NFA_Init
    631 **
    632 ** Description      This function initializes control blocks for NFA
    633 **
    634 **                  p_hal_entry_tbl points to a table of HAL entry points
    635 **
    636 **                  NOTE: the buffer that p_hal_entry_tbl points must be
    637 **                  persistent until NFA is disabled.
    638 **
    639 **
    640 ** Returns          none
    641 **
    642 *******************************************************************************/
    643 NFC_API extern void NFA_Init (tHAL_NFC_ENTRY *p_hal_entry_tbl);
    644 
    645 /*******************************************************************************
    646 **
    647 ** Function         NFA_Enable
    648 **
    649 ** Description      This function enables NFC. Prior to calling NFA_Enable,
    650 **                  the NFCC must be powered up, and ready to receive commands.
    651 **                  This function enables the tasks needed by NFC, opens the NCI
    652 **                  transport, resets the NFC controller, downloads patches to
    653 **                  the NFCC (if necessary), and initializes the NFC subsystems.
    654 **
    655 **                  This function should only be called once - typically when NFC
    656 **                  is enabled during boot-up, or when NFC is enabled from a
    657 **                  settings UI. Subsequent calls to NFA_Enable while NFA is
    658 **                  enabling or enabled will be ignored. When the NFC startup
    659 **                  procedure is completed, an NFA_DM_ENABLE_EVT is returned to the
    660 **                  application using the tNFA_DM_CBACK.
    661 **
    662 **                  The tNFA_CONN_CBACK parameter is used to register a callback
    663 **                  for polling, p2p and card emulation events.
    664 **
    665 **
    666 ** Returns          NFA_STATUS_OK if successfully initiated
    667 **                  NFA_STATUS_FAILED otherwise
    668 **
    669 *******************************************************************************/
    670 NFC_API extern tNFA_STATUS NFA_Enable (tNFA_DM_CBACK       *p_dm_cback,
    671                                        tNFA_CONN_CBACK     *p_conn_cback);
    672 
    673 /*******************************************************************************
    674 **
    675 ** Function         NFA_Disable
    676 **
    677 ** Description      This function is called to shutdown NFC. The tasks for NFC
    678 **                  are terminated, and clean up routines are performed. This
    679 **                  function is typically called during platform shut-down, or
    680 **                  when NFC is disabled from a settings UI. When the NFC
    681 **                  shutdown procedure is completed, an NFA_DM_DISABLE_EVT is
    682 **                  returned to the application using the tNFA_DM_CBACK.
    683 **
    684 **                  The platform should wait until the NFC_DISABLE_REVT is
    685 **                  received before powering down the NFC chip and NCI transport.
    686 **                  This is required to so that NFA can gracefully shut down any
    687 **                  open connections.
    688 **
    689 ** Returns          NFA_STATUS_OK if successfully initiated
    690 **                  NFA_STATUS_FAILED otherwise
    691 **
    692 *******************************************************************************/
    693 NFC_API extern tNFA_STATUS NFA_Disable (BOOLEAN graceful);
    694 
    695 /*******************************************************************************
    696 **
    697 ** Function         NFA_SetConfig
    698 **
    699 ** Description      Set the configuration parameters to NFCC. The result is
    700 **                  reported with an NFA_DM_SET_CONFIG_EVT in the tNFA_DM_CBACK
    701 **                  callback.
    702 **
    703 ** Note:            If RF discovery is started, NFA_StopRfDiscovery()/NFA_RF_DISCOVERY_STOPPED_EVT
    704 **                  should happen before calling this function. Most Configuration
    705 **                  parameters are related to RF discovery.
    706 **
    707 ** Returns          NFA_STATUS_OK if successfully initiated
    708 **                  NFA_STATUS_BUSY if previous setting is on-going
    709 **                  NFA_STATUS_FAILED otherwise
    710 **
    711 *******************************************************************************/
    712 NFC_API extern tNFA_STATUS NFA_SetConfig (tNFA_PMID    param_id,
    713                                           UINT8        length,
    714                                           UINT8       *p_data);
    715 
    716 /*******************************************************************************
    717 **
    718 ** Function         NFA_GetConfig
    719 **
    720 ** Description      Get the configuration parameters from NFCC. The result is
    721 **                  reported with an NFA_DM_GET_CONFIG_EVT in the tNFA_DM_CBACK
    722 **                  callback.
    723 **
    724 ** Returns          NFA_STATUS_OK if successfully initiated
    725 **                  NFA_STATUS_FAILED otherwise
    726 **
    727 *******************************************************************************/
    728 NFC_API extern tNFA_STATUS NFA_GetConfig (UINT8 num_ids, tNFA_PMID *p_param_ids);
    729 
    730 /*******************************************************************************
    731 **
    732 ** Function         NFA_RequestExclusiveRfControl
    733 **
    734 ** Description      Request exclusive control of NFC.
    735 **                  - Previous behavior (polling/tag reading, DH card emulation)
    736 **                    will be suspended .
    737 **                  - Polling and listening will be done based on the specified
    738 **                    params
    739 **
    740 **                  The NFA_EXCLUSIVE_RF_CONTROL_STARTED_EVT event of
    741 **                  tNFA_CONN_CBACK indicates the status of the operation.
    742 **
    743 **                  NFA_ACTIVATED_EVT and NFA_DEACTIVATED_EVT indicates link
    744 **                  activation/deactivation.
    745 **
    746 **                  NFA_SendRawFrame is used to send data to the peer. NFA_DATA_EVT
    747 **                  indicates data from the peer.
    748 **
    749 **                  If a tag is activated, then the NFA_RW APIs may be used to
    750 **                  send commands to the tag. Incoming NDEF messages are sent to
    751 **                  the NDEF callback.
    752 **
    753 **                  Once exclusive RF control has started, NFA will not activate
    754 **                  LLCP internally. The application has exclusive control of
    755 **                  the link.
    756 **
    757 ** Note:            If RF discovery is started, NFA_StopRfDiscovery()/NFA_RF_DISCOVERY_STOPPED_EVT
    758 **                  should happen before calling this function
    759 **
    760 ** Returns          NFA_STATUS_OK if successfully initiated
    761 **                  NFA_STATUS_FAILED otherwise
    762 **
    763 *******************************************************************************/
    764 NFC_API extern tNFA_STATUS NFA_RequestExclusiveRfControl (tNFA_TECHNOLOGY_MASK poll_mask,
    765                                                           tNFA_LISTEN_CFG *p_listen_cfg,
    766                                                           tNFA_CONN_CBACK *p_conn_cback,
    767                                                           tNFA_NDEF_CBACK *p_ndef_cback);
    768 
    769 /*******************************************************************************
    770 **
    771 ** Function         NFA_ReleaseExclusiveRfControl
    772 **
    773 ** Description      Release exclusive control of NFC. Once released, behavior
    774 **                  prior to obtaining exclusive RF control will resume.
    775 **
    776 Note??
    777 ** Returns          NFA_STATUS_OK if successfully initiated
    778 **                  NFA_STATUS_FAILED otherwise
    779 **
    780 *******************************************************************************/
    781 NFC_API extern tNFA_STATUS NFA_ReleaseExclusiveRfControl (void);
    782 
    783 /*******************************************************************************
    784 **
    785 ** Function         NFA_EnablePolling
    786 **
    787 ** Description      Enable polling for technologies specified by poll_mask.
    788 **
    789 **                  The following events (notified using the connection
    790 **                  callback registered with NFA_Enable) are generated during
    791 **                  polling:
    792 **
    793 **                  - NFA_POLL_ENABLED_EVT indicates whether or not polling
    794 **                    successfully enabled.
    795 **                  - NFA_DISC_RESULT_EVT indicates there are more than one devices,
    796 **                    so application must select one of tags by calling NFA_Select().
    797 **                  - NFA_SELECT_RESULT_EVT indicates whether previous selection was
    798 **                    successful or not. If it was failed then application must select
    799 **                    again or deactivate by calling NFA_Deactivate().
    800 **                  - NFA_ACTIVATED_EVT is generated when an NFC link is activated.
    801 **                  - NFA_NDEF_DETECT_EVT is generated if tag is activated
    802 **                  - NFA_LLCP_ACTIVATED_EVT/NFA_LLCP_DEACTIVATED_EVT is generated
    803 **                    if NFC-DEP is activated
    804 **                  - NFA_DEACTIVATED_EVT will be returned after deactivating NFC link.
    805 **
    806 ** Note:            If RF discovery is started, NFA_StopRfDiscovery()/NFA_RF_DISCOVERY_STOPPED_EVT
    807 **                  should happen before calling this function
    808 **
    809 ** Returns          NFA_STATUS_OK if successfully initiated
    810 **                  NFA_STATUS_FAILED otherwise
    811 **
    812 *******************************************************************************/
    813 NFC_API extern tNFA_STATUS NFA_EnablePolling (tNFA_TECHNOLOGY_MASK poll_mask);
    814 
    815 /*******************************************************************************
    816 **
    817 ** Function         NFA_DisablePolling
    818 **
    819 ** Description      Disable polling
    820 **                  NFA_POLL_DISABLED_EVT will be returned after stopping polling.
    821 **
    822 ** Note:            If RF discovery is started, NFA_StopRfDiscovery()/NFA_RF_DISCOVERY_STOPPED_EVT
    823 **                  should happen before calling this function
    824 **
    825 ** Returns          NFA_STATUS_OK if successfully initiated
    826 **                  NFA_STATUS_FAILED otherwise
    827 **
    828 *******************************************************************************/
    829 NFC_API extern tNFA_STATUS NFA_DisablePolling (void);
    830 
    831 /*******************************************************************************
    832 **
    833 ** Function         NFA_SetP2pListenTech
    834 **
    835 ** Description      This function is called to set listen technology for NFC-DEP.
    836 **                  This funtion may be called before or after starting any server
    837 **                  on NFA P2P/CHO/SNEP.
    838 **                  If there is no technology for NFC-DEP, P2P listening will be
    839 **                  stopped.
    840 **
    841 **                  NFA_SET_P2P_LISTEN_TECH_EVT without data will be returned.
    842 **
    843 ** Note:            If RF discovery is started, NFA_StopRfDiscovery()/NFA_RF_DISCOVERY_STOPPED_EVT
    844 **                  should happen before calling this function
    845 **
    846 ** Returns          NFA_STATUS_OK if successfully initiated
    847 **                  NFA_STATUS_FAILED otherwise
    848 **
    849 *******************************************************************************/
    850 NFC_API extern tNFA_STATUS NFA_SetP2pListenTech (tNFA_TECHNOLOGY_MASK tech_mask);
    851 
    852 /*******************************************************************************
    853 **
    854 ** Function         NFA_StartRfDiscovery
    855 **
    856 ** Description      Start RF discovery
    857 **                  RF discovery parameters shall be set by other APIs.
    858 **
    859 **                  An NFA_RF_DISCOVERY_STARTED_EVT indicates whether starting was successful or not.
    860 **
    861 ** Returns          NFA_STATUS_OK if successfully initiated
    862 **                  NFA_STATUS_FAILED otherwise
    863 **
    864 *******************************************************************************/
    865 NFC_API extern tNFA_STATUS NFA_StartRfDiscovery (void);
    866 
    867 /*******************************************************************************
    868 **
    869 ** Function         NFA_StopRfDiscovery
    870 **
    871 ** Description      Stop RF discovery
    872 **
    873 **                  An NFA_RF_DISCOVERY_STOPPED_EVT indicates whether stopping was successful or not.
    874 **
    875 ** Returns          NFA_STATUS_OK if successfully initiated
    876 **                  NFA_STATUS_FAILED otherwise
    877 **
    878 *******************************************************************************/
    879 NFC_API extern tNFA_STATUS NFA_StopRfDiscovery (void);
    880 
    881 /*******************************************************************************
    882 **
    883 ** Function         NFA_SetRfDiscoveryDuration
    884 **
    885 ** Description      Set the duration of the single discovery period in [ms].
    886 **                  Allowable range: 0 ms to 0xFFFF ms.
    887 **
    888 ** Note:            If discovery is already started, the application should
    889 **                  call NFA_StopRfDiscovery prior to calling
    890 **                  NFA_SetRfDiscoveryDuration, and then call
    891 **                  NFA_StartRfDiscovery afterwards to restart discovery using
    892 **                  the new duration.
    893 **
    894 ** Returns:
    895 **                  NFA_STATUS_OK, if command accepted
    896 **                  NFA_STATUS_FAILED: otherwise
    897 **
    898 *******************************************************************************/
    899 NFC_API extern tNFA_STATUS NFA_SetRfDiscoveryDuration (UINT16 discovery_period_ms);
    900 
    901 /*******************************************************************************
    902 **
    903 ** Function         NFA_Select
    904 **
    905 ** Description      Select one from detected devices by NFA_DISC_RESULT_EVT after the
    906 **                  last discovery result is received.
    907 **                  An NFA_SELECT_RESULT_EVT indicates whether selection was successful or not.
    908 **                  If failed then application must select again or deactivate by NFA_Deactivate ().
    909 **
    910 ** Returns          NFA_STATUS_OK if successfully initiated
    911 **                  NFA_STATUS_INVALID_PARAM if RF interface is not matched protocol
    912 **                  NFA_STATUS_FAILED otherwise
    913 **
    914 *******************************************************************************/
    915 NFC_API extern tNFA_STATUS NFA_Select (UINT8             rf_disc_id,
    916                                        tNFA_NFC_PROTOCOL protocol,
    917                                        tNFA_INTF_TYPE    rf_interface);
    918 
    919 /*******************************************************************************
    920 **
    921 ** Function         NFA_UpdateRFCommParams
    922 **
    923 ** Description      This function is called to update RF Communication parameters
    924 **                  once the Frame RF Interface has been activated.
    925 **
    926 **                  An NFA_UPDATE_RF_PARAM_RESULT_EVT indicates whether updating
    927 **                  was successful or not.
    928 **
    929 ** Returns          NFA_STATUS_OK if successfully initiated
    930 **                  NFA_STATUS_FAILED otherwise
    931 **
    932 *******************************************************************************/
    933 NFC_API extern tNFA_STATUS NFA_UpdateRFCommParams (tNFA_RF_COMM_PARAMS *p_params);
    934 
    935 /*******************************************************************************
    936 **
    937 ** Function         NFA_Deactivate
    938 **
    939 ** Description
    940 **                  If sleep_mode=TRUE:
    941 **                      Deselect the activated device by deactivating into sleep mode.
    942 **
    943 **                      An NFA_DEACTIVATE_FAIL_EVT indicates that selection was not successful.
    944 **                      Application can select another discovered device or deactivate by NFA_Deactivate ()
    945 **                      after receiving NFA_DEACTIVATED_EVT.
    946 **
    947 **                      Deactivating to sleep mode is not allowed when NFCC is in wait-for-host-select
    948 **                      mode, or in listen-sleep states; NFA will deactivate to idle or discovery state
    949 **                      for these cases respectively.
    950 **
    951 **
    952 **                  If sleep_mode=FALSE:
    953 **                      Deactivate the connection (e.g. as a result of presence check failure)
    954 **                      NFA_DEACTIVATED_EVT will indicate that link is deactivated.
    955 **                      Polling/listening will resume (unless the nfcc is in wait_for-all-discoveries state)
    956 **
    957 **
    958 ** Returns          NFA_STATUS_OK if successfully initiated
    959 **                  NFA_STATUS_FAILED otherwise
    960 **
    961 *******************************************************************************/
    962 NFC_API extern tNFA_STATUS NFA_Deactivate (BOOLEAN sleep_mode);
    963 
    964 /*******************************************************************************
    965 **
    966 ** Function         NFA_SendRawFrame
    967 **
    968 ** Description      Send a raw frame over the activated interface with the NFCC.
    969 **                  This function can only be called after NFC link is activated.
    970 **
    971 ** Returns          NFA_STATUS_OK if successfully initiated
    972 **                  NFA_STATUS_FAILED otherwise
    973 **
    974 *******************************************************************************/
    975 NFC_API extern tNFA_STATUS NFA_SendRawFrame (UINT8  *p_raw_data,
    976                                              UINT16  data_len);
    977 
    978 /*******************************************************************************
    979 ** NDEF APIs
    980 *******************************************************************************/
    981 
    982 /*******************************************************************************
    983 **
    984 ** Function         NFA_RegisterNDefTypeHandler
    985 **
    986 ** Description      This function allows the applications to register for
    987 **                  specific types of NDEF records. When NDEF records are
    988 **                  received, NFA will parse the record-type field, and pass
    989 **                  the record to the registered tNFA_NDEF_CBACK.
    990 **
    991 **                  For records types which were not registered, the record will
    992 **                  be sent to the default handler. A default type-handler may
    993 **                  be registered by calling this NFA_RegisterNDefTypeHandler
    994 **                  with tnf=NFA_TNF_DEFAULT. In this case, all un-registered
    995 **                  record types will be sent to the callback. Only one default
    996 **                  handler may be registered at a time.
    997 **
    998 **                  An NFA_NDEF_REGISTER_EVT will be sent to the tNFA_NDEF_CBACK
    999 **                  to indicate that registration was successful, and provide a
   1000 **                  handle for this record type.
   1001 **
   1002 **
   1003 ** Returns          NFA_STATUS_OK if successfully initiated
   1004 **                  NFA_STATUS_FAILED otherwise
   1005 **
   1006 *******************************************************************************/
   1007 NFC_API extern tNFA_STATUS NFA_RegisterNDefTypeHandler (BOOLEAN          handle_whole_message,
   1008                                                         tNFA_TNF         tnf,
   1009                                                         UINT8           *p_type_name,
   1010                                                         UINT8            type_name_len,
   1011                                                         tNFA_NDEF_CBACK *p_ndef_cback);
   1012 
   1013 /*******************************************************************************
   1014 **
   1015 ** Function         NFA_RegisterNDefUriHandler
   1016 **
   1017 ** Description      This API is a special-case of NFA_RegisterNDefTypeHandler
   1018 **                  with TNF=NFA_TNF_WKT, and type_name='U' (URI record); and allows
   1019 **                  registering for specific URI types (e.g. 'tel:' or 'mailto:').
   1020 **
   1021 **                  An NFA_NDEF_REGISTER_EVT will be sent to the tNFA_NDEF_CBACK
   1022 **                  to indicate that registration was successful, and provide a
   1023 **                  handle for this registration.
   1024 **
   1025 **                  If uri_id=NFA_NDEF_URI_ID_ABSOLUTE, then p_abs_uri contains the
   1026 **                  unabridged URI. For all other uri_id values, the p_abs_uri
   1027 **                  parameter is ignored (i.e the URI prefix is implied by uri_id).
   1028 **                  See [NFC RTD URI] for more information.
   1029 **
   1030 ** Returns          NFA_STATUS_OK if successfully initiated
   1031 **                  NFA_STATUS_FAILED otherwise
   1032 **
   1033 *******************************************************************************/
   1034 NFC_API extern tNFA_STATUS NFA_RegisterNDefUriHandler (BOOLEAN          handle_whole_message,
   1035                                                        tNFA_NDEF_URI_ID uri_id,
   1036                                                        UINT8            *p_abs_uri,
   1037                                                        UINT8            uri_id_len,
   1038                                                        tNFA_NDEF_CBACK  *p_ndef_cback);
   1039 
   1040 
   1041 /*******************************************************************************
   1042 **
   1043 ** Function         NFA_DeregisterNDefTypeHandler
   1044 **
   1045 ** Description      Deregister NDEF record type handler.
   1046 **
   1047 ** Returns          NFA_STATUS_OK if successfully initiated
   1048 **                  NFA_STATUS_FAILED otherwise
   1049 **
   1050 *******************************************************************************/
   1051 NFC_API extern tNFA_STATUS NFA_DeregisterNDefTypeHandler (tNFA_HANDLE ndef_type_handle);
   1052 
   1053 
   1054 /*******************************************************************************
   1055 **
   1056 ** Function         NFA_PowerOffSleepMode
   1057 **
   1058 ** Description      This function is called to enter or leave NFCC Power Off Sleep mode
   1059 **                  NFA_DM_PWR_MODE_CHANGE_EVT will be sent to indicate status.
   1060 **
   1061 **                  start_stop : TRUE if entering Power Off Sleep mode
   1062 **                               FALSE if leaving Power Off Sleep mode
   1063 **
   1064 Note??
   1065 ** Returns          NFA_STATUS_OK if successfully initiated
   1066 **                  NFA_STATUS_FAILED otherwise
   1067 **
   1068 *******************************************************************************/
   1069 NFC_API extern tNFA_STATUS NFA_PowerOffSleepMode (BOOLEAN start_stop);
   1070 
   1071 /*******************************************************************************
   1072 **
   1073 ** Function         NFA_RegVSCback
   1074 **
   1075 ** Description      This function is called to register or de-register a callback
   1076 **                  function to receive Proprietary NCI response and notification
   1077 **                  events.
   1078 **                  The maximum number of callback functions allowed is NFC_NUM_VS_CBACKS
   1079 **
   1080 ** Returns          tNFC_STATUS
   1081 **
   1082 *******************************************************************************/
   1083 NFC_API extern tNFC_STATUS NFA_RegVSCback (BOOLEAN          is_register,
   1084                                            tNFA_VSC_CBACK   *p_cback);
   1085 
   1086 /*******************************************************************************
   1087 **
   1088 ** Function         NFA_SendVsCommand
   1089 **
   1090 ** Description      This function is called to send an NCI Vendor Specific
   1091 **                  command to NFCC.
   1092 **
   1093 **                  oid             - The opcode of the VS command.
   1094 **                  cmd_params_len  - The command parameter len
   1095 **                  p_cmd_params    - The command parameter
   1096 **                  p_cback         - The callback function to receive the command
   1097 **                                    status
   1098 **
   1099 ** Returns          NFA_STATUS_OK if successfully initiated
   1100 **                  NFA_STATUS_FAILED otherwise
   1101 **
   1102 *******************************************************************************/
   1103 NFC_API extern tNFA_STATUS NFA_SendVsCommand (UINT8            oid,
   1104                                               UINT8            cmd_params_len,
   1105                                               UINT8            *p_cmd_params,
   1106                                               tNFA_VSC_CBACK   *p_cback);
   1107 
   1108 /*******************************************************************************
   1109 **
   1110 ** Function         NFA_SetTraceLevel
   1111 **
   1112 ** Description      This function sets the trace level for NFA.  If called with
   1113 **                  a value of 0xFF, it simply returns the current trace level.
   1114 **
   1115 ** Returns          The new or current trace level
   1116 **
   1117 *******************************************************************************/
   1118 NFC_API extern UINT8 NFA_SetTraceLevel (UINT8 new_level);
   1119 
   1120 
   1121 #ifdef __cplusplus
   1122 }
   1123 #endif
   1124 
   1125 #endif /* NFA_API_H */
   1126 
   1127