code update
[adaptation/devices/nfc-plugin-nxp.git] / inc / phNfcTypes.h
1 /*
2  * Copyright (C) 2010 NXP Semiconductors
3  * Copyright (C) 2012 Samsung Elevtronics Co., Ltd
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  *      http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17
18 /*
19  * \file  phNfcTypes.h
20  * \brief Basic type definitions.
21  *
22  * Project: NFC MW / HAL
23  *
24  * $Date: Thu Jun 25 21:24:53 2009 $
25  * $Author: ing04880 $
26  * $Revision: 1.13 $
27  * $Aliases: NFC_FRI1.1_WK926_R28_1,NFC_FRI1.1_WK928_R29_1,NFC_FRI1.1_WK930_R30_1,NFC_FRI1.1_WK934_PREP_1,NFC_FRI1.1_WK934_R31_1,NFC_FRI1.1_WK941_PREP1,NFC_FRI1.1_WK941_PREP2,NFC_FRI1.1_WK941_1,NFC_FRI1.1_WK943_R32_1,NFC_FRI1.1_WK949_PREP1,NFC_FRI1.1_WK943_R32_10,NFC_FRI1.1_WK943_R32_13,NFC_FRI1.1_WK943_R32_14,NFC_FRI1.1_WK1007_R33_1,NFC_FRI1.1_WK1007_R33_4,NFC_FRI1.1_WK1017_PREP1,NFC_FRI1.1_WK1017_R34_1,NFC_FRI1.1_WK1017_R34_2,NFC_FRI1.1_WK1023_R35_1 $
28  *
29  */
30
31 #ifndef PHNFCTYPES /* */
32 #define PHNFCTYPES /* */
33
34 /**
35  *  \name NFC Types
36  *
37  * File: \ref phNfcTypes.h
38  *
39  */
40 /*@{*/
41 #define PHNFCTYPES_FILEREVISION "$Revision: 1.13 $" /**< \ingroup grp_file_attributes */
42 #define PHNFCTYPES_FILEALIASES  "$Aliases: NFC_FRI1.1_WK926_R28_1,NFC_FRI1.1_WK928_R29_1,NFC_FRI1.1_WK930_R30_1,NFC_FRI1.1_WK934_PREP_1,NFC_FRI1.1_WK934_R31_1,NFC_FRI1.1_WK941_PREP1,NFC_FRI1.1_WK941_PREP2,NFC_FRI1.1_WK941_1,NFC_FRI1.1_WK943_R32_1,NFC_FRI1.1_WK949_PREP1,NFC_FRI1.1_WK943_R32_10,NFC_FRI1.1_WK943_R32_13,NFC_FRI1.1_WK943_R32_14,NFC_FRI1.1_WK1007_R33_1,NFC_FRI1.1_WK1007_R33_4,NFC_FRI1.1_WK1017_PREP1,NFC_FRI1.1_WK1017_R34_1,NFC_FRI1.1_WK1017_R34_2,NFC_FRI1.1_WK1023_R35_1 $"     /**< \ingroup grp_file_attributes */
43 /*@}*/
44
45 #ifndef _WIN32
46 #include <stdint.h>
47 #else
48 #include <Windows.h>
49 #include <stdio.h>
50 #define snprintf _snprintf
51
52 #ifndef linux
53 /**
54  *  \name Basic Type Definitions
55  *
56  *  Constant-length-type definition ('C99).
57  *
58  */
59 /*@{*/
60 #ifndef __int8_t_defined /* */
61 #define __int8_t_defined /* */
62 typedef signed   char   int8_t;         /**<  \ingroup grp_nfc_common
63                                                8 bit signed integer */
64 #endif
65
66 #ifndef __int16_t_defined /* */
67 #define __int16_t_defined /* */
68 typedef signed   short  int16_t;        /**< \ingroup grp_nfc_common
69                                              16 bit signed integer */
70 #endif
71
72 #ifndef __stdint_h
73 #ifndef __int32_t_defined /* */
74 #define __int32_t_defined /* */
75 typedef signed   long   int32_t;        /**< \ingroup grp_nfc_common
76                                              32 bit signed integer */
77 #endif
78 #endif
79
80 #ifndef __uint8_t_defined /* */
81 #define __uint8_t_defined /* */
82 typedef unsigned char   uint8_t;        /**<  \ingroup grp_nfc_common
83                                               8 bit unsigned integer */
84 #endif
85
86 #ifndef __uint16_t_defined /* */
87 #define __uint16_t_defined /* */
88 typedef unsigned short  uint16_t;       /**< \ingroup grp_nfc_common
89                                              16 bit unsigned integer */
90 #endif
91
92 #ifndef __stdint_h
93 #ifndef __uint32_t_defined /* */
94 #define __uint32_t_defined /* */
95 typedef unsigned long   uint32_t;       /**< \ingroup grp_nfc_common
96                                              32 bit unsigned integer */
97 #endif
98 #endif
99
100 #endif /* linux */
101
102 #endif /* _WIN32 */
103
104 #ifndef TRUE
105 #define TRUE                    (0x01)                    /**< \ingroup grp_nfc_common
106                                               Logical True Value */
107 #endif
108
109 #ifndef FALSE
110 #define FALSE                   (0x00)                    /**< \ingroup grp_nfc_common
111                                               Logical False Value */
112 #endif
113
114 typedef uint8_t                 utf8_t;                 /**< \ingroup grp_nfc_common
115                                              UTF8 Character String */
116
117 typedef uint8_t                 bool_t;                 /**< \ingroup grp_nfc_common
118                                                                                                 boolean data type */
119
120 typedef uint16_t        NFCSTATUS;      /**< \ingroup grp_nfc_common
121                                              NFC return values \r
122                                          \ref phNfcStatus.h for different status
123                                           values */
124
125 #ifndef NULL
126 #define NULL  ((void *)0)
127 #endif
128
129 /* This Macro to be used to resolve Unused and unreference
130  * compiler warnings. \r
131  */
132
133 #define PHNFC_UNUSED_VARIABLE(x) for((x)=(x);(x)!=(x);)
134
135 /*@}*/
136
137 /**
138  *
139  *  \name HAL Overall Definitions
140  *
141  *  Definitions applicable to a variety of purposes and functions/features.
142  *
143  */
144  /*@{*/
145
146 #define PHHAL_COMMON_MAX_STRING_LENGTH  0x40U     /**< \ingroup grp_hal_common
147                                                      Maximum vendor name length in bytes. */
148 #define PHHAL_UNKNOWN_DEVICE_TYPE       0x00U   /**< \ingroup grp_hal_common
149                                                      Unknown device type. */
150 #define PHHAL_SERIAL_DEVICE             0x01U  /**< \ingroup grp_hal_common
151                                                      Serial device type.  */
152 #define PHHAL_USB_DEVICE                0x02U   /**< \ingroup grp_hal_common
153                                                      USB device type. */
154 #define PHHAL_I2C_DEVICE                0x03U   /**< \ingroup grp_hal_common
155                                                      I2C device type. */
156 #define PHHAL_SPI_DEVICE                0x04U   /**< \ingroup grp_hal_common
157                                                      SPI device type. */
158 #define PHHAL_PARALLEL_DEVICE           0x05U   /**< \ingroup grp_hal_common
159                                                      Parallel device type. */
160 #define PHHAL_NFCID_LENGTH              0x0AU  /**< \ingroup grp_hal_common
161                                                      Maximum length of NFCID 1..3. */
162
163 #define PHHAL_MAX_DATASIZE              0xFBU       /* 256 * Maximum Data size sent
164                                                      * by the HAL
165                                                      */
166
167 #define PHHAL_ATQA_LENGTH               0x02U       /**< ATQA length */
168 #define PHHAL_MAX_UID_LENGTH            0x0AU       /**< Maximum UID length expected */
169 #define PHHAL_MAX_ATR_LENGTH            0x30U       /**< Maximum ATR_RES (General Bytes) \r
170                                                      *   length expected */
171
172 #define PHHAL_ATQB_LENGTH               0x0BU       /**< ATQB length */
173
174 #define PHHAL_PUPI_LENGTH               0x04U       /**< PUPI length */
175 #define PHHAL_APP_DATA_B_LENGTH         0x04U       /**< Application Data length for Type B */
176 #define PHHAL_PROT_INFO_B_LENGTH        0x03U       /**< Protocol info length for Type B */
177 #define PHHAL_FEL_SYS_CODE_LEN          0x02U       /**< Felica System Code Length */
178 #define PHHAL_FEL_ID_LEN                0x08U       /**< Felica current ID Length */
179 #define PHHAL_FEL_PM_LEN                0x08U       /**< Felica current PM Length */
180 #define PHHAL_15693_UID_LENGTH          0x08U       /**< Length of the Inventory bytes for
181                                                          ISO15693 Tag */
182
183 #define VENDOR_NAME_LEN                 0x14U
184 #define MAX_TRANSFER_UNIT               0x21U \r
185 #define SESSIONID_SIZE                  0x08U
186 #define MAX_AID_LEN                     0x10U
187 #define MAX_UICC_PARAM_LEN              0xFFU
188
189 #define MIFARE_BITMASK                  0x08U
190 #define ISO_14443_BITMASK               0x20U
191 #define ISO_14443_DETECTED              0x20U
192 #define NFCIP_BITMASK                   0x40U
193 #define NFCIP_DETECTED                  0x40U
194
195 #define MAX_TARGET_SUPPORTED            MAX_REMOTE_DEVICES
196
197 #define NFC_HW_PN65N                    0x10U
198
199 #define NXP_NFCIP_NFCID2_ID             0x01FEU
200
201 #define NXP_FULL_VERSION_LEN            0x0BU
202
203
204 /*@}*/
205
206
207 /**
208  *  \name NFC specific Type Definitions
209  *
210  */
211 /*@{*/
212
213 /**
214  * Data Buffer Structure to hold the Data Buffer
215  *
216  * This structure holds the Data in the Buffer of the specified \r
217  * size.
218  * \r
219  */
220 typedef struct phNfc_sData_t
221 {
222     uint8_t             *buffer;
223     uint32_t            length;
224 } phNfc_sData_t;
225
226
227 /**
228  *\brief Possible Hardware Configuration exposed to upper layer.
229  * Typically this should be port name (Ex:"COM1","COM2") to which PN544 is connected.
230  */
231 typedef enum
232 {
233    ENUM_LINK_TYPE_UART,
234    ENUM_LINK_TYPE_I2C,
235    ENUM_LINK_TYPE_USB,
236    ENUM_LINK_TYPE_TCP,
237
238    ENUM_LINK_TYPE_NB,
239 } phLibNfc_eConfigLinkType;
240
241 /**
242  * \brief Possible Hardware Configuration exposed to upper layer.
243  * Typically this should be at least the communication link (Ex:"COM1","COM2")
244  * the controller is connected to.
245  */   \r
246 typedef struct phLibNfc_sConfig_t
247 {
248    /** Device node of the controller */
249    const char*               deviceNode;
250    /** The client ID (thread ID or message queue ID) */
251    unsigned int              nClientId;
252 } phLibNfc_sConfig_t, *pphLibNfc_sConfig_t;
253
254
255 /*!
256  * NFC Message structure contains message specific details like
257  * message type, message specific data block details, etc.
258  */
259 typedef struct phLibNfc_Message_t
260 {
261     uint32_t eMsgType;/**< Type of the message to be posted*/
262     void   * pMsgData;/**< Pointer to message specific data block in case any*/
263     uint32_t Size;/**< Size of the datablock*/
264 } phLibNfc_Message_t,*pphLibNfc_Message_t;
265
266
267 #ifdef WIN32
268 #define PH_LIBNFC_MESSAGE_BASE  (WM_USER+0x3FF)
269 #endif
270 /**
271  * Deferred message. This message type will be posted to the client application thread
272  * to notify that a deferred call must be invoked.
273  */
274 #define PH_LIBNFC_DEFERREDCALL_MSG                        (0x311)
275
276 /**
277  *\brief Deferred call declaration.
278  * This type of API is called from ClientApplication ( main thread) to notify \r
279  * specific callback.
280  */
281 typedef  void (*pphLibNfc_DeferredCallback_t) (void*);
282 /**
283  *\brief Deferred parameter declaration.
284  * This type of data is passed as parameter from ClientApplication (main thread) to the \r
285  * callback.
286  */
287 typedef  void *pphLibNfc_DeferredParameter_t;
288 /**
289  *\brief Deferred message specific info declaration.
290  * This type of information is packed as message data when \ref PH_LIBNFC_DEFERREDCALL_MSG \r
291  * type message is posted to message handler thread.
292  */ \r
293 typedef struct phLibNfc_DeferredCall_t
294 {
295                 pphLibNfc_DeferredCallback_t  pCallback;/**< pointer to Deferred callback */
296                 pphLibNfc_DeferredParameter_t pParameter;/**< pointer to Deferred parameter */
297 } phLibNfc_DeferredCall_t;
298
299
300 /** \ingroup  grp_hal_common
301  *
302  *  \brief Protocol Support Information
303  *
304  *  The <em> Supported Protocols Structure </em> holds all protocol supported by the current NFC
305  *  device.
306  *
307  *  \note All members of this structure are output parameters [out].
308  *
309  */
310 typedef struct phNfc_sSupProtocol_t
311 {
312     unsigned int MifareUL    : 1;  /**< Protocol Mifare Ultra Light or \r
313                                    any NFC Forum Type-2 tags */
314     unsigned int MifareStd   : 1;  /**< Protocol Mifare Standard. */
315     unsigned int ISO14443_4A : 1;  /**< Protocol ISO14443-4 Type A.  */
316     unsigned int ISO14443_4B : 1;  /**< Protocol ISO14443-4 Type B.  */
317     unsigned int ISO15693    : 1;  /**< Protocol ISO15693 HiTag.  */
318     unsigned int Felica      : 1;  /**< Protocol Felica. */
319     unsigned int NFC         : 1;  /**< Protocol NFC. */
320     unsigned int Jewel       : 1;  /**< Protocol Innovision Jewel Tag. */
321     /*** TODO: Add SWP, ETSI HCI to this list **/
322 } phNfc_sSupProtocol_t;
323
324
325 /** \ingroup grp_hal_common
326  *
327  *
328  *  \brief Information related to the NFC Device
329  *
330  *  The <em> Device Information Structure </em> holds information
331  *  related to the NFC IC read during initialization time. \r
332  *  It allows the caller firware, hardware version, the model id,
333  *  HCI verison supported and vendor name. Refer to the NFC Device \r
334  *  User Manual on how to interpret each of the values. In addition
335  *  it also contains capabilities of the NFC Device such as the \r
336  *  protocols supported in Reader and emulation mode
337  *
338  */
339 typedef struct phNfc_sDeviceCapabilities_t
340 {
341     /* */
342     uint32_t                hal_version; /**< \ingroup grp_hal_common
343                                               HAL 4.0 Version Information. */
344     uint32_t                fw_version; /**< \ingroup grp_hal_common
345                                               Firmware Version Info. */
346     uint32_t                hw_version; /**< \ingroup grp_hal_common
347                                               Hardware Version Info. */
348     uint8_t                 model_id;   /**< \ingroup grp_hal_common
349                                               IC Variant . */
350     uint8_t                 hci_version; /**< \ingroup grp_hal_common
351                                               ETSI HCI Version Supported */
352     utf8_t                  vendor_name[VENDOR_NAME_LEN]; /**< \ingroup grp_hal_common
353                                               Vendor name (Null terminated string)*/
354     uint8_t                 full_version[NXP_FULL_VERSION_LEN];
355
356     phNfc_sSupProtocol_t    ReaderSupProtocol; /**< Supported protocols \r
357                                                       (Bitmapped) in Reader mode. */
358     phNfc_sSupProtocol_t    EmulationSupProtocol;    /**< Supported protocols
359                                                        (Bitmapped) in Emulation \r
360                                                         mode. */
361     char                    firmware_update_info; /** */
362 } phNfc_sDeviceCapabilities_t;
363
364
365 /*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
366
367
368 /** \ingroup grp_hal_common
369  *
370  *  \brief Enumerated MIFARE Commands
371  *
372  *  The <em> Mifare Command List Enumerator </em> lists all available Mifare native commands.
373  *
374  * \note None.
375  *
376  */
377 typedef enum phNfc_eMifareCmdList_t
378 {
379     phNfc_eMifareRaw        = 0x00U,     /**< This command performs raw transcations .
380                                               Format of the phLibNfc_sTransceiveInfo_t \r
381                                               content in this case shall be as below: \r
382                                                 \95   cmd: filed shall set to  phHal_eMifareRaw . \r
383                                                 \95   addr : doesn't carry any significance.\r
384                                                 \95   sSendData : Shall contain formatted raw buffer \r
385                                                                 based on MIFARE commands type used. \r
386                                                                 Formatted buffer shall follow below \r
387                                                                 formating scheme.
388  \r
389                                               CmdType+ Block No + CommandSpecific data + 2 byte CRC
390                                               Ex: With  Write  4 byte command  on block 8  looks as \r
391                                               " 0xA2,0x08,0x01,0x02,0x03,0x04,CRC1,CRC2 \r
392                                               Note :  For MIFARE Std card we recommend use MIFARE \r
393                                                       commands directly.
394                                            */
395     phNfc_eMifareAuthentA   = 0x60U,     /**< Mifare Standard:\n
396                                               This command performs an authentication with KEY A for a sector.\n
397                                               Format of the phLibNfc_sTransceiveInfo_t content in this case is : \r
398                                                 \95       cmd: field shall set to  phHal_eMifareAuthentA . \r
399                                                 \95       addr : indicates MIFARE block address. \r
400                                                            Ex: 0x08 indicates block 8 needs to be authenticated.
401                                                 \95       sSendData : Shall contain authentication key values. \r
402                                                                     sSendData ,buffer shall contain authentication \r
403                                                                     key values 01 02 03 04 05 06 authenticates \r
404                                                                     block 08 with the key 0x01[..]06. If this \r
405                                                                     command fails, then  user needs to reactivate \r
406                                                                     the remote Mifare card.                                            \r
407                                           */
408     phNfc_eMifareAuthentB   = 0x61U,     /**< Mifare Standard:\n
409                                               This command performs an authentication with KEY B for a sector.\n
410                                               Format of the phLibNfc_sTransceiveInfo_t content in this case is : \r
411                                                 \95       cmd: field shall set to  phHal_eMifareAuthentB . \r
412                                                 \95       addr : indicates MIFARE block address. \r
413                                                            Ex: 0x08 indicates block 8 needs to be authenticated.
414                                                 \95       sSendData : Shall contain authentication key values. \r
415                                                                     sSendData ,buffer shall contain authentication \r
416                                                                     key values 01 02 03 04 05 06 authenticates \r
417                                                                     block 08 with the key 0x01[..]06. If this \r
418                                                                     command fails, then  user needs to reactivate \r
419                                                                     the remote Mifare card.   \r
420                                           */
421     phNfc_eMifareRead16     = 0x30U,     /**< Mifare Standard and Ultra Light:\n
422                                               Read 16 Bytes from a Mifare Standard block or 4 Mifare Ultra Light pages.\n
423                                               Format of the phLibNfc_sTransceiveInfo_t content in this case is : \r
424                                                 \95       cmd: field shall set to  phHal_eMifareRead16 . \r
425                                                 \95       addr : memory adress to read.   \r
426                                                 \95       sRecvData : Shall contain buffer of size 16 \r
427                                                                     to read the data into.                                                                  \r
428
429                                               If this command fails, the user needs to reactivate the \r
430                                               the remote Mifare card
431                                           */
432     phNfc_eMifareRead       = 0x30U,
433     phNfc_eMifareWrite16    = 0xA0U,     /**< Mifare Standard and Ultra Light:\n
434                                               Write 16 Bytes to a Mifare Standard block or 4 Mifare Ultra Light pages.\n
435                                               Format of the phLibNfc_sTransceiveInfo_t content in this case is : \r
436                                                 \95       cmd: field shall set to  phHal_eMifareWrite16 . \r
437                                                 \95       addr : starting memory adress to write from.   \r
438                                                 \95       sSendData : Shall contain buffer of size 16 containing\r
439                                                                     the data bytes to be written.                                                                  \r
440                                              \r
441                                               If this command fails, the user needs to reactivate the \r
442                                               the remote Mifare card
443                                            */
444     phNfc_eMifareWrite4     = 0xA2U,     /**< Mifare Ultra Light:\n
445                                               Write 4 bytes.\n
446                                               Format of the phLibNfc_sTransceiveInfo_t content in this case is : \r
447                                                 \95       cmd: field shall set to  phHal_eMifareWrite4 . \r
448                                                 \95       addr : starting memory adress to write from.   \r
449                                                 \95       sSendData : Shall contain buffer of size 4 containing\r
450                                                                     the data bytes to be written.                                                                  \r
451
452                                               If this command fails, the user needs to reactivate the \r
453                                               the remote Mifare card
454                                           */
455     phNfc_eMifareInc        = 0xC1U,     /**< Increment. */
456     phNfc_eMifareDec        = 0xC0U,     /**< Decrement. */
457     phNfc_eMifareTransfer   = 0xB0U,     /**< Tranfer.   */
458     phNfc_eMifareRestore    = 0xC2U,     /**< Restore.   */
459     phNfc_eMifareReadSector = 0x38U,     /**< Read Sector.   */
460     phNfc_eMifareWriteSector= 0xA8U,     /**< Write Sector.   */
461     phNfc_eMifareInvalidCmd = 0xFFU      /**< Invalid Command */
462 } phNfc_eMifareCmdList_t;
463
464
465 /** \ingroup grp_hal_common
466  *
467  *  The <em> T=Cl Command List Enumerator </em> lists all available T=Cl Commands.
468  *
469  * \note None.
470  *
471  */
472 typedef enum phNfc_eIso14443_4_CmdList_t
473 {
474     phNfc_eIso14443_4_Raw             = 0x00U /**< ISO 14443-4 Exchange command:\n
475                                                  - This command sends the data buffer directly \r
476                                                  to the remote device */
477
478 } phNfc_eIso14443_4_CmdList_t;
479
480
481 /** \ingroup grp_hal_common
482  *
483  *  The <em> NFCIP1 Command List Enumerator </em> lists all available NFCIP1 Commands.
484  *
485  * \note None.
486  *
487  */
488 typedef enum phNfc_eNfcIP1CmdList_t
489 {
490        phNfc_eNfcIP1_Raw             = 0x00U /**< NfcIP Exchange command:\n
491                                                  - This command sends the data buffer directly \r
492                                                   to the remote device */
493 }phNfc_eNfcIP1CmdList_t;
494
495
496 /** \ingroup grp_hal_common
497  *
498  *  The <em> ISO15693 Command List Enumerator </em> lists all available ISO15693 Commands.
499  *
500  * \note None.
501  *
502  */
503 typedef enum phNfc_eIso15693_CmdList_t
504 {
505 #if 0
506     phNfc_eIso15693_Raw             = 0x00U, /**< ISO 15693 Exchange Raw command:\n
507                                                  - This command sends the data buffer directly \r
508                                                  to the remote device */
509 #endif
510     phNfc_eIso15693_Cmd             = 0x20U, /**< ISO 15693 Exchange command:\n
511                                                  - This command is used to access the card \r
512                                                  to the remote device */
513     phNfc_eIso15693_Invalid         = 0xFFU      /**< Invalid Command */
514 } phNfc_eIso15693_CmdList_t;
515
516
517 /** \ingroup grp_hal_common
518  *
519  *  The <em> Felica Command List Enumerator </em> lists all available Felica Commands.
520  *
521  * \note None.
522  *
523  */
524 typedef enum phNfc_eFelicaCmdList_t
525 {
526     phNfc_eFelica_Raw             = 0xF0U, /**< Felica Raw command:\n
527                                                  - This command sends the data buffer directly \r
528                                                  to the remote device */
529     phNfc_eFelica_Check           = 0x00, /**< Felica Check command:\n
530                                                  - This command checks the data from the Felica
531                                                   remote device */
532     phNfc_eFelica_Update          = 0x01, /**< Felica Update command:\n
533                                                  - This command updates the data onto the Felica
534                                                   remote device */
535     phNfc_eFelica_Invalid         = 0xFFU      /**< Invalid Command */
536 } phNfc_eFelicaCmdList_t;
537
538
539 /** \ingroup grp_hal_common
540  *
541  *  The <em> Jewel Command List Enumerator </em> lists all available Jewel Commands.
542  *
543  * \note None.
544  *
545  */
546 typedef enum phNfc_eJewelCmdList_t
547 {
548     phNfc_eJewel_Raw            = 0x00U, /**< Jewel command:\n
549                                                  - This command sends the data buffer directly \r
550                                                  to the remote device */
551     phNfc_eJewel_Invalid        = 0xFFU  /**< Invalid jewel command */
552 }phNfc_eJewelCmdList_t;
553
554
555 /** \ingroup grp_hal_nfci
556 *
557 *  \brief Remote Device Reader A RF Gate Information Container \r
558 *
559 *  The <em> Reader A structure </em> includes the available information
560 *  related to the discovered ISO14443A remote device. This information \r
561 *  is updated for every device discovery.
562 *  \note None.
563 *
564 */
565 typedef struct phNfc_sIso14443AInfo_t
566 {
567     uint8_t         Uid[PHHAL_MAX_UID_LENGTH];      /**< UID information of the TYPE A
568                                                        Tag Discovered */
569     uint8_t         UidLength;                      /**< UID information length, shall not be greater \r
570                                                     than PHHAL_MAX_UID_LENGTH i.e., 10 */
571     uint8_t         AppData[PHHAL_MAX_ATR_LENGTH]; /**< Application data information of the \r
572                                                         tag discovered (= Historical bytes for \r
573                                                         type A) */  \r
574     uint8_t         AppDataLength;                  /**< Application data length */
575     uint8_t         Sak;                            /**< SAK informationof the TYPE A
576                                                        Tag Discovered */
577     uint8_t         AtqA[PHHAL_ATQA_LENGTH];        /**< ATQA informationof the TYPE A
578                                                        Tag Discovered */
579     uint8_t         MaxDataRate;                    /**< Maximum data rate supported by the TYPE A
580                                                        Tag Discovered */
581     uint8_t         Fwi_Sfgt;                       /**< Frame waiting time and start up frame guard \r
582                                                     time as defined in ISO/IEC 14443-4[7] for \r
583                                                     type A */
584 } phNfc_sIso14443AInfo_t;
585
586
587 /** \ingroup grp_hal_nfci
588 *
589 *  \brief Remote Device Reader B RF Gate Information Container \r
590 *
591 *  The <em> Reader B structure </em> includes the available information
592 *  related to the discovered ISO14443B remote device. This information \r
593 *  is updated for every device discovery.
594 *  \note None.
595 *
596 */
597 typedef struct phNfc_sIso14443BInfo_t \r
598 {
599     union phNfc_uAtqBInfo
600     {
601         struct phNfc_sAtqBInfo
602         {
603             uint8_t         Pupi[PHHAL_PUPI_LENGTH];            /**< PUPI information  of the TYPE B
604                                                                     Tag Discovered */
605             uint8_t         AppData[PHHAL_APP_DATA_B_LENGTH];   /**< Application Data  of the TYPE B
606                                                                     Tag Discovered */
607             uint8_t         ProtInfo[PHHAL_PROT_INFO_B_LENGTH]; /**< Protocol Information  of the TYPE B
608                                                                     Tag Discovered */
609         } AtqResInfo;
610         uint8_t         AtqRes[PHHAL_ATQB_LENGTH];          /**< ATQB Response Information of TYPE B
611                                                                 Tag Discovered */
612     } AtqB;
613     uint8_t         HiLayerResp[PHHAL_MAX_ATR_LENGTH];  /**< Higher Layer Response information  \r
614                                                              in answer to ATRRIB Command for Type B */  \r
615     uint8_t         HiLayerRespLength;                  /**< Higher Layer Response length */
616     uint8_t         Afi;                                /**< Application Family Identifier of TYPE B
617                                                                 Tag Discovered */
618     uint8_t         MaxDataRate;                        /**< Maximum data rate supported by the TYPE B
619                                                              Tag Discovered */
620 } phNfc_sIso14443BInfo_t;
621
622
623 /** \ingroup grp_hal_nfci
624 *
625 *  \brief Remote Device Reader B prime RF Gate Information Container \r
626 *
627 */
628 typedef struct phNfc_sIso14443BPrimeInfo_t \r
629 {
630     /* TODO: This will be updated later */
631     void *BPrimeCtxt;
632 } phNfc_sIso14443BPrimeInfo_t;
633
634
635 /** \ingroup grp_hal_nfci
636 *
637 *  \brief Remote Device Jewel Reader RF Gate Information Container \r
638 *
639 *  The <em> Jewel Reader structure </em> includes the available information
640 *  related to the discovered Jewel remote device. This information \r
641 *  is updated for every device discovery.
642 *  \note None.
643 *
644 */
645 typedef struct phNfc_sJewelInfo_t \r
646 {
647     uint8_t         Uid[PHHAL_MAX_UID_LENGTH];      /**< UID information of the TYPE A
648                                                          Tag Discovered */
649     uint8_t         UidLength;                      /**< UID information length, shall not be greater \r
650                                                     than PHHAL_MAX_UID_LENGTH i.e., 10 */
651     uint8_t         HeaderRom0; /**< Header Rom byte zero */
652     uint8_t         HeaderRom1; /**< Header Rom byte one */
653
654 } phNfc_sJewelInfo_t;
655
656
657 /** \ingroup grp_hal_nfci
658 *
659 *  \brief Remote Device Felica Reader RF Gate Information Container \r
660 *
661 *  The <em> Felica Reader structure </em> includes the available information
662 *  related to the discovered Felica remote device. This information \r
663 *  is updated for every device discovery.
664 *  \note None.
665 *
666 */
667 typedef struct phNfc_sFelicaInfo_t
668 {
669     uint8_t     IDm[(PHHAL_FEL_ID_LEN + 2)];              /**< Current ID of Felica tag */
670     uint8_t     IDmLength;                          /**< IDm length, shall not be greater \r
671                                                     than PHHAL_FEL_ID_LEN i.e., 8 */
672     uint8_t     PMm[PHHAL_FEL_PM_LEN];              /**< Current PM of Felica tag */
673     uint8_t     SystemCode[PHHAL_FEL_SYS_CODE_LEN]; /**< System code of Felica tag */
674 } phNfc_sFelicaInfo_t;
675
676
677 /** \ingroup grp_hal_nfci
678 *
679 *  \brief Remote Device Reader 15693 RF Gate Information Container \r
680 *
681 *  The <em> Reader A structure </em> includes the available information
682 *  related to the discovered ISO15693 remote device. This information \r
683 *  is updated for every device discovery.
684 *  \note None.
685 *
686 */
687
688 typedef struct phNfc_sIso15693Info_t
689 {
690     uint8_t         Uid[PHHAL_15693_UID_LENGTH];      /**< UID information of the 15693
691                                                        Tag Discovered */
692     uint8_t         UidLength;                      /**< UID information length, shall not be greater \r
693                                                     than PHHAL_15693_UID_LENGTH i.e., 8 */
694     uint8_t         Dsfid;                          /**< DSF information of the 15693
695                                                        Tag Discovered */
696     uint8_t         Flags;                          /**< Information about the Flags
697                                                         in the 15693 Tag Discovered */
698     uint8_t         Afi;                            /**< Application Family Identifier of
699                                                           15693 Tag Discovered */
700 } phNfc_sIso15693Info_t;
701
702
703 /** \ingroup grp_hal_nfci
704 *
705 *  \brief NFC Data Rate Supported between the Reader and the Target
706 *
707 *  The <em> \ref phHalNfc_eDataRate enum </em> lists all the Data Rate \r
708 *  values to be used to determine the rate at which the data is transmitted
709 *  to the target.
710 *
711 *  \note None.
712 */
713
714
715 /** \ingroup grp_hal_nfci
716 *
717 *  \brief NFCIP1 Data rates \r
718 *
719 */
720 typedef enum phNfc_eDataRate_t{
721     phNfc_eDataRate_106    = 0x00U, \r
722     phNfc_eDataRate_212, \r
723     phNfc_eDataRate_424, \r
724     /* phNfc_eDataRate_848, \r
725     phNfc_eDataRate_1696, \r
726     phNfc_eDataRate_3392, \r
727     phNfc_eDataRate_6784,*/
728     phNfc_eDataRate_RFU \r
729 } phNfc_eDataRate_t;
730
731
732 /** \ingroup grp_hal_nfci
733 *
734 *  \brief NFCIP1 Gate Information Container \r
735 *
736 *  The <em> NFCIP1 structure </em> includes the available information
737 *  related to the discovered NFCIP1 remote device. This information \r
738 *  is updated for every device discovery.
739 *  \note None.
740 *
741 */
742 typedef struct phNfc_sNfcIPInfo_t \r
743 {
744     /* Contains the random NFCID3I conveyed with the ATR_REQ. \r
745         always 10 bytes length \r
746         or contains the random NFCID3T conveyed with the ATR_RES.
747         always 10 bytes length */
748     uint8_t         NFCID[PHHAL_MAX_UID_LENGTH];    \r
749     uint8_t         NFCID_Length;
750     /* ATR_RES = General bytes length, Max length = 48 bytes */
751     uint8_t         ATRInfo[PHHAL_MAX_ATR_LENGTH];  \r
752     uint8_t         ATRInfo_Length;
753     /**< SAK information of the tag discovered */
754     uint8_t         SelRes;
755     /**< ATQA information of the tag discovered */
756     uint8_t         SenseRes[PHHAL_ATQA_LENGTH];
757     /**< Is Detection Mode of the NFCIP Target Active */
758     uint8_t         Nfcip_Active;
759     /**< Maximum frame length supported by the NFCIP device */  \r
760     uint16_t        MaxFrameLength;
761     /**< Data rate supported by the NFCIP device */
762     phNfc_eDataRate_t         Nfcip_Datarate;
763
764 } phNfc_sNfcIPInfo_t;
765
766
767 /** \ingroup grp_hal_nfci
768 *
769 *  \brief Remote Device Specific Information Container
770 *
771 *  The <em> Remote Device Information Union </em> includes the available Remote Device Information
772 *  structures. Following the device detected, the corresponding data structure is used.
773 *
774 *  \note None.
775 *
776 */
777 typedef union phNfc_uRemoteDevInfo_t
778 {
779     phNfc_sIso14443AInfo_t          Iso14443A_Info;
780     phNfc_sIso14443BInfo_t          Iso14443B_Info;
781     phNfc_sIso14443BPrimeInfo_t     Iso14443BPrime_Info;
782     phNfc_sNfcIPInfo_t              NfcIP_Info;
783     phNfc_sFelicaInfo_t             Felica_Info;
784     phNfc_sJewelInfo_t              Jewel_Info;
785     phNfc_sIso15693Info_t           Iso15693_Info;
786 } phNfc_uRemoteDevInfo_t;
787
788
789 /** \ingroup grp_hal_nfci
790 *
791 *  \brief RF Device Type Listing
792 *
793 *  The <em> RF Device Type List </em> is used to identify the type of
794 *  remote device that is discovered/connected. There seperate
795 *  types to identify a Remote Reader (denoted by _PCD) and \r
796 *  Remote Tag (denoted by _PICC)
797 *  \note None.
798 *
799 */
800 typedef enum phNfc_eRFDevType_t
801 {
802     phNfc_eUnknown_DevType        = 0x00U,
803
804     /* Specific PCD Devices */
805     phNfc_eISO14443_A_PCD,
806     phNfc_eISO14443_B_PCD,
807     phNfc_eISO14443_BPrime_PCD,
808     phNfc_eFelica_PCD,
809     phNfc_eJewel_PCD,
810     phNfc_eISO15693_PCD,
811     /* Generic PCD Type */
812     phNfc_ePCD_DevType,
813
814     /* Generic PICC Type */
815     phNfc_ePICC_DevType,
816     /* Specific PICC Devices */
817     phNfc_eISO14443_A_PICC,
818     phNfc_eISO14443_4A_PICC,
819     phNfc_eISO14443_3A_PICC,
820     phNfc_eMifare_PICC,
821     phNfc_eISO14443_B_PICC,
822     phNfc_eISO14443_4B_PICC,
823     phNfc_eISO14443_BPrime_PICC,
824     phNfc_eFelica_PICC,
825     phNfc_eJewel_PICC,
826     phNfc_eISO15693_PICC,
827
828     /* NFC-IP1 Device Types */
829     phNfc_eNfcIP1_Target, \r
830     phNfc_eNfcIP1_Initiator, \r
831
832     /* Other Sources */
833     phNfc_eInvalid_DevType
834
835 } phNfc_eRFDevType_t;
836
837
838 /** \ingroup grp_hal_nfci
839 *
840 *  \brief Remote Device Type Listing
841 *
842 *  The <em> Remote Device Type List </em> is used to identify the type of
843 *  remote device that is discovered/connected
844 *  \note This is same as RF Device Type List.
845 *
846 */
847 typedef phNfc_eRFDevType_t phNfc_eRemDevType_t;
848
849
850 /** \ingroup grp_hal_common
851  *
852  *
853  *  \brief Common Command Attribute
854  *
855  *  The <em> Hal Command Union </em> includes each available type of Commands.
856  *
857  * \note None.
858  *
859  */
860 typedef union phNfc_uCommand_t
861 {
862   phNfc_eMifareCmdList_t         MfCmd;         /**< Mifare command structure.  */
863   phNfc_eIso14443_4_CmdList_t    Iso144434Cmd;  /**< ISO 14443-4 command structure.  */
864   phNfc_eFelicaCmdList_t         FelCmd;        /**< Felica command structure.  */
865   phNfc_eJewelCmdList_t          JewelCmd;      /**< Jewel command structure.  */
866   phNfc_eIso15693_CmdList_t      Iso15693Cmd;   /**< ISO 15693 command structure.  */
867   phNfc_eNfcIP1CmdList_t         NfcIP1Cmd;     /**< ISO 18092 (NFCIP1) command structure */
868 } phNfc_uCmdList_t;
869
870
871 /** \ingroup grp_hal_nfci
872  *
873  *  \brief Remote Device Information Structure
874  *
875  *  The <em> Remote Device Information Structure </em> holds information about one single Remote
876  *  Device detected by the polling function .\n
877  *  It lists parameters common to all supported remote devices.
878  *
879  *  \note \r
880  *
881  *  \sa \ref phHal4Nfc_ConfigureDiscovery and \ref phHal4Nfc_Connect
882  *
883  */
884 typedef struct phNfc_sRemoteDevInformation_t
885 {
886     uint8_t                    SessionOpened;       /**< [out] Boolean \r
887                                                      *   Flag indicating the validity of
888                                                      *   the handle of the remote device. */
889     phNfc_eRemDevType_t        RemDevType;          /**< [out] Remote device type which says that remote \r
890                                                     is Reader A or Reader B or NFCIP or Felica or \r
891                                                     Reader B Prime or Jewel*/
892     phNfc_uRemoteDevInfo_t     RemoteDevInfo;       /**< Union of available Remote Device.
893                                                      *   \ref phNfc_uRemoteDevInfo_t Information.  */
894 } phNfc_sRemoteDevInformation_t;
895
896
897 /*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
898 /*    TARGET STRUCTURES */
899
900
901 /** \ingroup  grp_hal_common
902  *
903  *  \brief Transceive Information Data Structure for sending commands/response \r
904  *         to the remote device
905  *
906  *  The <em> Transceive Information Data Structure </em> is used to pass the \r
907  *  Command, Address (only required for MIFARE) and the send and receive data
908  *  data structure (buffer and length) for communication with remote device
909  *
910  *
911  */
912 typedef struct phNfc_sTransceiveInfo_t
913 {
914     phNfc_uCmdList_t                cmd;
915
916     /** \internal Address Field required for only Mifare
917      *  Family Proprietary Cards.
918      *  The Address Size is Valid only upto 255 Blocks limit
919      *  i:e for Mifare 4K
920      */
921     uint8_t                         addr;
922     phNfc_sData_t                   sSendData;
923     phNfc_sData_t                   sRecvData;
924 } phNfc_sTransceiveInfo_t;
925
926
927 /** \ingroup grp_hal_nfci
928 *
929 *  \brief Poll Device Information for conifiguring the discovery wheel
930           Reader and Card Emulation Phases
931 *
932 *  The <em> \ref phNfc_sPollDevInfo_t enum </em> is used to enable/disable \r
933 *  phases of the discovery wheel related to specific reader types and \r
934 *  card emulation phase
935 *  \note Enabling specific Reader technology when NFCIP1 speed is set in the
936 *        phNfc_sADD_Cfg_t is implicitly done in HAL. Use this structure to only
937 *        enable/disable Card Reader Functionality
938 */
939 typedef struct phNfc_sPollDevInfo_t
940 {
941     unsigned                    EnableIso14443A : 1;      /**< Flag to enable \r
942                                                         Reader A discovery */
943     unsigned                    EnableIso14443B : 1;      /**< Flag to enable \r
944                                                         Reader B discovery */
945     unsigned                    EnableFelica212 : 1;   /**< Flag to enable
946                                                         Felica 212 discovery */
947     unsigned                    EnableFelica424 : 1;   /**< Flag to enable
948                                                         Felica 424 discovery */
949     unsigned                    EnableIso15693 : 1;     /**< Flag to enable \r
950                                                         ISO 15693 discovery */
951     unsigned                    EnableNfcActive : 1; /**< Flag to enable \r
952                                                         Active Mode of NFC-IP discovery. \r
953                                                         This is updated internally \r
954                                                         based on the NFC-IP speed.
955                                                         */
956     unsigned                    RFU : 1;                /**< Reserved for future use */
957     unsigned                    DisableCardEmulation : 1;    /**< Flag to \r
958                                                             disable the card emulation */
959 } phNfc_sPollDevInfo_t;
960
961
962 /** \ingroup grp_hal_nfci
963 *
964 *  \brief P2P speed for the Initiator
965 *
966 *  The <em> \ref phNfc_eP2PMode_t enum </em> lists all the NFCIP1 speeds \r
967 *  to be used for configuring the NFCIP1 discovery
968 *
969 *  \note None.
970 */
971 typedef enum phNfc_eP2PMode_t
972 {
973     phNfc_eDefaultP2PMode  = 0x00U,
974     phNfc_ePassive106 = 0x01U,
975     phNfc_ePassive212 = 0x02U,
976     phNfc_ePassive424 = 0x04U,
977     phNfc_eActive106 = 0x08U,
978     phNfc_eActive212 = 0x10U,
979     phNfc_eActive424 = 0x20U,
980     phNfc_eP2P_ALL   = 0x27U,  /* All Passive and 424 Active */
981     phNfc_eInvalidP2PMode = 0xFFU
982 } phNfc_eP2PMode_t;
983
984
985 /** \ingroup grp_hal_common
986 *
987 *  \brief Identities the type of Notification
988 *
989 *  This enumeration is used to specify the type of notification notified
990 *  to the upper layer. This classifies the notification into two types
991 *  one for the discovery notifications and the other for all the remaining
992 *  event notifications
993 *  \note None.
994 */
995 typedef enum phNfc_eNotificationType_t
996 {
997     INVALID_NFC_NOTIFICATION    = 0x00U, /* Invalid Notification */
998     NFC_DISCOVERY_NOTIFICATION,         /* Remote Device Discovery Notification */
999     NFC_EVENT_NOTIFICATION              /* Event Notification from the other hosts */
1000 } phNfc_eNotificationType_t;
1001
1002
1003 /** \ingroup grp_hal_common
1004 *
1005 *  \brief \r
1006 *
1007 *  \note None.
1008 */
1009 typedef struct phNfc_sUiccInfo_t
1010 {
1011     /* AID and Parameter Information is obtained if the
1012      * eventType is NFC_EVT_TRANSACTION.
1013      */
1014     phNfc_sData_t           aid;
1015     phNfc_sData_t           param;
1016
1017 } phNfc_sUiccInfo_t;
1018
1019
1020 /** \ingroup grp_hal_nfci
1021 *
1022 *  \brief P2P Information for the Initiator
1023 *
1024 *  The <em> \ref phNfc_sNfcIPCfg_t </em> holds the P2P related information
1025 *  use by the NFC Device during P2P Discovery and connection
1026 *
1027 *  \note None.
1028 */
1029 typedef struct phNfc_sNfcIPCfg_t \r
1030 {
1031     /* ATR_RES = General bytes length, Max length = 48 bytes */
1032     uint8_t         generalBytesLength;
1033     uint8_t         generalBytes[PHHAL_MAX_ATR_LENGTH];  \r
1034
1035     /* TODO: This will be updated later for any additional params*/
1036 } phNfc_sNfcIPCfg_t;
1037
1038
1039 /** \ingroup grp_hal_common
1040 *
1041 *  \brief Discovery Configuration Mode
1042 *
1043 *  This enumeration is used to choose the Discovery Configuration
1044 *  Mode :- Configure and Start, Stop or Start with last set \r
1045 *  configuration
1046 *  \note None.
1047 */
1048 typedef enum phNfc_eDiscoveryConfigMode_t
1049 {
1050     NFC_DISCOVERY_CONFIG  = 0x00U,/**< Configure discovery with values \r
1051                                        in phNfc_sADD_Cfg_t and start \r
1052                                        discovery */
1053     NFC_DISCOVERY_START,         /**< Start Discovery with previously set
1054                                       configuration */
1055     NFC_DISCOVERY_STOP,          /**< Stop the Discovery */
1056     NFC_DISCOVERY_RESUME       /**< Resume the Discovery with previously \r
1057                                    *  set configuration.
1058                                    *  This is valid only when the Target
1059                                    *  is not connected.
1060                                    */
1061 }phNfc_eDiscoveryConfigMode_t;
1062
1063 /** \ingroup grp_hal_common
1064 *
1065 *  \brief Target or Tag Release Mode
1066 *
1067 *  This enumeration defines various modes of releasing an acquired target \r
1068 *  or tag.
1069 *  \note None.
1070 */
1071 typedef enum phNfc_eReleaseType_t
1072 {
1073     NFC_INVALID_RELEASE_TYPE    =0x00U,/**<Invalid release type */
1074     NFC_DISCOVERY_RESTART,      /**< Release current target and \r
1075                                      restart discovery within same technology*/
1076     NFC_DISCOVERY_CONTINUE,    /**< Release current target and continue
1077                                     discovery with next technology in the wheel */
1078     NFC_SMARTMX_RELEASE    /**< Release SmartMX from wired mode to previous mode
1079                                 (Virtual or Off) */
1080 } phNfc_eReleaseType_t;
1081
1082 /** \ingroup  grp_hal_common
1083 *
1084 *  \brief Poll configuration structure
1085 *
1086 *  The <em> Poll configuration structure </em> holds information about the \r
1087 *  enabling the the type of discovery required by the application. This \r
1088 *  structure is the input parameter for the discovery call
1089 *
1090 *  \note All members of this structure are input parameters [out].
1091 *
1092 *  \sa \ref phNfc_eP2PMode_t
1093 *
1094 */
1095 typedef struct phNfc_sADD_Cfg_t
1096 {
1097     union \r
1098     {
1099         phNfc_sPollDevInfo_t        PollCfgInfo;        /**<  Enable/Disable Specific \r
1100                                                               Reader Functionality and \r
1101                                                               Card Emulation */ \r
1102         unsigned                    PollEnabled;     /** Can be used to set polling 'Off'
1103                                                       by setting PollEnabled to zero */
1104
1105     } PollDevInfo;
1106     uint32_t                    Duration;           /**< Duration of virtual or idle \r
1107                                                     period in microseconds in the step size
1108                                                     of 48 microseconds.If duration is set less
1109                                                     than  48 microseconds then default value is
1110                                                     used.For more details please refer PN 544 \r
1111                                                     user manual*/
1112     uint8_t                     NfcIP_Mode ;      /**< Select the P2P
1113                                                     speeds using phNfc_eP2PMode_t type.
1114                                                     This is used to enable NFC-IP Discovery \r
1115                                                     The related Reader Type will be implicitly
1116                                                     selected */
1117     uint8_t                     NfcIP_Tgt_Disable;   /**< Flag to \r
1118                                                    disable the NFCIP1 TARGET */
1119 } phNfc_sADD_Cfg_t;
1120
1121 /*@}*/
1122
1123 #endif /* PHNFCTYPES */
1124