1 /*
2  * Copyright 2017-2018,2021 NXP
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 #ifndef NCIBASE_H_
18 #define NCIBASE_H_
19 
20 #ifdef __cplusplus
21 extern "C" {
22 #endif
23 
24 class NCI_Base {
25  public:
26   typedef enum {
27     NCI_STATUS_OK = 0x00, /**< NCI common status code */
28     NCI_STATUS_REJECTED,
29     NCI_STATUS_RF_FRAME_CORRUPTED,
30     NCI_STATUS_FAILED,
31     NCI_STATUS_NOT_INITIALIZED,
32     NCI_STATUS_SYNTAX_ERROR,
33     NCI_STATUS_SEMANTIC_ERROR,
34     NCI_STATUS_UNKNOWN_GID,
35     NCI_STATUS_UNKNOWN_OID,
36     NCI_STATUS_INVALID_PARAM,
37     NCI_STATUS_MESSAGE_SIZE_EXCEEDED,
38     NCI_STATUS_OK_1BIT = 0x11,  //!< NCI 1.1 : NCI_STATUS_OK_1BIT to
39     NCI_STATUS_OK_2BIT,
40     NCI_STATUS_OK_3BIT,
41     NCI_STATUS_OK_4BIT,
42     NCI_STATUS_OK_5BIT,
43     NCI_STATUS_OK_6BIT,
44     NCI_STATUS_OK_7BIT,  //!< NCI 1.1 : NCI_STATUS_OK_7BIT
45     NCI_STATUS_DISCOVERY_ALREADY_STARTED = 0xA0,
46     NCI_STATUS_DISCOVERY_TARGET_ACTIVATION_FAILED,
47     NCI_STATUS_DISCOVERY_TEAR_DOWN,
48     NCI_STATUS_DISCOVERY_DETUNING_DETECTED,
49     NCI_STATUS_RF_TRANSMISSION_ERROR = 0xB0,
50     NCI_STATUS_RF_PROTOCOL_ERROR,
51     NCI_STATUS_RF_TIMEOUT_ERROR,
52     NCI_STATUS_RF_UNEXPECTED_DATA,
53     NCI_STATUS_NFCEE_INTERFACE_ACTIVATION_FAILED = 0xC0,
54     NCI_STATUS_NFCEE_TRANSMISSION_ERROR,
55     NCI_STATUS_NFCEE_PROTOCOL_ERROR,
56     NCI_STATUS_NFCEE_TIMEOUT_ERROR,
57     NCI_STATUS_DO_NOT_REPLY = 0xE0,  // Status to not reply on wrong packet
58     NCI_STATUS_BOOT_TRIM_CORRUPTED,
59     NCI_STATUS_PMU_TXLDO_OVERCURRENT = 0xE3,
60     NCI_STATUS_EMVCO_PCD_COLLISION,
61     NCI_STATUS_WIRED_SESSION_ABORTED,
62     NCI_STATUS_WIRED_SESSION_ABORT_TO,
63     NCI_STATUS_END_PARAMETER = 0xF1
64   } eNciStatusCodes_t;
65 
66   typedef enum {
67     NCI_MT_DATA_PKT,        /*000b*/
68     NCI_MT_CONTROL_PKT_CMD, /*001b*/
69     NCI_MT_CONTROL_PKT_RSP, /*010b*/
70     NCI_MT_CONTROL_PKT_NTF, /*011b*/
71     NCI_MT_RFU              /*100b to 111b*/
72   } eNciMsgType_t;
73 
74   typedef enum {
75     NCI_CONN_STATIC_FR_ID = 0x00,  // RFU due to Static
76     NCI_CONN_NFCC_LOOP_BACK_ID,
77     NCI_CONN_REMOTE_NFC_END_POINT_ID,
78     NCI_CONN_NFCEE_ID,
79     NCI_CONN_NFCEE_NDEF_ID = 0x05
80   } eNciConnIdentifier_t;
81 
82   typedef enum {
83     NCI_GID_CORE,
84     NCI_GID_RF_MNGT,
85     NCI_GID_NFCEE_MNGT,
86     NCI_GID_PROPRIETARY = 0xF,
87     NCI_NUMBER_OF_GID
88   } eNciGroupIdentifier_t;
89 
90   typedef enum {
91     NCI_OID_CORE_RESET,               /* 000000b */
92     NCI_OID_CORE_INIT,                /* 000001b */
93     NCI_OID_CORE_SET_CONFIG,          /* 000010b */
94     NCI_OID_CORE_GET_CONFIG,          /* 000011b */
95     NCI_OID_CORE_CONN_CREATE,         /* 000100b */
96     NCI_OID_CORE_CONN_CLOSE,          /* 000101b */
97     NCI_OID_CORE_CONN_CREDITS,        /* 000110b */
98     NCI_OID_CORE_GENERIC_ERROR,       /* 000111b */
99     NCI_OID_CORE_INTERFACE_ERROR,     /* 001000b */
100     NCI_OID_CORE_SET_POWER_SUB_STATE, /* 001001b */
101     NCI_NUMBER_OF_CORE_OID
102   } eNciCoreOpcodeIdentifier_t;
103 
104   typedef enum {
105     NCI_OID_RF_DISCOVER_MAP = 0x00,          /* 000000b */
106     NCI_OID_RF_SET_LISTEN_MODE_ROUTING,      /* 000001b */
107     NCI_OID_RF_GET_LISTEN_MODE_ROUTING,      /* 000010b */
108     NCI_OID_RF_DISCOVER,                     /* 000011b */
109     NCI_OID_RF_DISCOVER_SELECT,              /* 000100b */
110     NCI_OID_RF_INTF_ACTIVATE,                /* 000101b */
111     NCI_OID_RF_DEACTIVATE,                   /* 000110b */
112     NCI_OID_RF_FIELD_INFO,                   /* 000111b */
113     NCI_OID_RF_T3T_POLLING,                  /* 001000b */
114     NCI_OID_RF_NFCEE_ACTION,                 /* 001001b */
115     NCI_OID_RF_NFCEE_DISCOVERY_REQ,          /* 001010b */
116     NCI_OID_RF_PARAMETER_UPDATE,             /* 001011b */
117     NCI_OID_RF_INTF_EXT_START,               /* 001100b */
118     NCI_OID_RF_INTF_EXT_STOP,                /* 001101b */
119     NCI_OID_RF_EXT_AGG_ABORT,                /* 001110b */
120     NCI_OID_RF_NDEF_ABORT,                   /* 001111b */
121     NCI_OID_RF_ISO_DEP_NAK_PRESENCE_CMD,     /* 010000b */
122     NCI_OID_RF_SET_FORCED_NFCEE_ROUTING_CMD, /* 010001b */
123     NCI_OID_RF_VAS_NTF = 0x20,               /* 010000b */
124     NCI_OID_RF_PLL_UNLOCKED_NTF = 0x21,      /* 010001b */
125     NCI_OID_RF_RAPDU_SENT_NTF = 0x22,        /* 010010b */
126     NCI_OID_RF_TXLDO_ERROR_NTF = 0x23
127   } eNciRfMgmtOpcodeIdentifier_t;
128 
129   typedef enum {
130     NCI_OID_NFCEE_DISCOVER,                /* 000000b */
131     NCI_OID_NFCEE_MODE_SET,                /* 000001b */
132     NCI_OID_NFCEE_STATUS,                  /* 000010b */
133     NCI_OID_NFCEE_POWER_AND_LINK_CNTRL,    /* 000011b */
134     NCI_OID_NFCEE_MODE_SET_SINGLE = 0x3C,  /* 111100b */
135     NCI_OID_NFCEE_MODE_SET_HCI_NWK_ENABLE, /* 111101b */
136     NCI_OID_NFCEE_MODE_SET_DISABLE,        /* 111110b */
137     NCI_OID_NFCEE_END_PARAMETER            /* 111111b */
138   } eNciNfceeOpcodeIdentifier_t;
139 
140   NCI_Base();
141   virtual ~NCI_Base();
142 
143  private:
144   typedef enum {
145     NCI_OID_SYSTEM_SET_POWERMGT,
146     NCI_OID_SYSTEM_GET_POWERMGT,
147     NCI_OID_SYSTEM_PROPRIETARY_ACT = 0x02,
148     NCI_OID_SYSTEM_CHANGE_HSU_BAUDRATE = 0x03,
149     NCI_OID_SYSTEM_FW_DEBUG = 0x04,
150     NCI_OID_SYSTEM_RF_ISO_DEP_PRES_CHECK = 0x11,
151     NCI_OID_SYSTEM_RF_MF_PLUS_PROX_CHECK = 0x12,
152     NCI_OID_SYSTEM_RF_TAG_DETECTOR = 0x13,
153     NCI_OID_SYSTEM_RF_GET_RF_TRANSITION = 0x14,
154     NCI_OID_SYSTEM_PHONE_SCREEN_STATE = 0x15,
155     NCI_OID_SYSTEM_RFU1 = 0x16,
156     NCI_OID_SYSTEM_WTX = 0x17,
157     NCI_OID_SYSTEM_NFCEE_MODESET_DISABLE_NTF = 0x18,
158     NCI_OID_SYSTEM_EOOP = 0x20,
159     NCI_OID_SYSTEM_TEST_FAKE_WAKE_ON_RF_FIELD = 0x28,
160     NCI_OID_SYSTEM_KEEP_NFCEE_POWERED_ON = 0x29,
161     NCI_OID_SYSTEM_TEST_PRBS = 0x30,
162     NCI_OID_SYSTEM_TEST_TESTBUS_CONFIG = 0x31,
163     NCI_OID_SYSTEM_SVDD_PWRREQ_CONTROL = 0x31,
164     NCI_OID_SYSTEM_TEST_READ_RF_INTERNAL_REGISTER = 0x32,
165     NCI_OID_SYSTEM_MANUFACTURING_BUILD_TESTS_API = 0x33,
166     NCI_OID_SYSTEM_ENABLE_READER_MODE_LM_DECODING_NTF = 0x34,
167     NCI_OID_SYSTEM_DEBUG_STATE_L1_MESSAGE = 0x35,
168     NCI_OID_SYSTEM_DEBUG_STATE_L2_MESSAGE,
169     NCI_OID_SYSTEM_DEBUG_STATE_L3_MESSAGE,
170     NCI_OID_SYSTEM_TEST_CORE_DUMP = 0x3B, /* NFCC6872 */
171     NCI_OID_SYSTEM_STAG_GET_RFSTATUS = 0x39,
172     NCI_OID_SYSTEM_STAG_STOP_AUTH = 0x3A,
173     NCI_OID_SYSTEM_STAG_START_AUTH_XCHG = 0x3B,
174     NCI_OID_SYSTEM_STAG_START_AUTH = 0x3C,
175     NCI_OID_SYSTEM_TEST_ANTENNA = 0x3D,
176     NCI_OID_SYSTEM_TEST_SWP_INTERFACE = 0x3E,
177     NCI_OID_SYSTEM_RF_DEBUG = 0x3F,
178     NCI_OID_SYSTEM_END_PARAMETER = 0x40
179   } eNciSystemPropOpcodeIdentifier_t;
180 };
181 
182 #ifdef __cplusplus
183 }  // extern
184 #endif
185 
186 #endif /* NCIBASE_H_ */
187