Home | History | Annotate | Download | only in common
      1 /*
      2  * Copyright (C) 2015 The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 
     17 /*
     18  * NCI Interface
     19  */
     20 
     21 #ifndef PHNCINFCTYPES_H
     22 #define PHNCINFCTYPES_H
     23 
     24 /*
     25  ################################################################################
     26  ***************************** Header File Inclusion ****************************
     27  ################################################################################
     28  */
     29 #include <phNfcStatus.h>
     30 
     31 /*
     32  ################################################################################
     33  ****************************** Macro Definitions *******************************
     34  ################################################################################
     35  */
     36 #define PH_NCINFCTYPES_MAX_UID_LENGTH           (0x0AU)
     37 /* Maximum length of ATR_RES (General Bytes) length expected */
     38 #define PH_NCINFCTYPES_MAX_ATR_LENGTH           (0x30U)
     39 #define PH_NCINFCTYPES_ATQA_LENGTH              (0x02U)    /* ATQA length */
     40 #define PH_NCINFCTYPES_MAX_HIST_BYTES           (0x0FU)    /* Max Historical bytes returned by Type A tag */
     41 
     42 /*
     43  * Enum definition contains supported RF Protocols
     44  */
     45 typedef enum
     46 {
     47     phNciNfc_e_RfProtocolsUnknownProtocol = 0x00,  /* Protocol is not known */
     48     phNciNfc_e_RfProtocolsT1tProtocol     = 0x01,  /* Type 1 Tag protocol */
     49     phNciNfc_e_RfProtocolsT2tProtocol     = 0x02,  /* Type 2 Tag protocol */
     50     phNciNfc_e_RfProtocolsT3tProtocol     = 0x03,  /* Type 3 Tag protocol */
     51     phNciNfc_e_RfProtocolsIsoDepProtocol  = 0x04,  /* ISO DEP protocol */
     52     phNciNfc_e_RfProtocolsNfcDepProtocol  = 0x05,  /* NFC DEP protocol */
     53     phNciNfc_e_RfProtocols15693Protocol   = 0x06,  /* 15693 protocol */
     54     phNciNfc_e_RfProtocolsMifCProtocol    = 0x80,  /* Mifare Classic protocol */
     55     phNciNfc_e_RfProtocolsHidProtocol     = 0x81,  /* Hid protocol */
     56     phNciNfc_e_RfProtocolsEpcGen2Protocol = 0x82,  /* EpcGen2 protocol */
     57     phNciNfc_e_RfProtocolsKovioProtocol   = 0x83   /* Kovio protocol */
     58 } phNciNfc_RfProtocols_t;
     59 
     60 /*
     61  * Supported RF Interfaces
     62  */
     63 typedef enum
     64 {
     65     phNciNfc_e_RfInterfacesNfceeDirect_RF = 0x00,   /* Nfcee Direct RF Interface */
     66     phNciNfc_e_RfInterfacesFrame_RF =       0x01,   /* Frame RF Interface */
     67     phNciNfc_e_RfInterfacesISODEP_RF =      0x02,   /* ISO DEP RF Interface */
     68     phNciNfc_e_RfInterfacesNFCDEP_RF =      0x03,   /* NFC DEP RF Interface */
     69     phNciNfc_e_RfInterfacesTagCmd_RF =      0x80,   /* Tag-Cmd RF Interface (Nxp prop) */
     70     phNciNfc_e_RfInterfacesHID_RF =         0x81    /* Hid RF Interface (Nxp prop) */
     71 } phNciNfc_RfInterfaces_t;
     72 
     73 /*
     74  * Enum definition contains RF technology modes supported.
     75  * This information is a part of RF_DISCOVER_NTF or RF_INTF_ACTIVATED_NTF.
     76  */
     77 typedef enum
     78 {
     79     phNciNfc_NFCA_Poll                 = 0x00,  /* Nfc A Technology in Poll Mode */
     80     phNciNfc_NFCB_Poll                 = 0x01,  /* Nfc B Technology in Poll Mode */
     81     phNciNfc_NFCF_Poll                 = 0x02,  /* Nfc F Technology in Poll Mode */
     82     phNciNfc_NFCA_Active_Poll          = 0x03,  /* Nfc A Technology in Active Poll Mode */
     83     phNciNfc_NFCF_Active_Poll          = 0x05,  /* Nfc F Technology in Active Poll Mode */
     84     phNciNfc_NFCISO15693_Poll          = 0x06, /* Nfc ISO15693 Technology in Poll Mode */
     85     phNciNfc_NxpProp_NFCHID_Poll       = 0x70,      /* Nfc Hid Technology in Poll Mode */
     86     phNciNfc_NxpProp_NFCEPFGEN2_Poll   = 0x71,  /* Nfc EpcGen2 Technology in Poll Mode */
     87     phNciNfc_NxpProp_NFCKOVIO_Poll     = 0x72,    /* Nfc Kovio Technology in Poll Mode */
     88     phNciNfc_NFCA_Listen               = 0x80,/* Nfc A Technology in Listen Mode */
     89     phNciNfc_NFCB_Listen               = 0x81,/* Nfc B Technology in Listen Mode */
     90     phNciNfc_NFCF_Listen               = 0x82,/* Nfc F Technology in Listen Mode */
     91     phNciNfc_NFCA_Active_Listen        = 0x83,/* Nfc A Technology in Active Listen Mode */
     92     phNciNfc_NFCF_Active_Listen        = 0x85,  /* Nfc F Technology in Active Listen Mode */
     93     phNciNfc_NFCISO15693_Active_Listen = 0x86   /* Nfc ISO15693 Technology in Listen Mode */
     94 } phNciNfc_RfTechMode_t;
     95 
     96 /*
     97  * This is used to identify the exact device type
     98  */
     99 typedef enum
    100 {
    101     phNciNfc_eUnknown_DevType        = 0x00U,
    102 
    103     /* Generic PICC Type */
    104     phNciNfc_ePICC_DevType,
    105     /* Specific PICC Devices */
    106     /* This PICC type explains that the card is compliant to the
    107      * ISO 14443-1 and 2A specification. This type can be used for the
    108      * cards that is supporting these specifications
    109      */
    110     phNciNfc_eISO14443_A_PICC,
    111     /* This PICC type explains that the card is compliant to the
    112      * ISO 14443-4A specification
    113      */
    114     phNciNfc_eISO14443_4A_PICC,
    115     /* This PICC type explains that the card is compliant to the
    116      * ISO 14443-3A specification
    117      */
    118     phNciNfc_eISO14443_3A_PICC,
    119     /* This PICC type explains that the card is Mifare UL/1k/4k and
    120      * also it is compliant to ISO 14443-3A. There can also be other
    121      * ISO 14443-3A cards, so the phNciNfc_eISO14443_3A_PICC is also used for
    122      * PICC detection
    123      */
    124     phNciNfc_eMifareUL_PICC,
    125     phNciNfc_eMifare1k_PICC,
    126     phNciNfc_eMifare4k_PICC,
    127     phNciNfc_eMifareMini_PICC,
    128     /* This PICC type explains that the card is compliant to the
    129      * ISO 14443-1, 2 and 3B specification
    130      */
    131     phNciNfc_eISO14443_B_PICC,
    132     /* This PICC type explains that the card is compliant to the
    133      * ISO 14443-4B specification
    134      */
    135     phNciNfc_eISO14443_4B_PICC,
    136     /* This PICC type explains that the card is B-Prime type */
    137     phNciNfc_eISO14443_BPrime_PICC,
    138     phNciNfc_eFelica_PICC,
    139     phNciNfc_eJewel_PICC,
    140     /* This PICC type explains that the card is ISO15693 type */
    141     phNciNfc_eISO15693_PICC,
    142     /* This PICC type explains that the card is EpcGen2 type */
    143     phNciNfc_eEpcGen_PICC,
    144 
    145     /* NFC-IP1 Device Types */
    146     phNciNfc_eNfcIP1_Target,
    147     phNciNfc_eNfcIP1_Initiator,
    148 
    149     /* Other Sources */
    150     phNciNfc_eInvalid_DevType
    151 
    152 }phNciNfc_RFDevType_t;
    153 
    154 /*
    155  * RATS Response Params structure
    156  */
    157 typedef struct phNciNfc_RATSResp {
    158     uint8_t   bFormatByte;                 /* Format Byte */
    159     uint8_t   bIByteTA;                    /* Interface Byte TA(1) */
    160     uint8_t   bIByteTB;                    /* Interface Byte TB(1) */
    161     uint8_t   bIByteTC;                    /* Interface Byte TC(1) */
    162     uint8_t   bHistByte[PH_NCINFCTYPES_MAX_HIST_BYTES];   /* Historical Bytes - Max size 15 */
    163 } phNciNfc_RATSResp_t;
    164 
    165 /*
    166  * The Reader A structure includes the available information
    167  * related to the discovered ISO14443A remote device. This information
    168  * is updated for every device discovery.
    169  */
    170 typedef struct phNciNfc_Iso14443AInfo
    171 {
    172     uint8_t         Uid[PH_NCINFCTYPES_MAX_UID_LENGTH]; /* UID information of the TYPE A
    173                                                         Tag Discovered NFCID1 -
    174                                                         Considering max size of NFCID1*/
    175     uint8_t         UidLength;                          /* UID information length, shall not be greater
    176                                                         than PHNCINFC_MAX_UID_LENGTH i.e., 10 */
    177     uint8_t         AppData[PH_NCINFCTYPES_MAX_ATR_LENGTH]; /* Application data information of the
    178                                                         tag discovered (= Historical bytes for
    179                                                         type A) */
    180     uint8_t         AppDataLength;                      /* Application data length */
    181     uint8_t         Sak;                                /* SAK information of the TYPE ATag Discovered
    182                                                         Mapped to SEL_RES Response*/
    183     uint8_t         AtqA[PH_NCINFCTYPES_ATQA_LENGTH];        /* ATQA information of the TYPE A
    184                                                         Tag Discovered */
    185     uint8_t         MaxDataRate;                        /* Maximum data rate supported by the TYPE A
    186                                                         Tag Discovered */
    187     uint8_t         Fwi_Sfgt;                           /* Frame waiting time and start up frame guard
    188                                                         time as defined in ISO/IEC 14443-4[7] for type A */
    189     uint8_t         bSensResResp[2];                    /* SENS_RES Response */
    190     uint8_t         bSelResRespLen;                     /* SEL_RES Response Length */
    191     uint8_t         bRatsRespLen;                       /* Length of RATS Response */
    192     phNciNfc_RATSResp_t   tRatsResp;                    /* RATS Response Info */
    193 } phNciNfc_Iso14443AInfo_t;
    194 
    195 /*
    196  * The Remote Device Information Union includes the available Remote Device Information
    197  * structures. Following the device detected, the corresponding data structure is used.
    198  */
    199 typedef union phNciNfc_RemoteDevInfo
    200 {
    201     phNciNfc_Iso14443AInfo_t          Iso14443A_Info;/* Type A tag Info */
    202 } phNciNfc_RemoteDevInfo_t;
    203 
    204 /* Contains Details of Discovered Target */
    205 typedef struct phNciNfc_RemoteDevInformation
    206 {
    207     uint8_t                    SessionOpened;      /* Flag indicating the validity of the handle of the remote device. */
    208     phNciNfc_RFDevType_t       RemDevType;         /* Remote device type which says that remote
    209                                                     is Reader A or Reader B or NFCIP or Felica or
    210                                                     Reader B Prime or Jewel*/
    211     uint8_t bRfDiscId;                              /* ID of the Tag */
    212     phNciNfc_RfInterfaces_t    eRfIf;               /* RF Interface */
    213     phNciNfc_RfProtocols_t eRFProtocol;             /* RF protocol of the target */
    214     phNciNfc_RfTechMode_t eRFTechMode;              /* RF Technology mode of the discovered/activated target */
    215     uint8_t bMaxPayLoadSize;                        /* Max data payload size*/
    216     uint8_t bInitialCredit;                         /* Initial credit*/
    217     uint8_t bTechSpecificParamLen;                  /* Technology Specific parameter length, for Debugging purpose only*/
    218     phNciNfc_RfTechMode_t eDataXchgRFTechMode;      /* Data Exchange RF Technology mode of the activated target */
    219     uint8_t   bTransBitRate;                        /* Transmit Bit Rate */
    220     uint8_t   bRecvBitRate;                         /* Receive Bit Rate */
    221     phNciNfc_RemoteDevInfo_t tRemoteDevInfo;        /* Structure object to #phNciNfc_RemoteDevInfo_t*/
    222 } phNciNfc_RemoteDevInformation_t, *pphNciNfc_RemoteDevInformation_t;/* Pointer to Remote Dev Info*/
    223 
    224 /*
    225  * Structure contains buffer where payload of the received data packet
    226  * shall be stored and length of the payload stored in the buffer.
    227  */
    228 typedef struct phNciNfc_Data
    229 {
    230     uint8_t *pBuff;     /* Buffer to store received data packet's payload */
    231     uint16_t wLen;      /* Length of the payload */
    232 } phNciNfc_Data_t, *pphNciNfc_Data_t;
    233 
    234 
    235 /*
    236  * Type 2 tag command list supported by NCI stack
    237  * It includes command lists applicable to Mifare family cards also
    238  */
    239 typedef enum phNciNfc_T2TCmdList
    240 {
    241     phNciNfc_eT2TRaw    = 0x00,   /* Performs Raw communication over T2T Tag*/
    242     phNciNfc_eT2TWriteN,   /* Write Multiple blocks to T2T tag*/
    243     phNciNfc_eT2TreadN,   /* Read Multiple blocks to T2T tag*/
    244     phNciNfc_eT2TSectorSel,   /* Sector Select for MifareStd Cards*/
    245     phNciNfc_eT2TAuth,   /* Sector Select for MifareStd Cards*/
    246     phNciNfc_eT2TProxCheck,/* Proxy Check command for MF+*/
    247     phNciNfc_eT2TInvalidCmd /* Invalid Command*/
    248 } phNciNfc_T2TCmdList_t;    /* Type2 Tag and Mifare specicific command list*/
    249 
    250 /* All command list for tag operation supported by NCI stack */
    251 typedef union phNciNfc_TagCmdList
    252 {
    253     phNciNfc_T2TCmdList_t T2TCmd; /* T2T Specific command*/
    254 } phNciNfc_TagCmdList_t; /* Tag specific command */
    255 
    256 /* Transceive info */
    257 typedef struct phNciNfc_TransceiveInfo
    258 {
    259     phNciNfc_TagCmdList_t   uCmd;     /* Technology Specific commands */
    260     uint8_t                 bAddr;    /* Start address to perform operation,Valid for T1T T2T T3T and some Propriatery tags */
    261     uint8_t                 bNumBlock;/* Number of blocks */
    262     uint16_t                wTimeout; /* Timeout value to be used during transceive */
    263     phNciNfc_Data_t         tSendData;/* Buffer information for sending data */
    264     phNciNfc_Data_t         tRecvData;/* Buffer information for receiving data */
    265     /* Details for Felica To be Added if Check and Update supported */
    266 } phNciNfc_TransceiveInfo_t, *pphNciNfc_TransceiveInfo_t; /* pointer to struct #phNciNfc_TransceiveInfo_t */
    267 
    268 #endif                          /* end of #ifndef PHNCINFCTYPES_H */
    269