1 /* 2 * Copyright 2010-2018, 2020-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 /* 18 * NFC Status Values - Function Return Codes 19 */ 20 21 #ifndef PHNFCSTATUS_H 22 #define PHNFCSTATUS_H 23 24 #include <phNfcTypes.h> 25 26 /* Internally required by PHNFCSTVAL. */ 27 #define PHNFCSTSHL8 (8U) 28 /* Required by PHNFCSTVAL. */ 29 #define PHNFCSTBLOWER ((NFCSTATUS)(0x00FFU)) 30 31 /* 32 * NFC Status Composition Macro 33 * 34 * This is the macro which must be used to compose status values. 35 * 36 * phNfcCompID Component ID, as defined in phNfcCompId.h . 37 * phNfcStatus Status values, as defined in phNfcStatus.h . 38 * 39 * The macro is not required for the NFCSTATUS_SUCCESS value. 40 * This is the only return value to be used directly. 41 * For all other values it shall be used in assignment and conditional 42 * statements, e.g.: 43 * NFCSTATUS status = PHNFCSTVAL(phNfcCompID, phNfcStatus); ... 44 * if (status == PHNFCSTVAL(phNfcCompID, phNfcStatus)) ... 45 */ 46 #define PHNFCSTVAL(phNfcCompID, phNfcStatus) \ 47 (((phNfcStatus) == (NFCSTATUS_SUCCESS)) \ 48 ? (NFCSTATUS_SUCCESS) \ 49 : ((((NFCSTATUS)(phNfcStatus)) & (PHNFCSTBLOWER)) | \ 50 (((uint16_t)(phNfcCompID)) << (PHNFCSTSHL8)))) 51 52 /* 53 * PHNFCSTATUS 54 * Get grp_retval from Status Code 55 */ 56 #define PHNFCSTATUS(phNfcStatus) ((phNfcStatus)&0x00FFU) 57 #define PHNFCCID(phNfcStatus) (((phNfcStatus)&0xFF00U) >> 8) 58 59 #define PHNFC_I2C_FRAGMENT_SIZE 554 60 /* 61 * Status Codes 62 * 63 * Generic Status codes for the NFC components. Combined with the Component ID 64 * they build the value (status) returned by each function. 65 * Example: 66 * grp_comp_id "Component ID" - e.g. 0x10, plus 67 * status code as listed in this file - e.g. 0x03 68 * result in a status value of 0x0003. 69 */ 70 71 /* 72 * The function indicates successful completion 73 */ 74 #define NFCSTATUS_SUCCESS (0x0000) 75 76 /* 77 * The function indicates successful completion 78 */ 79 #define NFCSTATUS_OK (NFCSTATUS_SUCCESS) 80 81 /* 82 * At least one parameter could not be properly interpreted 83 */ 84 #define NFCSTATUS_INVALID_PARAMETER (0x0001) 85 86 /* 87 * The buffer provided by the caller is too small 88 */ 89 #define NFCSTATUS_BUFFER_TOO_SMALL (0x0003) 90 91 /* 92 * The function indicates given module not initialized 93 */ 94 #define NFC_STATUS_NOT_INITIALIZED_PROP (0x0004) 95 96 /* 97 * The function indicates given module not initialized 98 */ 99 #define NFCSTATUS_FW_CHECK_INTEGRITY_FAILED (0x0005) 100 101 /* 102 * Device specifier/handle value is invalid for the operation 103 */ 104 #define NFCSTATUS_INVALID_DEVICE (0x0006) 105 106 /* 107 * The function executed successfully but could have returned 108 * more information than space provided by the caller 109 */ 110 #define NFCSTATUS_MORE_INFORMATION (0x0008) 111 112 /* 113 * No response from the remote device received: Time-out 114 */ 115 #define NFCSTATUS_RF_TIMEOUT (0x0009) 116 117 /* 118 * RF Error during data transaction with the remote device 119 */ 120 #define NFCSTATUS_RF_ERROR (0x000A) 121 122 /* 123 * Not enough resources Memory, Timer etc(e.g. allocation failed.) 124 */ 125 #define NFCSTATUS_INSUFFICIENT_RESOURCES (0x000C) 126 127 /* 128 * A non-blocking function returns this immediately to indicate 129 * that an internal operation is in progress 130 */ 131 #define NFCSTATUS_PENDING (0x000D) 132 133 /* 134 * A board communication error occurred 135 * (e.g. Configuration went wrong) 136 */ 137 #define NFCSTATUS_BOARD_COMMUNICATION_ERROR (0x000F) 138 139 /* 140 * Invalid State of the particular state machine 141 */ 142 #define NFCSTATUS_INVALID_STATE (0x0011) 143 144 /* 145 * This Layer is Not initialized, hence initialization required. 146 */ 147 #define NFCSTATUS_NOT_INITIALISED (0x0031) 148 149 /* 150 * The Layer is already initialized, hence initialization repeated. 151 */ 152 #define NFCSTATUS_ALREADY_INITIALISED (0x0032) 153 154 /* 155 * Feature not supported 156 */ 157 #define NFCSTATUS_FEATURE_NOT_SUPPORTED (0x0033) 158 159 /* The Unregistration command has failed because the user wants to unregister 160 * on an element for which user was not registered 161 */ 162 #define NFCSTATUS_NOT_REGISTERED (0x0034) 163 164 /* The Registration command has failed because the user wants to register on 165 * an element for which user is already registered 166 */ 167 #define NFCSTATUS_ALREADY_REGISTERED (0x0035) 168 169 /* Single Tag with Multiple 170 Protocol support detected */ 171 #define NFCSTATUS_MULTIPLE_PROTOCOLS (0x0036) 172 173 /* 174 * Feature not supported 175 */ 176 #define NFCSTATUS_MULTIPLE_TAGS (0x0037) 177 178 /* 179 * A DESELECT event has occurred 180 */ 181 #define NFCSTATUS_DESELECTED (0x0038) 182 183 /* 184 * A RELEASE event has occurred 185 */ 186 #define NFCSTATUS_RELEASED (0x0039) 187 188 /* 189 * The operation is currently not possible or not allowed 190 */ 191 #define NFCSTATUS_NOT_ALLOWED (0x003A) 192 193 /* 194 * FW version error while performing FW download, 195 * FW major version mismatch (cannot downgrade FW major version) or FW version 196 * already upto date 197 * User may be trying to flash Mobile FW on top of Infra FW, which is not 198 * allowed 199 * Download appropriate version of FW 200 */ 201 #define NFCSTATUS_FW_VERSION_ERROR (0x003C) 202 203 /* 204 * The system is busy with the previous operation. 205 */ 206 #define NFCSTATUS_BUSY (0x006F) 207 208 /* NDEF Mapping error codes */ 209 210 /* The remote device (type) is not valid for this request. */ 211 #define NFCSTATUS_INVALID_REMOTE_DEVICE (0x001D) 212 213 /* Read operation failed */ 214 #define NFCSTATUS_READ_FAILED (0x0014) 215 216 /* 217 * Write operation failed 218 */ 219 #define NFCSTATUS_WRITE_FAILED (0x0015) 220 221 /* Non Ndef Compliant */ 222 #define NFCSTATUS_NO_NDEF_SUPPORT (0x0016) 223 224 /* Could not proceed further with the write operation: reached card EOF*/ 225 #define NFCSTATUS_EOF_NDEF_CONTAINER_REACHED (0x001A) 226 227 /* Incorrect number of bytes received from the card*/ 228 #define NFCSTATUS_INVALID_RECEIVE_LENGTH (0x001B) 229 230 /* The data format/composition is not understood/correct. */ 231 #define NFCSTATUS_INVALID_FORMAT (0x001C) 232 233 /* There is not sufficient storage available. */ 234 #define NFCSTATUS_INSUFFICIENT_STORAGE (0x001F) 235 236 /* The Ndef Format procedure has failed. */ 237 #define NFCSTATUS_FORMAT_ERROR (0x0023) 238 239 /* The NCI Cedit error */ 240 #define NFCSTATUS_CREDIT_TIMEOUT (0x0024) 241 242 /* 243 * Response Time out for the control message(NFCC not responded) 244 */ 245 #define NFCSTATUS_RESPONSE_TIMEOUT (0x0025) 246 247 /* 248 * Device is already connected 249 */ 250 #define NFCSTATUS_ALREADY_CONNECTED (0x0026) 251 252 /* 253 * Device is already connected 254 */ 255 #define NFCSTATUS_ANOTHER_DEVICE_CONNECTED (0x0027) 256 257 /* 258 * Single Target Detected and Activated 259 */ 260 #define NFCSTATUS_SINGLE_TAG_ACTIVATED (0x0028) 261 262 /* 263 * Single Target Detected 264 */ 265 #define NFCSTATUS_SINGLE_TAG_DISCOVERED (0x0029) 266 267 /* 268 * Secure element Detected and Activated 269 */ 270 #define NFCSTATUS_SECURE_ELEMENT_ACTIVATED (0x0028) 271 272 /* 273 * Unknown error Status Codes 274 */ 275 #define NFCSTATUS_UNKNOWN_ERROR (0x00FE) 276 277 /* 278 * Status code for failure 279 */ 280 #define NFCSTATUS_FAILED (0x00FF) 281 282 /* 283 * The function/command has been aborted 284 */ 285 #define NFCSTATUS_CMD_ABORTED (0x0002) 286 287 /* 288 * No target found after poll 289 */ 290 #define NFCSTATUS_NO_TARGET_FOUND (0x000A) 291 292 /* Attempt to disconnect a not connected remote device. */ 293 #define NFCSTATUS_NO_DEVICE_CONNECTED (0x000B) 294 295 /* External RF field detected. */ 296 #define NFCSTATUS_EXTERNAL_RF_DETECTED (0x000E) 297 298 /* Message is not allowed by the state machine 299 * (e.g. configuration went wrong) 300 */ 301 #define NFCSTATUS_MSG_NOT_ALLOWED_BY_FSM (0x0010) 302 303 /* 304 * No access has been granted 305 */ 306 #define NFCSTATUS_ACCESS_DENIED (0x001E) 307 308 /* No registry node matches the specified input data. */ 309 #define NFCSTATUS_NODE_NOT_FOUND (0x0017) 310 311 /* The current module is busy ; one might retry later */ 312 #define NFCSTATUS_SMX_BAD_STATE (0x00F0) 313 314 /* The Abort mechanism has failed for unexpected reason: user can try again*/ 315 #define NFCSTATUS_ABORT_FAILED (0x00F2) 316 317 /* The Registration command has failed because the user wants to register as 318 * target 319 * on a operating mode not supported 320 */ 321 #define NFCSTATUS_REG_OPMODE_NOT_SUPPORTED (0x00F5) 322 323 /* 324 * Shutdown in progress, cannot handle the request at this time. 325 */ 326 #define NFCSTATUS_SHUTDOWN (0x0091) 327 328 /* 329 * Target is no more in RF field 330 */ 331 #define NFCSTATUS_TARGET_LOST (0x0092) 332 333 /* 334 * Request is rejected 335 */ 336 #define NFCSTATUS_REJECTED (0x0093) 337 338 /* 339 * Target is not connected 340 */ 341 #define NFCSTATUS_TARGET_NOT_CONNECTED (0x0094) 342 343 /* 344 * Invalid handle for the operation 345 */ 346 #define NFCSTATUS_INVALID_HANDLE (0x0095) 347 348 /* 349 * Process aborted 350 */ 351 #define NFCSTATUS_ABORTED (0x0096) 352 353 /* 354 * Requested command is not supported 355 */ 356 #define NFCSTATUS_COMMAND_NOT_SUPPORTED (0x0097) 357 358 /* 359 * Tag is not NDEF compilant 360 */ 361 #define NFCSTATUS_NON_NDEF_COMPLIANT (0x0098) 362 363 /* 364 * Not enough memory available to complete the requested operation 365 */ 366 #define NFCSTATUS_NOT_ENOUGH_MEMORY (0x001F) 367 368 /* 369 * Indicates incoming connection 370 */ 371 #define NFCSTATUS_INCOMING_CONNECTION (0x0045) 372 373 /* 374 * Indicates Connection was successful 375 */ 376 #define NFCSTATUS_CONNECTION_SUCCESS (0x0046) 377 378 /* 379 * Indicates Connection failed 380 */ 381 #define NFCSTATUS_CONNECTION_FAILED (0x0047) 382 383 /* 384 * Indicates file is not present at the specified location 385 */ 386 #define NFCSTATUS_FILE_NOT_FOUND (0x0048) 387 388 /* 389 * Indicates force download is required 390 */ 391 #define NFCSTATUS_FORCE_FWDWNLD (0x0049) 392 393 #endif /* PHNFCSTATUS_H */ 394