phFriNfc_MifULFormat.h revision 5d9927ba30ba449badb9f6df0fbeb4d6aedc6e2a
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_MifULFormat.h 19 * \brief NFC Ndef Formatting For Mifare standard card. 20 * 21 * Project: NFC-FRI 22 * 23 * $Date: Wed Jun 3 14:38:25 2009 $ 24 * $Author: ing07336 $ 25 * $Revision: 1.4 $ 26 * $Aliases: NFC_FRI1.1_WK924_PREP1,NFC_FRI1.1_WK924_R27_1,NFC_FRI1.1_WK926_R28_1,NFC_FRI1.1_WK928_R29_1,NFC_FRI1.1_WK930_R30_1,NFC_FRI1.1_WK934_PREP_1,NFC_FRI1.1_WK934_R31_1,NFC_FRI1.1_WK941_PREP1,NFC_FRI1.1_WK941_PREP2,NFC_FRI1.1_WK941_1,NFC_FRI1.1_WK943_R32_1,NFC_FRI1.1_WK949_PREP1,NFC_FRI1.1_WK943_R32_10,NFC_FRI1.1_WK943_R32_13,NFC_FRI1.1_WK943_R32_14,NFC_FRI1.1_WK1007_R33_1,NFC_FRI1.1_WK1007_R33_4,NFC_FRI1.1_WK1017_PREP1,NFC_FRI1.1_WK1017_R34_1,NFC_FRI1.1_WK1017_R34_2,NFC_FRI1.1_WK1023_R35_1 $ 27 * 28 */ 29 30#ifndef PHFRINFC_MIFULFORMAT_H 31#define PHFRINFC_MIFULFORMAT_H 32 33#include <phFriNfc.h> 34#ifdef PH_HAL4_ENABLE 35 #include <phHal4Nfc.h> 36#else 37 #include <phHalNfc.h> 38#endif 39#include <phNfcStatus.h> 40#include <phNfcTypes.h> 41#include <phFriNfc_SmtCrdFmt.h> 42 43#ifdef PH_NDEF_MIFARE_ULC 44#include <phFriNfc_NdefMap.h> 45#endif /* #ifdef PH_NDEF_MIFARE_ULC */ 46 47#define PH_FRINFC_MIFUL_FORMAT_FILEREVISION "$Revision: 1.4 $" 48#define PH_FRINFC_MIFUL_FORMAT_FILEALIASES "$Aliases: NFC_FRI1.1_WK924_PREP1,NFC_FRI1.1_WK924_R27_1,NFC_FRI1.1_WK926_R28_1,NFC_FRI1.1_WK928_R29_1,NFC_FRI1.1_WK930_R30_1,NFC_FRI1.1_WK934_PREP_1,NFC_FRI1.1_WK934_R31_1,NFC_FRI1.1_WK941_PREP1,NFC_FRI1.1_WK941_PREP2,NFC_FRI1.1_WK941_1,NFC_FRI1.1_WK943_R32_1,NFC_FRI1.1_WK949_PREP1,NFC_FRI1.1_WK943_R32_10,NFC_FRI1.1_WK943_R32_13,NFC_FRI1.1_WK943_R32_14,NFC_FRI1.1_WK1007_R33_1,NFC_FRI1.1_WK1007_R33_4,NFC_FRI1.1_WK1017_PREP1,NFC_FRI1.1_WK1017_R34_1,NFC_FRI1.1_WK1017_R34_2,NFC_FRI1.1_WK1023_R35_1 $" 49 50 51/*! 52 * \name Mifare UL - constants for the state 53 * 54 */ 55/*@{*/ 56#define PH_FRINFC_MFUL_FMT_RESET_INIT 0 /*!< Reset state */ 57#define PH_FRINFC_MFUL_FMT_RD_16BYTES 1 /*!< Read 16 bytes */ 58#define PH_FRINFC_MFUL_FMT_WR_OTPBYTES 2 /*!< Write OTP bytes */ 59#define PH_FRINFC_MFUL_FMT_WR_TLV 3 /*!< Write TLV */ 60#ifdef PH_NDEF_MIFARE_ULC 61#define PH_FRINFC_MFUL_FMT_WR_TLV1 4 /*!< Write TLV (second part) */ 62#endif /* #ifdef PH_NDEF_MIFARE_ULC */ 63 64/*@}*/ 65 66 67/*! 68* \name Mifare standard - Block numbers 69* 70*/ 71/*@{*/ 72#define PH_FRINFC_MFUL_FMT_LOCK_BITS_VAL 0x00 /*!< Lock bits block is 2 */ 73 74/*@}*/ 75 76/*! 77 * \name Mifare UL - OTP bytes 78 * 79 */ 80/*@{*/ 81#ifdef PH_NDEF_MIFARE_ULC 82#define PH_FRINFC_MFULC_FMT_OTP_BYTES {0xE1, 0x10, 0x12, 0x00} /*!< OTP bytes macro */ 83#endif /* #ifdef PH_NDEF_MIFARE_ULC */ 84#define PH_FRINFC_MFUL_FMT_OTP_BYTES {0xE1, 0x10, 0x06, 0x00} /*!< OTP bytes macro */ 85 86/*@}*/ 87 88/*! 89 * \name Mifare UL - enums the values 90 * 91 */ 92/*@{*/ 93enum{ 94PH_FRINFC_MFUL_FMT_VAL_0, 95PH_FRINFC_MFUL_FMT_VAL_1, 96PH_FRINFC_MFUL_FMT_VAL_2, 97PH_FRINFC_MFUL_FMT_VAL_3, 98PH_FRINFC_MFUL_FMT_VAL_4, 99PH_FRINFC_MFUL_FMT_VAL_5, 100PH_FRINFC_MFUL_FMT_VAL_6, 101PH_FRINFC_MFUL_FMT_VAL_7 102}; 103/*@}*/ 104 105/*! 106 * \name Mifare UL - constants 107 * 108 */ 109/*@{*/ 110#define PH_FRINFC_MFUL_FMT_NON_NDEF_COMPL 0 /*!< Card is not ndef compliant */ 111#define PH_FRINFC_MFUL_FMT_NDEF_COMPL 1 /*!< Card is ndef compliant */ 112/*@}*/ 113 114/*! 115 * \name Mifare UL - constants 116 * 117 */ 118/*@{*/ 119#define PH_FRINFC_MFUL_FMT_MAX_RECV_LENGTH 252 /*!< Maximum receive length */ 120#define PH_FRINFC_MFUL_FMT_WR_SEND_LENGTH 5 /*!< Send length for write */ 121#define PH_FRINFC_MFUL_FMT_MAX_BLK 16 /*!< Maximum blocks */ 122 123/*@}*/ 124 125/*! 126 * \name Mifare UL - constants for filling send buffer, calculating the block number, 127 * checking the authenticate state 128 * 129 */ 130/*@{*/ 131 132/*@}*/ 133 134 135/** 136 * \ingroup grp_fri_smart_card_formatting 137 * \brief Smart Card Formatting \b Reset function 138 * 139 * \copydoc page_reg Resets the component instance to the initial state and initializes the 140 * internal variables. 141 */ 142void phFriNfc_MfUL_Reset(phFriNfc_sNdefSmtCrdFmt_t *NdefSmtCrdFmt); 143 144/*! 145 * \ingroup grp_fri_smart_card_formatting 146 * 147 * \brief Initiates the card formatting procedure for Remote Smart Card Type. 148 * 149 * \copydoc page_ovr The function initiates and formats the Smart Card.After this formation, remote 150 * card would be properly initialized and Ndef Compliant. 151 * Depending upon the different card type, this function handles formatting procedure. 152 * This function also handles the different recovery procedures for different types of the cards. For both 153 * Format and Recovery Management same API is used. 154 * 155 * \param[in] phFriNfc_sNdefSmartCardFmt_t Pointer to a valid instance of the \ref phFriNfc_sNdefSmartCardFmt_t 156 * structure describing the component context. 157 * \retval NFCSTATUS_PENDING The action has been successfully triggered. 158 * \retval Other values An error has occurred. 159 * 160 */ 161NFCSTATUS phFriNfc_MfUL_Format(phFriNfc_sNdefSmtCrdFmt_t *NdefSmtCrdFmt); 162 163/** 164 *\ingroup grp_fri_smart_card_formatting 165 * 166 * \brief Smart card Formatting \b Completion \b Routine or \b Process function 167 * 168 * \copydoc page_ovr Completion Routine: This function is called by the lower layer (OVR HAL) 169 * when an I/O operation has finished. The internal state machine decides 170 * whether to call into the lower device again or to complete the process 171 * by calling into the upper layer's completion routine, stored within this 172 * component's context (\ref phFriNfc_sNdefSmtCrdFmt_t). 173 * 174 * The function call scheme is according to \ref grp_interact. No State reset is performed during 175 * operation. 176 * 177 * \param[in] Context The context of the current (not the lower/upper) instance, as set by the lower, 178 * calling layer, upon its completion. 179 * \param[in] Status The completion status of the lower layer (to be handled by the implementation of 180 * the state machine of this function like a regular return value of an internally 181 * called function). 182 * 183 * \note For general information about the completion routine interface please see \ref pphFriNfc_Cr_t . * The Different Status Values are as follows 184 * 185 */ 186void phFriNfc_MfUL_Process(void *Context, 187 NFCSTATUS Status); 188#endif /* PHFRINFC_MIFULFORMAT_H */ 189 190