Initialize Tizen 2.3
[adaptation/devices/nfc-plugin-nxp.git] / src / phFriNfc_MifULFormat.h
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: Mon Dec 13 14:14:12 2010 $
24  * $Author: ing02260 $
25  * $Revision: 1.5 $
26  * $Aliases:  $
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.5 $"
48 #define PH_FRINFC_MIFUL_FORMAT_FILEALIASES  "$Aliases:  $"
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 #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 */
67
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 */
74
75 #endif /* #ifdef FRINFC_READONLY_NDEF */
76
77 /*@}*/
78
79
80 /*!
81 * \name Mifare standard - Block numbers
82 *
83 */
84 /*@{*/
85 #define PH_FRINFC_MFUL_FMT_LOCK_BITS_VAL       0x00   /*!< Lock bits block is 2 */
86
87 /*@}*/
88
89 /*!
90  * \name Mifare UL - OTP bytes
91  *
92  */
93 /*@{*/
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 */
98
99 /*@}*/
100
101 /*!
102  * \name Mifare UL - enums the values 
103  *
104  */
105 /*@{*/
106 enum{
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
115 };
116 /*@}*/
117
118 /*!
119  * \name Mifare UL - constants
120  *
121  */
122 /*@{*/
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 */
125 /*@}*/
126
127 /*!
128  * \name Mifare UL - constants
129  *
130  */
131 /*@{*/
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 */
135
136 /*@}*/
137
138 /*!
139  * \name Mifare UL - constants for filling send buffer, calculating the block number,
140  * checking the authenticate state
141  *
142  */
143 /*@{*/
144
145 /*@}*/
146
147
148 /**
149  * \ingroup grp_fri_smart_card_formatting
150  * \brief Smart Card Formatting \b Reset function
151  *
152  * \copydoc page_reg Resets the component instance to the initial state and initializes the 
153  *          internal variables.
154  */
155 void phFriNfc_MfUL_Reset(phFriNfc_sNdefSmtCrdFmt_t    *NdefSmtCrdFmt);
156
157 /*!
158  * \ingroup grp_fri_smart_card_formatting
159  *
160  * \brief Initiates the card formatting procedure for Remote Smart Card Type.
161  *
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.
167  * 
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.
172  *
173  */
174 NFCSTATUS phFriNfc_MfUL_Format(phFriNfc_sNdefSmtCrdFmt_t    *NdefSmtCrdFmt);
175
176 #ifdef FRINFC_READONLY_NDEF
177
178 /*!
179  * \ingroup grp_fri_smart_card_formatting
180  *
181  * \brief Initiates the conversion of the already NDEF formatted tag to READ ONLY.
182  *
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.
186  *
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.
191  *
192  */
193 NFCSTATUS
194 phFriNfc_MfUL_ConvertToReadOnly (
195     phFriNfc_sNdefSmtCrdFmt_t    *NdefSmtCrdFmt);
196
197 #endif /* #ifdef FRINFC_READONLY_NDEF */
198
199 /**
200  *\ingroup grp_fri_smart_card_formatting
201  *
202  * \brief Smart card Formatting \b Completion \b Routine or \b Process function
203  *
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).
209  *
210  * The function call scheme is according to \ref grp_interact. No State reset is performed during
211  * operation.
212  *
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
217  *                    called function).
218  *
219  * \note For general information about the completion routine interface please see \ref pphFriNfc_Cr_t . * The Different Status Values are as follows
220  *
221  */
222 void phFriNfc_MfUL_Process(void            *Context,
223                             NFCSTATUS       Status);
224 #endif /* PHFRINFC_MIFULFORMAT_H */
225