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