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