2 * Copyright (C) 2010 NXP Semiconductors
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
18 * \file phFriNfc_MifULFormat.h
19 * \brief NFC Ndef Formatting For Mifare standard card.
23 * $Date: Mon Dec 13 14:14:12 2010 $
30 #ifndef PHFRINFC_MIFULFORMAT_H
31 #define PHFRINFC_MIFULFORMAT_H
35 #include <phHal4Nfc.h>
39 #include <phNfcStatus.h>
40 #include <phNfcTypes.h>
41 #include <phFriNfc_SmtCrdFmt.h>
43 #ifdef PH_NDEF_MIFARE_ULC
44 #include <phFriNfc_NdefMap.h>
45 #endif /* #ifdef PH_NDEF_MIFARE_ULC */
47 #define PH_FRINFC_MIFUL_FORMAT_FILEREVISION "$Revision: 1.5 $"
48 #define PH_FRINFC_MIFUL_FORMAT_FILEALIASES "$Aliases: $"
52 * \name Mifare UL - constants for the state
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 #ifdef FRINFC_READONLY_NDEF
64 #define PH_FRINFC_MFUL_FMT_RO_RD_16BYTES 5 /*!< Read only the tag */
65 #define PH_FRINFC_MFUL_FMT_RO_WR_LOCK_BYTES 6 /*!< Write lock bytes to make the tag Read only */
66 #define PH_FRINFC_MFUL_FMT_RO_WR_OTP_BYTES 7 /*!< Write OTP bytes to make the tag Read only */
68 #ifdef PH_NDEF_MIFARE_ULC
69 #define PH_FRINFC_MFUL_FMT_RO_RD_DYN_LOCK_BYTES 8 /*!< Read default dynamic lock bytes address */
70 #define PH_FRINFC_MFUL_FMT_RO_WR_DYN_LOCK_BYTES 9 /*!< Write default dynamic lock bytes address */
71 #define PH_FRINFC_MFUL_FMT_RO_PARSE_NDEF 10 /*!< Write default dynamic lock bytes address */
72 #define PH_FRINFC_MFUL_FMT_RO_NDEF_PARSE_RD_BYTES 12 /*!< Read bytes from the card for parsing NDEF */
73 #endif /* #ifdef PH_NDEF_MIFARE_ULC */
75 #endif /* #ifdef FRINFC_READONLY_NDEF */
81 * \name Mifare standard - Block numbers
85 #define PH_FRINFC_MFUL_FMT_LOCK_BITS_VAL 0x00 /*!< Lock bits block is 2 */
90 * \name Mifare UL - OTP bytes
94 #ifdef PH_NDEF_MIFARE_ULC
95 #define PH_FRINFC_MFULC_FMT_OTP_BYTES {0xE1, 0x10, 0x12, 0x00} /*!< OTP bytes macro */
96 #endif /* #ifdef PH_NDEF_MIFARE_ULC */
97 #define PH_FRINFC_MFUL_FMT_OTP_BYTES {0xE1, 0x10, 0x06, 0x00} /*!< OTP bytes macro */
102 * \name Mifare UL - enums the values
107 PH_FRINFC_MFUL_FMT_VAL_0,
108 PH_FRINFC_MFUL_FMT_VAL_1,
109 PH_FRINFC_MFUL_FMT_VAL_2,
110 PH_FRINFC_MFUL_FMT_VAL_3,
111 PH_FRINFC_MFUL_FMT_VAL_4,
112 PH_FRINFC_MFUL_FMT_VAL_5,
113 PH_FRINFC_MFUL_FMT_VAL_6,
114 PH_FRINFC_MFUL_FMT_VAL_7
119 * \name Mifare UL - constants
123 #define PH_FRINFC_MFUL_FMT_NON_NDEF_COMPL 0 /*!< Card is not ndef compliant */
124 #define PH_FRINFC_MFUL_FMT_NDEF_COMPL 1 /*!< Card is ndef compliant */
128 * \name Mifare UL - constants
132 #define PH_FRINFC_MFUL_FMT_MAX_RECV_LENGTH 252 /*!< Maximum receive length */
133 #define PH_FRINFC_MFUL_FMT_WR_SEND_LENGTH 5 /*!< Send length for write */
134 #define PH_FRINFC_MFUL_FMT_MAX_BLK 16 /*!< Maximum blocks */
139 * \name Mifare UL - constants for filling send buffer, calculating the block number,
140 * checking the authenticate state
149 * \ingroup grp_fri_smart_card_formatting
150 * \brief Smart Card Formatting \b Reset function
152 * \copydoc page_reg Resets the component instance to the initial state and initializes the
153 * internal variables.
155 void phFriNfc_MfUL_Reset(phFriNfc_sNdefSmtCrdFmt_t *NdefSmtCrdFmt);
158 * \ingroup grp_fri_smart_card_formatting
160 * \brief Initiates the card formatting procedure for Remote Smart Card Type.
162 * \copydoc page_ovr The function initiates and formats the Smart Card.After this formation, remote
163 * card would be properly initialized and Ndef Compliant.
164 * Depending upon the different card type, this function handles formatting procedure.
165 * This function also handles the different recovery procedures for different types of the cards. For both
166 * Format and Recovery Management same API is used.
168 * \param[in] phFriNfc_sNdefSmartCardFmt_t Pointer to a valid instance of the \ref phFriNfc_sNdefSmartCardFmt_t
169 * structure describing the component context.
170 * \retval NFCSTATUS_PENDING The action has been successfully triggered.
171 * \retval Other values An error has occurred.
174 NFCSTATUS phFriNfc_MfUL_Format(phFriNfc_sNdefSmtCrdFmt_t *NdefSmtCrdFmt);
176 #ifdef FRINFC_READONLY_NDEF
179 * \ingroup grp_fri_smart_card_formatting
181 * \brief Initiates the conversion of the already NDEF formatted tag to READ ONLY.
183 * \copydoc page_ovr The function initiates the conversion of the already NDEF formatted
184 * tag to READ ONLY.After this formation, remote card would be properly Ndef Compliant and READ ONLY.
185 * Depending upon the different card type, this function handles formatting procedure.
187 * \param[in] phFriNfc_sNdefSmartCardFmt_t Pointer to a valid instance of the \ref phFriNfc_sNdefSmartCardFmt_t
188 * structure describing the component context.
189 * \retval NFCSTATUS_PENDING The action has been successfully triggered.
190 * \retval Other values An error has occurred.
194 phFriNfc_MfUL_ConvertToReadOnly (
195 phFriNfc_sNdefSmtCrdFmt_t *NdefSmtCrdFmt);
197 #endif /* #ifdef FRINFC_READONLY_NDEF */
200 *\ingroup grp_fri_smart_card_formatting
202 * \brief Smart card Formatting \b Completion \b Routine or \b Process function
204 * \copydoc page_ovr Completion Routine: This function is called by the lower layer (OVR HAL)
205 * when an I/O operation has finished. The internal state machine decides
206 * whether to call into the lower device again or to complete the process
207 * by calling into the upper layer's completion routine, stored within this
208 * component's context (\ref phFriNfc_sNdefSmtCrdFmt_t).
210 * The function call scheme is according to \ref grp_interact. No State reset is performed during
213 * \param[in] Context The context of the current (not the lower/upper) instance, as set by the lower,
214 * calling layer, upon its completion.
215 * \param[in] Status The completion status of the lower layer (to be handled by the implementation of
216 * the state machine of this function like a regular return value of an internally
219 * \note For general information about the completion routine interface please see \ref pphFriNfc_Cr_t . * The Different Status Values are as follows
222 void phFriNfc_MfUL_Process(void *Context,
224 #endif /* PHFRINFC_MIFULFORMAT_H */