• 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  phFriNfc_TopazMap.h
19  * \brief NFC Ndef Mapping For Mifare UL Card.
20  *
21  * Project: NFC-FRI
22  *
23  * $Date: Mon Dec 13 14:14:14 2010 $
24  * $Author: ing02260 $
25  * $Revision: 1.26 $
26  * $Aliases:  $
27  *
28  */
29 
30 #ifndef PHFRINFC_TOPAZMAP_H
31 #define PHFRINFC_TOPAZMAP_H
32 
33 #include <phFriNfc.h>
34 #ifdef PH_HAL4_ENABLE
35 #include <phHal4Nfc.h>
36 #else
37 #include <phHalNfc.h>
38 #endif
39 #include <phNfcStatus.h>
40 #include <phNfcTypes.h>
41 #include <phFriNfc_NdefMap.h>
42 
43 
44 #define PH_FRINFC_NDEFMAP_TOPAZMAP_FILEREVISION "$Revision: 1.26 $"
45 #define PH_FRINFC_NDEFMAP_TOPAZMAP_FILEALIASES  "$Aliases:  $"
46 
47 #if !defined (ES_HW_VER)
48 
49     #define ES_HW_VER                                       (32U)
50 
51 #endif /* #if !defined (ES_HW_VER) */
52 
53 #if (ES_HW_VER >= 32)
54 
55     /* This macro is used for the new 3.2 chip,as the JEWEL_READ and
56         JEWEL_WRITE for this chip is removed from the firmware. And for the
57         new FW, only JEWEL_RAW shall be used */
58     #define TOPAZ_RAW_SUPPORT
59 
60 #endif /* #if (ES_HW_VER == 32) */
61 
62 #define TOPAZ_UID_LENGTH_FOR_READ_WRITE                     0x04U
63 
64 /*!
65  * \name Topaz - states of the Finite State machine
66  *
67  */
68 /*@{*/
69 #define PH_FRINFC_TOPAZ_STATE_READ                        1   /*!< Read State */
70 #define PH_FRINFC_TOPAZ_STATE_WRITE                       2   /*!< Write is going on*/
71 #define PH_FRINFC_TOPAZ_STATE_CHK_NDEF                    3   /*!< Check Ndef is going on */
72 #define PH_FRINFC_TOPAZ_STATE_READID                      4   /*!< Read Id under progress */
73 #define PH_FRINFC_TOPAZ_STATE_READALL                     5   /*!< Read all under progress */
74 #define PH_FRINFC_TOPAZ_STATE_WRITE_NMN                   6   /*!< Write ndef magic number */
75 #define PH_FRINFC_TOPAZ_STATE_WRITE_L_TLV                 7   /*!< Write length field of TLV */
76 #define PH_FRINFC_TOPAZ_STATE_WR_CC_OR_TLV                8   /*!< Write CC or NDEF TLV */
77 
78 #ifdef FRINFC_READONLY_NDEF
79 
80     #define PH_FRINFC_TOPAZ_STATE_WR_CC_BYTE               9   /*!< READ ONLY state */
81     #define PH_FRINFC_TOPAZ_STATE_RD_LOCK0_BYTE           10  /*!< read Lock byte 0 state */
82     #define PH_FRINFC_TOPAZ_STATE_WR_LOCK0_BYTE           11  /*!< write Lock byte 0 state */
83     #define PH_FRINFC_TOPAZ_STATE_RD_LOCK1_BYTE           12  /*!< read Lock byte 1 state */
84     #define PH_FRINFC_TOPAZ_STATE_WR_LOCK1_BYTE           13  /*!< write Lock byte 1 state */
85 
86 #endif /* #ifdef FRINFC_READONLY_NDEF */
87 /*@}*/
88 
89 /*!
90  * \name Topaz - constants for the capability container
91  *
92  */
93 /*@{*/
94 #define PH_FRINFC_TOPAZ_CC_BYTE0                 0xE1 /*!< Capability container byte 0 = 0xE1 (NMN) */
95 #define PH_FRINFC_TOPAZ_CC_BYTE1                 0x10 /*!< Capability container byte 1 = 0x10 (version number) */
96 #define PH_FRINFC_TOPAZ_CC_BYTE2_MAX             0x0E /*!< Capability container byte 2 = 0x0E (Total free space
97                                                             in the card) */
98 #define PH_FRINFC_TOPAZ_CC_BYTE3_RW              0x00 /*!< Capability container byte 3 = 0x00 for
99                                                                   READ WRITE/INITIALISED card state */
100 #define PH_FRINFC_TOPAZ_CC_BYTE3_RO              0x0F /*!< Capability container byte 3 = 0x0F for
101                                                                   READ only card state */
102 
103 /*@}*/
104 
105 /*!
106  * \name Topaz - constants for Flags
107  *
108  */
109 /*@{*/
110 #define PH_FRINFC_TOPAZ_FLAG0                    0 /*!< Flag value = 0 */
111 #define PH_FRINFC_TOPAZ_FLAG1                    1 /*!< Flag value = 1 */
112 /*@}*/
113 
114 /*!
115  * \name Topaz - constants for left shift
116  *
117  */
118 /*@{*/
119 #define PH_FRINFC_TOPAZ_SHIFT3                   3 /*!< Shift by 3 bits */
120 /*@}*/
121 
122 /*!
123  * \name Topaz - internal state for write
124  *
125  */
126 /*@{*/
127 enum
128 {
129     PH_FRINFC_TOPAZ_WR_CC_BYTE0,                  /*!< CC Byte 0 = 0xE1 ndef magic number */
130     PH_FRINFC_TOPAZ_WR_CC_BYTE1,                  /*!< CC Byte 1 = 0x10 version number */
131     PH_FRINFC_TOPAZ_WR_CC_BYTE2,                  /*!< CC Byte 2 = 0x0C space in the data area */
132     PH_FRINFC_TOPAZ_WR_CC_BYTE3,                  /*!< CC Byte 3 = 0x00 read write access */
133     PH_FRINFC_TOPAZ_WR_T_OF_TLV,                  /*!< CC Byte 3 = 0x00 read write access */
134     PH_FRINFC_TOPAZ_WR_NMN_0,                     /*!< NMN = 0x00 */
135     PH_FRINFC_TOPAZ_WR_NMN_E1,                    /*!< NMN = 0xE1 */
136     PH_FRINFC_TOPAZ_WR_L_TLV_0,                   /*!< L field of TLV = 0 */
137     PH_FRINFC_TOPAZ_WR_L_TLV,                     /*!< To update the L field */
138     PH_FRINFC_TOPAZ_DYNAMIC_INIT_CHK_NDEF,    /*!< Internal state to represent the  parsing of card to locate Ndef TLV*/
139     PH_FRINFC_TOPAZ_DYNAMIC_INIT_FIND_NDEF_TLV
140 
141 
142 };
143 /*@}*/
144 
145 /*!
146  * \name Topaz - TLV related constants
147  *
148  */
149 /*@{*/
150 #define PH_FRINFC_TOPAZ_NULL_T                   0x00 /*!< Null TLV value = 0x00 */
151 #define PH_FRINFC_TOPAZ_LOCK_CTRL_T              0x01 /*!< Lock TLV = 0x01 */
152 #define PH_FRINFC_TOPAZ_MEM_CTRL_T               0x02 /*!< Memory TLV = 0x02 */
153 #define PH_FRINFC_TOPAZ_NDEF_T                   0x03 /*!< NDEF TLV = 0x03 */
154 #define PH_FRINFC_TOPAZ_PROP_T                   0xFD /*!< NDEF TLV = 0xFD */
155 #define PH_FRINFC_TOPAZ_TERM_T                   0xFE /*!< Terminator TLV value = 0xFE */
156 
157 #define PH_FRINFC_TOPAZ_NDEFTLV_L                0x00 /*!< Length value of TLV = 0x00 */
158 #define PH_FRINFC_TOPAZ_NDEFTLV_LFF              0xFF /*!< Length value of TLV = 0xFF */
159 #define PH_FRINFC_TOPAZ_MAX_CARD_SZ              0x60 /*!< Send Length for Read Ndef */
160 /*@}*/
161 
162 
163 /*!
164  * \name Topaz - Standard constants
165  *
166  */
167 /*@{*/
168 #define PH_FRINFC_TOPAZ_WR_A_BYTE                0x02 /*!< Send Length for Write Ndef */
169 #define PH_FRINFC_TOPAZ_SEND_BUF_READ            0x01 /*!< Send Length for Read Ndef */
170 #define PH_FRINFC_TOPAZ_HEADROM0_CHK             0xFF /*!< To check the header rom byte 0 */
171 #define PH_FRINFC_TOPAZ_HEADROM0_VAL             0x11 /*!< Header rom byte 0 value of static card */
172 #define PH_FRINFC_TOPAZ_READALL_RESP             0x7A /*!< Response of the read all command 122 bytes */
173 #define PH_FRINFC_TOPAZ_TOTAL_RWBYTES            0x60 /*!< Total number of raw Bytes that can
174                                                             be read or written to the card 96 bytes */
175 #define PH_FRINFC_TOPAZ_TOTAL_RWBYTES1           0x5A /*!< Total number of bytes that can be read
176                                                             or written 90 bytes */
177 #define PH_FRINFC_TOPAZ_BYTE3_MSB                0xF0 /*!< most significant nibble of byte 3(RWA) shall be
178                                                             0 */
179 #define PH_FRINFC_TOPAZ_LOCKBIT_BYTE114          0x01 /*!< lock bits value of byte 104 */
180 #define PH_FRINFC_TOPAZ_LOCKBIT_BYTE115_1        0x60 /*!< lock bits value of byte 105 */
181 #define PH_FRINFC_TOPAZ_LOCKBIT_BYTE115_2        0xE0 /*!< lock bits value of byte 105 */
182 #define PH_FRINFC_TOPAZ_LOCKBIT_BYTENO_0         114  /*!< lock bits byte number 104 */
183 #define PH_FRINFC_TOPAZ_LOCKBIT_BYTENO_1         115  /*!< lock bits byte number 105 */
184 #define PH_FRINFC_TOPAZ_CC_BYTENO_3              13   /*! Lock status according to CC bytes */
185 #define PH_FRINFC_TOPAZ_CC_READWRITE             0x00     /*! Lock status according to CC bytes */
186 #define PH_FRINFC_TOPAZ_CC_READONLY              0x0F     /*! Lock status according to CC bytes */
187 
188 /**Topaz static commands*/
189 #define PH_FRINFC_TOPAZ_CMD_READID               0x78U
190 #define PH_FRINFC_TOPAZ_CMD_READALL              0x00U
191 #define PH_FRINFC_TOPAZ_CMD_READ                 0x01U
192 #define PH_FRINFC_TOPAZ_CMD_WRITE_1E             0x53U
193 #define PH_FRINFC_TOPAZ_CMD_WRITE_1NE            0x1AU
194 
195 /**Topaz Dynamic commands*/
196 #define PH_FRINFC_TOPAZ_CMD_RSEG                 0x10U
197 #define PH_FRINFC_TOPAZ_CMD_READ8                0x02U
198 #define PH_FRINFC_TOPAZ_CMD_WRITE_E8             0x54U
199 #define PH_FRINFC_TOPAZ_CMD_WRITE_NE8            0x1BU
200 
201 enum
202 {
203     PH_FRINFC_TOPAZ_VAL0,
204     PH_FRINFC_TOPAZ_VAL1,
205     PH_FRINFC_TOPAZ_VAL2,
206     PH_FRINFC_TOPAZ_VAL3,
207     PH_FRINFC_TOPAZ_VAL4,
208     PH_FRINFC_TOPAZ_VAL5,
209     PH_FRINFC_TOPAZ_VAL6,
210     PH_FRINFC_TOPAZ_VAL7,
211     PH_FRINFC_TOPAZ_VAL8,
212     PH_FRINFC_TOPAZ_VAL9,
213     PH_FRINFC_TOPAZ_VAL10,
214     PH_FRINFC_TOPAZ_VAL11,
215     PH_FRINFC_TOPAZ_VAL12,
216     PH_FRINFC_TOPAZ_VAL13,
217     PH_FRINFC_TOPAZ_VAL14,
218     PH_FRINFC_TOPAZ_VAL15,
219     PH_FRINFC_TOPAZ_VAL16,
220     PH_FRINFC_TOPAZ_VAL17,
221     PH_FRINFC_TOPAZ_VAL18
222 };
223 
224 
225 /*@}*/
226 
227 /*!
228  * \brief \copydoc page_reg Resets the component instance to the initial state and lets the component forget about
229  *        the list of registered items. Moreover, the lower device is set.
230  *
231  * \param[in] NdefMap Pointer to a valid or uninitialised instance of \ref phFriNfc_NdefMap_t .
232  *
233  * \note  This function has to be called at the beginning, after creating an instance of
234  *        \ref phFriNfc_NdefMap_t . Use this function to reset the instance and/or switch
235  *        to a different underlying device (different NFC device or device mode, or different
236  *        Remote Device).
237  */
238 void phFriNfc_TopazMap_H_Reset(  phFriNfc_NdefMap_t        *NdefMap);
239 
240 #ifdef FRINFC_READONLY_NDEF
241 
242 /*!
243  * \ingroup grp_fri_smart_card_formatting
244  *
245  * \brief Initiates the conversion of the already NDEF formatted tag to READ ONLY.
246  *
247  * \copydoc page_ovr  The function initiates the conversion of the already NDEF formatted
248  * tag to READ ONLY.After this formation, remote card would be properly Ndef Compliant and READ ONLY.
249  * Depending upon the different card type, this function handles formatting procedure.
250  * This function supports only for the TOPAZ tags.
251  *
252  * \param[in] NdefMap Pointer to a valid instance of the \ref phFriNfc_NdefMap_t structure describing
253  *                    the component context.
254  * \retval  NFCSTATUS_PENDING   The action has been successfully triggered.
255  * \retval  Other values        An error has occurred.
256  *
257  */
258 NFCSTATUS
259 phFriNfc_TopazMap_ConvertToReadOnly (
260     phFriNfc_NdefMap_t          *NdefMap);
261 
262 #endif /* #ifdef FRINFC_READONLY_NDEF */
263 
264 /*!
265  * \brief \copydoc page_ovr Initiates Reading of NDEF information from the Remote Device.
266  *
267  * The function initiates the reading of NDEF information from a Remote Device.
268  * It performs a reset of the state and starts the action (state machine).
269  * A periodic call of the \ref phFriNfc_NdefMap_Process has to be done once the action
270  * has been triggered.
271  *
272  * \param[in] NdefMap Pointer to a valid instance of the \ref phFriNfc_NdefMap_t structure describing
273  *                    the component context.
274  *
275  * \param[in] PacketData  Pointer to a location that receives the NDEF Packet.
276  *
277  * \param[in,out] PacketDataLength Pointer to a variable receiving the length of the NDEF packet.
278  *
279  * \param[in] Offset Indicates whether the read operation shall start from the begining of the
280  *            file/card storage \b or continue from the last offset. The last Offset set is stored
281  *            within a context variable (must not be modified by the integration).
282  *            If the caller sets the value to \ref PH_FRINFC_NDEFMAP_SEEK_CUR, the component shall
283  *            start reading from the last offset set (continue where it has stopped before).
284  *            If set to \ref PH_FRINFC_NDEFMAP_SEEK_BEGIN, the component shall start reading
285  *            from the begining of the card (restarted)
286  *
287  * \retval NFCSTATUS_PENDING                       The action has been successfully triggered.
288  * \retval NFCSTATUS_INVALID_DEVICE_REQUEST        If Previous Operation is Write Ndef and Offset
289  *                                                 is Current then this error is displayed.
290  * \retval NFCSTATUS_EOF_NDEF_CONTAINER_REACHED         No Space in the File to read.
291  * \retval NFCSTATUS_MORE_INFORMATION              There are more bytes to read in the card.
292  * \retval NFCSTATUS_SUCCESS                       Last Byte of the card read.
293  * \retval NFCSTATUS_INVALID_DEVICE                The device has not been opened or has been disconnected
294  *                                                 meanwhile.
295  * \retval NFCSTATUS_CMD_ABORTED                   The caller/driver has aborted the request.
296  * \retval NFCSTATUS_BUFFER_TOO_SMALL              The buffer provided by the caller is too small.
297  * \retval NFCSTATUS_RF_TIMEOUT                    No data has been received within the TIMEOUT period.
298  *
299  */
300 
301 NFCSTATUS phFriNfc_TopazMap_RdNdef( phFriNfc_NdefMap_t  *NdefMap,
302                                     uint8_t             *PacketData,
303                                     uint32_t            *PacketDataLength,
304                                     uint8_t             Offset);
305 
306 
307 
308 /*!
309  * \brief \copydoc page_ovr Initiates Writing of NDEF information to the Remote Device.
310  *
311  * The function initiates the writing of NDEF information to a Remote Device.
312  * It performs a reset of the state and starts the action (state machine).
313  * A periodic call of the \ref phFriNfc_NdefMap_Process has to be done once the action
314  * has been triggered.
315  *
316  * \param[in] NdefMap Pointer to a valid instance of the \ref phFriNfc_NdefMap_t structure describing
317  *                    the component context.
318  *
319  * \param[in] PacketData  Pointer to a location that holds the prepared NDEF Packet.
320  *
321  * \param[in,out] PacketDataLength Variable specifying the length of the prepared NDEF packet.
322  *
323  * \param[in] Offset Indicates whether the write operation shall start from the begining of the
324  *            file/card storage \b or continue from the last offset. The last Offset set is stored
325  *            within a context variable (must not be modified by the integration).
326  *            If the caller sets the value to \ref PH_FRINFC_NDEFMAP_SEEK_CUR, the component shall
327  *            start writing from the last offset set (continue where it has stopped before).
328  *            If set to \ref PH_FRINFC_NDEFMAP_SEEK_BEGIN, the component shall start writing
329  *            from the begining of the card (restarted)
330  *
331  * \retval NFCSTATUS_PENDING                        The action has been successfully triggered.
332  * \retval NFCSTATUS_INVALID_DEVICE_REQUEST         If Previous Operation is Write Ndef and Offset
333  *                                                  is Current then this error is displayed.
334  * \retval NFCSTATUS_EOF_NDEF_CONTAINER_REACHED               Last byte is written to the card after this
335  *                                                  no further writing is possible.
336  * \retval NFCSTATUS_SUCCESS                        Buffer provided by the user is completely written
337  *                                                  into the card.
338  * \retval NFCSTATUS_INVALID_DEVICE                 The device has not been opened or has been disconnected
339  *                                                  meanwhile.
340  * \retval NFCSTATUS_CMD_ABORTED                    The caller/driver has aborted the request.
341  * \retval NFCSTATUS_BUFFER_TOO_SMALL               The buffer provided by the caller is too small.
342  * \retval NFCSTATUS_RF_TIMEOUT                     No data has been received within the TIMEOUT period.
343  *
344  */
345 
346 NFCSTATUS phFriNfc_TopazMap_WrNdef( phFriNfc_NdefMap_t  *NdefMap,
347                                     uint8_t             *PacketData,
348                                     uint32_t            *PacketDataLength,
349                                     uint8_t             Offset);
350 
351 /*!
352  * \brief \copydoc page_ovr Check whether a particulat Remote Device is NDEF compliant.
353  *
354  * The function checks whether the peer device is NDEF compliant.
355  *
356  * \param[in] NdefMap Pointer to a valid instance of the \ref phFriNfc_NdefMap_t structure describing
357  *                    the component context.
358  *
359  * \retval NFCSTATUS_PENDING               The action has been successfully triggered.
360  * \retval NFCSTATUS_INVALID_PARAMETER     At least one parameter of the function is invalid.
361  * \retval NFCSTATUS_INVALID_DEVICE         The device has not been opened or has been disconnected
362  *                                          meanwhile.
363  * \retval NFCSTATUS_CMD_ABORTED            The caller/driver has aborted the request.
364  * \retval NFCSTATUS_BUFFER_TOO_SMALL       The buffer provided by the caller is too small.
365  * \retval NFCSTATUS_RF_TIMEOUT             No data has been received within the TIMEOUT period.
366  *
367  */
368 
369 NFCSTATUS phFriNfc_TopazMap_ChkNdef(    phFriNfc_NdefMap_t  *NdefMap);
370 
371 extern NFCSTATUS phFriNfc_Tpz_H_ChkSpcVer( phFriNfc_NdefMap_t  *NdefMap,
372                                           uint8_t             VersionNo);
373 
374 
375 /*!
376  * \brief \copydoc page_cb Completion Routine, Processing function, needed to avoid long blocking.
377  *
378  * The function call scheme is according to \ref grp_interact. No State reset is performed during operation.
379  *
380  * \copydoc pphFriNfc_Cr_t
381  *
382  * \note The lower (Overlapped HAL) layer must register a pointer to this function as a Completion
383  *       Routine in order to be able to notify the component that an I/O has finished and data are
384  *       ready to be processed.
385  *
386  */
387 
388 void phFriNfc_TopazMap_Process( void        *Context,
389                                 NFCSTATUS   Status);
390 
391 
392 /*!
393  * \name TopazDynamicMap - Following section describes constans, functions, variables used in
394  *       Topaz Dyanmic card mapping. Ex : Topaz-512
395  *
396  */
397 /*@{*/
398 /*!
399  * \brief \copydoc Dynamic Card supported definitions.
400  * \note State Mechine Delcations.
401  */
402 
403 #define PH_FRINFC_TOPAZ_DYNAMIC_STATE_WRITE_COMPLETE            11  /*!< Write Operation Complete */
404 #define PH_FRINFC_TOPAZ_DYNAMIC_STATE_NXP_READ                  12
405 #define PH_FRINFC_TOPAZ_DYNAMIC_STATE_RD_CCBLK                  13
406 #define PH_FRINFC_TOPAZ_DYNAMIC_STATE_INIT_RD_CCBLK             14
407 #define PH_FRINFC_TOPAZ_DYNAMIC_STATE_INIT_WR                   15
408 #define PH_FRINFC_TOPAZ_DYNAMIC_STATE_WRITE_LEN                 16
409 #define PH_FRINFC_TOPAZ_DYNAMIC_STATE_FIND_NDEF_TLV             17
410 #define PH_FRINFC_TOPAZ_DYNAMI_FOUND_RESERV_AREA                18
411 #define PH_FRINFC_TOPAZ_DYNAMIC_NOT_FOUND_RESERV_AREA           19
412 #define PH_FRINFC_TOPAZ_DYNAMIC_PROCESS_CHK_NDEF                20
413 #define PH_FRINFC_TOPAZ_DYNAMIC_FIND_NDEF_TLV                   21
414 #define PH_FRINFC_TOPAZ_DYNAMIC_INIT_RD_NDEF                    22
415 #define PH_FRINFC_TOPAZ_DYNAMIC_STATE_WR_MEM_TLV                23
416 #define PH_FRINFC_TOPAZ_DYNAMIC_STATE_WR_LOCK_TLV               24
417 
418 /*!
419  * \brief \copydoc Dynamic Card : Capability Container bytes.
420  * \note State Mechine Delcations.
421  */
422 
423 #define PH_FRINFC_TOPAZ_DYNAMIC_CC_BYTE2_MMSIZE                 0x3F  /*!< Capability container byte 2 = 0x3F (Total free space
424                                                                         in the card) */
425 #define PH_FRINFC_TOPAZ_DYNAMIC_HEADROM0_VAL                    0x12  /*!< Header rom byte 0 value of dynamic card */
426 
427 #define PH_FRINFC_TOPAZ_DYNAMIC_TOTAL_RWBYTES                   0x1CC /*!< Total number of raw Bytes that can
428                                                                         be read or written to the card 460 bytes
429 																		460 = 512 - 6 bloks * 8(48)( this includes 2 bytes of null byte in 02 block)
430 																		- 4 bytes ( NDEF TLV )*/
431 #define PH_FRINFC_TOPAZ_DYNAMIC_MAX_CARD_SZ                     0x1E0 /*!< Card size */
432 #define PH_FRINFC_TOPAZ_DYNAMIC_MX_ONEBYTE_TLV_SIZE             0xFF  /*!< MAX size supported in one byte length TLV*/
433 #define PH_FRINFC_TOPAZ_DYNAMIC_MAX_DATA_SIZE_TO_WRITE          0xE6  /*!< MAX size supported by HAL if the data size > 255*/
434 
435 #define PH_FRINFC_TOPAZ_DYNAMIC_LOCKBYTE_0                      0x00 /*!< lock bits value of byte 104 */
436 #define PH_FRINFC_TOPAZ_DYNAMIC_LOCKBYTE_1                      0x00 /*!< lock bits value of byte 105 */
437 #define PH_FRINFC_TOPAZ_DYNAMIC_LOCKBYTE_2TO7                   0x00 /*!< lock bits value of byte 105 */
438 
439 #define PH_FRINFC_TOPAZ_DYNAMIC_LOCKBIT_BYTENO_0                112  /*!< lock bits byte number 104:Blk0-7 */
440 #define PH_FRINFC_TOPAZ_DYNAMIC_LOCKBIT_BYTENO_1                113  /*!< lock bits byte number 105:Blk08-F */
441 #define PH_FRINFC_TOPAZ_DYNAMIC_LOCKBIT_BYTENO_2                122  /*!< lock bits byte number 124:Blk10-17 */
442 #define PH_FRINFC_TOPAZ_DYNAMIC_LOCKBIT_BYTENO_3                123  /*!< lock bits byte number 125:Blk18-1F */
443 #define PH_FRINFC_TOPAZ_DYNAMIC_LOCKBIT_BYTENO_4                124  /*!< lock bits byte number 126:Blk20-27*/
444 #define PH_FRINFC_TOPAZ_DYNAMIC_LOCKBIT_BYTENO_5                125  /*!< lock bits byte number 127:Blk28-2F*/
445 #define PH_FRINFC_TOPAZ_DYNAMIC_LOCKBIT_BYTENO_6                126  /*!< lock bits byte number 128:Blk30-37*/
446 #define PH_FRINFC_TOPAZ_DYNAMIC_LOCKBIT_BYTENO_7                127  /*!< lock bits byte number 128:Blk30-37*/
447 #define PH_FRINFC_TOPAZ_DYNAMIC_CC_BYTENO_3                     11   /*! Lock status according to CC bytes */
448 
449 #define PH_FRINFC_TOPAZ_DYNAMIC_SEGMENT0                        0x00  /*!< 00000000 : 0th segment */
450 #define PH_FRINFC_TOPAZ_DYNAMIC_READSEG_RESP                    0x80
451 
452 #define PH_FRINFC_TOPAZ_DYNAMIC_MAX_BYTES_TO_READ_IN_ONEB_LTLV_FSEG             78
453 #define PH_FRINFC_TOPAZ_DYNAMIC_MAX_BYTES_TO_READ_IN_THREEB_LTLV_FSEG           76
454 
455 #define PH_FRINFC_TOPAZ_DYNAMIC_MAX_DATA_SIZE                                   PHHAL_MAX_DATASIZE
456 #define PH_FRINFC_TOPAZ_DYNAMIC_FSEG_BYTE_COUNT                                 104
457 #define PH_FRINFC_TOPAZ_DYNAMIC_SEG_BYTE_COUNT									128
458 #define PH_FRINFC_TOPAZ_DYNAMIC_CC_BLK_SIZE                                     18
459 #define PH_FRINFC_TOPAZ_DYNAMIC_CC_BLK_ADDRESS                                  8
460 #define PH_FRINFC_TOPAZ_DYNAMIC_UID_BLK_ADDRESS                                 0
461 #define PH_FRINFC_TOPAZ_DYNAMIC_LOCK_BYTE_SIZE                                  24
462 #define PH_FRINFC_TOPAZ_DYNAMIC_FSEG_TOT_DATA_BYTES                             120
463 
464 #define PH_FRINFC_TOPAZ_DYNAMIC_DATA_BYTE_COUNT_OF_FSEG_IN_ONEB_LTLV_FSEG       26
465 #define PH_FRINFC_TOPAZ_DYNAMIC_DATA_BYTE_COUNT_OF_FSEG_IN_THREEB_LTLV_FSEG     28
466 
467 
468 enum
469 {
470 
471     NULL_TLV,
472     LOCK_TLV,
473     MEM_TLV,
474     NDEF_TLV,
475     PROP_TLV,
476     TERM_TLV,
477     INVALID_TLV,
478     VALID_TLV,
479     TLV_NOT_FOUND
480 
481 };
482 
483 /*!
484  * \brief \copydoc page_ovr Initiates Reading of NDEF information from the Remote Device.
485  *
486  * The function initiates the reading of NDEF information from a Remote Device.
487  * It performs a reset of the state and starts the action (state machine).
488  * A periodic call of the \ref phFriNfc_NdefMap_Process has to be done once the action
489  * has been triggered.
490  *
491  * \param[in] NdefMap Pointer to a valid instance of the \ref phFriNfc_NdefMap_t structure describing
492  *                    the component context.
493  *
494  * \param[in] PacketData  Pointer to a location that receives the NDEF Packet.
495  *
496  * \param[in,out] PacketDataLength Pointer to a variable receiving the length of the NDEF packet.
497  *
498  * \param[in] Offset Indicates whether the read operation shall start from the begining of the
499  *            file/card storage \b or continue from the last offset. The last Offset set is stored
500  *            within a context variable (must not be modified by the integration).
501  *            If the caller sets the value to \ref PH_FRINFC_NDEFMAP_SEEK_CUR, the component shall
502  *            start reading from the last offset set (continue where it has stopped before).
503  *            If set to \ref PH_FRINFC_NDEFMAP_SEEK_BEGIN, the component shall start reading
504  *            from the begining of the card (restarted)
505  *
506  * \retval NFCSTATUS_PENDING                       The action has been successfully triggered.
507  * \retval NFCSTATUS_INVALID_DEVICE_REQUEST        If Previous Operation is Write Ndef and Offset
508  *                                                 is Current then this error is displayed.
509  * \retval NFCSTATUS_EOF_NDEF_CONTAINER_REACHED         No Space in the File to read.
510  * \retval NFCSTATUS_MORE_INFORMATION              There are more bytes to read in the card.
511  * \retval NFCSTATUS_SUCCESS                       Last Byte of the card read.
512  * \retval NFCSTATUS_INVALID_DEVICE                The device has not been opened or has been disconnected
513  *                                                 meanwhile.
514  * \retval NFCSTATUS_CMD_ABORTED                   The caller/driver has aborted the request.
515  * \retval NFCSTATUS_BUFFER_TOO_SMALL              The buffer provided by the caller is too small.
516  * \retval NFCSTATUS_RF_TIMEOUT                    No data has been received within the TIMEOUT period.
517  *
518  */
519 
520 NFCSTATUS phFriNfc_TopazDynamicMap_RdNdef( phFriNfc_NdefMap_t  *NdefMap,
521                                     uint8_t             *PacketData,
522                                     uint32_t            *PacketDataLength,
523                                     uint8_t             Offset);
524 
525 /*!
526  * \brief \copydoc page_ovr Initiates Writing of NDEF information to the Remote Device.
527  *
528  * The function initiates the writing of NDEF information to a Remote Device.
529  * It performs a reset of the state and starts the action (state machine).
530  * A periodic call of the \ref phFriNfc_NdefMap_Process has to be done once the action
531  * has been triggered.
532  *
533  * \param[in] NdefMap Pointer to a valid instance of the \ref phFriNfc_NdefMap_t structure describing
534  *                    the component context.
535  *
536  * \param[in] PacketData  Pointer to a location that holds the prepared NDEF Packet.
537  *
538  * \param[in,out] PacketDataLength Variable specifying the length of the prepared NDEF packet.
539  *
540  * \param[in] Offset Indicates whether the write operation shall start from the begining of the
541  *            file/card storage \b or continue from the last offset. The last Offset set is stored
542  *            within a context variable (must not be modified by the integration).
543  *            If the caller sets the value to \ref PH_FRINFC_NDEFMAP_SEEK_CUR, the component shall
544  *            start writing from the last offset set (continue where it has stopped before).
545  *            If set to \ref PH_FRINFC_NDEFMAP_SEEK_BEGIN, the component shall start writing
546  *            from the begining of the card (restarted)
547  *
548  * \retval NFCSTATUS_PENDING                        The action has been successfully triggered.
549  * \retval NFCSTATUS_INVALID_DEVICE_REQUEST         If Previous Operation is Write Ndef and Offset
550  *                                                  is Current then this error is displayed.
551  * \retval NFCSTATUS_EOF_NDEF_CONTAINER_REACHED               Last byte is written to the card after this
552  *                                                  no further writing is possible.
553  * \retval NFCSTATUS_SUCCESS                        Buffer provided by the user is completely written
554  *                                                  into the card.
555  * \retval NFCSTATUS_INVALID_DEVICE                 The device has not been opened or has been disconnected
556  *                                                  meanwhile.
557  * \retval NFCSTATUS_CMD_ABORTED                    The caller/driver has aborted the request.
558  * \retval NFCSTATUS_BUFFER_TOO_SMALL               The buffer provided by the caller is too small.
559  * \retval NFCSTATUS_RF_TIMEOUT                     No data has been received within the TIMEOUT period.
560  *
561  */
562 NFCSTATUS phFriNfc_TopazDynamicMap_WrNdef( phFriNfc_NdefMap_t  *NdefMap,
563                                     uint8_t             *PacketData,
564                                     uint32_t            *PacketDataLength,
565                                     uint8_t             Offset);
566 
567 /*!
568  * \brief \copydoc page_ovr Check whether a particulat Remote Device is NDEF compliant.
569  *
570  * The function checks whether the peer device is NDEF compliant.
571  *
572  * \param[in] NdefMap Pointer to a valid instance of the \ref phFriNfc_NdefMap_t structure describing
573  *                    the component context.
574  *
575  * \retval NFCSTATUS_PENDING               The action has been successfully triggered.
576  * \retval NFCSTATUS_INVALID_PARAMETER     At least one parameter of the function is invalid.
577  * \retval NFCSTATUS_INVALID_DEVICE         The device has not been opened or has been disconnected
578  *                                          meanwhile.
579  * \retval NFCSTATUS_CMD_ABORTED            The caller/driver has aborted the request.
580  * \retval NFCSTATUS_BUFFER_TOO_SMALL       The buffer provided by the caller is too small.
581  * \retval NFCSTATUS_RF_TIMEOUT             No data has been received within the TIMEOUT period.
582  *
583  */
584 NFCSTATUS phFriNfc_TopazDynamicMap_ChkNdef(    phFriNfc_NdefMap_t  *NdefMap);
585 
586 /*!
587  * \brief \copydoc page_cb Completion Routine, Processing function, needed to avoid long blocking.
588  *
589  * The function call scheme is according to \ref grp_interact. No State reset is performed during operation.
590  *
591  * \copydoc pphFriNfc_Cr_t
592  *
593  * \note The lower (Overlapped HAL) layer must register a pointer to this function as a Completion
594  *       Routine in order to be able to notify the component that an I/O has finished and data are
595  *       ready to be processed.
596  *
597  */
598 void phFriNfc_TopazDynamicMap_Process( void        *Context,
599                                 NFCSTATUS   Status);
600 
601 #ifdef FRINFC_READONLY_NDEF
602 /*!
603  * \brief \copydoc page_ovr Initiates Writing of NDEF information to the Remote Device.
604  *
605  * The function initiates the writing of NDEF information to a Remote Device.
606  * It performs a reset of the state and starts the action (state machine).
607  * A periodic call of the \ref phFriNfc_NdefMap_Process has to be done once the action
608  * has been triggered.
609  *
610  * \param[in] psNdefMap Pointer to a valid instance of the \ref phFriNfc_NdefMap_t structure describing
611  *                    the component context.
612  *
613  *
614  * \retval NFCSTATUS_PENDING                        The action has been successfully triggered.
615  * \retval NFCSTATUS_INVALID_DEVICE_REQUEST         If Previous Operation is Write Ndef and Offset
616  *                                                  is Current then this error is displayed.
617  * \retval NFCSTATUS_EOF_NDEF_CONTAINER_REACHED               Last byte is written to the card after this
618  *                                                  no further writing is possible.
619  * \retval NFCSTATUS_SUCCESS                        Buffer provided by the user is completely written
620  *                                                  into the card.
621  * \retval NFCSTATUS_INVALID_DEVICE                 The device has not been opened or has been disconnected
622  *                                                  meanwhile.
623  * \retval NFCSTATUS_CMD_ABORTED                    The caller/driver has aborted the request.
624  * \retval NFCSTATUS_BUFFER_TOO_SMALL               The buffer provided by the caller is too small.
625  * \retval NFCSTATUS_RF_TIMEOUT                     No data has been received within the TIMEOUT period.
626  *
627  */
628 NFCSTATUS
629 phFriNfc_TopazDynamicMap_ConvertToReadOnly (
630     phFriNfc_NdefMap_t     *psNdefMap);
631 #endif /* #ifdef FRINFC_READONLY_NDEF */
632 
633 
634 
635 #endif /* PHFRINFC_TOPAZMAP_H */
636 
637