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