aboutsummaryrefslogtreecommitdiff
path: root/pn54x/common/phNfcStatus.h
blob: f3aa51ad3e440a008ae66c7b3342b5de55c585ec (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
/*
 * Copyright (C) 2010-2014 NXP Semiconductors
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/*
 * NFC Status Values - Function Return Codes
 */

#ifndef PHNFCSTATUS_H
#define PHNFCSTATUS_H

#include <phNfcTypes.h>

/* Internally required by PHNFCSTVAL. */
#define PHNFCSTSHL8 (8U)
/* Required by PHNFCSTVAL. */
#define PHNFCSTBLOWER ((NFCSTATUS)(0x00FFU))

/*
 *  NFC Status Composition Macro
 *
 *  This is the macro which must be used to compose status values.
 *
 *  phNfcCompID Component ID, as defined in phNfcCompId.h .
 *  phNfcStatus Status values, as defined in phNfcStatus.h .
 *
 *  The macro is not required for the NFCSTATUS_SUCCESS value.
 *  This is the only return value to be used directly.
 *  For all other values it shall be used in assignment and conditional
 * statements, e.g.:
 *     NFCSTATUS status = PHNFCSTVAL(phNfcCompID, phNfcStatus); ...
 *     if (status == PHNFCSTVAL(phNfcCompID, phNfcStatus)) ...
 */
#define PHNFCSTVAL(phNfcCompID, phNfcStatus)               \
  (((phNfcStatus) == (NFCSTATUS_SUCCESS))                  \
       ? (NFCSTATUS_SUCCESS)                               \
       : ((((NFCSTATUS)(phNfcStatus)) & (PHNFCSTBLOWER)) | \
          (((uint16_t)(phNfcCompID)) << (PHNFCSTSHL8))))

/*
 * PHNFCSTATUS
 * Get grp_retval from Status Code
 */
#define PHNFCSTATUS(phNfcStatus) ((phNfcStatus)&0x00FFU)
#define PHNFCCID(phNfcStatus) (((phNfcStatus)&0xFF00U) >> 8)

#define PHNFC_I2C_FRAGMENT_SIZE 512
/*
 *  Status Codes
 *
 *  Generic Status codes for the NFC components. Combined with the Component ID
 *  they build the value (status) returned by each function.
 *  Example:
 *      grp_comp_id "Component ID" -  e.g. 0x10, plus
 *      status code as listed in this file - e.g. 0x03
 *      result in a status value of 0x0003.
 */

/*
 * The function indicates successful completion
 */
#define NFCSTATUS_SUCCESS (0x0000)

/*
 *  The function indicates successful completion
 */
#define NFCSTATUS_OK (NFCSTATUS_SUCCESS)

/*
 * At least one parameter could not be properly interpreted
 */
#define NFCSTATUS_INVALID_PARAMETER (0x0001)

/*
 * The buffer provided by the caller is too small
 */
#define NFCSTATUS_BUFFER_TOO_SMALL (0x0003)

/*
 * Device specifier/handle value is invalid for the operation
 */
#define NFCSTATUS_INVALID_DEVICE (0x0006)

/*
 * The function executed successfully but could have returned
 * more information than space provided by the caller
 */
#define NFCSTATUS_MORE_INFORMATION (0x0008)

/*
 * No response from the remote device received: Time-out
 */
#define NFCSTATUS_RF_TIMEOUT (0x0009)

/*
 * RF Error during data transaction with the remote device
 */
#define NFCSTATUS_RF_ERROR (0x000A)

/*
 * Not enough resources Memory, Timer etc(e.g. allocation failed.)
 */
#define NFCSTATUS_INSUFFICIENT_RESOURCES (0x000C)

/*
 * A non-blocking function returns this immediately to indicate
 * that an internal operation is in progress
 */
#define NFCSTATUS_PENDING (0x000D)

/*
 * A board communication error occurred
 * (e.g. Configuration went wrong)
 */
#define NFCSTATUS_BOARD_COMMUNICATION_ERROR (0x000F)

/*
 * Invalid State of the particular state machine
 */
#define NFCSTATUS_INVALID_STATE (0x0011)

/*
 * This Layer is Not initialized, hence initialization required.
 */
#define NFCSTATUS_NOT_INITIALISED (0x0031)

/*
 * The Layer is already initialized, hence initialization repeated.
 */
#define NFCSTATUS_ALREADY_INITIALISED (0x0032)

/*
 * Feature not supported
 */
#define NFCSTATUS_FEATURE_NOT_SUPPORTED (0x0033)

/*  The Unregistration command has failed because the user wants to unregister
 * on
 * an element for which he was not registered
 */
#define NFCSTATUS_NOT_REGISTERED (0x0034)

/* The Registration command has failed because the user wants to register on
 * an element for which he is already registered
 */
#define NFCSTATUS_ALREADY_REGISTERED (0x0035)

/*  Single Tag with Multiple
    Protocol support detected */
#define NFCSTATUS_MULTIPLE_PROTOCOLS (0x0036)

/*
 * Feature not supported
 */
#define NFCSTATUS_MULTIPLE_TAGS (0x0037)

/*
 * A DESELECT event has occurred
 */
#define NFCSTATUS_DESELECTED (0x0038)

/*
 * A RELEASE event has occurred
 */
#define NFCSTATUS_RELEASED (0x0039)

/*
 * The operation is currently not possible or not allowed
 */
#define NFCSTATUS_NOT_ALLOWED (0x003A)

/*
 * FW version error while performing FW download,
 * FW major version mismatch (cannot downgrade FW major version) or FW version
 * already upto date
 * User may be trying to flash Mobile FW on top of Infra FW, which is not
 * allowed
 * Download appropriate version of FW
 */
#define NFCSTATUS_FW_VERSION_ERROR (0x003C)

/*
 *  The system is busy with the previous operation.
 */
#define NFCSTATUS_BUSY (0x006F)

/* NDEF Mapping error codes */

/* The remote device (type) is not valid for this request. */
#define NFCSTATUS_INVALID_REMOTE_DEVICE (0x001D)

/* Read operation failed */
#define NFCSTATUS_READ_FAILED (0x0014)

/*
 * Write operation failed
 */
#define NFCSTATUS_WRITE_FAILED (0x0015)

/* Non Ndef Compliant */
#define NFCSTATUS_NO_NDEF_SUPPORT (0x0016)

/* Could not proceed further with the write operation: reached card EOF*/
#define NFCSTATUS_EOF_NDEF_CONTAINER_REACHED (0x001A)

/* Incorrect number of bytes received from the card*/
#define NFCSTATUS_INVALID_RECEIVE_LENGTH (0x001B)

/* The data format/composition is not understood/correct. */
#define NFCSTATUS_INVALID_FORMAT (0x001C)

/* There is not sufficient storage available. */
#define NFCSTATUS_INSUFFICIENT_STORAGE (0x001F)

/* The Ndef Format procedure has failed. */
#define NFCSTATUS_FORMAT_ERROR (0x0023)

/* The NCI Cedit error */
#define NFCSTATUS_CREDIT_TIMEOUT (0x0024)

/*
 * Response Time out for the control message(NFCC not responded)
 */
#define NFCSTATUS_RESPONSE_TIMEOUT (0x0025)

/*
 * Device is already connected
 */
#define NFCSTATUS_ALREADY_CONNECTED (0x0026)

/*
 * Device is already connected
 */
#define NFCSTATUS_ANOTHER_DEVICE_CONNECTED (0x0027)

/*
 * Single Target Detected and Activated
 */
#define NFCSTATUS_SINGLE_TAG_ACTIVATED (0x0028)

/*
 * Single Target Detected
 */
#define NFCSTATUS_SINGLE_TAG_DISCOVERED (0x0029)

/*
 * Secure element Detected and Activated
 */
#define NFCSTATUS_SECURE_ELEMENT_ACTIVATED (0x0028)

/*
 * Unknown error Status Codes
 */
#define NFCSTATUS_UNKNOWN_ERROR (0x00FE)

/*
 * Status code for failure
 */
#define NFCSTATUS_FAILED (0x00FF)

/*
 * The function/command has been aborted
 */
#define NFCSTATUS_CMD_ABORTED (0x0002)

/*
 * No target found after poll
 */
#define NFCSTATUS_NO_TARGET_FOUND (0x000A)

/* Attempt to disconnect a not connected remote device. */
#define NFCSTATUS_NO_DEVICE_CONNECTED (0x000B)

/* External RF field detected. */
#define NFCSTATUS_EXTERNAL_RF_DETECTED (0x000E)

/* Message is not allowed by the state machine
 * (e.g. configuration went wrong)
 */
#define NFCSTATUS_MSG_NOT_ALLOWED_BY_FSM (0x0010)

/*
 * No access has been granted
 */
#define NFCSTATUS_ACCESS_DENIED (0x001E)

/* No registry node matches the specified input data. */
#define NFCSTATUS_NODE_NOT_FOUND (0x0017)

/* The current module is busy ; one might retry later */
#define NFCSTATUS_SMX_BAD_STATE (0x00F0)

/* The Abort mechanism has failed for unexpected reason: user can try again*/
#define NFCSTATUS_ABORT_FAILED (0x00F2)

/* The Registration command has failed because the user wants to register as
 * target
 * on a operating mode not supported
 */
#define NFCSTATUS_REG_OPMODE_NOT_SUPPORTED (0x00F5)

/*
 * Shutdown in progress, cannot handle the request at this time.
 */
#define NFCSTATUS_SHUTDOWN (0x0091)

/*
 * Target is no more in RF field
 */
#define NFCSTATUS_TARGET_LOST (0x0092)

/*
 * Request is rejected
 */
#define NFCSTATUS_REJECTED (0x0093)

/*
 * Target is not connected
 */
#define NFCSTATUS_TARGET_NOT_CONNECTED (0x0094)

/*
 * Invalid handle for the operation
 */
#define NFCSTATUS_INVALID_HANDLE (0x0095)

/*
 * Process aborted
 */
#define NFCSTATUS_ABORTED (0x0096)

/*
 * Requested command is not supported
 */
#define NFCSTATUS_COMMAND_NOT_SUPPORTED (0x0097)

/*
 * Tag is not NDEF compilant
 */
#define NFCSTATUS_NON_NDEF_COMPLIANT (0x0098)

/*
 * Not enough memory available to complete the requested operation
 */
#define NFCSTATUS_NOT_ENOUGH_MEMORY (0x001F)

/*
 * Indicates incoming connection
 */
#define NFCSTATUS_INCOMING_CONNECTION (0x0045)

/*
 * Indicates Connection was successful
 */
#define NFCSTATUS_CONNECTION_SUCCESS (0x0046)

/*
 * Indicates Connection failed
 */
#define NFCSTATUS_CONNECTION_FAILED (0x0047)

#endif /* PHNFCSTATUS_H */