code update
[adaptation/devices/nfc-plugin-nxp.git] / src / phFriNfc_SmtCrdFmt.c
1 /*\r
2  * Copyright (C) 2010 NXP Semiconductors\r
3  *\r
4  * Licensed under the Apache License, Version 2.0 (the "License");\r
5  * you may not use this file except in compliance with the License.\r
6  * You may obtain a copy of the License at\r
7  *\r
8  *      http://www.apache.org/licenses/LICENSE-2.0\r
9  *\r
10  * Unless required by applicable law or agreed to in writing, software\r
11  * distributed under the License is distributed on an "AS IS" BASIS,\r
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
13  * See the License for the specific language governing permissions and\r
14  * limitations under the License.\r
15  */\r
16 \r
17 /*!\r
18  * \file  phFriNfc_SmtCrdFmt.c\r
19  * \brief This component encapsulates different smart and simple tag formatting functionalities,\r
20  *        for the mapping layer. \r
21  *\r
22  * Project: NFC-FRI\r
23  *\r
24  * $Date: Mon Dec 13 14:14:13 2010 $\r
25  * $Author: ing02260 $\r
26  * $Revision: 1.9 $\r
27  * $Aliases:  $\r
28  *\r
29  */\r
30 \r
31 #ifndef PH_FRINFC_CARD_FORMAT_DISABLED\r
32 \r
33 #include <phNfcTypes.h>\r
34 #include <phFriNfc_OvrHal.h>\r
35 #include <phFriNfc_SmtCrdFmt.h>\r
36 #ifdef DISABLE_FORMAT\r
37 #include <phFriNfc_TopazFormat.h>\r
38 #endif /* #ifdef DISABLE_FORMAT */\r
39 #include <phFriNfc_MifULFormat.h>\r
40 #include <phFriNfc_DesfireFormat.h>\r
41 #include <phFriNfc_MifStdFormat.h>\r
42 #ifndef PH_FRINFC_FMT_ISO15693_DISABLED\r
43     #include <phFriNfc_ISO15693Format.h>\r
44 #endif /* #ifndef PH_FRINFC_FMT_ISO15693_DISABLED */\r
45 \r
46 \r
47 /*! \ingroup grp_file_attributes\r
48  *  \name NDEF Mapping\r
49  *\r
50  * File: \ref phFriNfc_CardFormatFunctions.c\r
51  *\r
52  */\r
53 /*@{*/\r
54 // file versions\r
55 /*@}*/\r
56 \r
57 \r
58 \r
59 \r
60 void phFriNfc_SmtCrdFmt_HCrHandler(phFriNfc_sNdefSmtCrdFmt_t  *NdefSmtCrdFmt,\r
61                                        NFCSTATUS            Status)\r
62 {\r
63     /* set the state back to the Reset_Init state*/\r
64     NdefSmtCrdFmt->State =  PH_FRINFC_SMTCRDFMT_STATE_RESET_INIT;\r
65 \r
66     /* set the completion routine*/\r
67     NdefSmtCrdFmt->CompletionRoutine[PH_FRINFC_SMTCRDFMT_CR_FORMAT].\r
68         CompletionRoutine(NdefSmtCrdFmt->CompletionRoutine->Context, Status);\r
69 }\r
70 \r
71 /*!\r
72  * \brief Used to Reset the context variables , before the actual smart card formatting\r
73  *        procedure.\r
74  *\r
75  */\r
76 NFCSTATUS phFriNfc_NdefSmtCrd_Reset(phFriNfc_sNdefSmtCrdFmt_t       *NdefSmtCrdFmt,\r
77                                     void                            *LowerDevice,\r
78                                     phHal_sRemoteDevInformation_t   *psRemoteDevInfo,\r
79                                     phHal_sDevInputParam_t          *psDevInputParam,\r
80                                     uint8_t                         *SendRecvBuffer,\r
81                                     uint16_t                        *SendRecvBuffLen)\r
82 {\r
83     NFCSTATUS   result = NFCSTATUS_SUCCESS;\r
84     uint8_t     index;\r
85 \r
86     if (    (SendRecvBuffLen == NULL) || (NdefSmtCrdFmt == NULL) || (psRemoteDevInfo == NULL) || \r
87             (SendRecvBuffer == NULL) ||  (LowerDevice == NULL) || \r
88             (*SendRecvBuffLen == 0) ||  (psDevInputParam == NULL) ||\r
89             (*SendRecvBuffLen < PH_FRINFC_SMTCRDFMT_MAX_SEND_RECV_BUF_SIZE) )\r
90     {\r
91         result = PHNFCSTVAL(CID_FRI_NFC_NDEF_SMTCRDFMT, NFCSTATUS_INVALID_PARAMETER);\r
92     }\r
93     else\r
94     {\r
95         /* Initialise the state to Init */\r
96         NdefSmtCrdFmt->State = PH_FRINFC_SMTCRDFMT_STATE_RESET_INIT;\r
97        \r
98         for(index = 0;index<PH_FRINFC_SMTCRDFMT_CR;index++)\r
99         {\r
100             /* Initialise the NdefMap Completion Routine to Null */\r
101             NdefSmtCrdFmt->CompletionRoutine[index].CompletionRoutine = NULL;\r
102             /* Initialise the NdefMap Completion Routine context to Null  */\r
103             NdefSmtCrdFmt->CompletionRoutine[index].Context = NULL;\r
104         }\r
105 \r
106         /* Lower Device(Always Overlapped HAL Struct initialised in application\r
107             is registred in NdefMap Lower Device) */\r
108         NdefSmtCrdFmt->LowerDevice = LowerDevice;\r
109 \r
110         /* Remote Device info received from Manual Device Discovery is registered here */\r
111         NdefSmtCrdFmt->psRemoteDevInfo = psRemoteDevInfo;\r
112 \r
113         /* Trx Buffer registered */\r
114         NdefSmtCrdFmt->SendRecvBuf = SendRecvBuffer;\r
115 \r
116         /* Trx Buffer Size */\r
117         NdefSmtCrdFmt->SendRecvLength = SendRecvBuffLen;\r
118 \r
119         /* Register Transfer Buffer Length */\r
120         NdefSmtCrdFmt->SendLength = 0;\r
121 \r
122         /* Initialise the Format status flag*/\r
123         NdefSmtCrdFmt->FmtProcStatus = 0;\r
124 \r
125         /* Reset the Card Type */\r
126         NdefSmtCrdFmt->CardType = 0;\r
127 \r
128         /* Reset MapCompletion Info*/\r
129         NdefSmtCrdFmt->SmtCrdFmtCompletionInfo.CompletionRoutine = NULL;\r
130         NdefSmtCrdFmt->SmtCrdFmtCompletionInfo.Context = NULL;\r
131 \r
132 #ifndef PH_FRINFC_FMT_TOPAZ_DISABLED\r
133         phFriNfc_Topaz_Reset(NdefSmtCrdFmt);\r
134 \r
135 #endif  /* PH_FRINFC_FMT_TOPAZ_DISABLED */\r
136 \r
137 #ifndef PH_FRINFC_FMT_DESFIRE_DISABLED\r
138         /*Reset Desfire Cap Container elements*/\r
139         phFriNfc_Desfire_Reset(NdefSmtCrdFmt);\r
140 #endif  /* PH_FRINFC_FMT_DESFIRE_DISABLED */\r
141 \r
142 #ifndef PH_FRINFC_FMT_MIFARESTD_DISABLED\r
143         /*Reset Mifare Standard Container elements*/\r
144         NdefSmtCrdFmt->AddInfo.MfStdInfo.DevInputParam = psDevInputParam;\r
145         phFriNfc_MfStd_Reset(NdefSmtCrdFmt);\r
146 #endif  /* PH_FRINFC_MAP_MIFARESTD_DISABLED */\r
147 \r
148 #ifndef PH_FRINFC_FMT_MIFAREUL_DISABLED\r
149         phFriNfc_MfUL_Reset(NdefSmtCrdFmt);\r
150 #endif /* #ifndef PH_FRINFC_FMT_MIFAREUL_DISABLED */\r
151 \r
152 #ifndef PH_FRINFC_FMT_ISO15693_DISABLED\r
153         phFriNfc_ISO15693_FmtReset (NdefSmtCrdFmt);\r
154 #endif /* #ifndef PH_FRINFC_FMT_ISO15693_DISABLED */\r
155 \r
156 #ifdef PHFRINFC_OVRHAL_MOCKUP\r
157         /*Reset Desfire Cap Container elements*/\r
158   //      phFriNfc_Mockup_H_Reset(NdefSmtCrdFmt);\r
159 #endif  /* PHFRINFC_OVRHAL_MOCKUP */\r
160     \r
161     }\r
162     return (result);\r
163 \r
164 }\r
165 \r
166 /*!\r
167  * \brief Completion Routine initialisation\r
168  *\r
169  */\r
170 NFCSTATUS phFriNfc_NdefSmtCrd_SetCR(phFriNfc_sNdefSmtCrdFmt_t     *NdefSmtCrdFmt,\r
171                                     uint8_t                       FunctionID,\r
172                                     pphFriNfc_Cr_t                CompletionRoutine,\r
173                                     void                          *CompletionRoutineContext)\r
174 {\r
175     NFCSTATUS   status = NFCSTATUS_SUCCESS;\r
176        \r
177     if ((NdefSmtCrdFmt == NULL) || (FunctionID >= PH_FRINFC_SMTCRDFMT_CR) || \r
178         (CompletionRoutine == NULL) || (CompletionRoutineContext == NULL))\r
179     {\r
180         status = PHNFCSTVAL(CID_FRI_NFC_NDEF_SMTCRDFMT, NFCSTATUS_INVALID_PARAMETER);\r
181     }\r
182     else\r
183     {\r
184         /* Register the application callback with the NdefMap Completion Routine */\r
185         NdefSmtCrdFmt->CompletionRoutine[FunctionID].CompletionRoutine = CompletionRoutine;\r
186         \r
187         /* Register the application context with the NdefMap Completion Routine context */\r
188         NdefSmtCrdFmt->CompletionRoutine[FunctionID].Context = CompletionRoutineContext;\r
189     }\r
190 \r
191     return status;\r
192 }\r
193 \r
194 #ifdef FRINFC_READONLY_NDEF\r
195 \r
196 NFCSTATUS\r
197 phFriNfc_NdefSmtCrd_ConvertToReadOnly (\r
198     phFriNfc_sNdefSmtCrdFmt_t *NdefSmtCrdFmt)\r
199 {\r
200     NFCSTATUS   result = PHNFCSTVAL(CID_FRI_NFC_NDEF_SMTCRDFMT,\r
201                                   NFCSTATUS_INVALID_PARAMETER);\r
202     uint8_t     sak = 0;\r
203 \r
204     if((NdefSmtCrdFmt != NULL)\r
205         && (NdefSmtCrdFmt->CompletionRoutine->CompletionRoutine != NULL)\r
206         && (NdefSmtCrdFmt->CompletionRoutine->Context != NULL))\r
207     {\r
208         sak = NdefSmtCrdFmt->psRemoteDevInfo->RemoteDevInfo.Iso14443A_Info.Sak;\r
209         switch (NdefSmtCrdFmt->psRemoteDevInfo->RemDevType)\r
210         {\r
211             case phHal_eMifare_PICC:\r
212             {\r
213                 if (0x00 == sak)\r
214                 {\r
215                     result = phFriNfc_MfUL_ConvertToReadOnly (NdefSmtCrdFmt);\r
216                 }\r
217                 else\r
218                 {\r
219                     /* MIFARE classic 1k/4k is not supported */\r
220                     result = PHNFCSTVAL(CID_FRI_NFC_NDEF_SMTCRDFMT,\r
221                                         NFCSTATUS_INVALID_REMOTE_DEVICE);\r
222                 }\r
223                 break;\r
224             }\r
225 \r
226             case phHal_eISO14443_A_PICC:\r
227             {\r
228                 result = phFriNfc_Desfire_ConvertToReadOnly (NdefSmtCrdFmt);\r
229                 break;\r
230             }\r
231 \r
232             default :\r
233             {\r
234                 /*  Remote device is not recognised.\r
235                 Probably not NDEF compliant */\r
236                 result = PHNFCSTVAL(CID_FRI_NFC_NDEF_SMTCRDFMT,\r
237                                     NFCSTATUS_INVALID_REMOTE_DEVICE);\r
238                 break;\r
239             }\r
240         }\r
241     }\r
242     return result;\r
243 }\r
244 \r
245 #endif /* #ifdef FRINFC_READONLY_NDEF */\r
246 \r
247 \r
248 /*!\r
249  * \brief Used to format the different smart cards.\r
250  *\r
251  */\r
252 NFCSTATUS phFriNfc_NdefSmtCrd_Format( phFriNfc_sNdefSmtCrdFmt_t *NdefSmtCrdFmt, const uint8_t *ScrtKeyB )\r
253 {\r
254     /* Component ID needs to be changed */\r
255     NFCSTATUS   Result = PHNFCSTVAL(CID_FRI_NFC_NDEF_SMTCRDFMT, \r
256                                     NFCSTATUS_INVALID_PARAMETER);\r
257     uint8_t     sak = 0;\r
258     \r
259     /* Check for the correct context structure */\r
260     if((NdefSmtCrdFmt != NULL) &&  \r
261         (NdefSmtCrdFmt->CompletionRoutine->CompletionRoutine != NULL) && \r
262         (NdefSmtCrdFmt->CompletionRoutine->Context != NULL))\r
263     {\r
264 #ifdef PH_HAL4_ENABLE\r
265         /* SAK (Select response) */\r
266         sak = NdefSmtCrdFmt->psRemoteDevInfo->RemoteDevInfo.Iso14443A_Info.Sak;\r
267 \r
268         /* Depending on the Opmodes, call the respective card functions */\r
269         switch ( NdefSmtCrdFmt->psRemoteDevInfo->RemDevType )\r
270 #else\r
271         /* SAK (Select response) */\r
272         sak = NdefSmtCrdFmt->psRemoteDevInfo->RemoteDevInfo.CardInfo106.\r
273                 Startup106.SelRes;\r
274 \r
275         /* Depending on the Opmodes, call the respective card functions */\r
276         switch ( NdefSmtCrdFmt->psRemoteDevInfo->OpMode )\r
277 #endif /* #ifdef PH_HAL4_ENABLE */\r
278         {\r
279 #ifdef PH_HAL4_ENABLE\r
280             case phHal_eMifare_PICC :\r
281 #else\r
282             case phHal_eOpModesMifare :\r
283 #endif /* #ifdef PH_HAL4_ENABLE */\r
284                 /*  Remote device is Mifare card . Check for Mifare\r
285                 NDEF compliance */\r
286                 if(0x00 == sak) \r
287                 {\r
288 #ifndef PH_FRINFC_FMT_MIFAREUL_DISABLED\r
289                     /*  The SAK/Sel_Res says the card is of the type\r
290                         Mifare UL */\r
291                    NdefSmtCrdFmt->CardType = PH_FRINFC_SMTCRDFMT_MIFARE_UL_CARD;\r
292                                         if (NdefSmtCrdFmt->psRemoteDevInfo->RemoteDevInfo.Iso14443A_Info.UidLength == 7 &&\r
293                                                 NdefSmtCrdFmt->psRemoteDevInfo->RemoteDevInfo.Iso14443A_Info.Uid[0] == 0x04)\r
294                                         {\r
295                                                 \r
296                             Result = phFriNfc_MfUL_Format( NdefSmtCrdFmt);\r
297                                         }\r
298                                         else\r
299                                         {\r
300                                                 Result = PHNFCSTVAL(CID_FRI_NFC_NDEF_SMTCRDFMT, \r
301                                     NFCSTATUS_INVALID_REMOTE_DEVICE);\r
302                                         }\r
303 #else\r
304                     Result = PHNFCSTVAL(CID_FRI_NFC_NDEF_SMTCRDFMT, \r
305                                     NFCSTATUS_INVALID_REMOTE_DEVICE);\r
306 #endif /* #ifndef PH_FRINFC_FMT_MIFAREUL_DISABLED */\r
307                 }\r
308                 else if((0x08 == (sak & 0x18)) || \r
309                         (0x18 == (sak & 0x18)))    \r
310                 {\r
311 #ifndef PH_FRINFC_FMT_MIFARESTD_DISABLED\r
312                     NdefSmtCrdFmt->CardType = (uint8_t)\r
313                         (((sak & 0x18) == 0x08)?\r
314                         PH_FRINFC_SMTCRDFMT_MFSTD_1K_CRD:\r
315                         PH_FRINFC_SMTCRDFMT_MFSTD_4K_CRD);\r
316 \r
317                     /*  The SAK/Sel_Res says the card is of the type\r
318                         Mifare standard */\r
319                     Result = phFriNfc_MfStd_Format( NdefSmtCrdFmt, ScrtKeyB);\r
320 #else\r
321                     Result = PHNFCSTVAL(CID_FRI_NFC_NDEF_SMTCRDFMT, \r
322                                     NFCSTATUS_INVALID_REMOTE_DEVICE);\r
323 #endif /* #ifndef PH_FRINFC_FMT_MIFARESTD_DISABLED */\r
324                 }\r
325                 else\r
326                 {\r
327                     /*  Invalid Mifare card, as the remote device \r
328                         info - opmode says its a Mifare card but, \r
329                         The SAK/Sel_Res is wrong */\r
330                     Result = PHNFCSTVAL(CID_FRI_NFC_NDEF_SMTCRDFMT, \r
331                                         NFCSTATUS_INVALID_REMOTE_DEVICE);\r
332                 }\r
333             break;\r
334 #ifdef PH_HAL4_ENABLE\r
335             case phHal_eISO14443_A_PICC :\r
336 #else\r
337             case phHal_eOpModesISO14443_4A :\r
338 #endif /* #ifdef PH_HAL4_ENABLE */\r
339                 /*  Remote device is Desfire card . Check for Desfire\r
340                 NDEF compliancy */\r
341                  if(0x20 == (sak & 0xFF))\r
342                 {\r
343 #ifndef PH_FRINFC_FMT_DESFIRE_DISABLED\r
344                     NdefSmtCrdFmt->CardType = PH_FRINFC_SMTCRDFMT_ISO14443_4A_CARD;\r
345                     /*  The SAK/Sel_Res says the card is of the type\r
346                         ISO14443_4A */\r
347                     \r
348                     Result = phFriNfc_Desfire_Format(NdefSmtCrdFmt);\r
349 #else\r
350                     Result = PHNFCSTVAL(CID_FRI_NFC_NDEF_SMTCRDFMT, \r
351                                         NFCSTATUS_INVALID_REMOTE_DEVICE);\r
352 #endif /* #ifndef PH_FRINFC_FMT_DESFIRE_DISABLED */\r
353                 }\r
354                 else\r
355                 {\r
356                     /*  Invalid Desfire card, as the remote device \r
357                         info - opmode says its a desfire card but, \r
358                         The SAK/Sel_Res is wrong */\r
359                     Result = PHNFCSTVAL(CID_FRI_NFC_NDEF_SMTCRDFMT, \r
360                                         NFCSTATUS_INVALID_REMOTE_DEVICE);\r
361                 }\r
362             break;\r
363 #ifdef PH_HAL4_ENABLE\r
364             case phHal_eJewel_PICC :\r
365 #else\r
366             case phHal_eOpModesJewel :\r
367 #endif /* #ifdef PH_HAL4_ENABLE */\r
368                 /*  Remote device is Topaz card . Check for Topaz\r
369                 NDEF compliancy */\r
370                 if(0xC2 == sak)\r
371                 {\r
372 #ifndef PH_FRINFC_FMT_TOPAZ_DISABLED\r
373                     NdefSmtCrdFmt->CardType = PH_FRINFC_SMTCRDFMT_TOPAZ_CARD;\r
374                     /*  The SAK/Sel_Res says the card is of the type\r
375                         ISO14443_4A */\r
376                     Result = phFriNfc_Topaz_Format(NdefSmtCrdFmt);\r
377 #else\r
378                     Result = PHNFCSTVAL(CID_FRI_NFC_NDEF_SMTCRDFMT, \r
379                                         NFCSTATUS_INVALID_REMOTE_DEVICE);\r
380 #endif /* #ifndef PH_FRINFC_FMT_TOPAZ_DISABLED */\r
381                     \r
382                 }\r
383                 else\r
384                 {\r
385                     /*  Invalid Topaz card, as the remote device \r
386                         info - opmode says its a desfire card but, \r
387                         The SAK/Sel_Res is wrong */\r
388                     Result = PHNFCSTVAL(CID_FRI_NFC_NDEF_SMTCRDFMT, \r
389                                         NFCSTATUS_INVALID_REMOTE_DEVICE);\r
390                 }\r
391             break;\r
392 \r
393 #ifdef PHFRINFC_OVRHAL_MOCKUP\r
394             case phHal_eOpModesMockup :\r
395                     /*Set the OpMode Ttype Flag*/\r
396                     NdefSmtCrdFmt->OpModeType[0] = phHal_eOpModesMockup;\r
397                     NdefSmtCrdFmt->OpModeType[1] = phHal_eOpModesArrayTerminator;\r
398                     //Result = phFriNfc_Mockup_ChkNdef(NdefSmtCrdFmt);\r
399             break;\r
400 #endif  /* PHFRINFC_OVRHAL_MOCKUP */\r
401 \r
402 #ifndef PH_FRINFC_FMT_ISO15693_DISABLED\r
403             case phHal_eISO15693_PICC:\r
404             {\r
405                 Result = phFriNfc_ISO15693_Format (NdefSmtCrdFmt);\r
406                 break;\r
407             }\r
408 #endif /* #ifndef PH_FRINFC_FMT_ISO15693_DISABLED */\r
409             default :\r
410                 /*  Remote device is not recognised.\r
411                 Probably not NDEF compliant */\r
412                 Result = PHNFCSTVAL(CID_FRI_NFC_NDEF_SMTCRDFMT,\r
413                                     NFCSTATUS_INVALID_REMOTE_DEVICE);\r
414             break;\r
415         }\r
416     }\r
417     return Result;\r
418 }\r
419 /*!\r
420  * \brief Handles different request and responses from the integration layer.\r
421  *\r
422  */\r
423 void phFriNfc_NdefSmtCrd_Process(void        *Context,\r
424                                  NFCSTATUS    Status)\r
425 {\r
426     if ( Context != NULL )\r
427     {\r
428         phFriNfc_sNdefSmtCrdFmt_t  *NdefSmtCrdFmt = (phFriNfc_sNdefSmtCrdFmt_t *)Context;\r
429 #ifdef PH_HAL4_ENABLE\r
430         switch ( NdefSmtCrdFmt->psRemoteDevInfo->RemDevType )\r
431 #else\r
432         switch ( NdefSmtCrdFmt->psRemoteDevInfo->OpMode )\r
433 #endif /* #ifdef PH_HAL4_ENABLE */\r
434         {\r
435 #ifdef PH_HAL4_ENABLE\r
436             case phHal_eMifare_PICC :\r
437 #else\r
438             case  phHal_eOpModesMifare :\r
439 #endif /* #ifdef PH_HAL4_ENABLE */\r
440                 if((NdefSmtCrdFmt->CardType == PH_FRINFC_SMTCRDFMT_MFSTD_1K_CRD) ||\r
441                     (NdefSmtCrdFmt->CardType == PH_FRINFC_SMTCRDFMT_MFSTD_4K_CRD))\r
442                 {\r
443 #ifndef PH_FRINFC_FMT_MIFARESTD_DISABLED\r
444                     /*  Remote device is Mifare Standard card */\r
445                     phFriNfc_MfStd_Process(NdefSmtCrdFmt,Status);\r
446                     \r
447 #else   /* PH_FRINFC_FMT_MIFARESTD_DISABLED*/\r
448                         Status = PHNFCSTVAL(CID_FRI_NFC_NDEF_SMTCRDFMT, \r
449                                             NFCSTATUS_INVALID_REMOTE_DEVICE);               \r
450 #endif  /* PH_FRINFC_FMT_MIFARESTD_DISABLED*/\r
451                 }\r
452                 else\r
453                 {\r
454 #ifndef PH_FRINFC_FMT_MIFAREUL_DISABLED\r
455                     /*  Remote device is Mifare UL card */\r
456                     phFriNfc_MfUL_Process(NdefSmtCrdFmt,Status);\r
457 #else   /* PH_FRINFC_FMT_MIFAREUL_DISABLED*/\r
458                     Status = PHNFCSTVAL(CID_FRI_NFC_NDEF_SMTCRDFMT, \r
459                                          NFCSTATUS_INVALID_REMOTE_DEVICE);               \r
460 #endif  /* PH_FRINFC_FMT_MIFAREUL_DISABLED*/\r
461                 }\r
462             break;\r
463 \r
464 #ifdef PH_HAL4_ENABLE\r
465             case phHal_eISO14443_A_PICC :\r
466 #else\r
467             case phHal_eOpModesISO14443_4A :\r
468 #endif /* #ifdef PH_HAL4_ENABLE */\r
469 #ifndef PH_FRINFC_FMT_DESFIRE_DISABLED\r
470                 /*  Remote device is Desfire card */\r
471                 phFriNfc_Desf_Process(NdefSmtCrdFmt, Status);\r
472 #else   /* PH_FRINFC_FMT_DESFIRE_DISABLED*/\r
473                  Status = PHNFCSTVAL(CID_FRI_NFC_NDEF_SMTCRDFMT, \r
474                                             NFCSTATUS_INVALID_REMOTE_DEVICE);               \r
475 #endif  /* PH_FRINFC_FMT_DESFIRE_DISABLED*/\r
476             break;\r
477 #ifdef PH_HAL4_ENABLE\r
478             case phHal_eJewel_PICC :\r
479 #else\r
480             case phHal_eOpModesJewel:\r
481 #endif /* #ifdef PH_HAL4_ENABLE */\r
482 #ifndef PH_FRINFC_FMT_TOPAZ_DISABLED\r
483                 /*  Remote device is Topaz Smart card */\r
484                phFriNfc_Topaz_Process(NdefSmtCrdFmt, Status);\r
485 #else   /* PH_FRINFC_FMT_TOPAZ_DISABLED*/\r
486                Status = PHNFCSTVAL(CID_FRI_NFC_NDEF_SMTCRDFMT, \r
487                                             NFCSTATUS_INVALID_REMOTE_DEVICE);               \r
488 #endif  /* PH_FRINFC_FMT_TOPAZ_DISABLED*/\r
489             break;\r
490 \r
491 #ifndef PH_FRINFC_FMT_ISO15693_DISABLED\r
492             case phHal_eISO15693_PICC :\r
493             {\r
494                 phFriNfc_ISO15693_FmtProcess (NdefSmtCrdFmt, Status);\r
495                 break;\r
496             }\r
497 #endif /* #ifndef PH_FRINFC_FMT_ISO15693_DISABLED */\r
498 \r
499 #ifdef PHFRINFC_OVRHAL_MOCKUP\r
500             case phHal_eOpModesMockup:\r
501                 /*  Remote device is Desfire card */\r
502                 //phFriNfc_Mockup_Process(NdefSmtCrdFmt, Status);     \r
503             break;\r
504 #endif  /* PHFRINFC_OVRHAL_MOCKUP*/\r
505             default : \r
506                 /*  Remote device opmode not recognised.\r
507                     Probably not NDEF compliant */\r
508                 Status = PHNFCSTVAL(CID_FRI_NFC_NDEF_SMTCRDFMT,\r
509                                     NFCSTATUS_INVALID_REMOTE_DEVICE);\r
510                 /* set the state back to the Reset_Init state*/\r
511                 NdefSmtCrdFmt->State =  PH_FRINFC_SMTCRDFMT_STATE_RESET_INIT;\r
512 \r
513                 /* set the completion routine*/\r
514                 NdefSmtCrdFmt->CompletionRoutine[PH_FRINFC_SMTCRDFMT_CR_INVALID_OPE].\r
515                 CompletionRoutine(NdefSmtCrdFmt->CompletionRoutine->Context, Status);\r
516             break;\r
517         }\r
518     }\r
519     else\r
520     {\r
521         Status = PHNFCSTVAL(CID_FRI_NFC_NDEF_SMTCRDFMT,\\r
522                             NFCSTATUS_INVALID_PARAMETER);\r
523         /* The control should not come here. As Context itself is NULL ,\r
524            Can't call the CR*/\r
525     }\r
526 }\r
527 \r
528 #endif  /* PH_FRINFC_CARD_FORMAT_DISABLED */\r
529 \r