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_Desfire.c
19 * \brief This component encapsulates read/write/check ndef/process functionalities,
20 * for the Desfire Card.
24 * $Date: Tue Jul 27 08:58:22 2010 $
31 #ifndef PH_FRINFC_MAP_DESFIRE_DISABLED
33 #include <phFriNfc_OvrHal.h>
34 #include <phFriNfc_DesfireMap.h>
35 #include <phFriNfc_MapTools.h>
38 /*! \ingroup grp_file_attributes
41 * File: \ref phFriNfc_Desfire.c
45 #define PHFRINFCNDEFMAP_FILEREVISION "$Revision: 1.11 $"
46 #define PHFRINFCNDEFMAP_FILEALIASES "$Aliases: $"
50 /***************** Start of MACROS ********************/
52 #define DESFIRE_EV1_P2_OFFSET_VALUE (0x0CU)
53 #endif /* #ifdef DESFIRE_EV1 */
55 /***************** End of MACROS ********************/
60 * \name Desfire Mapping - Helper Functions
66 * \brief \copydoc page_ovr Helper function for Desfire. This function specifies
67 * the card is a Desfire card or not.
69 static NFCSTATUS phFriNfc_Desfire_SelectSmartTag( phFriNfc_NdefMap_t *NdefMap);
72 * \brief \copydoc page_ovr Helper function for Desfire. This function is used
73 * to selct a file in the card.
75 static NFCSTATUS phFriNfc_Desfire_SelectFile ( phFriNfc_NdefMap_t *NdefMap);
78 * \brief \copydoc page_ovr Helper function for Desfire. This function is to
81 static NFCSTATUS phFriNfc_Desfire_ReadBinary( phFriNfc_NdefMap_t *NdefMap);
84 * \brief \copydoc page_ovr Helper function for Desfire. This function is to
87 static NFCSTATUS phFriNfc_Desfire_UpdateBinary( phFriNfc_NdefMap_t *NdefMap);
90 * \brief \copydoc page_ovr Helper function for Desfire. This function is to
91 * update the capability container of the card.
93 static NFCSTATUS phFriNfc_Desfire_Update_SmartTagCapContainer( phFriNfc_NdefMap_t *NdefMap);
96 /* Completion Helper*/
97 static void phFriNfc_Desfire_HCrHandler( phFriNfc_NdefMap_t *NdefMap,
100 /* Calculates the Le Bytes for Read Operation*/
101 static uint32_t phFriNfc_Desfire_HGetLeBytes( phFriNfc_NdefMap_t *NdefMap);
103 static NFCSTATUS phFriNfc_Desf_HChkAndParseTLV( phFriNfc_NdefMap_t *NdefMap,
106 static NFCSTATUS phFriNfc_Desfire_HSetGet_NLEN( phFriNfc_NdefMap_t *NdefMap);
108 static void phFriNfc_Desfire_HProcReadData( phFriNfc_NdefMap_t *NdefMap);
110 static void phFriNfc_Desfire_HChkNDEFFileAccessRights( phFriNfc_NdefMap_t *NdefMap);
111 static NFCSTATUS phFriNfc_Desfire_HSendTransCmd(phFriNfc_NdefMap_t *NdefMap,uint8_t SendRecvLen);
113 #ifdef PH_HAL4_ENABLE
117 /* Following are the API's are used to get the version of the desfire card*/
118 static NFCSTATUS phFriNfc_Desfire_HGetHWVersion(phFriNfc_NdefMap_t *NdefMap);
119 static NFCSTATUS phFriNfc_Desfire_HGetSWVersion(phFriNfc_NdefMap_t *NdefMap);
120 static NFCSTATUS phFriNfc_Desfire_HGetUIDDetails(phFriNfc_NdefMap_t *NdefMap);
121 static NFCSTATUS phFriNfc_Desfire_HUpdateVersionDetails(const phFriNfc_NdefMap_t *NdefMap);
123 #endif /* #ifdef PH_HAL4_ENABLE */
125 #ifdef PH_HAL4_ENABLE
129 static NFCSTATUS phFriNfc_Desfire_HGetHWVersion(phFriNfc_NdefMap_t *NdefMap)
132 NFCSTATUS status = NFCSTATUS_PENDING;
135 NdefMap->State = PH_FRINFC_DESF_STATE_GET_HW_VERSION;
137 /* Helper routine to wrap the native desfire cmds*/
138 PH_FRINFC_DESF_ISO_NATIVE_WRAPPER();
139 status = phFriNfc_Desfire_HSendTransCmd(NdefMap,PH_FRINFC_NDEFMAP_MAX_SEND_RECV_BUF_SIZE);
144 static NFCSTATUS phFriNfc_Desfire_HGetSWVersion(phFriNfc_NdefMap_t *NdefMap)
147 NFCSTATUS status = NFCSTATUS_PENDING;
148 if( ( NdefMap->SendRecvBuf[*(NdefMap->SendRecvLength)- 1] == PH_FRINFC_DESF_NATIVE_GETVER_RESP) )
151 NdefMap->State = PH_FRINFC_DESF_STATE_GET_SW_VERSION;
153 /* Helper routine to wrap the native desfire commands*/
154 PH_FRINFC_DESF_ISO_NATIVE_WRAPPER();
155 status = phFriNfc_Desfire_HSendTransCmd(NdefMap,PH_FRINFC_NDEFMAP_MAX_SEND_RECV_BUF_SIZE);
157 #ifdef PH_HAL4_ENABLE
160 status = PHNFCSTVAL(CID_FRI_NFC_NDEF_MAP,
161 NFCSTATUS_INVALID_PARAMETER);
163 #endif /* #ifdef PH_HAL4_ENABLE */
167 static NFCSTATUS phFriNfc_Desfire_HGetUIDDetails(phFriNfc_NdefMap_t *NdefMap)
170 NFCSTATUS status = NFCSTATUS_PENDING;
172 if( ( NdefMap->SendRecvBuf[*(NdefMap->SendRecvLength)- 1] == PH_FRINFC_DESF_NATIVE_GETVER_RESP) )
175 NdefMap->State = PH_FRINFC_DESF_STATE_GET_UID;
177 /* Helper routine to wrap the native desfire commands*/
178 PH_FRINFC_DESF_ISO_NATIVE_WRAPPER();
180 status = phFriNfc_Desfire_HSendTransCmd(NdefMap,PH_FRINFC_NDEFMAP_MAX_SEND_RECV_BUF_SIZE);
182 #ifdef PH_HAL4_ENABLE
185 status = PHNFCSTVAL(CID_FRI_NFC_NDEF_MAP,
186 NFCSTATUS_INVALID_PARAMETER);
188 #endif /* #ifdef PH_HAL4_ENABLE */
193 static NFCSTATUS phFriNfc_Desfire_HUpdateVersionDetails(const phFriNfc_NdefMap_t *NdefMap)
195 NFCSTATUS status = PHNFCSTVAL(CID_FRI_NFC_NDEF_MAP,
196 NFCSTATUS_INVALID_PARAMETER);
198 if( ( NdefMap->SendRecvBuf[*(NdefMap->SendRecvLength)- 1] == 0xAF) )
201 status = NFCSTATUS_SUCCESS;
203 /* We do not need the following details presently.Retained for future use*/
205 NdefMap->AddInfo.Type4Info.MajorVersion = NdefSmtCrdFmt->SendRecvBuf[3];
206 NdefMap->AddInfo.Type4Info.MinorVersion = NdefSmtCrdFmt->SendRecvBuf[4];
207 if ( ( NdefMap->AddInfo.Type4Info.MajorVersion == 0x00 )&&
208 ( NdefMap->AddInfo.Type4Info.MinorVersion == 0x06 ))
210 /* card size of DESFire4 type */
211 //NdefMap->AddInfo.Type4Info.CardSize = 0xEDE;
216 // need to handle the Desfire8 type cards
217 // need to use get free memory
225 #endif /* #ifdef PH_HAL4_ENABLE */
228 * \brief Initiates Reading of NDEF information from the Desfire Card.
230 * The function initiates the reading of NDEF information from a Remote Device.
231 * It performs a reset of the state and starts the action (state machine).
232 * A periodic call of the \ref phFriNfcNdefMap_Process has to be
233 * done once the action has been triggered.
236 NFCSTATUS phFriNfc_Desfire_RdNdef( phFriNfc_NdefMap_t *NdefMap,
238 uint32_t *PacketDataLength,
241 NFCSTATUS status = NFCSTATUS_PENDING;
243 NdefMap->ApduBufferSize = *PacketDataLength;
244 /* To return actual number of bytes read to the caller */
245 NdefMap->NumOfBytesRead = PacketDataLength ;
246 *NdefMap->NumOfBytesRead = 0;
248 /* store the offset in to map context*/
249 NdefMap->Offset = Offset;
251 if( (Offset == PH_FRINFC_NDEFMAP_SEEK_CUR) &&
252 (*NdefMap->DataCount == NdefMap->DesfireCapContainer.NdefDataLen))
254 /* No space on card for Reading : we have already
255 reached the end of file !
256 Offset is set to Continue Operation */
257 status = PHNFCSTVAL(CID_FRI_NFC_NDEF_MAP,
258 NFCSTATUS_EOF_NDEF_CONTAINER_REACHED);
263 /* reset the inter flag*/
264 NdefMap->DesfireCapContainer.IsNlenPresentFlag = 0;
265 NdefMap->DesfireCapContainer.SkipNlenBytesFlag = 0;
267 /* Set the desfire read operation */
268 NdefMap->DespOpFlag = PH_FRINFC_NDEFMAP_DESF_READ_OP;
270 /* Save the packet data buffer address in the context */
271 NdefMap->ApduBuffer = PacketData;
273 NdefMap->PrevOperation = PH_FRINFC_NDEFMAP_READ_OPE;
276 /* Select smart tag operation. First step for the read operation. */
277 if (PH_FRINFC_NDEFMAP_ISO14443_4A_CARD_EV1 == NdefMap->CardType)
279 status = phFriNfc_Desfire_SelectFile(NdefMap);
282 #endif /* #ifdef DESFIRE_EV1 */
284 status = phFriNfc_Desfire_SelectSmartTag(NdefMap);
292 * \brief Initiates Writing of NDEF information to the Remote Device.
294 * The function initiates the writing of NDEF information to a Remote Device.
295 * It performs a reset of the state and starts the action (state machine).
296 * A periodic call of the \ref phFriNfcNdefMap_Process has to be done once the action
297 * has been triggered.
300 NFCSTATUS phFriNfc_Desfire_WrNdef( phFriNfc_NdefMap_t *NdefMap,
302 uint32_t *PacketDataLength,
305 NFCSTATUS status = NFCSTATUS_PENDING;
307 NdefMap->ApduBufferSize = *PacketDataLength;
308 NdefMap->WrNdefPacketLength = PacketDataLength;
310 /* Now, let's initialize *NdefMap->WrNdefPacketLength to zero.
311 In case we get an error, this will be correctly set to "no byte written".
312 In case there is no error, this will be updated later on, in the _process function.
314 *NdefMap->WrNdefPacketLength = 0;
316 /* we have write access. */
317 if( *NdefMap->DataCount >= PH_NFCFRI_NDEFMAP_DESF_NDEF_FILE_SIZE)
319 /* No space on card for writing : we have already
320 reached the end of file !
321 Offset is set to Continue Operation */
322 status = PHNFCSTVAL(CID_FRI_NFC_NDEF_MAP,
323 NFCSTATUS_EOF_NDEF_CONTAINER_REACHED);
327 /* Adapt the nb of bytes that the user would like to write */
329 /*set the defire write operation*/
330 NdefMap->DespOpFlag = PH_FRINFC_NDEFMAP_DESF_WRITE_OP;
331 NdefMap->PrevOperation = PH_FRINFC_NDEFMAP_WRITE_OPE;
332 NdefMap->Offset = Offset;
334 /*Store the packet data buffer*/
335 NdefMap->ApduBuffer = PacketData;
338 if (PH_FRINFC_NDEFMAP_ISO14443_4A_CARD_EV1 == NdefMap->CardType)
340 status = phFriNfc_Desfire_SelectFile(NdefMap);
343 #endif /* #ifdef DESFIRE_EV1 */
345 /* Select smart tag operation. First step for the write operation. */
346 status = phFriNfc_Desfire_SelectSmartTag (NdefMap);
353 * \brief Check whether a particular Remote Device is NDEF compliant.
355 * The function checks whether the peer device is NDEF compliant.
359 NFCSTATUS phFriNfc_Desfire_ChkNdef( phFriNfc_NdefMap_t *NdefMap)
361 NFCSTATUS status = NFCSTATUS_PENDING;
363 #ifdef PH_HAL4_ENABLE
366 /* Reset card type */
367 NdefMap->CardType = 0;
368 #endif /* #ifdef DESFIRE_EV1 */
369 /*Set the desfire operation flag*/
370 NdefMap->DespOpFlag = PH_FRINFC_NDEFMAP_DESF_NDEF_CHK_OP;
372 /*Call Select Smart tag Functinality*/
373 status = phFriNfc_Desfire_SelectSmartTag(NdefMap);
375 /* Need to get the version details of the card, to
376 identify the the desfire4card type */
377 status = phFriNfc_Desfire_HGetHWVersion(NdefMap);
383 static NFCSTATUS phFriNfc_Desf_HChkAndParseTLV(phFriNfc_NdefMap_t *NdefMap, uint8_t BuffIndex)
385 NFCSTATUS status = NFCSTATUS_SUCCESS;
387 if((NdefMap->SendRecvBuf[BuffIndex] <= 0x03) ||
388 (NdefMap->SendRecvBuf[BuffIndex] >= 0x06) )
390 status = PHNFCSTVAL( CID_FRI_NFC_NDEF_MAP,
391 NFCSTATUS_NO_NDEF_SUPPORT);
395 /* check for the type of TLV*/
396 NdefMap->TLVFoundFlag =
397 ((NdefMap->SendRecvBuf[BuffIndex] == 0x04)?
398 PH_FRINFC_NDEFMAP_DESF_NDEF_CNTRL_TLV:
399 PH_FRINFC_NDEFMAP_DESF_PROP_CNTRL_TLV);
401 status = PHNFCSTVAL( CID_FRI_NFC_NDEF_MAP,
407 static NFCSTATUS phFriNfc_Desfire_HSetGet_NLEN(phFriNfc_NdefMap_t *NdefMap)
410 NFCSTATUS status = NFCSTATUS_PENDING;
412 if ( PH_FRINFC_NDEFMAP_DESF_GET_LEN_OP == NdefMap->DespOpFlag)
415 /*Call Select Smart tag Functinality*/
416 status = phFriNfc_Desfire_SelectSmartTag(NdefMap);
421 /* Get the Data Count and set it to NoOfBytesWritten
422 Update the NLEN using Transceive cmd*/
424 /*Form the packet for the update binary command*/
425 NdefMap->SendRecvBuf[0] = 0x00;
426 NdefMap->SendRecvBuf[1] = 0xD6;
428 /* As we need to set the NLEN @ first 2 bytes of NDEF File*/
429 /* set the p1/p2 offsets */
430 NdefMap->SendRecvBuf[2] = 0x00; /* p1 */
431 NdefMap->SendRecvBuf[3] = 0x00; /* p2 */
433 /* Set only two bytes as NLEN*/
434 NdefMap->SendRecvBuf[4] = 0x02;
437 NdefMap->SendRecvBuf[5] = (uint8_t)(*NdefMap->DataCount >> PH_FRINFC_NDEFMAP_DESF_SHL8);
438 NdefMap->SendRecvBuf[6] = (uint8_t)(*NdefMap->DataCount & (0x00ff));
440 NdefMap->SendLength = 0x07 ;
442 /* Change the state to Write */
443 NdefMap->State = PH_FRINFC_NDEFMAP_DESF_STATE_UPDATE_BIN_END;
445 status = phFriNfc_Desfire_HSendTransCmd(NdefMap,PH_FRINFC_NDEFMAP_DESF_RESP_OFFSET);
450 static void phFriNfc_Desfire_HProcReadData(phFriNfc_NdefMap_t *NdefMap)
452 NFCSTATUS Result = NFCSTATUS_PENDING;
453 uint32_t BufferSize = 0;
455 uint16_t SizeToCpy=0;
457 /* Need to check the Actual Ndef Length before copying the data to buffer*/
458 /* Only NDEF data should be copied , rest all the data should be ignored*/
459 /* Ex : Ndef File Size 50 bytes , but only 5 bytes(NLEN) are relavent to NDEF data*/
460 /* component should only copy 5 bytes to user buffer*/
462 /* Data has been read successfully in the TRX buffer. */
463 /* copy it to the user buffer. */
465 /* while copying need check the offset if its begin need to skip the first 2 bytes
466 while copying. If its current no need to skip the first 2 bytes*/
468 if ( NdefMap->Offset == PH_FRINFC_NDEFMAP_SEEK_BEGIN )
470 BufIndex = (uint8_t)(( NdefMap->DesfireCapContainer.IsNlenPresentFlag == 1 )?
471 0:PH_FRINFC_NDEFMAP_DESF_NLEN_SIZE_IN_BYTES);
473 /* Update the latest NLEN to context*/
474 NdefMap->DesfireCapContainer.NdefDataLen = ((*NdefMap->DataCount == 0)?
475 ( (((uint16_t)NdefMap->SendRecvBuf[
476 PH_FRINFC_NDEFMAP_DESF_CCLEN_BYTE_FIRST_INDEX])<<8)+ \
477 NdefMap->SendRecvBuf[PH_FRINFC_NDEFMAP_DESF_CCLEN_BYTE_SECOND_INDEX]):
478 NdefMap->DesfireCapContainer.NdefDataLen);
480 /* Decide how many byes to be copied into user buffer: depending upon the actual NDEF
481 size need to copy the content*/
482 if ( (NdefMap->DesfireCapContainer.NdefDataLen) <= (*NdefMap->SendRecvLength - \
483 (PH_FRINFC_NDEFMAP_DESF_RESP_OFFSET + BufIndex)))
485 SizeToCpy = NdefMap->DesfireCapContainer.NdefDataLen;
490 SizeToCpy = ((*NdefMap->SendRecvLength)-(PH_FRINFC_NDEFMAP_DESF_RESP_OFFSET+BufIndex));
493 /* Check do we have Ndef Data len > 0 present in the card.If No Ndef Data
494 present in the card , set the card state to Initalised and set an Error*/
495 if ( NdefMap->DesfireCapContainer.NdefDataLen == 0x00 )
497 NdefMap->CardState = PH_NDEFMAP_CARD_STATE_INITIALIZED;
498 Result = PHNFCSTVAL(CID_FRI_NFC_NDEF_MAP, NFCSTATUS_EOF_NDEF_CONTAINER_REACHED);
499 #ifdef PH_HAL4_ENABLE
501 NdefMap->PrevOperation = 0;
502 #endif /* #ifdef PH_HAL4_ENABLE */
503 phFriNfc_Desfire_HCrHandler(NdefMap,Result);
507 (void)memcpy( (&(NdefMap->ApduBuffer[
508 NdefMap->ApduBuffIndex])),
509 (&(NdefMap->SendRecvBuf[BufIndex])),
512 /* Increment the Number of Bytes Read, which will be returned to the caller. */
513 *NdefMap->NumOfBytesRead = (uint32_t)(*NdefMap->NumOfBytesRead + SizeToCpy);
515 /*update the data count*/
516 *NdefMap->DataCount = (uint16_t)(*NdefMap->DataCount + SizeToCpy);
518 /*update the buffer index of the apdu buffer*/
519 NdefMap->ApduBuffIndex = (uint16_t)(NdefMap->ApduBuffIndex + SizeToCpy);
524 (void)memcpy( (&(NdefMap->ApduBuffer[
525 NdefMap->ApduBuffIndex])),
526 (NdefMap->SendRecvBuf),/* to avoid the length of the NDEF File*/
527 (*(NdefMap->SendRecvLength)-(PH_FRINFC_NDEFMAP_DESF_RESP_OFFSET)));
529 /* Increment the Number of Bytes Read, which will be returned to the caller. */
530 *NdefMap->NumOfBytesRead +=( *NdefMap->SendRecvLength - \
531 (PH_FRINFC_NDEFMAP_DESF_RESP_OFFSET));
533 /*update the data count*/
534 *NdefMap->DataCount += \
535 (*NdefMap->SendRecvLength - (PH_FRINFC_NDEFMAP_DESF_RESP_OFFSET));
537 /*update the buffer index of the apdu buffer*/
538 NdefMap->ApduBuffIndex += \
539 *NdefMap->SendRecvLength - (PH_FRINFC_NDEFMAP_DESF_RESP_OFFSET );
542 /* check whether we still have to read some more data. */
543 if (*NdefMap->DataCount < NdefMap->DesfireCapContainer.NdefDataLen )
545 /* we have some bytes to read. */
547 /* Now check, we still have bytes left in the user buffer. */
548 BufferSize = NdefMap->ApduBufferSize - NdefMap->ApduBuffIndex;
551 /* Before read need to set the flag to intimate the module to
552 dont skip the first 2 bytes as we are in mode reading next
553 continues available bytes, which will not contain the NLEN
554 information in the begining part that is 2 bytes*/
555 NdefMap->DesfireCapContainer.IsNlenPresentFlag = 1;
556 /* Read Operation is not complete */
557 Result = phFriNfc_Desfire_ReadBinary( NdefMap );
558 /* handle the error in Transc function*/
559 if ( (Result & PHNFCSTBLOWER) != (NFCSTATUS_PENDING & PHNFCSTBLOWER) )
561 /* call respective CR */
562 phFriNfc_Desfire_HCrHandler(NdefMap,Result);
567 /* There are some more bytes to read, but
568 no space in the user buffer */
569 Result = PHNFCSTVAL(CID_NFC_NONE,NFCSTATUS_SUCCESS);
570 NdefMap->ApduBuffIndex =0;
571 /* call respective CR */
572 phFriNfc_Desfire_HCrHandler(NdefMap,Result);
577 if (*NdefMap->DataCount == NdefMap->DesfireCapContainer.NdefDataLen )
579 /* we have read all the bytes available in the card. */
580 Result = PHNFCSTVAL(CID_NFC_NONE,NFCSTATUS_SUCCESS);
581 #ifdef PH_HAL4_ENABLE
584 NdefMap->PrevOperation = 0;
585 #endif /* #ifndef PH_HAL4_ENABLE */
589 /* The control should not come here. */
590 /* we have actually read more byte than available in the card. */
591 NdefMap->PrevOperation = 0;
592 #ifndef PH_HAL4_ENABLE
593 Result = PHNFCSTVAL(CID_FRI_NFC_NDEF_MAP,
594 NFCSTATUS_CMD_ABORTED);
596 Result = PHNFCSTVAL(CID_FRI_NFC_NDEF_MAP,
602 NdefMap->ApduBuffIndex = 0;
604 /* call respective CR */
605 phFriNfc_Desfire_HCrHandler(NdefMap,Result);
612 * \brief Completion Routine, Processing function, needed to avoid long blocking.
613 * \note The lower (Overlapped HAL) layer must register a pointer to this function as a Completion
614 * Routine in order to be able to notify the component that an I/O has finished and data are
615 * ready to be processed.
619 void phFriNfc_Desfire_Process(void *Context,
622 /*Set the context to Map Module*/
623 phFriNfc_NdefMap_t *NdefMap = (phFriNfc_NdefMap_t *)Context;
625 uint16_t NLength = 0,
627 uint32_t BytesRead = 0;
630 /* Sujatha P: Fix for 0000255/0000257:[gk] MAP:Handling HAL Errors */
631 if ( Status == NFCSTATUS_SUCCESS )
633 switch (NdefMap->State)
636 #ifdef PH_HAL4_ENABLE
639 case PH_FRINFC_DESF_STATE_GET_HW_VERSION :
641 /* Check and store the h/w and s/w specific details.
642 Ex: Major/Minor version, memory storage info. */
643 Status = phFriNfc_Desfire_HGetSWVersion(NdefMap);
645 /* handle the error in Transc function*/
646 if ( (Status & PHNFCSTBLOWER) != (NFCSTATUS_PENDING & PHNFCSTBLOWER))
648 /* call respective CR */
649 phFriNfc_Desfire_HCrHandler(NdefMap,Status);
654 case PH_FRINFC_DESF_STATE_GET_SW_VERSION :
656 /* Check and store the h/w and s/w specific details.
657 Ex: Major/Minor version, memory storage info. */
659 Status = phFriNfc_Desfire_HUpdateVersionDetails(NdefMap);
660 if ( Status == NFCSTATUS_SUCCESS )
662 Status = phFriNfc_Desfire_HGetUIDDetails(NdefMap);
663 /* handle the error in Transc function*/
664 if ( (Status & PHNFCSTBLOWER) != (NFCSTATUS_PENDING & PHNFCSTBLOWER))
666 /* call respective CR */
667 phFriNfc_Desfire_HCrHandler(NdefMap,Status);
673 case PH_FRINFC_DESF_STATE_GET_UID :
675 /*Set the desfire operation flag*/
676 NdefMap->DespOpFlag = PH_FRINFC_NDEFMAP_DESF_NDEF_CHK_OP;
678 /*Call Select Smart tag Functinality*/
679 Status = phFriNfc_Desfire_SelectSmartTag(NdefMap);
682 #endif /* #ifdef PH_HAL4_ENABLE */
685 case PH_FRINFC_NDEFMAP_DESF_STATE_SELECT_SMART_TAG_EV1:
687 if(( NdefMap->SendRecvBuf[(*(NdefMap->SendRecvLength) - 2)] ==
688 PH_FRINFC_NDEFMAP_DESF_RAPDU_SW1_BYTE) &&
689 (NdefMap->SendRecvBuf[(*(NdefMap->SendRecvLength) - 1)] ==
690 PH_FRINFC_NDEFMAP_DESF_RAPDU_SW2_BYTE))
692 NdefMap->CardType = PH_FRINFC_NDEFMAP_ISO14443_4A_CARD_EV1;
694 Status = phFriNfc_Desfire_SelectFile(NdefMap);
696 /* handle the error in Transc function*/
697 if ((Status & PHNFCSTBLOWER) != (NFCSTATUS_PENDING & PHNFCSTBLOWER))
699 /* call respective CR */
700 phFriNfc_Desfire_HCrHandler(NdefMap,Status);
705 NdefMap->CardType = PH_FRINFC_NDEFMAP_ISO14443_4A_CARD;
706 /* The card is not the new desfire, so send select smart tag command
707 of the old desfire */
708 Status = phFriNfc_Desfire_SelectSmartTag(NdefMap);
714 #endif /* #ifdef DESFIRE_EV1 */
716 case PH_FRINFC_NDEFMAP_DESF_STATE_SELECT_SMART_TAG:
718 if(( NdefMap->SendRecvBuf[(*(NdefMap->SendRecvLength) - 2)] ==
719 PH_FRINFC_NDEFMAP_DESF_RAPDU_SW1_BYTE) &&
720 (NdefMap->SendRecvBuf[(*(NdefMap->SendRecvLength) - 1)] ==
721 PH_FRINFC_NDEFMAP_DESF_RAPDU_SW2_BYTE))
723 if(( NdefMap->SendRecvBuf[PH_FRINFC_NDEFMAP_DESF_SW1_INDEX] ==
724 PH_FRINFC_NDEFMAP_DESF_RAPDU_SW1_BYTE) &&
725 (NdefMap->SendRecvBuf[PH_FRINFC_NDEFMAP_DESF_SW2_INDEX] ==
726 PH_FRINFC_NDEFMAP_DESF_RAPDU_SW2_BYTE))
727 #endif /* #ifdef DESFIRE_EV1 */
729 Status = phFriNfc_Desfire_SelectFile(NdefMap);
731 /* handle the error in Transc function*/
732 if ( (Status & PHNFCSTBLOWER) != (NFCSTATUS_PENDING & PHNFCSTBLOWER))
734 /* call respective CR */
735 phFriNfc_Desfire_HCrHandler(NdefMap,Status);
740 /*Error " Smart Tag Functionality Not Supported"*/
741 Status = PHNFCSTVAL(CID_FRI_NFC_NDEF_MAP,\
742 NFCSTATUS_SMART_TAG_FUNC_NOT_SUPPORTED);
744 NdefMap->CardType = 0;
745 #endif /* #ifdef DESFIRE_EV1 */
747 /* call respective CR */
748 phFriNfc_Desfire_HCrHandler(NdefMap,Status);
754 case PH_FRINFC_NDEFMAP_DESF_STATE_SELECT_FILE :
756 if(( NdefMap->SendRecvBuf[PH_FRINFC_NDEFMAP_DESF_SW1_INDEX] == PH_FRINFC_NDEFMAP_DESF_RAPDU_SW1_BYTE) &&
757 (NdefMap->SendRecvBuf[PH_FRINFC_NDEFMAP_DESF_SW2_INDEX] == PH_FRINFC_NDEFMAP_DESF_RAPDU_SW2_BYTE))
759 /*check for the which operation */
760 if( (NdefMap->DespOpFlag == PH_FRINFC_NDEFMAP_DESF_READ_OP) ||
761 (NdefMap->DespOpFlag == PH_FRINFC_NDEFMAP_DESF_NDEF_CHK_OP) ||
762 (NdefMap->DespOpFlag == PH_FRINFC_NDEFMAP_DESF_GET_LEN_OP ))
764 /* call for read binary operation*/
765 Status = phFriNfc_Desfire_ReadBinary(NdefMap);
767 /* handle the error in Transc function*/
768 if ( (Status & PHNFCSTBLOWER) != (NFCSTATUS_PENDING & PHNFCSTBLOWER) )
770 /* call respective CR */
771 phFriNfc_Desfire_HCrHandler(NdefMap,Status);
774 /*its a write Operation*/
775 else if(NdefMap->DespOpFlag == PH_FRINFC_NDEFMAP_DESF_WRITE_OP )
777 Status = phFriNfc_Desfire_UpdateBinary (NdefMap);
778 /* handle the error in Transc function*/
779 if ( (Status & PHNFCSTBLOWER) != (NFCSTATUS_PENDING & PHNFCSTBLOWER))
781 /* call respective CR */
782 phFriNfc_Desfire_HCrHandler(NdefMap,Status);
787 /* unknown/invalid desfire operations*/
788 Status = PHNFCSTVAL(CID_FRI_NFC_NDEF_MAP,\
789 NFCSTATUS_INVALID_REMOTE_DEVICE);
791 /* call respective CR */
792 phFriNfc_Desfire_HCrHandler(NdefMap,Status);
797 /*return Error " Select File Operation Failed"*/
798 Status = PHNFCSTVAL(CID_FRI_NFC_NDEF_MAP,\
799 NFCSTATUS_INVALID_REMOTE_DEVICE);
801 /* call respective CR */
802 phFriNfc_Desfire_HCrHandler(NdefMap,Status);
806 case PH_FRINFC_NDEFMAP_DESF_STATE_READ_CAP_CONT:
807 if( (NdefMap->SendRecvBuf[(*(NdefMap->SendRecvLength)-2)] == PH_FRINFC_NDEFMAP_DESF_RAPDU_SW1_BYTE) &&
808 (NdefMap->SendRecvBuf[(*(NdefMap->SendRecvLength)-1)] == PH_FRINFC_NDEFMAP_DESF_RAPDU_SW2_BYTE))
810 /* Read successful. */
811 /*Update the smart tag capability container*/
812 Status = phFriNfc_Desfire_Update_SmartTagCapContainer(NdefMap);
814 if ( Status == NFCSTATUS_SUCCESS)
816 NdefMap->DespOpFlag = PH_FRINFC_NDEFMAP_DESF_GET_LEN_OP;
818 if (PH_FRINFC_NDEFMAP_ISO14443_4A_CARD_EV1 == NdefMap->CardType)
820 Status = phFriNfc_Desfire_SelectFile(NdefMap);
823 #endif /* #ifdef DESFIRE_EV1 */
825 Status = phFriNfc_Desfire_HSetGet_NLEN(NdefMap);
827 /* handle the error in Transc function*/
828 if ( (Status & PHNFCSTBLOWER) != (NFCSTATUS_PENDING & PHNFCSTBLOWER))
830 /* call respective CR */
831 phFriNfc_Desfire_HCrHandler(NdefMap,Status);
836 /* call respective CR */
837 phFriNfc_Desfire_HCrHandler(NdefMap,Status);
844 /*return Error " Capability Container Not Found"*/
845 Status = PHNFCSTVAL(CID_FRI_NFC_NDEF_MAP,
846 NFCSTATUS_INVALID_REMOTE_DEVICE);
847 /* call respective CR */
848 phFriNfc_Desfire_HCrHandler(NdefMap,Status);
852 case PH_FRINFC_NDEFMAP_DESF_STATE_READ_BIN:
854 /* Check how many bytes have been read/returned from the card*/
855 BytesRead = phFriNfc_Desfire_HGetLeBytes(NdefMap);
857 /* set the send recev len*/
858 SendRecLen = *NdefMap->SendRecvLength - (PH_FRINFC_NDEFMAP_DESF_RESP_OFFSET );
859 if ( (NdefMap->DesfireCapContainer.SkipNlenBytesFlag == 1) && ((BytesRead == 1) || (BytesRead == 2 )))
861 BytesRead += PH_FRINFC_NDEFMAP_DESF_NLEN_SIZE_IN_BYTES; /* to take care of first 2 len bytes*/
866 /* Nothing to process*/
869 /* Read More Number Of Bytes than Expected*/
870 if ( ( BytesRead == SendRecLen ) &&
871 ((NdefMap->SendRecvBuf[(*NdefMap->SendRecvLength-2)] == PH_FRINFC_NDEFMAP_DESF_RAPDU_SW1_BYTE) &&
872 (NdefMap->SendRecvBuf[(*NdefMap->SendRecvLength-1)] == PH_FRINFC_NDEFMAP_DESF_RAPDU_SW2_BYTE)))
875 /* this is to check the card state in first Read Operation*/
876 if ( NdefMap->DespOpFlag == PH_FRINFC_NDEFMAP_DESF_GET_LEN_OP )
878 /* check the actual length of the ndef data : NLEN*/
879 NLength = ( (((uint16_t)NdefMap->SendRecvBuf[0])<<PH_FRINFC_NDEFMAP_DESF_SHL8)+ \
880 NdefMap->SendRecvBuf[1]);
881 if (( NLength > PH_NFCFRI_NDEFMAP_DESF_NDEF_FILE_SIZE )||
882 ( NLength == 0xFFFF))
885 Status = PHNFCSTVAL(CID_FRI_NFC_NDEF_MAP,
886 NFCSTATUS_NO_NDEF_SUPPORT);
890 /* Store the NLEN into the context */
891 NdefMap->DesfireCapContainer.NdefDataLen = NLength;
893 Status = phFriNfc_MapTool_SetCardState( NdefMap,
895 if ( Status == NFCSTATUS_SUCCESS )
897 /*Set the card type to Desfire*/
899 NdefMap->CardType = PH_FRINFC_NDEFMAP_ISO14443_4A_CARD;
900 #endif /* #ifdef DESFIRE_EV1 */
901 /*Set the state to specify True for Ndef Compliant*/
902 NdefMap->State = PH_FRINFC_NDEFMAP_DESF_STATE_CHK_NDEF;
904 /*set the data count back to zero*/;
905 *NdefMap->DataCount = 0;
906 /*set the apdu buffer index to zero*/
907 NdefMap->ApduBuffIndex = 0;
908 /* Set the Operationg flag to Complete check NDEF Operation*/
909 NdefMap->DespOpFlag = PH_FRINFC_NDEFMAP_DESF_NDEF_CHK_OP;
912 /* call respective CR */
913 phFriNfc_Desfire_HCrHandler(NdefMap,Status);
914 }/* End ofNdefMap->DespOpFlag == PH_FRINFC_NDEFMAP_DESF_GET_LEN_OP*/
916 else if ( NdefMap->DespOpFlag == PH_FRINFC_NDEFMAP_DESF_READ_OP )
918 phFriNfc_Desfire_HProcReadData(NdefMap);
922 /* Invalid Desfire Operation */
923 Status = PHNFCSTVAL(CID_FRI_NFC_NDEF_MAP,
924 NFCSTATUS_INVALID_REMOTE_DEVICE);
925 phFriNfc_Desfire_HCrHandler(NdefMap,Status);
931 /*handle the Error case*/
932 Status = PHNFCSTVAL(CID_FRI_NFC_NDEF_MAP,\
933 NFCSTATUS_READ_FAILED);
938 *NdefMap->DataCount = 0;
940 /*set the buffer index back to zero*/
941 NdefMap->ApduBuffIndex = 0;
943 /* call respective CR */
944 phFriNfc_Desfire_HCrHandler(NdefMap,Status);
949 case PH_FRINFC_NDEFMAP_DESF_STATE_UPDATE_BIN_BEGIN:
950 if( (NdefMap->SendRecvBuf[PH_FRINFC_NDEFMAP_DESF_SW1_INDEX] == PH_FRINFC_NDEFMAP_DESF_RAPDU_SW1_BYTE) &&
951 (NdefMap->SendRecvBuf[PH_FRINFC_NDEFMAP_DESF_SW2_INDEX] == PH_FRINFC_NDEFMAP_DESF_RAPDU_SW2_BYTE))
953 /* Write operation was successful. */
954 /* NdefMap->NumOfBytesWritten have been written on to the card.
955 Update the DataCount and the ApduBufferIndex */
956 *NdefMap->DataCount = (uint16_t)(*NdefMap->DataCount +
957 NdefMap->NumOfBytesWritten);
958 NdefMap->ApduBuffIndex = (uint16_t)(NdefMap->ApduBuffIndex +
959 NdefMap->NumOfBytesWritten);
961 /* Update the user-provided buffer size to write */
962 *NdefMap->WrNdefPacketLength += NdefMap->NumOfBytesWritten;
964 /* Call Upadte Binary function to check if some more bytes are to be written. */
965 Status = phFriNfc_Desfire_UpdateBinary( NdefMap );
969 /*handle the Error case*/
970 Status = PHNFCSTVAL(CID_FRI_NFC_NDEF_MAP,\
971 NFCSTATUS_WRITE_FAILED);
973 /*set the buffer index back to zero*/
974 NdefMap->ApduBuffIndex = 0;
976 /* call respective CR */
977 phFriNfc_Desfire_HCrHandler(NdefMap,Status);
980 case PH_FRINFC_NDEFMAP_DESF_STATE_UPDATE_BIN_END :
981 if((NdefMap->SendRecvBuf[PH_FRINFC_NDEFMAP_DESF_SW1_INDEX] == PH_FRINFC_NDEFMAP_DESF_RAPDU_SW1_BYTE) &&
982 (NdefMap->SendRecvBuf[PH_FRINFC_NDEFMAP_DESF_SW2_INDEX] == PH_FRINFC_NDEFMAP_DESF_RAPDU_SW2_BYTE))
984 /* Updating NLEN operation was successful. */
985 /* Entire Write Operation is complete*/
986 /* Reset the relevant parameters. */
987 Status = PHNFCSTVAL(CID_NFC_NONE,\
990 /* set the state & Data len into context*/
991 NdefMap->CardState = (uint8_t)((NdefMap->CardState ==
992 PH_NDEFMAP_CARD_STATE_INITIALIZED)?
993 PH_NDEFMAP_CARD_STATE_READ_WRITE :
996 NdefMap->DesfireCapContainer.NdefDataLen = (uint16_t)(*NdefMap->WrNdefPacketLength);
997 #ifdef PH_HAL4_ENABLE
1000 NdefMap->PrevOperation = 0;
1001 #endif /* #ifndef PH_HAL4_ENABLE */
1006 NdefMap->PrevOperation = 0;
1007 /*handle the Error case*/
1008 Status = PHNFCSTVAL(CID_FRI_NFC_NDEF_MAP,\
1009 NFCSTATUS_WRITE_FAILED);
1012 /*set the buffer index back to zero*/
1013 NdefMap->ApduBuffIndex = 0;
1015 /* call respective CR */
1016 phFriNfc_Desfire_HCrHandler(NdefMap,Status);
1020 /*define the invalid state*/
1021 Status = PHNFCSTVAL(CID_FRI_NFC_NDEF_MAP,\
1022 NFCSTATUS_INVALID_DEVICE_REQUEST);
1023 phFriNfc_Desfire_HCrHandler(NdefMap,Status);
1029 /* call respective CR */
1030 phFriNfc_Desfire_HCrHandler(NdefMap,Status);
1037 * \brief this shall select the smart tag functinality of the Desfire card.
1039 * Only when this command returns command completed it is a Smart Tag
1040 * compatible product.
1044 NFCSTATUS phFriNfc_Desfire_SelectSmartTag(phFriNfc_NdefMap_t *NdefMap)
1047 NFCSTATUS status = NFCSTATUS_PENDING;
1049 uint8_t card_type = PH_FRINFC_NDEFMAP_ISO14443_4A_CARD_EV1;
1050 #endif /* #ifdef DESFIRE_EV1 */
1052 /*form the packet for Select smart tag command*/
1053 NdefMap->SendRecvBuf[0] = 0x00; /* cls */
1054 NdefMap->SendRecvBuf[1] = 0xa4; /* ins */
1055 NdefMap->SendRecvBuf[2] = 0x04; /* p1 */
1056 NdefMap->SendRecvBuf[3] = 0x00; /* p2 */
1057 NdefMap->SendRecvBuf[4] = 0x07; /* lc */
1059 /* next 7 bytes specify the DF Name*/
1060 NdefMap->SendRecvBuf[5] = 0xd2;
1061 NdefMap->SendRecvBuf[6] = 0x76;
1062 NdefMap->SendRecvBuf[7] = 0x00;
1063 NdefMap->SendRecvBuf[8] = 0x00;
1064 NdefMap->SendRecvBuf[9] = 0x85;
1065 NdefMap->SendRecvBuf[10] = 0x01;
1069 switch (NdefMap->DespOpFlag)
1071 case PH_FRINFC_NDEFMAP_DESF_NDEF_CHK_OP:
1073 /* First select the smart tag using the new desfire EV1 and increment the
1074 "sel_index" and if it fails then try the old desfire select smart tag
1076 if (0 == NdefMap->CardType)
1079 NdefMap->SendRecvBuf[3] = DESFIRE_EV1_P2_OFFSET_VALUE; */
1080 NdefMap->SendRecvBuf[11] = 0x01;
1082 NdefMap->SendRecvBuf[12] = 0x00;
1083 NdefMap->State = PH_FRINFC_NDEFMAP_DESF_STATE_SELECT_SMART_TAG_EV1;
1084 card_type = PH_FRINFC_NDEFMAP_ISO14443_4A_CARD_EV1;
1088 NdefMap->SendRecvBuf[3] = 0x00; /* p2 */
1089 NdefMap->SendRecvBuf[11] = 0x00;
1090 NdefMap->State = PH_FRINFC_NDEFMAP_DESF_STATE_SELECT_SMART_TAG;
1091 card_type = PH_FRINFC_NDEFMAP_ISO14443_4A_CARD;
1096 case PH_FRINFC_NDEFMAP_DESF_READ_OP:
1099 if (PH_FRINFC_NDEFMAP_ISO14443_4A_CARD_EV1 == NdefMap->CardType)
1101 NdefMap->SendRecvBuf[11] = 0x01;
1102 NdefMap->SendRecvBuf[12] = 0x00;
1103 NdefMap->State = (uint8_t)PH_FRINFC_NDEFMAP_DESF_STATE_SELECT_SMART_TAG_EV1;
1104 card_type = PH_FRINFC_NDEFMAP_ISO14443_4A_CARD_EV1;
1108 NdefMap->SendRecvBuf[11] = 0x00;
1109 NdefMap->State = (uint8_t)PH_FRINFC_NDEFMAP_DESF_STATE_SELECT_SMART_TAG;
1110 card_type = PH_FRINFC_NDEFMAP_ISO14443_4A_CARD;
1116 #else /* #ifdef DESFIRE_EV1 */
1118 NdefMap->SendRecvBuf[11] = 0x00;
1120 #endif /* #ifdef DESFIRE_EV1 */
1122 /*Set the Send length*/
1123 NdefMap->SendLength = PH_FRINFC_NDEFMAP_DESF_CAPDU_SMARTTAG_PKT_SIZE;
1126 if (PH_FRINFC_NDEFMAP_ISO14443_4A_CARD_EV1 == card_type)
1128 /* Send length is updated for the NEW DESFIRE EV1 */
1129 NdefMap->SendLength = (uint16_t)(NdefMap->SendLength + 1);
1133 /* Change the state to Select Smart Tag */
1134 NdefMap->State = PH_FRINFC_NDEFMAP_DESF_STATE_SELECT_SMART_TAG;
1135 #endif /* #ifdef DESFIRE_EV1 */
1137 status = phFriNfc_Desfire_HSendTransCmd(NdefMap,PH_FRINFC_NDEFMAP_DESF_RESP_OFFSET);
1143 * \brief this shall select/access the capability container of the Desfire
1146 * This shall be used to identify, if NDEF data structure do exist on
1147 * the smart tag, we receive command completed status.
1151 NFCSTATUS phFriNfc_Desfire_SelectFile (phFriNfc_NdefMap_t *NdefMap)
1154 NFCSTATUS status = NFCSTATUS_PENDING;
1156 /* check for the invalid/unknown desfire operations*/
1157 if ((NdefMap->DespOpFlag != PH_FRINFC_NDEFMAP_DESF_NDEF_CHK_OP)&& \
1158 (NdefMap->DespOpFlag != PH_FRINFC_NDEFMAP_DESF_READ_OP)&&\
1159 ( NdefMap->DespOpFlag != PH_FRINFC_NDEFMAP_DESF_WRITE_OP) &&
1160 ( NdefMap->DespOpFlag != PH_FRINFC_NDEFMAP_DESF_GET_LEN_OP))
1162 status = PHNFCSTVAL(CID_FRI_NFC_NDEF_MAP, NFCSTATUS_INVALID_REMOTE_DEVICE);
1167 /* Set the command*/
1168 //NdefMap->Cmd.Iso144434Cmd = phHal_eIso14443_4_CmdListTClCmd;
1170 /* Form the packet for select file command either for the
1171 Check Ndef/Read/Write functionalities*/
1172 NdefMap->SendRecvBuf[0] = 0x00; /* cls */
1173 NdefMap->SendRecvBuf[1] = 0xa4; /* ins */
1174 NdefMap->SendRecvBuf[2] = 0x00; /* p1 */
1175 NdefMap->SendRecvBuf[3] = 0x00; /* p2 */
1176 NdefMap->SendRecvBuf[4] = 0x02; /* lc */
1179 if (PH_FRINFC_NDEFMAP_ISO14443_4A_CARD_EV1 == NdefMap->CardType)
1181 NdefMap->SendRecvBuf[3] = DESFIRE_EV1_P2_OFFSET_VALUE; /* p2 */
1183 #endif /* #ifdef DESFIRE_EV1 */
1185 if ( (NdefMap->DespOpFlag == PH_FRINFC_NDEFMAP_DESF_NDEF_CHK_OP))
1188 /* cap container file identifier*/
1189 NdefMap->SendRecvBuf[5] = 0xe1;
1190 NdefMap->SendRecvBuf[6] = 0x03;
1192 /* Mantis entry 0394 fixed */
1195 NdefMap->SendRecvBuf[5] = (uint8_t)((NdefMap->DesfireCapContainer.NdefMsgFid) >> PH_FRINFC_NDEFMAP_DESF_SHL8);
1196 NdefMap->SendRecvBuf[6] = (uint8_t)((NdefMap->DesfireCapContainer.NdefMsgFid) & (0x00ff));
1198 /*Set the Send length*/
1199 NdefMap->SendLength = PH_FRINFC_NDEFMAP_DESF_CAPDU_SELECT_FILE_PKT_SIZE;
1201 /* Change the state to Select File */
1202 NdefMap->State = PH_FRINFC_NDEFMAP_DESF_STATE_SELECT_FILE;
1204 status = phFriNfc_Desfire_HSendTransCmd(NdefMap,PH_FRINFC_NDEFMAP_DESF_RESP_OFFSET);
1213 * \brief this shall read the data from Desfire card.
1215 * This is used in two cases namely Reading the Capability container
1216 * data( le == 0 ) and reading the file data.Maximum bytes to be read during
1217 * a single read binary is known after the reading the data from the capability
1222 NFCSTATUS phFriNfc_Desfire_ReadBinary(phFriNfc_NdefMap_t *NdefMap)
1224 NFCSTATUS status = NFCSTATUS_PENDING;
1225 uint32_t BytesToRead = 0;
1226 uint8_t BufIndex=0,OperFlag=0;
1229 /* to read the capability container data*/
1230 if (NdefMap->DespOpFlag == PH_FRINFC_NDEFMAP_DESF_NDEF_CHK_OP )
1232 /*specifies capability container shall be read*/
1233 NdefMap->SendRecvBuf[0] = 0x00;
1234 NdefMap->SendRecvBuf[1] = 0xb0;
1235 NdefMap->SendRecvBuf[2] = 0x00; /* p1 */
1236 NdefMap->SendRecvBuf[3] = 0x00; /* p2 */
1237 NdefMap->SendRecvBuf[4] = 0x0F; /* le */
1239 NdefMap->SendLength = PH_FRINFC_NDEFMAP_DESF_CAPDU_READ_BIN_PKT_SIZE;
1241 /* Change the state to Cap Container Read */
1242 NdefMap->State = PH_FRINFC_NDEFMAP_DESF_STATE_READ_CAP_CONT;
1244 /* set the send receive buffer length*/
1247 /*desfire file read operation*/
1250 NdefMap->SendRecvBuf[0] = 0x00;
1251 NdefMap->SendRecvBuf[1] = 0xb0;
1253 /*TBD the NLEN bytes*/
1254 if( *NdefMap->DataCount == 0 )
1257 /* set the offset p1 and p2*/
1258 NdefMap->SendRecvBuf[2] = 0;
1259 NdefMap->SendRecvBuf[3] = 0;
1263 /* as the p1 of the 8bit is 0, p1 and p2 are used to store the
1265 DataCnt = *NdefMap->DataCount;
1266 DataCnt += PH_FRINFC_NDEFMAP_DESF_NLEN_SIZE_IN_BYTES;
1267 NdefMap->SendRecvBuf[2] = (uint8_t)((DataCnt)>> PH_FRINFC_NDEFMAP_DESF_SHL8);
1268 NdefMap->SendRecvBuf[3] = (uint8_t)((DataCnt)& (0x00ff));
1270 /* calculate the Le Byte*/
1271 BytesToRead = phFriNfc_Desfire_HGetLeBytes(NdefMap);
1273 if ( NdefMap->Offset == PH_FRINFC_NDEFMAP_SEEK_BEGIN )
1275 /* BufIndex represents the 2 NLEN bytes and decides about the presence of
1278 BufIndex = (uint8_t)(( NdefMap->DesfireCapContainer.SkipNlenBytesFlag == 1 ) ?
1279 PH_FRINFC_NDEFMAP_DESF_NLEN_SIZE_IN_BYTES:0);
1281 if( ((BytesToRead == 1) || (BytesToRead == 2)) && (NdefMap->DesfireCapContainer.SkipNlenBytesFlag == 1))
1283 BytesToRead += BufIndex;
1287 /* set the Le byte*/
1288 /* This following code is true for get nlen and current offset set*/
1289 NdefMap->SendRecvBuf[4]=(uint8_t) BytesToRead ;
1291 /* Change the state to Read */
1292 NdefMap->State = PH_FRINFC_NDEFMAP_DESF_STATE_READ_BIN;
1294 /*set the send length*/
1295 NdefMap->SendLength = PH_FRINFC_NDEFMAP_DESF_CAPDU_READ_BIN_PKT_SIZE;
1301 status = phFriNfc_Desfire_HSendTransCmd(NdefMap,PH_FRINFC_NDEFMAP_MAX_SEND_RECV_BUF_SIZE);
1305 status = phFriNfc_Desfire_HSendTransCmd(NdefMap,(uint8_t)(BytesToRead +PH_FRINFC_NDEFMAP_DESF_RESP_OFFSET));
1311 * \brief this shall write the data to Desfire card.
1312 * Maximum bytes to be written during a single update binary
1313 * is known after the reading the data from the capability
1316 * le filed specifes , how many bytes of data to be written to the
1321 NFCSTATUS phFriNfc_Desfire_UpdateBinary(phFriNfc_NdefMap_t *NdefMap)
1324 NFCSTATUS status = NFCSTATUS_PENDING;
1325 uint16_t noOfBytesToWrite = 0, DataCnt=0,
1328 /* Do we have space in the file to write? */
1329 if ( (*NdefMap->DataCount < PH_NFCFRI_NDEFMAP_DESF_NDEF_FILE_SIZE) &&
1330 (NdefMap->ApduBuffIndex < NdefMap->ApduBufferSize))
1332 /* Yes, we have some bytes to write */
1333 /* Check and set the card memory size , if user sent bytes are more than the
1335 if( (uint16_t)(NdefMap->ApduBufferSize - NdefMap->ApduBuffIndex) >\
1336 (uint16_t)(PH_NFCFRI_NDEFMAP_DESF_NDEF_FILE_SIZE - *NdefMap->DataCount))
1338 NdefMap->ApduBufferSize =( (PH_NFCFRI_NDEFMAP_DESF_NDEF_FILE_SIZE) - (*NdefMap->DataCount + NdefMap->ApduBuffIndex));
1341 /* Now, we have space in the card to write the data, */
1342 /*Form the packet for the update binary command*/
1343 NdefMap->SendRecvBuf[0] = 0x00;
1344 NdefMap->SendRecvBuf[1] = 0xD6;
1346 if( *NdefMap->DataCount == 0)
1348 /* set the p1/p2 offsets */
1349 NdefMap->SendRecvBuf[2] = 0x00; /* p1 */
1350 NdefMap->SendRecvBuf[3] = 0x00; /* p2 */
1351 NdefMap->DesfireCapContainer.SkipNlenBytesFlag = 0;
1355 /* as the p1 of the 8bit is 0, p1 and p2 are used to store the
1357 /* This sets card offset in a card for a write operation. + 2 is
1358 added as first 2 offsets represents the size of the NDEF Len present
1361 DataCnt = *NdefMap->DataCount;
1362 DataCnt += PH_FRINFC_NDEFMAP_DESF_NLEN_SIZE_IN_BYTES;
1363 NdefMap->SendRecvBuf[2] = (uint8_t)((DataCnt)>> PH_FRINFC_NDEFMAP_DESF_SHL8);
1364 NdefMap->SendRecvBuf[3] = (uint8_t)((DataCnt)& (0x00ff));
1365 /* No need to attach 2 NLEN bytes at the begining.
1366 as we have already attached in the first write operation.*/
1367 NdefMap->DesfireCapContainer.SkipNlenBytesFlag = 1;
1371 /* Calculate the bytes to write */
1372 if( (NdefMap->ApduBufferSize - NdefMap->ApduBuffIndex) >= (uint32_t)( NdefMap->DesfireCapContainer.MaxCmdSize ))
1375 noOfBytesToWrite = ( ( NdefMap->DesfireCapContainer.SkipNlenBytesFlag == 1) ?
1376 NdefMap->DesfireCapContainer.MaxCmdSize :
1377 (NdefMap->DesfireCapContainer.MaxCmdSize - PH_FRINFC_NDEFMAP_DESF_NLEN_SIZE_IN_BYTES));
1381 /* Read only till the available buffer space */
1382 noOfBytesToWrite = (uint16_t)(NdefMap->ApduBufferSize - NdefMap->ApduBuffIndex);
1385 if ( NdefMap->Offset == PH_FRINFC_NDEFMAP_SEEK_BEGIN )
1387 if ( NdefMap->DesfireCapContainer.SkipNlenBytesFlag == 1 )
1390 /* To Specify the NDEF data len written : updated at the of write cycle*/
1391 NdefMap->SendRecvBuf[4] = (uint8_t)noOfBytesToWrite;
1395 /* Leave space to update NLEN */
1396 NdefMap->SendRecvBuf[5] = 0x00;
1397 NdefMap->SendRecvBuf[6] = 0x00;
1399 /* To Specify the NDEF data len written : updated at the of write cycle*/
1400 NdefMap->SendRecvBuf[4] = (uint8_t)noOfBytesToWrite + PH_FRINFC_NDEFMAP_DESF_NLEN_SIZE_IN_BYTES;
1403 /* copy the data to SendRecvBuf from the apdu buffer*/
1404 (void)memcpy( &NdefMap->SendRecvBuf[index],
1405 &NdefMap->ApduBuffer[NdefMap->ApduBuffIndex],
1407 NdefMap->SendLength = (noOfBytesToWrite + index);
1411 NdefMap->SendRecvBuf[4] = (uint8_t)noOfBytesToWrite;
1413 /* copy the data to SendRecvBuf from the apdu buffer*/
1414 (void)memcpy( &NdefMap->SendRecvBuf[5],
1415 &NdefMap->ApduBuffer[NdefMap->ApduBuffIndex],
1417 NdefMap->SendLength = (noOfBytesToWrite + 5);
1420 /* Store the number of bytes being written in the context structure, so that
1421 the parameters can be updated, after a successful write operation. */
1422 NdefMap->NumOfBytesWritten = noOfBytesToWrite;
1424 /* Change the state to Write */
1425 NdefMap->State = PH_FRINFC_NDEFMAP_DESF_STATE_UPDATE_BIN_BEGIN;
1427 status = phFriNfc_Desfire_HSendTransCmd(NdefMap,PH_FRINFC_NDEFMAP_DESF_RESP_OFFSET);
1429 } /* if(NdefMap->ApduBuffIndex < NdefMap->ApduBufferSize) */
1432 if ( (*NdefMap->DataCount == PH_NFCFRI_NDEFMAP_DESF_NDEF_FILE_SIZE) ||
1433 (NdefMap->ApduBuffIndex == NdefMap->ApduBufferSize))
1435 /* The NdefMap->DespOpFlag = PH_FRINFC_NDEFMAP_DESF_SET_LEN_OP is not
1436 required, because the DespOpFlag shall be WRITE_OP
1438 /* Update the NLEN Bytes*/
1439 #ifdef PH_HAL4_ENABLE
1442 NdefMap->DespOpFlag = PH_FRINFC_NDEFMAP_DESF_SET_LEN_OP;
1443 #endif /* #ifdef PH_HAL4_ENABLE */
1444 status = phFriNfc_Desfire_HSetGet_NLEN(NdefMap);
1448 /* The control should not come here.
1449 wrong internal calculation.
1450 we have actually written more than the space available
1452 #ifndef PH_HAL4_ENABLE
1453 status = PHNFCSTVAL(CID_FRI_NFC_NDEF_MAP,
1454 NFCSTATUS_CMD_ABORTED);
1456 status = PHNFCSTVAL(CID_FRI_NFC_NDEF_MAP,
1459 /* Reset the relevant parameters. */
1460 NdefMap->ApduBuffIndex = 0;
1461 NdefMap->PrevOperation = 0;
1463 /* call respective CR */
1464 phFriNfc_Desfire_HCrHandler(NdefMap,status);
1468 /* if(*NdefMap->DataCount < PH_NFCFRI_NDEFMAP_DESF_NDEF_FILE_SIZE) */
1474 static void phFriNfc_Desfire_HChkNDEFFileAccessRights(phFriNfc_NdefMap_t *NdefMap)
1476 if ( (NdefMap->DesfireCapContainer.ReadAccess == 0x00) &&
1477 (NdefMap->DesfireCapContainer.WriteAccess == 0x00 ))
1479 /* Set the card state to Read/write State*/
1480 /* This state can be either INITIALISED or READWRITE. but default
1482 NdefMap->CardState = PH_NDEFMAP_CARD_STATE_READ_WRITE;
1485 else if((NdefMap->DesfireCapContainer.ReadAccess == 0x00) &&
1486 (NdefMap->DesfireCapContainer.WriteAccess == 0xFF ))
1488 /* Set the card state to Read Only State*/
1489 NdefMap->CardState = PH_NDEFMAP_CARD_STATE_READ_ONLY;
1493 /* Set the card state to invalid State*/
1494 NdefMap->CardState = PH_NDEFMAP_CARD_STATE_INVALID;
1499 * \brief this shall update the Desfire capability container structure.
1501 * This function shall store version,maximum Ndef data structure size,
1502 * Read Access permissions, Write Access permissions , Maximum data size
1503 * that can be sent using a single Update Binary, maximum data size that
1504 * can be read from the Desfire using a singlr read binary.
1505 * These vaues shall be stored and used during the read/update binary
1510 NFCSTATUS phFriNfc_Desfire_Update_SmartTagCapContainer(phFriNfc_NdefMap_t *NdefMap)
1512 uint16_t CapContSize = 0,
1513 /* this is initalised 2 because CCLEN includes the field size bytes i.e 2bytes*/
1515 uint8_t ErrFlag = 0;
1517 NFCSTATUS status= NFCSTATUS_SUCCESS;
1519 /*Check the Size of Cap Container */
1520 CapContSize = ( (((uint16_t)NdefMap->SendRecvBuf[PH_FRINFC_NDEFMAP_DESF_CCLEN_BYTE_FIRST_INDEX])<<8)+ \
1521 NdefMap->SendRecvBuf[PH_FRINFC_NDEFMAP_DESF_CCLEN_BYTE_SECOND_INDEX]);
1525 if ( (CapContSize < 0x0f) || (CapContSize == 0xffff))
1531 /*Version : Smart Tag Spec version */
1532 /* check for the validity of Major and Minor Version numbers*/
1533 status = phFriNfc_MapTool_ChkSpcVer ( NdefMap,
1534 PH_FRINFC_NDEFMAP_DESF_VER_INDEX);
1535 if ( status != NFCSTATUS_SUCCESS )
1543 /*Get Response APDU data size
1544 to check the integration s/w response size*/
1545 #ifdef PH_HAL4_ENABLE
1547 uint16_t max_rsp_size =
1548 ((((uint16_t)NdefMap->SendRecvBuf[PH_FRINFC_NDEFMAP_DESF_MLE_BYTE_FIRST_INDEX]) << 8)\
1549 + NdefMap->SendRecvBuf[PH_FRINFC_NDEFMAP_DESF_MLE_BYTE_SECOND_INDEX]);
1550 NdefMap->DesfireCapContainer.MaxRespSize =
1551 ((max_rsp_size > PHHAL_MAX_DATASIZE)?
1552 (PHHAL_MAX_DATASIZE) : max_rsp_size);
1555 NdefMap->DesfireCapContainer.MaxRespSize =
1556 ((((uint16_t)NdefMap->SendRecvBuf[PH_FRINFC_NDEFMAP_DESF_MLE_BYTE_FIRST_INDEX]) << 8)\
1557 +NdefMap->SendRecvBuf[PH_FRINFC_NDEFMAP_DESF_MLE_BYTE_SECOND_INDEX]);
1558 #endif /* #ifdef PH_HAL4_ENABLE */
1560 /*Get Command APDU data size*/
1561 #ifdef PH_HAL4_ENABLE
1563 uint16_t max_cmd_size =
1564 ((((uint16_t)NdefMap->SendRecvBuf[PH_FRINFC_NDEFMAP_DESF_MLC_BYTE_FIRST_INDEX])<<8)\
1565 + NdefMap->SendRecvBuf[PH_FRINFC_NDEFMAP_DESF_MLC_BYTE_SECOND_INDEX]);
1567 NdefMap->DesfireCapContainer.MaxCmdSize =
1568 ((max_cmd_size > PHHAL_MAX_DATASIZE)?
1569 (PHHAL_MAX_DATASIZE): max_cmd_size);
1572 NdefMap->DesfireCapContainer.MaxCmdSize =
1573 ((((uint16_t)NdefMap->SendRecvBuf[PH_FRINFC_NDEFMAP_DESF_MLC_BYTE_FIRST_INDEX])<<8)\
1574 +NdefMap->SendRecvBuf[PH_FRINFC_NDEFMAP_DESF_MLC_BYTE_SECOND_INDEX]);
1575 #endif /* #ifdef PH_HAL4_ENABLE */
1576 /* Check for the Validity of Cmd & Resp Size*/
1577 /* check the Validity of the Cmd Size*/
1578 if( (NdefMap->DesfireCapContainer.MaxRespSize < 0x0f) ||
1579 ( NdefMap->DesfireCapContainer.MaxCmdSize == 0x00))
1588 /* Check and Parse the TLV structure */
1589 /* In future this chk can be extended to Propritery TLV */
1590 //status = phFriNfc_ChkAndParseTLV(NdefMap);
1591 status = phFriNfc_Desf_HChkAndParseTLV(NdefMap,PH_FRINFC_NDEFMAP_DESF_TLV_INDEX);
1592 if ( (status == NFCSTATUS_SUCCESS) && (NdefMap->TLVFoundFlag == PH_FRINFC_NDEFMAP_DESF_NDEF_CNTRL_TLV))
1596 /* check the TLV length*/
1597 if ( (( NdefMap->SendRecvBuf[PH_FRINFC_NDEFMAP_DESF_TLV_LEN_INDEX]) > 0x00 ) &&
1598 (( NdefMap->SendRecvBuf[PH_FRINFC_NDEFMAP_DESF_TLV_LEN_INDEX]) <= 0xFE )&&
1599 (( NdefMap->SendRecvBuf[PH_FRINFC_NDEFMAP_DESF_TLV_LEN_INDEX]) == 0x06 ))
1602 /* store the contents in to the container structure*/
1603 NdefMap->DesfireCapContainer.NdefMsgFid = ( (((uint16_t)NdefMap->SendRecvBuf[PH_FRINFC_NDEFMAP_DESF_NDEF_FILEID_BYTE_FIRST_INDEX])<<PH_FRINFC_NDEFMAP_DESF_SHL8)+ \
1604 NdefMap->SendRecvBuf[PH_FRINFC_NDEFMAP_DESF_NDEF_FILEID_BYTE_SECOND_INDEX]);
1608 /* Invalid Msg File Id : User Can't Have read/write Opeartion*/
1609 if ( (NdefMap->DesfireCapContainer.NdefMsgFid == 0xFFFF) ||
1610 (NdefMap->DesfireCapContainer.NdefMsgFid == 0xE102) ||
1611 (NdefMap->DesfireCapContainer.NdefMsgFid == 0xE103) ||
1612 (NdefMap->DesfireCapContainer.NdefMsgFid == 0x3F00) ||
1613 (NdefMap->DesfireCapContainer.NdefMsgFid == 0x3FFF ) )
1621 NdefMap->DesfireCapContainer.NdefFileSize =
1622 ((((uint16_t)NdefMap->SendRecvBuf[PH_FRINFC_NDEFMAP_DESF_NDEF_FILESZ_BYTE_FIRST_INDEX])<<8)
1623 | (NdefMap->SendRecvBuf[PH_FRINFC_NDEFMAP_DESF_NDEF_FILESZ_BYTE_SECOND_INDEX] & 0x00ff));
1627 /* TBD : Do we need to minus 2 bytes of size it self?*/
1628 if ( ((NdefMap->DesfireCapContainer.NdefFileSize -2) <= 0x0004 ) ||
1629 ((NdefMap->DesfireCapContainer.NdefFileSize -2) == 0xFFFD ) )
1637 /*Ndef File Read Access*/
1638 NdefMap->DesfireCapContainer.ReadAccess = NdefMap->\
1639 SendRecvBuf[PH_FRINFC_NDEFMAP_DESF_NDEF_FILERD_ACCESS_INDEX] ;
1641 /*Ndef File Write Access*/
1642 NdefMap->DesfireCapContainer.WriteAccess = NdefMap->SendRecvBuf[PH_FRINFC_NDEFMAP_DESF_NDEF_FILEWR_ACCESS_INDEX];
1646 phFriNfc_Desfire_HChkNDEFFileAccessRights(NdefMap);
1653 /* TLV Lenth is of two byte value
1654 TBD: As the length of TLV is fixed for 6 bytes. We need not
1655 handle the 2 byte value*/
1662 if ( NdefMap->TLVFoundFlag == PH_FRINFC_NDEFMAP_DESF_PROP_CNTRL_TLV )
1664 /*TBD: To Handle The Proprietery TLV*/
1668 /*Invalid T found case*/
1672 /* check for the entire LENGTH Validity
1673 CCLEN + TLV L value == CCLEN*/
1674 if ( CapContSize != CCLen )
1679 }/* if NdefMap->DesfireCapContainer.MaxRespSize < 0x0f */
1680 }/* Chkeck Map Version*/
1681 }/* CC size invalid*/
1684 status = PHNFCSTVAL(CID_FRI_NFC_NDEF_MAP,
1685 NFCSTATUS_NO_NDEF_SUPPORT);
1690 static uint32_t phFriNfc_Desfire_HGetLeBytes(phFriNfc_NdefMap_t *NdefMap)
1692 /*Represents the LE byte*/
1693 uint16_t BytesToRead =0;
1695 if ( NdefMap->DespOpFlag == PH_FRINFC_NDEFMAP_DESF_GET_LEN_OP )
1697 BytesToRead = PH_FRINFC_NDEFMAP_DESF_NLEN_SIZE_IN_BYTES;
1698 NdefMap->DesfireCapContainer.SkipNlenBytesFlag =0;
1703 /* Calculate Le bytes : No of bytes to read*/
1704 /* Check for User Apdu Buffer Size and Msg Size of Desfire Capability container */
1705 if((NdefMap->ApduBufferSize - NdefMap->ApduBuffIndex) >= NdefMap->DesfireCapContainer.MaxRespSize)
1707 /* We have enough buffer space to read the whole capability container
1709 Now, check do we have NdefMap->DesfireCapContainer.MaxRespSize to read ? */
1711 BytesToRead = (((NdefMap->DesfireCapContainer.NdefDataLen - *NdefMap->DataCount) >=
1712 NdefMap->DesfireCapContainer.MaxRespSize) ?
1713 NdefMap->DesfireCapContainer.MaxRespSize :
1714 (NdefMap->DesfireCapContainer.NdefDataLen -
1715 *NdefMap->DataCount));
1719 /* Read only till the available buffer space */
1720 BytesToRead = (uint16_t)(NdefMap->ApduBufferSize - NdefMap->ApduBuffIndex);
1721 if(BytesToRead >= (uint16_t)(NdefMap->DesfireCapContainer.NdefDataLen - *NdefMap->DataCount))
1723 BytesToRead = (NdefMap->DesfireCapContainer.NdefDataLen - *NdefMap->DataCount);
1727 NdefMap->DesfireCapContainer.SkipNlenBytesFlag =
1728 (uint8_t)(((NdefMap->Offset == PH_FRINFC_NDEFMAP_SEEK_BEGIN )&&( *NdefMap->DataCount == 0 )) ?
1732 return (BytesToRead);
1738 * \brief this shall notify the integration software with respective
1739 * success/error status along with the completion routines.
1741 * This routine is called from the desfire process function.
1745 static void phFriNfc_Desfire_HCrHandler( phFriNfc_NdefMap_t *NdefMap,
1748 /* set the state back to the Reset_Init state*/
1749 NdefMap->State = PH_FRINFC_NDEFMAP_STATE_RESET_INIT;
1751 switch(NdefMap->DespOpFlag)
1753 /* check which routine has the problem and set the CR*/
1754 case PH_FRINFC_NDEFMAP_DESF_NDEF_CHK_OP :
1755 /* set the completion routine*/
1756 NdefMap->CompletionRoutine[PH_FRINFC_NDEFMAP_CR_CHK_NDEF].\
1757 CompletionRoutine(NdefMap->CompletionRoutine->Context,\
1761 case PH_FRINFC_NDEFMAP_DESF_READ_OP :
1762 /* set the completion routine*/
1763 NdefMap->CompletionRoutine[PH_FRINFC_NDEFMAP_CR_RD_NDEF].\
1764 CompletionRoutine(NdefMap->CompletionRoutine->Context,\
1768 case PH_FRINFC_NDEFMAP_DESF_WRITE_OP :
1769 /* set the completion routine*/
1770 NdefMap->CompletionRoutine[PH_FRINFC_NDEFMAP_CR_WR_NDEF].\
1771 CompletionRoutine(NdefMap->CompletionRoutine->Context,\
1776 /* set the completion routine*/
1777 NdefMap->CompletionRoutine[PH_FRINFC_NDEFMAP_CR_INVALID_OPE].\
1778 CompletionRoutine(NdefMap->CompletionRoutine->Context,\
1785 static NFCSTATUS phFriNfc_Desfire_HSendTransCmd(phFriNfc_NdefMap_t *NdefMap,uint8_t SendRecvLen)
1788 NFCSTATUS status = NFCSTATUS_SUCCESS;
1790 /* set the command type*/
1791 #ifndef PH_HAL4_ENABLE
1792 NdefMap->Cmd.Iso144434Cmd = phHal_eIso14443_4_CmdListTClCmd;
1794 NdefMap->Cmd.Iso144434Cmd = phHal_eIso14443_4_Raw;
1797 /* set the Additional Info*/
1798 NdefMap->psDepAdditionalInfo.DepFlags.MetaChaining = 0;
1799 NdefMap->psDepAdditionalInfo.DepFlags.NADPresent = 0;
1801 /*set the completion routines for the desfire card operations*/
1802 NdefMap->MapCompletionInfo.CompletionRoutine = phFriNfc_Desfire_Process;
1803 NdefMap->MapCompletionInfo.Context = NdefMap;
1805 /* set the receive length */
1806 *NdefMap->SendRecvLength = ((uint16_t)(SendRecvLen));
1809 /*Call the Overlapped HAL Transceive function */
1810 status = phFriNfc_OvrHal_Transceive(NdefMap->LowerDevice,
1811 &NdefMap->MapCompletionInfo,
1812 NdefMap->psRemoteDevInfo,
1814 &NdefMap->psDepAdditionalInfo,
1815 NdefMap->SendRecvBuf,
1816 NdefMap->SendLength,
1817 NdefMap->SendRecvBuf,
1818 NdefMap->SendRecvLength);
1827 #include <phUnitTestNfc_Desfire_static.c>
1830 #endif /* PH_FRINFC_MAP_DESFIRE_DISABLED */