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