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_NdefMap.h
     19  * \brief NFC Ndef Mapping For Different Smart Cards.
     20  *
     21  * Project: NFC-FRI
     22  *
     23  * $Date: Mon Mar 29 16:55:50 2010 $
     24  * $Author: ing02260 $
     25  * $Revision: 1.23 $
     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_NDEFMAP_H
     31 #define PHFRINFC_NDEFMAP_H
     32 
     33 
     34 /*include files*/
     35 #include <phNfcTypes.h>
     36 #include <phNfcStatus.h>
     37 #include <phFriNfc.h>
     38 #if !defined PH_HAL4_ENABLE
     39 #include <phHal4Nfc.h>
     40 #endif
     41 
     42 
     43 #include <phFriNfc_OvrHal.h>
     44 
     45 #ifndef PH_FRINFC_EXCLUDE_FROM_TESTFW /* */
     46 
     47 /**
     48  * \name NDEF Mapping
     49  *
     50  * File: \ref phFriNfc_NdefMap.h
     51  *
     52  */
     53 /*@{*/
     54 #define PH_FRINFC_NDEFMAP_FILEREVISION "$Revision: 1.23 $"  /**< \ingroup grp_file_attributes */
     55 #define PH_FRINFC_NDEFMAP_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 $"       /**< \ingroup grp_file_attributes */
     56 /*@}*/
     57 
     58 #endif /* PH_FRINFC_EXCLUDE_FROM_TESTFW */
     59 
     60 
     61 /** \defgroup grp_fri_nfc_ndef_map NDEF Mapping Component
     62  *
     63  *  This component implements the read/write/check NDEF functions for remote devices.
     64  *  NDEF data, as defined by the NFC Forum NDEF specification are written to or read from
     65  *  a remote device that can be a smart- or memory card. \n\n
     66  *  Please notice that the NDEF mapping command sequence must
     67  *  be \b contiguous (after correct initialisation): \n
     68  *  \b Examples:
     69  *  - Checking and Reading
     70  *      - \ref phFriNfc_NdefMap_ChkNdef
     71  *      - \ref phFriNfc_NdefMap_RdNdef
     72  *      .
     73  *  - Checking and Writing
     74  *      - \ref phFriNfc_NdefMap_ChkNdef
     75  *      - \ref phFriNfc_NdefMap_WrNdef
     76  *      .
     77  *  - Checking, Reading and Writing
     78  *      - \ref phFriNfc_NdefMap_ChkNdef
     79  *      - \ref phFriNfc_NdefMap_RdNdef
     80  *      - \ref phFriNfc_NdefMap_WrNdef
     81  *      .
     82  *  .
     83  * There must be \b no \b other FRI or HAL call between these mapping commands. Exceptions to this
     84  * rule are specific to the NDEF mapping of certain card / remote device types and separately noted,
     85  * typically for true multi-activation capable devices.
     86  *
     87  */
     88 
     89 /**
     90  * \name NDEF Mapping - specifies the different card types
     91  * These are the only recognised card types in this version.
     92  *
     93  */
     94 /*@{*/
     95 #define PH_FRINFC_NDEFMAP_MIFARE_UL_CARD                  1 /**< \internal Mifare UL */
     96 #define PH_FRINFC_NDEFMAP_ISO14443_4A_CARD                2 /**< \internal Iso 14443-4A */
     97 #define PH_FRINFC_NDEFMAP_MIFARE_STD_1K_CARD              3 /**< \internal Mifare Standard */
     98 #define PH_FRINFC_NDEFMAP_MIFARE_STD_4K_CARD              4 /**< \internal Mifare Standard */
     99 #define PH_FRINFC_NDEFMAP_FELICA_SMART_CARD               5 /**< \internal Felica Smart Tag */
    100 #define PH_FRINFC_NDEFMAP_TOPAZ_CARD                      7 /**< \internal Felica Smart Tag */
    101 #define PH_FRINFC_NDEFMAP_TOPAZ_DYNAMIC_CARD              8 /**< \internal Felica Smart Tag */
    102 #define PH_FRINFC_NDEFMAP_ISO14443_4A_CARD_EV1            9 /**< \internal Iso 14443-4A EV1 */
    103 
    104 
    105 #ifdef PH_NDEF_MIFARE_ULC
    106 #define PH_FRINFC_NDEFMAP_MIFARE_ULC_CARD                  8 /**< \internal Mifare UL */
    107 #endif /* #ifdef PH_NDEF_MIFARE_ULC */
    108 
    109 #define PH_FRINFC_NDEFMAP_EMPTY_NDEF_MSG                  {0xD0, 0x00, 0x00}  /**< \internal Empty ndef message */
    110 
    111 
    112 #ifdef PHFRINFC_OVRHAL_MOCKUP  /* */
    113 #define PH_FRINFC_NDEFMAP_MOCKUP_CARD                     6 /**< \internal Mocup*/
    114 #endif  /* PHFRINFC_OVRHAL_MOCKUP */
    115 
    116 
    117 
    118 /* Enum reperesents the different card state*/
    119 typedef enum
    120 {
    121     PH_NDEFMAP_CARD_STATE_INITIALIZED,
    122     PH_NDEFMAP_CARD_STATE_READ_ONLY,
    123     PH_NDEFMAP_CARD_STATE_READ_WRITE,
    124     PH_NDEFMAP_CARD_STATE_INVALID
    125 }phNDEF_CARD_STATE;
    126 
    127 
    128 /*@}*/
    129 
    130 
    131 #ifndef PH_FRINFC_MAP_MIFARESTD_DISABLED
    132 /**
    133  * \name NDEF Mapping - specifies the Compliant Blocks in the Mifare 1k and 4k card types
    134  *
    135  */
    136 /*@{*/
    137 #define PH_FRINFC_NDEFMAP_MIFARESTD_1KNDEF_COMPBLOCK      45 /**< \internal Total Ndef Compliant blocks Mifare 1k */
    138 #define PH_FRINFC_NDEFMAP_MIFARESTD_4KNDEF_COMPBLOCK      210 /**< \internal Total Ndef Compliant blocks Mifare 4k */
    139 #define PH_FRINFC_NDEFMAP_MIFARESTD_RDWR_SIZE             16 /**< \internal Bytes read/write for one read/write operation*/
    140 #define PH_FRINFC_NDEFMAP_MIFARESTD_TOTALNO_BLK           40 /**< \internal Total number of sectors in Mifare 4k */
    141 #define PH_FRINFC_NDEFMAP_MIFARESTD_ST15_BYTES            15 /**< \internal To store 15 bytes after reading a block */
    142 /*@}*/
    143 #endif  /* PH_FRINFC_MAP_MIFARESTD_DISABLED */
    144 
    145 #ifndef PH_FRINFC_MAP_TOPAZ_DISABLED
    146 /**
    147  * \name NDEF Mapping - specifies the Compliant Blocks in the Mifare 1k and 4k card types
    148  *
    149  */
    150 /*@{*/
    151 #define PH_FRINFC_NDEFMAP_TOPAZ_MAX_SIZE                  256  /**< \internal Total Memory size = 96 bytes (newer version have mode) */
    152 #define PH_FRINFC_NDEFMAP_TOPAZ_UID_SIZE                  0x04  /**< \internal UID size returned by READID command = 4 bytes */
    153 /*@}*/
    154 #endif  /* PH_FRINFC_MAP_TOPAZ_DISABLED */
    155 
    156 #ifndef PH_FRINFC_MAP_FELICA_DISABLED
    157 /* Felica Mapping - Constants */
    158 #define PH_FRINFC_NDEFMAP_FELICA_BLOCK_SIZE               16
    159 #define PH_FRINFC_NDEFMAP_FELICA_ATTR_NDEF_DATA_LEN        3
    160 #define PH_FRINFC_NDEFMAP_FELICA_MANUF_ID_DATA_LEN         8
    161 #endif  /* PH_FRINFC_MAP_FELICA_DISABLED */
    162 
    163 /* MifareUL/Type2 specific constants*/
    164 #ifndef PH_FRINFC_MAP_MIFAREUL_DISABLED
    165 
    166 #ifdef PH_NDEF_MIFARE_ULC
    167 #define PH_FRINFC_NDEFMAP_MFUL_64BYTES_BUF                2048 /**< \internal To store 2048 bytes after reading entire card */
    168 #else
    169 #define PH_FRINFC_NDEFMAP_MFUL_64BYTES_BUF                64 /**< \internal To store 64 bytes after reading entire card */
    170 #endif /*#ifdef PH_NDEF_MIFARE_ULC */
    171 
    172 #define PH_FRINFC_NDEFMAP_MFUL_4BYTES_BUF                 4  /**< \internal To store 4 bytes after write */
    173 
    174 #endif /*#ifndef PH_FRINFC_MAP_MIFAREUL_DISABLED*/
    175 
    176 #ifdef PHFRINFC_OVRHAL_MOCKUP  /* */
    177 
    178 #define PH_FRINFC_NDEFMAP_MOCKUP_4096BYTES_BUF            4096  /**< \internal To store 4 bytes after write */
    179 
    180 #endif /*#ifndef PH_FRINFC_MAP_MOCKUP_DISABLED*/
    181 
    182 /**
    183  * \name Completion Routine Indices
    184  *
    185  * These are the indices of the completion routine pointers within the component context.
    186  * Completion routines belong to upper components.
    187  *
    188  */
    189 /*@{*/
    190 /** \ingroup grp_fri_nfc_ndef_map
    191  *  Completion Routine Index for \ref phFriNfc_NdefMap_ChkNdef */
    192 #define PH_FRINFC_NDEFMAP_CR_CHK_NDEF       0  /* */
    193 /** \ingroup grp_fri_nfc_ndef_map
    194  *  Completion Routine Index for \ref phFriNfc_NdefMap_RdNdef */
    195 #define PH_FRINFC_NDEFMAP_CR_RD_NDEF        1  /* */
    196 /** \ingroup grp_fri_nfc_ndef_map
    197  *  Completion Routine Index for \ref phFriNfc_NdefMap_WrNdef */
    198 #define PH_FRINFC_NDEFMAP_CR_WR_NDEF        2  /* */
    199 /** \ingroup grp_fri_nfc_ndef_map
    200  *  Completion Routine Index for \ref phFriNfc_NdefMap_EraseNdef */
    201 #define PH_FRINFC_NDEFMAP_CR_ERASE_NDEF     3  /* */
    202 /** \ingroup grp_fri_nfc_ndef_map Completion
    203  *  Routine Index for Unknown States/Operations */
    204 #define PH_FRINFC_NDEFMAP_CR_INVALID_OPE    4  /* */
    205 /** \ingroup grp_fri_nfc_ndef_map
    206  *  Number of completion routines that have to be initialised */
    207 #define PH_FRINFC_NDEFMAP_CR                5  /* */
    208 /*@}*/
    209 
    210 /**
    211  * \name File Offset Attributes
    212  *
    213  * Following values are used to determine the offset value for Read/Write. This specifies whether
    214  * the Read/Write operation needs to be restarted/continued from the last offset set.
    215  *
    216  */
    217 /*@{*/
    218 /** \ingroup grp_fri_nfc_ndef_map
    219  *  Read/Write operation shall start from the last offset set */
    220 #define PH_FRINFC_NDEFMAP_SEEK_CUR                          0 /* */
    221 /** \ingroup grp_fri_nfc_ndef_map
    222  *  Read/Write operation shall start from the begining of the file/card */
    223 #define PH_FRINFC_NDEFMAP_SEEK_BEGIN                        1 /* */
    224 /*@}*/
    225 
    226 
    227 /**
    228  * \name Buffer Size Definitions
    229  *
    230  */
    231 /*@{*/
    232 /** \ingroup grp_fri_nfc_ndef_map Minimum size of the TRX buffer required */
    233 #define PH_FRINFC_NDEFMAP_MAX_SEND_RECV_BUF_SIZE            252 /* */
    234 /** \internal The size of s MIFARE block */
    235 #define PH_FRINFC_NDEFMAP_MF_READ_BLOCK_SIZE                16  /* */
    236 
    237 
    238 #ifndef PH_FRINFC_EXCLUDE_FROM_TESTFW /* */
    239 
    240 
    241 
    242 
    243 
    244 
    245 #ifndef PH_FRINFC_MAP_FELICA_DISABLED
    246 /**
    247  *  \ingroup grp_fri_nfc_ndef_map
    248  *  \brief Felica Basic structure which details the different vaiables
    249  *         used for Reading/writing.
    250  *
    251  */
    252 typedef struct phFriNfc_Felica
    253 {
    254     /**< Current block being read or written*/
    255     uint8_t     CurBlockNo;
    256 
    257     /**< No. Of Written*/
    258     uint8_t     NoBlocksWritten;
    259 
    260     /**< Following are different variables used for write operation*/
    261     uint8_t     Wr_BytesRemained;   /* No of bytes to pad*/
    262 
    263     /**< Buffer to store odd number of block data */
    264     uint8_t     Wr_RemainedBytesBuff[PH_FRINFC_NDEFMAP_FELICA_BLOCK_SIZE];
    265 
    266     /**< Following are different variables used for read operation*/
    267     uint8_t     Rd_NoBytesToCopy;         /*specifies the extra number of read bytes */
    268 
    269     /**< stores extra read data bytes*/
    270     uint8_t     Rd_BytesToCopyBuff[PH_FRINFC_NDEFMAP_FELICA_BLOCK_SIZE];
    271 
    272     /**< Flag determines Intermediate Copy Operation*/
    273     uint8_t     IntermediateCpyFlag;
    274 
    275     /**< Stores Intermediate Copy data len*/
    276     uint8_t     IntermediateCpyLen;
    277 
    278     /**< Flag specifies Pad Byte Information*/
    279     uint8_t     PadByteFlag;
    280 
    281     /**< Flag specifies Intermediate WR Information*/
    282     uint8_t     IntermediateWrFlag;
    283 
    284     /**< Flag specifies Intermediate Rd Information*/
    285     uint8_t     IntermediateRdFlag;
    286 
    287     /**< Flag specifies Last Block Reached Information*/
    288     uint8_t     LastBlkReachedFlag;
    289 
    290     /**< Specifies how many bytes read from the card*/
    291     uint16_t        CurrBytesRead;
    292 
    293     /**< Flag specifies EOF card reached Information*/
    294     uint8_t     EofCardReachedFlag;
    295 
    296     /**< Flag specifies different Operation Types*/
    297     uint8_t     OpFlag;
    298 
    299     /**< Specifies Offset*/
    300     uint8_t     Offset;
    301 
    302     /**< Specifies TrxLen Information*/
    303     uint16_t    TrxLen;
    304 
    305 }phFriNfc_Felica_t;
    306 
    307 /**
    308  *  \ingroup grp_fri_nfc_ndef_map
    309  *  \brief Felica structure which details the different vaiables
    310  *         used to store the poll related information.
    311  *
    312  */
    313 typedef struct phFriNfc_Felica_PollDetails
    314 {
    315     phHal_sDevInputParam_t          *DevInputParam;
    316 #ifndef PH_HAL4_ENABLE
    317     phHal_eOpModes_t                *OpMode;
    318 #endif
    319     /**<   Temporary place holder to the Remote Device
    320                     Information, required to store the Felica
    321                     session opened information. */
    322     phHal_sRemoteDevInformation_t   psTempRemoteDevInfo;
    323 }phFriNfc_Felica_PollDetails_t;
    324 
    325 /**
    326  *  \ingroup grp_fri_nfc_ndef_map
    327  *  \brief Felica structure which details the attribute related information.
    328  *
    329  */
    330 typedef struct phFriNfc_Felica_AttrInfo
    331 {
    332     /** Version of the Ndefmap document*/
    333     uint8_t     Version;
    334     /** Nbr for check cmd*/
    335     uint8_t     Nbr;
    336     /** Nbw for update cmd*/
    337     uint8_t     Nbw;
    338     /** Maximum number of blocks to store Ndef data*/
    339     uint16_t    Nmaxb;
    340     /** Flag to indicate the status of the write operation*/
    341     uint8_t     WriteFlag;
    342     /** Flag to indicate the status of the read/write operation*/
    343     uint8_t     RdWrFlag;
    344     /** Represents the length of Ndef data : 3 bytes*/
    345     uint8_t     LenBytes[PH_FRINFC_NDEFMAP_FELICA_ATTR_NDEF_DATA_LEN];
    346     /** Specifies the ERASE NDEF Message Operation */
    347     uint8_t     EraseMsgFlag;
    348 
    349 }phFriNfc_Felica_AttrInfo_t;
    350 
    351 /**
    352  *  \ingroup grp_fri_nfc_ndef_map
    353  *  \brief Felica structure which details the different vaiables
    354  *         used to store the Card Manufacturer details.
    355  */
    356 typedef struct phFriNfc_Felica_ManufDetails
    357 {
    358     /** Manufacture identifier*/
    359     uint8_t     ManufID[PH_FRINFC_NDEFMAP_FELICA_MANUF_ID_DATA_LEN];
    360     /** Manufacture Parameters*/
    361     uint8_t     ManufParameter[PH_FRINFC_NDEFMAP_FELICA_MANUF_ID_DATA_LEN];
    362 }phFriNfc_Felica_ManufDetails_t;
    363 #endif  /* PH_FRINFC_MAP_FELICA_DISABLED */
    364 
    365 #ifndef PH_FRINFC_MAP_MIFARESTD_DISABLED
    366 typedef struct phFriNfc_MifareStdCont
    367 {
    368     /** Device input parameter for poll and connect after failed authentication */
    369     phHal_sDevInputParam_t  *DevInputParam;
    370     /** to store bytes that will be used in the
    371         next write/read operation, if any */
    372     uint8_t             internalBuf[PH_FRINFC_NDEFMAP_MIFARESTD_ST15_BYTES];
    373     /** to Store the length of the internalBuf */
    374     uint16_t            internalLength;
    375     /** holds the block number which is presently been used */
    376     uint8_t             currentBlock;
    377     /** the number of Ndef Compliant blocks written/read */
    378     uint8_t             NdefBlocks;
    379     /** Total Number of Ndef Complaint Blocks */
    380     uint16_t            NoOfNdefCompBlocks;
    381     /** used in write ndef, to know that internal bytes
    382         are accessed */
    383     uint8_t             internalBufFlag;
    384     /** used in write ndef, to know that last 16 bytes
    385         are used to write*/
    386     uint8_t             RemainingBufFlag;
    387     /** indicates that Read has reached the end of the
    388         card */
    389     uint8_t             ReadWriteCompleteFlag;
    390     /** indicates that Read has reached the end of the
    391         card */
    392     uint8_t             ReadCompleteFlag;
    393     /** indicates that Write is possible or not */
    394     uint8_t             WriteFlag;
    395     /** indicates that Write is possible or not */
    396     uint8_t             ReadFlag;
    397     /** indicates that Write is possible or not */
    398     uint8_t             RdBeforeWrFlag;
    399     /** Authentication Flag indicating that a particular
    400         sector is authenticated or not */
    401     uint8_t             AuthDone;
    402     /** to store the last Sector ID in Check Ndef */
    403     uint8_t             SectorIndex;
    404     /** to read the access bits of each sector */
    405     uint8_t             ReadAcsBitFlag;
    406     /** Buffer to store 16 bytes */
    407     uint8_t             Buffer[PH_FRINFC_NDEFMAP_MIFARESTD_RDWR_SIZE];
    408     /** to store the AIDs of Mifare 1k or 4k */
    409     uint8_t             aid[PH_FRINFC_NDEFMAP_MIFARESTD_TOTALNO_BLK];
    410     /** flag to write with offset begin */
    411     uint8_t             WrNdefFlag;
    412     /** flag to read with offset begin */
    413     uint8_t             ReadNdefFlag;
    414     /** flag to check with offset begin */
    415     uint8_t             ChkNdefFlag;
    416     /** To store the remaining size of the Mifare 1k or 4k card */
    417     uint16_t            remainingSize;
    418     /** To update the remaining size when writing to the Mifare 1k or 4k card */
    419     uint8_t             remSizeUpdFlag;
    420     /** The flag is to know that there is a different AID apart from
    421         NFC forum sector AID */
    422     uint16_t            aidCompleteFlag;
    423     /** The flag is to know that there is a a NFC forum sector exists
    424         in the card */
    425     uint16_t            NFCforumSectFlag;
    426     /** The flag is to know that the particular sector is a proprietary
    427         NFC forum sector */
    428     uint16_t            ProprforumSectFlag;
    429     /** The flag is set after reading the MAD sectors */
    430     uint16_t            ChkNdefCompleteFlag;
    431     /** Flag to store the current block */
    432     uint8_t             TempBlockNo;
    433     /** Completion routine index */
    434     uint8_t             CRIndex;
    435     /** Bytes remaining to write for one write procedure */
    436     uint16_t            WrLength;
    437     /** Flag to read after write */
    438     uint8_t             RdAfterWrFlag;
    439     /** Flag to say that poll is required before write ndef (authentication) */
    440     uint8_t             PollFlag;
    441     /** Flag is to know that this is first time the read has been called. This
    442     is required when read is called after write (especially for the card formatted
    443     with the 2nd configuration) */
    444     uint8_t             FirstReadFlag;
    445     /** Flag is to know that this is first time the write has been called. This
    446     is required when the card formatted with the 3rd configuration */
    447     uint8_t             FirstWriteFlag;
    448 }phFriNfc_MifareStdCont_t;
    449 /*@}*/
    450 #endif  /* PH_FRINFC_MAP_MIFARESTD_DISABLED */
    451 
    452 #ifndef PH_FRINFC_MAP_DESFIRE_DISABLED
    453 /**
    454  *  \ingroup grp_fri_nfc_ndef_map
    455  *  \brief Capability Container.
    456  *
    457  *  The Capability Container structure required for smart card operations.
    458  *
    459  */
    460 typedef struct phFriNfc_DesfireCapCont
    461 {
    462     uint16_t    DesfVersion; /**< \internal Desfire Version . */
    463     uint16_t    NdefMsgFid;  /**< \internal Ndef Message file pointer*/
    464     uint16_t    NdefFileSize; /**< \internal Holds Desfire File Size */
    465     uint8_t     ReadAccess;  /**< \internal Read Access Information. */
    466     uint8_t     WriteAccess; /**< \internal Write Access Information. */
    467     uint16_t    MaxRespSize; /**< \internal Maximum expected response size. */
    468     uint16_t    MaxCmdSize;  /**< \internal Maximum command size. */
    469     uint16_t    NdefDataLen;  /**< \internal Holds actual NDEF Data Len.*/
    470     uint8_t     IsNlenPresentFlag; /**< \internal specifies NLEN presence .*/
    471     uint8_t     SkipNlenBytesFlag; /**< \internal sets on presence of NLEN.*/
    472 } phFriNfc_DesfireCapCont_t;
    473 #endif  /* PH_FRINFC_MAP_DESFIRE_DISABLED */
    474 
    475 #ifndef PH_FRINFC_MAP_MIFAREUL_DISABLED
    476 /**
    477  *  \ingroup grp_fri_nfc_ndef_map
    478  *  \brief Mifare UL Basic structure which details the different vaiables
    479  *         used for Reading/writing.
    480  *
    481  */
    482 typedef struct phFriNfc_MifareULCont
    483 {
    484     /** to store bytes that will be used in the
    485         next write/read operation, if any */
    486     uint8_t             InternalBuf[PH_FRINFC_NDEFMAP_MFUL_4BYTES_BUF];
    487     /** to Store the length of the internalBuf */
    488     uint16_t            InternalLength;
    489     /** holds the sector number which is presently been used */
    490     uint8_t             CurrentSector;
    491     /** holds the block number which is presently been used */
    492     uint8_t             CurrentBlock;
    493     /** to know the completion routine */
    494     uint8_t             CRindex;
    495     /** This stores the free memory size left in the card */
    496     uint16_t            RemainingSize;
    497     /** Copy all the data(including non NDEF TLVs) from the card */
    498     uint8_t             ReadBuf[PH_FRINFC_NDEFMAP_MFUL_64BYTES_BUF];
    499     /** index of the above buffer */
    500     uint16_t            ReadBufIndex;
    501     /** This variable stores the index of the "ReadBuf" from which actual
    502         data has to be copied into the user buffer */
    503     uint16_t            ByteNumber;
    504     /** indicates that read/write has reached the end of the
    505         card */
    506     uint8_t             ReadWriteCompleteFlag;
    507     /** Buffer to store 4 bytes of data which is written to a block */
    508     uint8_t             Buffer[PH_FRINFC_NDEFMAP_MFUL_4BYTES_BUF];
    509 }phFriNfc_MifareULCont_t;
    510 #endif  /* PH_FRINFC_MAP_MIFAREUL_DISABLED */
    511 
    512 #ifdef PHFRINFC_OVRHAL_MOCKUP  /* */
    513 /**
    514  *  \ingroup grp_fri_nfc_ndef_map
    515  *  \brief Mifare UL Basic structure which details the different vaiables
    516  *         used for Reading/writing.
    517  *
    518  */
    519 typedef struct phFriNfc_MockupCont
    520 {
    521     /** to store bytes that will be used in the
    522         next write/read operation, if any */
    523     uint8_t             *NdefData;
    524     /** to Store the length of the internalBuf */
    525     uint32_t            NdefActualSize;
    526     /** to Store the length of the internalBuf */
    527     uint32_t            NdefMaxSize;
    528     /** to Store the length of the internalBuf */
    529     uint32_t            CardSize;
    530     /** holds the block number which is presently been used */
    531     uint32_t             CurrentBlock;
    532 } phFriNfc_MockupCont_t;
    533 #endif  /* PHFRINFC_OVRHAL_MOCKUP */
    534 
    535 #endif /* PH_FRINFC_EXCLUDE_FROM_TESTFW */
    536 
    537 /**
    538  *  \ingroup grp_fri_nfc_ndef_map
    539  *  \brief NDEF TLV structure which details the different vaiables
    540  *         used for TLV.
    541  *
    542  */
    543 typedef struct phFriNfc_NDEFTLVCont
    544 {
    545     /** Flag is to know that the TLV Type Found */
    546     uint8_t             NdefTLVFoundFlag;
    547     /** Sector number of the next/present available TLV */
    548     uint8_t             NdefTLVSector;
    549     /** Following two variables are used to store the
    550         T byte and the Block number in which the T is
    551         found in Tag */
    552     /** Byte number of the next/present available TLV */
    553     uint16_t            NdefTLVByte;
    554     /** Block number of the next/present available TLV */
    555     uint8_t             NdefTLVBlock;
    556     /** Authentication flag for NDEF TLV Block */
    557     uint8_t             NdefTLVAuthFlag;
    558     /** if the 16th byte of the last read is type (T) of TLV
    559         and next read contains length (L) bytes of TLV. This flag
    560         is set when the type (T) of TLV is found in the last read */
    561     uint8_t             TcheckedinTLVFlag;
    562     /** if the 16th byte of the last read is Length (L) of TLV
    563         and next read contains length (L) bytes of TLV. This flag
    564         is set when the Length (L) of TLV is found in the last read */
    565     uint8_t             LcheckedinTLVFlag;
    566     /** This flag is set, if Terminator TLV is already written
    567         and next read contains value (V) bytes of TLV. This flag
    568         is set when the value (V) of TLV is found in the last read */
    569     uint8_t             SetTermTLVFlag;
    570     /** To know the number of Length (L) field is present in the
    571         next block */
    572     uint8_t             NoLbytesinTLV;
    573     /** The value of 3 bytes length(L) field in TLV. In 3 bytes
    574         length field, 2 bytes are in one block and other 1 byte
    575         is in the next block. To store the former block length
    576         field value, this variable is used */
    577     uint16_t            prevLenByteValue;
    578     /** The value of length(L) field in TLV. */
    579     uint16_t            BytesRemainLinTLV;
    580     /** Actual size to read and write. This will be always equal to the
    581         length (L) of TLV as there is only one NDEF TLV . */
    582     uint16_t            ActualSize;
    583     /** Flag is to write the length (L) field of the TLV */
    584     uint8_t             WrLenFlag;
    585     /** Flag is to write the length (L) field of the TLV */
    586     uint16_t            NULLTLVCount;
    587     /** Buffer to store 4 bytes of data which is written to a block */
    588     uint8_t             NdefTLVBuffer[PH_FRINFC_NDEFMAP_MFUL_4BYTES_BUF];
    589     /** Buffer to store 4 bytes of data which is written to a next block */
    590     uint8_t             NdefTLVBuffer1[PH_FRINFC_NDEFMAP_MFUL_4BYTES_BUF];
    591 }phFriNfc_NDEFTLVCont_t;
    592 
    593 /**
    594  *  \ingroup grp_fri_nfc_ndef_map
    595  *  \brief Lock Control TLV structure which stores the Position,
    596  *         Size and PageCntrl details.
    597  */
    598 
    599 typedef struct phFriNfc_LockCntrlTLVCont
    600 {
    601     /** Specifies the Byte Position of the lock cntrl tlv
    602         in the card memory*/
    603     uint16_t             ByteAddr;
    604 
    605     /** Specifies the Size of the lock area in terms of
    606         bits/bytes*/
    607     uint16_t             Size;
    608 
    609     /** Specifies the Bytes per Page*/
    610     uint8_t             BytesPerPage;
    611 
    612     /** Specifies the BytesLockedPerLockBit */
    613     uint8_t             BytesLockedPerLockBit;
    614 
    615     /** Specifies the index of Lock cntrl TLV*/
    616     uint8_t             LockTlvBuffIdx;
    617 
    618     /** Store the content of Lock cntrl TLV*/
    619     uint8_t             LockTlvBuff[8];
    620 
    621     /** Specifies the Block number Lock cntrl TLV*/
    622     uint16_t             BlkNum;
    623 
    624     /** Specifies the Byte Number position of Lock cntrl TLV*/
    625     uint16_t             ByteNum;
    626 
    627 
    628 }phFriNfc_LockCntrlTLVCont_t;
    629 
    630 
    631 /**
    632  *  \ingroup grp_fri_nfc_ndef_map
    633  *  \brief Memeory Control TLV structure which stores the Position,
    634  *         Size and PageCntrl details of the reserved byte area.
    635  */
    636 
    637 typedef struct phFriNfc_ResMemCntrlTLVCont
    638 {
    639     /** Specifies the Byte Position of the lock cntrl tlv
    640         in the card memory*/
    641     uint16_t             ByteAddr;
    642 
    643     /** Specifies the Size of the lock area in terms of
    644         bits/bytes*/
    645     uint16_t             Size;
    646 
    647     /** Store the content of Memory cntrl TLV*/
    648     uint8_t             MemCntrlTlvBuff[8];
    649 
    650     /** Specifies the Bytes per Page*/
    651     uint8_t             BytesPerPage;
    652 
    653     /** Specifies the index of Mem cntrl TLV*/
    654     uint8_t             MemTlvBuffIdx;
    655 
    656     /** Specifies the Block number Lock cntrl TLV*/
    657     uint16_t             BlkNum;
    658 
    659     /** Specifies the Byte Number position of Lock cntrl TLV*/
    660     uint16_t             ByteNum;
    661 
    662 
    663 
    664 }phFriNfc_ResMemCntrlTLVCont_t;
    665 
    666 #if !(defined(PH_FRINFC_MAP_TOPAZ_DISABLED ) || defined (PH_FRINFC_MAP_TOPAZ_DYNAMIC_DISABLED ))
    667 
    668 /**
    669  *  \ingroup grp_fri_nfc_ndef_map
    670  *  \brief Topaz container structure which details the different vaiables
    671  *         used for Topaz card mapping.
    672  *
    673  */
    674 typedef struct phFriNfc_TopazCont
    675 {
    676     /** This stores the free memory size left in the card. In case of topaz,
    677         this is updated only during check ndef */
    678     uint16_t            RemainingSize;
    679     /** Stores the current block number */
    680     uint8_t             CurrentBlock;
    681     /** Stores the current block number */
    682     uint8_t             ByteNumber;
    683     /** To know the completion routine call */
    684     uint8_t             CRIndex;
    685 
    686     uint8_t             ReadWriteCompleteFlag;
    687     /** This state is used for write */
    688     uint8_t             InternalState;
    689      /** This state is used for write */
    690     uint8_t             SkipLockBlkFlag;
    691     /** To store the UID */
    692     uint8_t             UID[PH_FRINFC_NDEFMAP_TOPAZ_UID_SIZE];
    693     /** To CC bytes length */
    694     uint8_t             CCByteBuf[4];
    695     /** Store the Buffer Index */
    696     uint16_t             Cur_RW_Index;
    697 
    698     /* No of bytes read or write*/
    699     uint16_t            ByteRWFrmCard;
    700 
    701     /* Cuurent Segment */
    702     uint8_t             CurrentSeg;
    703 
    704      /** Store the read bytes */
    705     uint8_t             ReadBuffer[PH_FRINFC_NDEFMAP_TOPAZ_MAX_SIZE];
    706 
    707     /** Size to know the exact data filled in the ReadBuffer. Useful, when the
    708         offset = PH_FRINFC_NDEFMAP_SEEK_CUR */
    709     uint8_t             ReadBufferSize;
    710 
    711     /** NDEF TLV byte address, This stores the byte address of
    712         TYPE field of the TLV */
    713     uint16_t            NdefTLVByteAddress;
    714 
    715     /** Expected sequence */
    716     uint8_t             ExpectedSeq;
    717 
    718     /** Write sequence */
    719     uint8_t             WriteSeq;
    720 
    721     /** Actual NDEF message size */
    722     uint16_t            ActualNDEFMsgSize;
    723 
    724     /** NDEF Read Write size in the card, this excludes lock and reserved bytes,
    725         mentioned in the LOCK and MEMORY control TLVs */
    726     uint16_t            NDEFRWSize;
    727 
    728     /** Remaining read size in the card, after reading the card.
    729         User has asked for the data less than " ActualNDEFMsgSize ",
    730         then remaining read bytes are stored in this variable.
    731         If the next read is with offset = PH_FRINFC_NDEFMAP_SEEK_CUR,
    732         then this variable is used.
    733     */
    734     uint16_t            RemainingReadSize;
    735 
    736 }phFriNfc_TopazCont_t;
    737 
    738 #endif /* PH_FRINFC_MAP_TOPAZ_DISABLED */
    739 /**
    740  *  \ingroup grp_fri_nfc_ndef_map
    741  *  \brief NFC NDEF Mapping Component Context Structure
    742  *
    743  *  This structure is used to store the current context information of the instance.
    744  *
    745  */
    746 typedef struct phFriNfc_NdefMap
    747 {
    748     /**< \internal The state of the operation. */
    749     uint8_t                         State;
    750 
    751     /**< \internal Completion Routine Context. */
    752     phFriNfc_CplRt_t                CompletionRoutine[PH_FRINFC_NDEFMAP_CR];
    753 
    754     /**< \internal Pointer to the lower (HAL) instance. */
    755     void                            *LowerDevice;
    756 
    757     /**<\internal Holds the device additional informations*/
    758     phHal_sDepAdditionalInfo_t      psDepAdditionalInfo;
    759 
    760     /**<\internal Holds the completion routine informations of the Map Layer*/
    761     phFriNfc_CplRt_t                MapCompletionInfo;
    762 
    763     /**< \internal Pointer to the Remote Device Information */
    764     phHal_sRemoteDevInformation_t   *psRemoteDevInfo;
    765 
    766     /**<\internal Holds the Command Type(read/write)*/
    767     phHal_uCmdList_t               Cmd;
    768 
    769     /**< \internal Pointer to a temporary buffer. Could be
    770           used for read/write purposes */
    771     uint8_t                         *ApduBuffer;
    772 
    773     /**< \internal Size allocated to the ApduBuffer. */
    774     uint32_t                        ApduBufferSize;
    775 
    776     /**< \internal Index to the APDU Buffer. Used for internal calculations */
    777     uint16_t                        ApduBuffIndex;
    778 
    779     /**< \internal Pointer to the user-provided Data Size to be written trough WrNdef function. */
    780     uint32_t                        *WrNdefPacketLength;
    781 
    782 
    783     /**< \internal Holds the length of the received data. */
    784     uint16_t                        *SendRecvLength;
    785 
    786     /**<\internal Holds the ack of some intial commands*/
    787     uint8_t                         *SendRecvBuf;
    788 
    789     /**< \internal Holds the length of the data to be sent. */
    790     uint16_t                        SendLength;
    791 
    792     /**< \internal Data Byte Count, which gives the offset to the integration.*/
    793     uint16_t                        *DataCount;
    794 
    795     /**< \ internal Holds the previous operation on the card*/
    796     uint8_t                         PrevOperation;
    797 
    798     /**< \ internal Holds the previous state on the card*/
    799     uint8_t                         PrevState;
    800 
    801     /**< \internal Stores the type of the smart card. */
    802     uint8_t                         CardType;
    803 
    804      /**< \internal Stores the card state. */
    805     uint8_t                         CardState;
    806 
    807     /**< \internal Stores the memory size of the card */
    808     uint16_t                        CardMemSize;
    809 
    810     /**<\internal to Store the page offset on the mifare ul card*/
    811     uint8_t                         Offset;
    812 
    813     /** \internal specifies the desfire operation to be performed*/
    814     uint8_t                         DespOpFlag;
    815 
    816     /** \internal  Used to remeber how many bytes were written, to update
    817                    the dataCount and the BufferIndex */
    818     uint16_t                        NumOfBytesWritten;
    819 
    820     /**\internal used to remember number of L byte Remaining to be written */
    821     uint16_t                        NumOfLReminWrite;
    822 
    823     /** \internal  Pointer Used to remeber and return how many bytes were read,
    824                    to update the PacketDataLength in case of Read operation */
    825     /*  Fix for 0000238: [gk] MAP: Number of bytes actually read out is
    826         not returned. */
    827     uint32_t                        *NumOfBytesRead;
    828 
    829     /** \internal  Flag used to tell the process function that WRITE has
    830                    requested for an internal READ.*/
    831     uint8_t                         ReadingForWriteOperation;
    832 
    833     /** \internal  Buffer of 5 bytes used for the write operation for the
    834                    Mifare UL card.*/
    835     uint8_t                         BufferForWriteOp[5];
    836 
    837     /** \internal Temporary Receive Length to update the Receive Length
    838                   when every time the Overlapped HAL is called. */
    839     uint16_t                        TempReceiveLength;
    840 
    841     uint8_t                         NoOfDevices ;
    842 
    843     /** \internal stores operating mode type of the felica smart tag */
    844     /* phHal_eOpModes_t                OpModeType[2]; */
    845 
    846     /** \internal stores the type of the TLV found */
    847     uint8_t                         TLVFoundFlag;
    848 
    849     /** \internal stores the TLV structure related informations  */
    850     phFriNfc_NDEFTLVCont_t          TLVStruct;
    851 
    852 
    853     /** \internal stores the Lock Contrl Tlv related informations  */
    854     phFriNfc_LockCntrlTLVCont_t     LockTlv;
    855 
    856     /** \internal stores the Mem Contrl Tlv related informations  */
    857     phFriNfc_ResMemCntrlTLVCont_t   MemTlv;
    858 
    859 
    860 
    861     /** Capabilitity Containers: */
    862     #ifndef PH_FRINFC_EXCLUDE_FROM_TESTFW /* */
    863         /** \internal Desfire capability Container Structure. */
    864 #ifndef PH_FRINFC_MAP_DESFIRE_DISABLED
    865         phFriNfc_DesfireCapCont_t       DesfireCapContainer;
    866 #endif  /* PH_FRINFC_MAP_DESFIRE_DISABLED */
    867 
    868 #ifndef PH_FRINFC_MAP_MIFARESTD_DISABLED
    869         /** \internal Pointer to the Mifare Standard capability Container Structure. */
    870         phFriNfc_MifareStdCont_t        StdMifareContainer;
    871 #endif  /* PH_FRINFC_MAP_MIFARESTD_DISABLED */
    872 
    873 #ifndef PH_FRINFC_MAP_FELICA_DISABLED
    874         /** \internal Following are the Felica Smart tag related strucutre & variables */
    875         phFriNfc_Felica_t               Felica;
    876 
    877         /** \internal Struture Stores the dev i/p , opmode informations of smart tag */
    878         phFriNfc_Felica_PollDetails_t   FelicaPollDetails;
    879 
    880         /** \internal Struture Stores the different attribute informations of smart tag */
    881         phFriNfc_Felica_AttrInfo_t      FelicaAttrInfo;
    882 
    883         /** \internal Struture Stores the PMm,IDm informations of smart tag */
    884         phFriNfc_Felica_ManufDetails_t  FelicaManufDetails;
    885 #endif  /* PH_FRINFC_MAP_FELICA_DISABLED */
    886 #ifndef PH_FRINFC_MAP_MIFAREUL_DISABLED
    887         /** \internal Mifare UL capability container structure. */
    888         phFriNfc_MifareULCont_t         MifareULContainer;
    889 #endif  /* PH_FRINFC_MAP_MIFAREUL_DISABLED */
    890 #ifndef PH_FRINFC_MAP_TOPAZ_DISABLED
    891         /** \internal Mifare UL capability container structure. */
    892         phFriNfc_TopazCont_t            TopazContainer;
    893 #endif  /* PH_FRINFC_MAP_TOPAZ_DISABLED */
    894 
    895 #ifdef PHFRINFC_OVRHAL_MOCKUP
    896         phFriNfc_MockupCont_t MochupContainer;
    897 #endif  /* PHFRINFC_OVRHAL_MOCKUP */
    898 
    899     #endif /* PH_FRINFC_EXCLUDE_FROM_TESTFW */
    900 
    901 } phFriNfc_NdefMap_t;
    902 
    903 
    904 #ifndef PH_FRINFC_EXCLUDE_FROM_TESTFW /* */
    905 
    906 /**
    907  * \ingroup grp_fri_nfc_ndef_map
    908  *
    909  * \brief Ndef Mapping \b Reset function
    910  *
    911  * \copydoc page_reg Resets the component instance to the initial state and initialises the
    912  *          internal variables.
    913  *
    914  * \param[in] NdefMap is a Pointer to a valid and initialised or uninitialised instance
    915  *            of \ref phFriNfc_NdefMap_t .
    916  * \param[in] LowerDevice Overlapped HAL reference, pointing at a valid instance of this
    917  *            underlying component.
    918  * \param[in] psRemoteDevInfo Points to the Remote Device Information structure encapsulating
    919  *                            the information about the device (Smart card, NFC device) to access.
    920  * \param[in] psDevInputParam The Device input parameter, as used for the HAL POLL function.
    921  *                            This parameter is needed by the component in special cases, when an internal call
    922  *                            to POLL is required again, such as for FeliCa. The storage of the structure behind
    923  *                            the pointer must be retained by the calling software. The component itself only
    924  *                            keeps the reference. No change is applied to the structure's content.
    925  * \param[in] TrxBuffer Pointer to an internally used buffer. The buffer has to be allocated by
    926  *                      the integrating software (not done by the component). The purpose of
    927  *                      this storage is to serve as an intermediate buffer for data frame
    928  *                      composition and analysis.
    929  *                      The size shall be at least \ref PH_FRINFC_NDEFMAP_MAX_SEND_RECV_BUF_SIZE .
    930  * \param[in] TrxBufferSize The size of TrxBuffer:
    931  *            The size shall be at least \ref PH_FRINFC_NDEFMAP_MAX_SEND_RECV_BUF_SIZE .
    932  * \param[in] ReceiveBuffer Pointer to a buffer that the component uses internally use to
    933  *            store the data received from the lower component.
    934  *            The size shall be at least \ref PH_FRINFC_NDEFMAP_MAX_SEND_RECV_BUF_SIZE .
    935  * \param[in] ReceiveLength The size of ReceiveBuffer. This specifies the actual length
    936  *            of the data received from the lower component.
    937  *            The size shall be at least \ref PH_FRINFC_NDEFMAP_MAX_SEND_RECV_BUF_SIZE .
    938  * \param[in] DataCount Specifies the offset count during read/write operations. This can be
    939  *            used by the integrating software to know about the total number of bytes read/written
    940  *            from/to the card. The caller shall set the value behind the pointer to zero
    941  *            before calling this function.
    942  *
    943  * \retval NFCSTATUS_SUCCESS                Operation successful.
    944  * \retval NFCSTATUS_INVALID_PARAMETER      At least one parameter of the function is invalid.
    945  *
    946  * \note  The DataCount variable is internally updated by the module and must not be changed by the
    947  *        embedding software.
    948  * \note  This function has to be called at the beginning, after creating an instance of
    949  *        \ref phFriNfc_NdefMap_t .  Use this function to reset the instance and/or to switch
    950  *        to a different underlying device (different NFC device or device mode).
    951  */
    952 NFCSTATUS phFriNfc_NdefMap_Reset(phFriNfc_NdefMap_t              *NdefMap,
    953                                  void                            *LowerDevice,
    954                                  phHal_sRemoteDevInformation_t   *psRemoteDevInfo,
    955                                  phHal_sDevInputParam_t          *psDevInputParam,
    956                                  uint8_t                         *TrxBuffer,
    957                                  uint16_t                         TrxBufferSize,
    958                                  uint8_t                         *ReceiveBuffer,
    959                                  uint16_t                        *ReceiveLength,
    960                                  uint16_t                        *DataCount);
    961 
    962 
    963 /**
    964  * \ingroup grp_fri_nfc_ndef_map
    965  *
    966  * \brief Ndef Mapping \b Set \b Completion \b Routine function
    967  *
    968  * \copydoc page_reg Setting of the Completion Routine.
    969  *
    970  * This function sets the Completion Routine for the specified function ID:\n
    971  * The completion routine is a function of an upper layer in the stack that needs to be notified
    972  * when the current instance has completed an I/O operation and data and/or an I/O status value
    973  * is available. The list of valid function IDs can be found under the section
    974  * "Completion Routine Indices", like e.g. \ref PH_FRINFC_NDEFMAP_CR_CHK_NDEF.
    975  *
    976  * \param[in] NdefMap Pointer to a valid instance of the \ref phFriNfc_NdefMap_t structure
    977  *                    serving as the component context.
    978  * \param[in] FunctionID ID of the component API function to set a with a completion routine for.
    979  *                       A valid routine has to be assigned for each function ID.
    980  *                       Use the "Completion Routine Indices", such as \ref PH_FRINFC_NDEFMAP_CR_CHK_NDEF .
    981  * \param[in] CompletionRoutine Pointer to a completion routine (part of a component of the upper layer)
    982  *                              to be called when the non-blocking opertaion has finished.
    983  * \param[in] CompletionRoutineContext Pointer to the context of the (upper) component where the
    984  *                                     particular completion routine is located.
    985  *
    986  * \retval NFCSTATUS_SUCCESS                Operation successful.
    987  * \retval NFCSTATUS_INVALID_PARAMETER      At least one parameter of the function is invalid.
    988  *
    989  * \note  This function has to be called after \ref phFriNfc_NdefMap_Reset .
    990  */
    991 NFCSTATUS phFriNfc_NdefMap_SetCompletionRoutine(phFriNfc_NdefMap_t  *NdefMap,
    992                                                 uint8_t              FunctionID,
    993                                                 pphFriNfc_Cr_t       CompletionRoutine,
    994                                                 void                *CompletionRoutineContext);
    995 
    996 
    997 /**
    998  * \ingroup grp_fri_nfc_ndef_map
    999  *
   1000  * \brief Ndef Mapping \b Read \b Ndef function
   1001  *
   1002  * \copydoc page_ovr Initiates Reading of NDEF information from the Remote Device.
   1003  *
   1004  * The function initiates the reading of NDEF information from a Remote Device.
   1005  * It performs a reset of the state and restarts the state machine.
   1006  *
   1007  * \param[in] NdefMap Pointer to a valid instance of the \ref phFriNfc_NdefMap_t
   1008  *                    component context structure.
   1009  * \param[in,out] PacketData  Pointer to a location that shall receive the NDEF Packet.
   1010  * \param[in,out] PacketDataLength Pointer to a variable that shall receive the length of the NDEF packet.
   1011  *                                 The caller has to provide the maximum length, the function fills
   1012  *                                 in the actual number of bytes received.
   1013  * \param[in] Offset Indicates whether the read operation shall start from the begining of the
   1014  *            file/card storage \b or continue from the last offset. The last Offset set is stored
   1015  *            within a context (Data Count) variable (must not be modified by the integration).
   1016  *            If the caller sets the value to \ref PH_FRINFC_NDEFMAP_SEEK_CUR, the component shall
   1017  *            start reading from the last offset set (continue where it has stopped before).
   1018  *            If set to \ref PH_FRINFC_NDEFMAP_SEEK_BEGIN, the component shall start reading
   1019  *            from the begining of the card (restarted)
   1020  *
   1021  * \retval NFCSTATUS_PENDING               The action has been successfully triggered.
   1022  * \retval NFCSTATUS_SUCCESS               Operation Successful.
   1023  *
   1024  * \retval NFCSTATUS_INVALID_PARAMETER     At least one parameter of the function is invalid.
   1025  * \retval NFCSTATUS_INVALID_REMOTE_DEVICE Card Type is unsupported.
   1026  * \retval NFCSTATUS_EOF_CARD_REACHED      No Space in the File to read.
   1027  * \retval NFCSTATUS_INVALID_DEVICE        The device has not been opened or has been disconnected
   1028  *                                         meanwhile.
   1029  * \retval NFCSTATUS_CMD_ABORTED           The caller/driver has aborted the request.
   1030  * \retval NFCSTATUS_BUFFER_TOO_SMALL      The buffer provided by the caller is too small.
   1031  * \retval NFCSTATUS_RF_TIMEOUT            No data has been received within the TIMEOUT period.
   1032  *
   1033  */
   1034 NFCSTATUS phFriNfc_NdefMap_RdNdef(phFriNfc_NdefMap_t      *NdefMap,
   1035                                   uint8_t                 *PacketData,
   1036                                   uint32_t                *PacketDataLength,
   1037                                   uint8_t                  Offset);
   1038 
   1039 
   1040 /**
   1041  * \ingroup grp_fri_nfc_ndef_map
   1042  *
   1043  * \brief Ndef Mapping \b Check \b Ndef function
   1044  *
   1045  * \copydoc page_ovr Initiates Writing of NDEF information to the Remote Device.
   1046  *
   1047  * The function initiates the writing of NDEF information to a Remote Device.
   1048  * It performs a reset of the state and starts the action (state machine).
   1049  * A periodic call of the \ref phFriNfc_NdefMap_Process has to be done once the action
   1050  * has been triggered.
   1051  *
   1052  * \param[in] NdefMap Pointer to a valid instance of the \ref phFriNfc_NdefMap_t
   1053  *                    component context structure.
   1054  * \param[in] PacketData  Pointer to a location that holds the prepared NDEF Packet.
   1055  * \param[in,out] PacketDataLength Pointer to a variable that shall specify the length of the prepared NDEF packet.
   1056  *                                 The caller has to provide the length, the function fills
   1057  *                                 in the actual number of bytes received.
   1058  * \param[in] Offset Indicates whether the write operation shall start from the begining of the
   1059  *            file/card storage \b or continue from the last offset. The last Offset set is stored
   1060  *            within a context (Data Count) variable (must not be modified by the integration).
   1061  *            If the caller sets the value to \ref PH_FRINFC_NDEFMAP_SEEK_CUR, the component shall
   1062  *            start writing from the last offset set (continue where it has stopped before).
   1063  *            If set to \ref PH_FRINFC_NDEFMAP_SEEK_BEGIN, the component shall start writing
   1064  *            from the begining of the card (restarted)
   1065  *
   1066  * \retval NFCSTATUS_PENDING               The action has been successfully triggered.
   1067  * \retval NFCSTATUS_SUCCESS               Operation Successful.
   1068  *
   1069  * \retval NFCSTATUS_INVALID_PARAMETER     At least one parameter of the function is invalid.
   1070  * \retval NFCSTATUS_INVALID_REMOTE_DEVICE Card Type is unsupported.
   1071  * \retval NFCSTATUS_EOF_CARD_REACHED      No Space in the File to write.
   1072  * \retval NFCSTATUS_INVALID_DEVICE        The device has not been opened or has been disconnected
   1073  *                                         meanwhile.
   1074  * \retval NFCSTATUS_CMD_ABORTED           The caller/driver has aborted the request.
   1075  * \retval NFCSTATUS_BUFFER_TOO_SMALL      The buffer provided by the caller is too small.
   1076  * \retval NFCSTATUS_RF_TIMEOUT            No data has been received within the TIMEOUT period.
   1077  *
   1078  */
   1079 
   1080 extern NFCSTATUS phFriNfc_NdefMap_WrNdef(phFriNfc_NdefMap_t  *NdefMap,
   1081                                   uint8_t             *PacketData,
   1082                                   uint32_t            *PacketDataLength,
   1083                                   uint8_t              Offset);
   1084 
   1085 
   1086 /**
   1087  * \ingroup grp_fri_nfc_ndef_map
   1088  *
   1089  * \brief Ndef Mapping \b Check \b NDEF function
   1090  *
   1091  * \copydoc page_ovr Check whether a particular Remote Device is NDEF compliant.
   1092  *
   1093  * \param[in] NdefMap Pointer to a valid instance of the \ref phFriNfc_NdefMap_t
   1094  *                    component context structure.
   1095  *
   1096  * \retval NFCSTATUS_PENDING               The action has been successfully triggered.
   1097  * \retval NFCSTATUS_INVALID_PARAMETER     At least one parameter of the function is invalid.
   1098  * \retval NFCSTATUS_INVALID_REMOTE_DEVICE Card Type is unsupported.
   1099  * \retval NFCSTATUS_INVALID_PARAMETER     Completion Routine is NULL.
   1100  * \retval NFCSTATUS_INVALID_REMOTE_DEVICE OpModes invalid.
   1101  * \retval NFCSTATUS_INVALID_DEVICE        The device has not been opened or has been disconnected
   1102  *                                         meanwhile.
   1103  * \retval NFCSTATUS_CMD_ABORTED           The caller/driver has aborted the request.
   1104  * \retval NFCSTATUS_BUFFER_TOO_SMALL      The buffer provided by the caller is too small.
   1105  * \retval NFCSTATUS_RF_TIMEOUT            No data has been received within the TIMEOUT period.
   1106  *
   1107  */
   1108 NFCSTATUS phFriNfc_NdefMap_ChkNdef(phFriNfc_NdefMap_t *NdefMap);
   1109 
   1110 /**
   1111  * \ingroup grp_fri_nfc_ndef_map
   1112  *
   1113  * \brief Ndef Mapping \b Erase \b NDEF function
   1114  *
   1115  * \copydoc page_ovr find the position of the existing NDEF TLV and overwrite with \b empty NDEF
   1116  * message \b at that position.
   1117  *
   1118  * \param[in] NdefMap Pointer to a valid instance of the \ref phFriNfc_NdefMap_t
   1119  *                    component context structure.
   1120  *
   1121  * \retval NFCSTATUS_PENDING               The action has been successfully triggered.
   1122  * \retval NFCSTATUS_INVALID_PARAMETER     At least one parameter of the function is invalid.
   1123  * \retval NFCSTATUS_INVALID_REMOTE_DEVICE Card Type is unsupported.
   1124  * \retval NFCSTATUS_INVALID_PARAMETER     Completion Routine is NULL.
   1125  * \retval NFCSTATUS_INVALID_REMOTE_DEVICE OpModes invalid.
   1126  * \retval NFCSTATUS_INVALID_DEVICE        The device has not been opened or has been disconnected
   1127  *                                         meanwhile.
   1128  * \retval NFCSTATUS_CMD_ABORTED           The caller/driver has aborted the request.
   1129  * \retval NFCSTATUS_BUFFER_TOO_SMALL      The buffer provided by the caller is too small.
   1130  * \retval NFCSTATUS_RF_TIMEOUT            No data has been received within the TIMEOUT period.
   1131  *
   1132  */
   1133 NFCSTATUS phFriNfc_NdefMap_EraseNdef(phFriNfc_NdefMap_t *NdefMap);
   1134 
   1135 /**
   1136  * \ingroup grp_fri_nfc_ndef_map
   1137  *
   1138  * \brief Ndef Mapping \b Get Container size function
   1139  *
   1140  * \copydoc page_ovr Returns the size of the NDEF data that the card can hold to the caller.
   1141  *
   1142  * \param[in] NdefMap Pointer to a valid instance of the \ref phFriNfc_NdefMap_t
   1143  *                    component context structure.
   1144  *
   1145  * \param[out] size Pointer to a uint32_t variable, which receives the size of the NDEF data
   1146  *
   1147  * \retval  NFCSTATUS_SUCCESS               The size has been successfully calculated.
   1148  * \retval  NFCSTATUS_INVALID_PARAMETER     At least one parameter of the function is invalid.
   1149  * \retval  NFCSTATUS_INVALID_REMOTE_DEVICE          Card Type is unsupported.
   1150  *
   1151  */
   1152 
   1153 NFCSTATUS phFriNfc_NdefMap_GetContainerSize(const phFriNfc_NdefMap_t *NdefMap,uint32_t *maxSize, uint32_t *actualSize);
   1154 
   1155 /**
   1156  * \ingroup grp_fri_nfc_ndef_map
   1157  *
   1158  * \brief Ndef Mapping \b Completion \b Routine or \b Process function
   1159  *
   1160  * \copydoc page_cb Completion Routine: This function is called by the lower layer (OVR HAL)
   1161  *                  when an I/O operation has finished. The internal state machine decides
   1162  *                  whether to call into the lower device again or to complete the process
   1163  *                  by calling into the upper layer's completion routine, stored within this
   1164  *                  component's context (\ref phFriNfc_NdefMap_t).
   1165  *
   1166  * The function call scheme is according to \ref grp_interact. No State reset is performed during
   1167  * operation.
   1168  *
   1169  * \param[in] Context The context of the current (not the lower/upper) instance, as set by the lower,
   1170  *            calling layer, upon its completion.
   1171  * \param[in] Status  The completion status of the lower layer (to be handled by the implementation of
   1172  *                    the state machine of this function like a regular return value of an internally
   1173  *                    called function).
   1174  *
   1175  * \note For general information about the completion routine interface please see \ref pphFriNfc_Cr_t . * The Different Status Values are as follows
   1176  *
   1177  */
   1178 void phFriNfc_NdefMap_Process(void        *Context,
   1179                               NFCSTATUS   Status);
   1180 
   1181 
   1182 
   1183 /**
   1184  * \ingroup grp_fri_nfc_ndef_map
   1185  *
   1186  * \brief Ndef Mapping \b Check And Parse TLV Structure \b NDEF function
   1187  *
   1188  * \copydoc page_ovr Checks the presence of a valid TLV's(NDEF/Propritery).
   1189  *
   1190  * \param[in] NdefMap Pointer to a valid instance of the \ref phFriNfc_NdefMap_t
   1191  *                    component context structure.
   1192  *
   1193  * \retval NFCSTATUS_INVALID_FORMAT         No valid TLV Found.
   1194  * \retval NFCSTATUS_SUCCESS                Operation Successful.
   1195  *
   1196  */
   1197 NFCSTATUS phFriNfc_ChkAndParseTLV(phFriNfc_NdefMap_t    *NdefMap);
   1198 
   1199 
   1200 #ifdef PHFRINFC_OVRHAL_MOCKUP  /* */
   1201 
   1202 /**
   1203  * \ingroup grp_fri_nfc_ndef_map
   1204  *
   1205  * \brief Set data NDEF in mockup mode
   1206  *
   1207  * \param[in]       NdefMap          Pointer to a valid instance of the \ref phFriNfc_NdefMap_t component context structure.
   1208  * \param[in]       NdefData         Pointer to card mockup data
   1209  * \param[in]       NdefActualSize    The actual data length
   1210  * \param[in]       NdefMaxSize       The max data length
   1211  * \param[in]       NdefCardSize     The total card size
   1212  *
   1213  * \retval NFCSTATUS_SUCCESS          The operation is ok.
   1214  *
   1215  */
   1216 NFCSTATUS phFriNfc_NdefMap_MockupCardSetter(phFriNfc_NdefMap_t *NdefMap, uint8_t *NdefData, uint32_t NdefActualSize, uint32_t NdefMaxSize, uint32_t CardSize);
   1217 NFCSTATUS phFriNfc_NdefMap_MockupNDefModeEn(uint8_t  *pNdefCompliancy, uint8_t  *pCardType, uint8_t Enable);
   1218 #endif /*#ifndef PH_FRINFC_MAP_MOCKUP_DISABLED*/
   1219 
   1220 
   1221 /**
   1222  * \internal
   1223  * \name States of the FSM.
   1224  *
   1225  */
   1226 /*@{*/
   1227 #define PH_FRINFC_NDEFMAP_STATE_RESET_INIT                  0   /**< \internal Initial state */
   1228 #define PH_FRINFC_NDEFMAP_STATE_CR_REGISTERED               1   /**< \internal CR has been registered */
   1229 #define PH_FRINFC_NDEFMAP_STATE_EOF_CARD                    2   /**< \internal EOF card reached */
   1230 /*@}*/
   1231 
   1232 /* Following values specify the previous operation on the card. This value is assigned to
   1233    the context structure variable: PrevOperation. */
   1234 
   1235 /**< Previous operation is check*/
   1236 #define PH_FRINFC_NDEFMAP_CHECK_OPE                         1
   1237 /**< Previous operation is read*/
   1238 #define PH_FRINFC_NDEFMAP_READ_OPE                          2
   1239 /**< Previous operation is write */
   1240 #define PH_FRINFC_NDEFMAP_WRITE_OPE                         3
   1241 /**< Previous operation is Actual size */
   1242 #define PH_FRINFC_NDEFMAP_GET_ACTSIZE_OPE                   4
   1243 
   1244 /* This flag is set when there is a need of write operation on the odd positions
   1245    ex: 35,5 etc. This is used with MfUlOp Flag */
   1246 #define PH_FRINFC_MFUL_INTERNAL_READ                        3  /**< \internal Read/Write control*/
   1247 
   1248 
   1249 #endif /* PH_FRINFC_EXCLUDE_FROM_TESTFW */
   1250 
   1251 #endif /* PHFRINFC_NDEFMAP_H */
   1252