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