Lines Matching refs:NdefSmtCrdFmt
48 static void phFriNfc_MfStd_H_FillSendBuf(phFriNfc_sNdefSmtCrdFmt_t *NdefSmtCrdFmt,
55 static NFCSTATUS phFriNfc_MfStd_H_Transceive(phFriNfc_sNdefSmtCrdFmt_t *NdefSmtCrdFmt);
61 static NFCSTATUS phFriNfc_MfStd_H_CallDisCon(phFriNfc_sNdefSmtCrdFmt_t *NdefSmtCrdFmt,
68 static NFCSTATUS phFriNfc_MfStd_H_CallCon(phFriNfc_sNdefSmtCrdFmt_t *NdefSmtCrdFmt);
75 static NFCSTATUS phFriNfc_MfStd_H_CallPoll(phFriNfc_sNdefSmtCrdFmt_t *NdefSmtCrdFmt);
82 static NFCSTATUS phFriNfc_MfStd_H_ProCon(phFriNfc_sNdefSmtCrdFmt_t *NdefSmtCrdFmt);
88 static NFCSTATUS phFriNfc_MfStd_H_ProAuth(phFriNfc_sNdefSmtCrdFmt_t *NdefSmtCrdFmt);
94 static NFCSTATUS phFriNfc_MfStd_H_ProRdSectTr(phFriNfc_sNdefSmtCrdFmt_t *NdefSmtCrdFmt);
100 static NFCSTATUS phFriNfc_MfStd_H_ProWrSectTr(phFriNfc_sNdefSmtCrdFmt_t *NdefSmtCrdFmt);
106 static NFCSTATUS phFriNfc_MfStd_H_WrRdAuth(phFriNfc_sNdefSmtCrdFmt_t *NdefSmtCrdFmt);
121 static void phFriNfc_MfStd_H_ChangeAuthSt(phFriNfc_sNdefSmtCrdFmt_t *NdefSmtCrdFmt);
134 static NFCSTATUS phFriNfc_MfStd_H_ProWrMADBlk(phFriNfc_sNdefSmtCrdFmt_t *NdefSmtCrdFmt);
140 static NFCSTATUS phFriNfc_MfStd_H_ProErrAuth(phFriNfc_sNdefSmtCrdFmt_t *NdefSmtCrdFmt);
146 static NFCSTATUS phFriNfc_MfStd_H_ErrWrSectTr(phFriNfc_sNdefSmtCrdFmt_t *NdefSmtCrdFmt);
152 static NFCSTATUS phFriNfc_MfStd_H_ErrRdSectTr(phFriNfc_sNdefSmtCrdFmt_t *NdefSmtCrdFmt);
158 static NFCSTATUS phFriNfc_MfStd_H_ProUpdMADBlk(phFriNfc_sNdefSmtCrdFmt_t *NdefSmtCrdFmt);
164 static void phFriNfc_MfStd_H_StrNdefData(phFriNfc_sNdefSmtCrdFmt_t *NdefSmtCrdFmt);
170 static void phFriNfc_MfStd_H_BlkNoToWrTLV(phFriNfc_sNdefSmtCrdFmt_t *NdefSmtCrdFmt);
175 void phFriNfc_MfStd_Reset(phFriNfc_sNdefSmtCrdFmt_t *NdefSmtCrdFmt)
181 NdefSmtCrdFmt->AddInfo.MfStdInfo.AuthState = PH_FRINFC_MFSTD_FMT_VAL_1;
184 (void)memset(NdefSmtCrdFmt->AddInfo.MfStdInfo.Default_KeyA_OR_B,
189 (void)memcpy(NdefSmtCrdFmt->AddInfo.MfStdInfo.MADSect_KeyA,
194 (void)memcpy(NdefSmtCrdFmt->AddInfo.MfStdInfo.MADSect_AccessBits,
199 (void)memcpy(NdefSmtCrdFmt->AddInfo.MfStdInfo.NFCForumSect_KeyA,
204 (void)memcpy(NdefSmtCrdFmt->AddInfo.MfStdInfo.NFCForumSect_AccessBits,
209 (void)memset(NdefSmtCrdFmt->AddInfo.MfStdInfo.SectCompl,
213 NdefSmtCrdFmt->AddInfo.MfStdInfo.WrMADBlkFlag = (uint8_t)PH_FRINFC_MFSTD_FMT_VAL_0;
214 NdefSmtCrdFmt->AddInfo.MfStdInfo.UpdMADBlk = (uint8_t)PH_FRINFC_MFSTD_FMT_NOT_A_MAD_BLK;
218 NFCSTATUS phFriNfc_MfStd_Format( phFriNfc_sNdefSmtCrdFmt_t *NdefSmtCrdFmt, const uint8_t *ScrtKeyB )
226 NdefSmtCrdFmt->AddInfo.MfStdInfo.UpdMADBlk =
231 NdefSmtCrdFmt->AddInfo.MfStdInfo.ScrtKeyB[index] = ScrtKeyB[index];
235 NdefSmtCrdFmt->State = PH_FRINFC_MFSTD_FMT_AUTH_SECT;
237 NdefSmtCrdFmt->AddInfo.MfStdInfo.CurrentBlock = PH_FRINFC_MFSTD_FMT_VAL_3;
239 NdefSmtCrdFmt->AddInfo.MfStdInfo.AuthState = PH_FRINFC_MFSTD_FMT_AUTH_DEF_KEY;
241 Result = phFriNfc_MfStd_H_WrRdAuth(NdefSmtCrdFmt);
249 phFriNfc_sNdefSmtCrdFmt_t *NdefSmtCrdFmt = (phFriNfc_sNdefSmtCrdFmt_t *)Context;
251 NdefSmtCrdFmt->FmtProcStatus = Status;
254 switch(NdefSmtCrdFmt->State)
257 Status = phFriNfc_MfStd_H_ProAuth(NdefSmtCrdFmt);
262 Status = phFriNfc_MfStd_H_CallPoll(NdefSmtCrdFmt);
267 Status = phFriNfc_MfStd_H_CallCon(NdefSmtCrdFmt);
271 Status = phFriNfc_MfStd_H_ProCon(NdefSmtCrdFmt);
275 Status = phFriNfc_MfStd_H_ProRdSectTr(NdefSmtCrdFmt);
279 Status = phFriNfc_MfStd_H_ProWrSectTr(NdefSmtCrdFmt);
283 Status = phFriNfc_MfStd_H_ProWrMADBlk(NdefSmtCrdFmt);
290 Status = phFriNfc_MfStd_H_ProUpdMADBlk(NdefSmtCrdFmt);
301 switch(NdefSmtCrdFmt->State)
304 Status = phFriNfc_MfStd_H_ProErrAuth(NdefSmtCrdFmt);
308 Status = phFriNfc_MfStd_H_ErrWrSectTr(NdefSmtCrdFmt);
312 Status = phFriNfc_MfStd_H_ErrRdSectTr(NdefSmtCrdFmt);
316 Status = NdefSmtCrdFmt->FmtProcStatus;
324 phFriNfc_SmtCrdFmt_HCrHandler(NdefSmtCrdFmt, Status);
328 static void phFriNfc_MfStd_H_FillSendBuf(phFriNfc_sNdefSmtCrdFmt_t *NdefSmtCrdFmt,
345 NdefSmtCrdFmt->SendRecvBuf[PH_FRINFC_MFSTD_FMT_VAL_0] = (uint8_t)BlockNo;
347 *NdefSmtCrdFmt->SendRecvLength = PH_FRINFC_MFSTD_FMT_MAX_RECV_LENGTH;
350 switch(NdefSmtCrdFmt->State)
354 switch(NdefSmtCrdFmt->AddInfo.MfStdInfo.AuthState)
382 NdefSmtCrdFmt->Cmd.MfCmd = phHal_eMifareRead;
384 NdefSmtCrdFmt->Cmd.MfCmd = phHal_eMifareCmdListMifareRead;
388 NdefSmtCrdFmt->SendLength = PH_FRINFC_MFSTD_FMT_VAL_1;
394 NdefSmtCrdFmt->Cmd.MfCmd = phHal_eMifareWrite16;
396 NdefSmtCrdFmt->Cmd.MfCmd = phHal_eMifareCmdListMifareWrite16;
399 switch(NdefSmtCrdFmt->AddInfo.MfStdInfo.CurrentBlock)
402 if (NdefSmtCrdFmt->CardType == PH_FRINFC_SMTCRDFMT_MFSTD_1K_CRD)
404 (void)memcpy(&NdefSmtCrdFmt->SendRecvBuf[PH_FRINFC_MFSTD_FMT_VAL_1],
410 (void)memcpy(&NdefSmtCrdFmt->SendRecvBuf[PH_FRINFC_MFSTD_FMT_VAL_1],
416 (void)memcpy(&NdefSmtCrdFmt->SendRecvBuf[PH_FRINFC_MFSTD_FMT_VAL_1],
421 (void)memcpy(&NdefSmtCrdFmt->SendRecvBuf[PH_FRINFC_MFSTD_FMT_VAL_1],
426 (void)memcpy(&NdefSmtCrdFmt->SendRecvBuf[PH_FRINFC_MFSTD_FMT_VAL_11],
427 NdefSmtCrdFmt->AddInfo.MfStdInfo.ScrtKeyB,
428 sizeof(NdefSmtCrdFmt->AddInfo.MfStdInfo.ScrtKeyB));
431 NdefSmtCrdFmt->SendLength = PH_FRINFC_MFSTD_FMT_WR_SEND_LENGTH;
437 NdefSmtCrdFmt->Cmd.MfCmd = phHal_eMifareWrite16;
439 NdefSmtCrdFmt->Cmd.MfCmd = phHal_eMifareCmdListMifareWrite16;
442 (void)memcpy(&NdefSmtCrdFmt->SendRecvBuf[PH_FRINFC_MFSTD_FMT_VAL_1],
445 NdefSmtCrdFmt->SendLength = PH_FRINFC_MFSTD_FMT_WR_SEND_LENGTH;
451 NdefSmtCrdFmt->Cmd.MfCmd = phHal_eMifareWrite16;
453 NdefSmtCrdFmt->Cmd.MfCmd = phHal_eMifareCmdListMifareWrite16;
465 (void)memcpy(&NdefSmtCrdFmt->SendRecvBuf[PH_FRINFC_MFSTD_FMT_VAL_1],
468 NdefSmtCrdFmt->SendLength = PH_FRINFC_MFSTD_FMT_WR_SEND_LENGTH;
475 NdefSmtCrdFmt->Cmd.MfCmd = phHal_eMifareWrite16;
477 NdefSmtCrdFmt->Cmd.MfCmd = phHal_eMifareCmdListMifareWrite16;
479 NdefSmtCrdFmt->SendLength = PH_FRINFC_MFSTD_FMT_WR_SEND_LENGTH;
480 switch(NdefSmtCrdFmt->AddInfo.MfStdInfo.UpdMADBlk)
483 (void)memcpy(&NdefSmtCrdFmt->SendRecvBuf[PH_FRINFC_MFSTD_FMT_VAL_1],
484 NdefSmtCrdFmt->AddInfo.MfStdInfo.MADSectBlk,
489 (void)memcpy(&NdefSmtCrdFmt->SendRecvBuf[PH_FRINFC_MFSTD_FMT_VAL_1],
490 &NdefSmtCrdFmt->AddInfo.MfStdInfo.MADSectBlk[16],
495 (void)memcpy(&NdefSmtCrdFmt->SendRecvBuf[PH_FRINFC_MFSTD_FMT_VAL_1],
496 &NdefSmtCrdFmt->AddInfo.MfStdInfo.MADSectBlk[32],
501 (void)memcpy(&NdefSmtCrdFmt->SendRecvBuf[PH_FRINFC_MFSTD_FMT_VAL_1],
502 &NdefSmtCrdFmt->AddInfo.MfStdInfo.MADSectBlk[48],
508 (void)memcpy(&NdefSmtCrdFmt->SendRecvBuf[PH_FRINFC_MFSTD_FMT_VAL_1],
509 &NdefSmtCrdFmt->AddInfo.MfStdInfo.MADSectBlk[64],
518 static NFCSTATUS phFriNfc_MfStd_H_Transceive(phFriNfc_sNdefSmtCrdFmt_t *NdefSmtCrdFmt)
523 NdefSmtCrdFmt->psDepAdditionalInfo.DepFlags.MetaChaining = 0;
524 NdefSmtCrdFmt->psDepAdditionalInfo.DepFlags.NADPresent = 0;
525 NdefSmtCrdFmt->psDepAdditionalInfo.NAD = 0;
528 NdefSmtCrdFmt->SmtCrdFmtCompletionInfo.CompletionRoutine = phFriNfc_NdefSmtCrd_Process;
529 NdefSmtCrdFmt->SmtCrdFmtCompletionInfo.Context = NdefSmtCrdFmt;
531 *NdefSmtCrdFmt->SendRecvLength = PH_FRINFC_SMTCRDFMT_MAX_SEND_RECV_BUF_SIZE;
534 Result = phFriNfc_OvrHal_Transceive( NdefSmtCrdFmt->LowerDevice,
535 &NdefSmtCrdFmt->SmtCrdFmtCompletionInfo,
536 NdefSmtCrdFmt->psRemoteDevInfo,
537 NdefSmtCrdFmt->Cmd,
538 &NdefSmtCrdFmt->psDepAdditionalInfo,
539 NdefSmtCrdFmt->SendRecvBuf,
540 NdefSmtCrdFmt->SendLength,
541 NdefSmtCrdFmt->SendRecvBuf,
542 NdefSmtCrdFmt->SendRecvLength);
546 static NFCSTATUS phFriNfc_MfStd_H_CallDisCon(phFriNfc_sNdefSmtCrdFmt_t *NdefSmtCrdFmt,
552 NdefSmtCrdFmt->State = PH_FRINFC_MFSTD_FMT_DIS_CON;
557 Result = phFriNfc_OvrHal_Reconnect( NdefSmtCrdFmt->LowerDevice,
558 &NdefSmtCrdFmt->SmtCrdFmtCompletionInfo,
559 NdefSmtCrdFmt->psRemoteDevInfo);
562 Result = phFriNfc_OvrHal_Disconnect( NdefSmtCrdFmt->LowerDevice,
563 &NdefSmtCrdFmt->SmtCrdFmtCompletionInfo,
564 NdefSmtCrdFmt->psRemoteDevInfo);
570 static NFCSTATUS phFriNfc_MfStd_H_CallCon(phFriNfc_sNdefSmtCrdFmt_t *NdefSmtCrdFmt)
574 NdefSmtCrdFmt->State = PH_FRINFC_MFSTD_FMT_CON;
578 Result = phFriNfc_OvrHal_Connect( NdefSmtCrdFmt->LowerDevice,
579 &NdefSmtCrdFmt->SmtCrdFmtCompletionInfo,
580 NdefSmtCrdFmt->psRemoteDevInfo,
581 NdefSmtCrdFmt->AddInfo.MfStdInfo.DevInputParam);
583 Result = phFriNfc_OvrHal_Connect( NdefSmtCrdFmt->LowerDevice,
584 &NdefSmtCrdFmt->SmtCrdFmtCompletionInfo,
586 NdefSmtCrdFmt->psRemoteDevInfo,
587 NdefSmtCrdFmt->AddInfo.MfStdInfo.DevInputParam);
595 static NFCSTATUS phFriNfc_MfStd_H_CallPoll(phFriNfc_sNdefSmtCrdFmt_t *NdefSmtCrdFmt)
599 NdefSmtCrdFmt->State = PH_FRINFC_MFSTD_FMT_POLL;
601 NdefSmtCrdFmt->OpModeType[PH_FRINFC_MFSTD_FMT_VAL_0] = phHal_eOpModesMifare;
602 NdefSmtCrdFmt->OpModeType[PH_FRINFC_MFSTD_FMT_VAL_1] = phHal_eOpModesArrayTerminator;
605 NdefSmtCrdFmt->AddInfo.MfStdInfo.NoOfDevices = PH_FRINFC_MFSTD_FMT_VAL_1;
608 Result = phFriNfc_OvrHal_Poll( NdefSmtCrdFmt->LowerDevice,
609 &NdefSmtCrdFmt->SmtCrdFmtCompletionInfo,
610 NdefSmtCrdFmt->OpModeType,
611 NdefSmtCrdFmt->psRemoteDevInfo,
612 &NdefSmtCrdFmt->AddInfo.MfStdInfo.NoOfDevices,
613 NdefSmtCrdFmt->AddInfo.MfStdInfo.DevInputParam);
619 static NFCSTATUS phFriNfc_MfStd_H_ProCon(phFriNfc_sNdefSmtCrdFmt_t *NdefSmtCrdFmt)
626 phFriNfc_MfStd_H_ChangeAuthSt(NdefSmtCrdFmt);
634 NdefSmtCrdFmt->State = PH_FRINFC_MFSTD_FMT_AUTH_SECT;
636 Result = phFriNfc_MfStd_H_WrRdAuth(NdefSmtCrdFmt);
641 static NFCSTATUS phFriNfc_MfStd_H_ProAuth(phFriNfc_sNdefSmtCrdFmt_t *NdefSmtCrdFmt)
646 switch(NdefSmtCrdFmt->AddInfo.MfStdInfo.AuthState)
649 if((NdefSmtCrdFmt->AddInfo.MfStdInfo.CurrentBlock ==
651 (NdefSmtCrdFmt->AddInfo.MfStdInfo.WrMADBlkFlag ==
656 NdefSmtCrdFmt->AddInfo.MfStdInfo.CurrentBlock =
659 NdefSmtCrdFmt->State = PH_FRINFC_MFSTD_FMT_WR_MAD_BLK;
661 else if((NdefSmtCrdFmt->AddInfo.MfStdInfo.CurrentBlock == 67)
662 && (NdefSmtCrdFmt->AddInfo.MfStdInfo.WrMADBlkFlag ==
667 NdefSmtCrdFmt->AddInfo.MfStdInfo.CurrentBlock = 64;
669 NdefSmtCrdFmt->State = PH_FRINFC_MFSTD_FMT_WR_MAD_BLK;
674 NdefSmtCrdFmt->AddInfo.MfStdInfo.WrMADBlkFlag =
677 NdefSmtCrdFmt->State = PH_FRINFC_MFSTD_FMT_WR_SECT_TR;
682 if((NdefSmtCrdFmt->AddInfo.MfStdInfo.UpdMADBlk ==
684 (NdefSmtCrdFmt->AddInfo.MfStdInfo.UpdMADBlk ==
686 (NdefSmtCrdFmt->AddInfo.MfStdInfo.UpdMADBlk ==
688 (NdefSmtCrdFmt->AddInfo.MfStdInfo.UpdMADBlk ==
690 (NdefSmtCrdFmt->AddInfo.MfStdInfo.UpdMADBlk ==
693 NdefSmtCrdFmt->AddInfo.MfStdInfo.CurrentBlock =
694 NdefSmtCrdFmt->AddInfo.MfStdInfo.UpdMADBlk;
695 NdefSmtCrdFmt->State = PH_FRINFC_MFSTD_FMT_UPD_MAD_BLK;
699 NdefSmtCrdFmt->AddInfo.MfStdInfo.UpdMADBlk =
701 NdefSmtCrdFmt->State = PH_FRINFC_MFSTD_FMT_WR_SECT_TR;
707 if((NdefSmtCrdFmt->AddInfo.MfStdInfo.UpdMADBlk ==
709 (NdefSmtCrdFmt->AddInfo.MfStdInfo.UpdMADBlk ==
711 (NdefSmtCrdFmt->AddInfo.MfStdInfo.UpdMADBlk ==
713 (NdefSmtCrdFmt->AddInfo.MfStdInfo.UpdMADBlk ==
715 (NdefSmtCrdFmt->AddInfo.MfStdInfo.UpdMADBlk ==
718 NdefSmtCrdFmt->AddInfo.MfStdInfo.CurrentBlock =
719 NdefSmtCrdFmt->AddInfo.MfStdInfo.UpdMADBlk;
720 NdefSmtCrdFmt->State = PH_FRINFC_MFSTD_FMT_UPD_MAD_BLK;
724 NdefSmtCrdFmt->AddInfo.MfStdInfo.UpdMADBlk =
726 NdefSmtCrdFmt->State = PH_FRINFC_MFSTD_FMT_WR_SECT_TR;
733 if((NdefSmtCrdFmt->AddInfo.MfStdInfo.UpdMADBlk ==
735 (NdefSmtCrdFmt->AddInfo.MfStdInfo.UpdMADBlk ==
739 NdefSmtCrdFmt->AddInfo.MfStdInfo.UpdMADBlk =
742 NdefSmtCrdFmt->State = PH_FRINFC_MFSTD_FMT_WR_TLV;
747 NdefSmtCrdFmt->State = PH_FRINFC_MFSTD_FMT_RD_SECT_TR;
752 Result = phFriNfc_MfStd_H_WrRdAuth(NdefSmtCrdFmt);
756 static NFCSTATUS phFriNfc_MfStd_H_ErrWrSectTr( phFriNfc_sNdefSmtCrdFmt_t *NdefSmtCrdFmt )
758 NFCSTATUS Result = NdefSmtCrdFmt->FmtProcStatus;
761 if(NdefSmtCrdFmt->AddInfo.MfStdInfo.AuthState ==
765 NdefSmtCrdFmt->State = PH_FRINFC_MFSTD_FMT_AUTH_SECT;
767 NdefSmtCrdFmt->AddInfo.MfStdInfo.AuthState = PH_FRINFC_MFSTD_FMT_AUTH_KEYB;
769 Result = phFriNfc_MfStd_H_WrRdAuth(NdefSmtCrdFmt);
773 Result = phFriNfc_MfStd_H_ProWrSectTr(NdefSmtCrdFmt);
777 static NFCSTATUS phFriNfc_MfStd_H_ProRdSectTr(phFriNfc_sNdefSmtCrdFmt_t *NdefSmtCrdFmt)
789 memcompare = phFriNfc_MfStd_H_ChkAcsBit(NdefSmtCrdFmt->AddInfo.MfStdInfo.CurrentBlock,
790 NdefSmtCrdFmt->SendRecvBuf,
791 NdefSmtCrdFmt->AddInfo.MfStdInfo.MADSect_AccessBits,
792 NdefSmtCrdFmt->AddInfo.MfStdInfo.NFCForumSect_AccessBits);
795 NdefSmtCrdFmt->AddInfo.MfStdInfo.SectCompl[SectIndex] = (uint8_t)
810 NdefSmtCrdFmt->State = PH_FRINFC_MFSTD_FMT_AUTH_SECT;
812 NdefSmtCrdFmt->AddInfo.MfStdInfo.AuthState =
815 Result = phFriNfc_MfStd_H_WrRdAuth(NdefSmtCrdFmt);
820 static NFCSTATUS phFriNfc_MfStd_H_ProWrSectTr(phFriNfc_sNdefSmtCrdFmt_t *NdefSmtCrdFmt)
832 NdefSmtCrdFmt->AddInfo.MfStdInfo.SectCompl[SectIndex] = (uint8_t)
833 ((NdefSmtCrdFmt->FmtProcStatus != NFCSTATUS_SUCCESS)?
847 NdefSmtCrdFmt->State = PH_FRINFC_MFSTD_FMT_AUTH_SECT;
849 NdefSmtCrdFmt->AddInfo.MfStdInfo.AuthState =
852 Result = phFriNfc_MfStd_H_WrRdAuth(NdefSmtCrdFmt);
877 static NFCSTATUS phFriNfc_MfStd_H_WrRdAuth(phFriNfc_sNdefSmtCrdFmt_t *NdefSmtCrdFmt)
881 phFriNfc_MfStd_H_FillSendBuf(NdefSmtCrdFmt,
882 NdefSmtCrdFmt->AddInfo.MfStdInfo.CurrentBlock);
884 Result = phFriNfc_MfStd_H_Transceive(NdefSmtCrdFmt);
889 static void phFriNfc_MfStd_H_ChangeAuthSt(phFriNfc_sNdefSmtCrdFmt_t *NdefSmtCrdFmt)
893 if( NdefSmtCrdFmt->AddInfo.MfStdInfo.AuthState ==
900 NdefSmtCrdFmt->AddInfo.MfStdInfo.SectCompl[SectIndex] =
979 static NFCSTATUS phFriNfc_MfStd_H_ProWrMADBlk(phFriNfc_sNdefSmtCrdFmt_t *NdefSmtCrdFmt)
983 switch(NdefSmtCrdFmt->AddInfo.MfStdInfo.CurrentBlock)
987 NdefSmtCrdFmt->State = PH_FRINFC_MFSTD_FMT_WR_MAD_BLK;
989 NdefSmtCrdFmt->AddInfo.MfStdInfo.CurrentBlock =
995 NdefSmtCrdFmt->AddInfo.MfStdInfo.WrMADBlkFlag =
998 NdefSmtCrdFmt->State = PH_FRINFC_MFSTD_FMT_WR_SECT_TR;
1000 NdefSmtCrdFmt->AddInfo.MfStdInfo.CurrentBlock =
1006 NdefSmtCrdFmt->State = PH_FRINFC_MFSTD_FMT_WR_MAD_BLK;
1007 NdefSmtCrdFmt->AddInfo.MfStdInfo.CurrentBlock = 65;
1012 NdefSmtCrdFmt->State = PH_FRINFC_MFSTD_FMT_WR_MAD_BLK;
1013 NdefSmtCrdFmt->AddInfo.MfStdInfo.CurrentBlock = 66;
1019 NdefSmtCrdFmt->AddInfo.MfStdInfo.WrMADBlkFlag =
1022 NdefSmtCrdFmt->State = PH_FRINFC_MFSTD_FMT_WR_SECT_TR;
1023 NdefSmtCrdFmt->AddInfo.MfStdInfo.CurrentBlock = 67;
1028 Result = phFriNfc_MfStd_H_WrRdAuth(NdefSmtCrdFmt);
1033 static NFCSTATUS phFriNfc_MfStd_H_ProErrAuth( phFriNfc_sNdefSmtCrdFmt_t *NdefSmtCrdFmt )
1035 NFCSTATUS Result = NdefSmtCrdFmt->FmtProcStatus;
1040 if ((NdefSmtCrdFmt->AddInfo.MfStdInfo.CurrentBlock == 67) &&
1041 (NdefSmtCrdFmt->AddInfo.MfStdInfo.AuthState ==
1046 (void)memset(&NdefSmtCrdFmt->AddInfo.MfStdInfo.SectCompl[16],
1051 else if(((NdefSmtCrdFmt->AddInfo.MfStdInfo.CurrentBlock >
1053 (NdefSmtCrdFmt->AddInfo.MfStdInfo.AuthState !=
1055 ((NdefSmtCrdFmt->AddInfo.MfStdInfo.CurrentBlock ==
1057 (NdefSmtCrdFmt->AddInfo.MfStdInfo.AuthState <
1061 Result = phFriNfc_MfStd_H_CallDisCon(NdefSmtCrdFmt,
1066 if (NdefSmtCrdFmt->AddInfo.MfStdInfo.CurrentBlock ==
1069 (void)memset(NdefSmtCrdFmt->AddInfo.MfStdInfo.SectCompl,
1078 static NFCSTATUS phFriNfc_MfStd_H_ProUpdMADBlk(phFriNfc_sNdefSmtCrdFmt_t *NdefSmtCrdFmt)
1081 switch(NdefSmtCrdFmt->AddInfo.MfStdInfo.UpdMADBlk)
1085 NdefSmtCrdFmt->AddInfo.MfStdInfo.UpdMADBlk = (uint8_t)
1087 NdefSmtCrdFmt->AddInfo.MfStdInfo.CurrentBlock =
1093 if((NdefSmtCrdFmt->CardType == PH_FRINFC_SMTCRDFMT_MFSTD_1K_CRD) ||
1094 (NdefSmtCrdFmt->AddInfo.MfStdInfo.CurrentBlock ==
1098 phFriNfc_MfStd_H_BlkNoToWrTLV(NdefSmtCrdFmt);
1100 NdefSmtCrdFmt->State = PH_FRINFC_MFSTD_FMT_AUTH_SECT;
1101 NdefSmtCrdFmt->AddInfo.MfStdInfo.AuthState =
1107 NdefSmtCrdFmt->AddInfo.MfStdInfo.UpdMADBlk = (uint8_t)
1109 NdefSmtCrdFmt->AddInfo.MfStdInfo.CurrentBlock =
1111 NdefSmtCrdFmt->State = PH_FRINFC_MFSTD_FMT_AUTH_SECT;
1112 NdefSmtCrdFmt->AddInfo.MfStdInfo.AuthState =
1119 NdefSmtCrdFmt->AddInfo.MfStdInfo.UpdMADBlk = (uint8_t)
1121 NdefSmtCrdFmt->AddInfo.MfStdInfo.CurrentBlock =
1128 NdefSmtCrdFmt->AddInfo.MfStdInfo.UpdMADBlk = (uint8_t)
1130 NdefSmtCrdFmt->AddInfo.MfStdInfo.CurrentBlock =
1134 Result = phFriNfc_MfStd_H_WrRdAuth(NdefSmtCrdFmt);
1138 static void phFriNfc_MfStd_H_StrNdefData( phFriNfc_sNdefSmtCrdFmt_t *NdefSmtCrdFmt )
1143 (void)memset(NdefSmtCrdFmt->AddInfo.MfStdInfo.MADSectBlk,
1148 NdefSmtCrdFmt->AddInfo.MfStdInfo.MADSectBlk[PH_FRINFC_MFSTD_FMT_VAL_0] = 0x14;
1151 NdefSmtCrdFmt->AddInfo.MfStdInfo.MADSectBlk[PH_FRINFC_MFSTD_FMT_VAL_1] = 0x01;
1153 if(NdefSmtCrdFmt->CardType == PH_FRINFC_SMTCRDFMT_MFSTD_4K_CRD)
1156 NdefSmtCrdFmt->AddInfo.MfStdInfo.MADSectBlk[32] = 0xE8;
1160 NdefSmtCrdFmt->AddInfo.MfStdInfo.MADSectBlk[33] = 0x01;
1166 (NdefSmtCrdFmt->CardType == PH_FRINFC_SMTCRDFMT_MFSTD_4K_CRD)) ||
1168 (NdefSmtCrdFmt->CardType == PH_FRINFC_SMTCRDFMT_MFSTD_1K_CRD)))
1171 if(NdefSmtCrdFmt->AddInfo.MfStdInfo.SectCompl[SectIndex] ==
1177 NdefSmtCrdFmt->AddInfo.MfStdInfo.MADSectBlk[index] =
1180 NdefSmtCrdFmt->AddInfo.MfStdInfo.MADSectBlk[index] =
1189 NdefSmtCrdFmt->AddInfo.MfStdInfo.MADSectBlk[index] = 0x00;
1191 NdefSmtCrdFmt->AddInfo.MfStdInfo.MADSectBlk[index] = 0x00;
1206 static void phFriNfc_MfStd_H_BlkNoToWrTLV( phFriNfc_sNdefSmtCrdFmt_t *NdefSmtCrdFmt )
1210 NdefSmtCrdFmt->CardType == (uint8_t)PH_FRINFC_SMTCRDFMT_MFSTD_4K_CRD)) ||
1212 (NdefSmtCrdFmt->CardType == (uint8_t)PH_FRINFC_SMTCRDFMT_MFSTD_1K_CRD)))
1214 if (NdefSmtCrdFmt->AddInfo.MfStdInfo.SectCompl[SectIndex] ==
1218 NdefSmtCrdFmt->AddInfo.MfStdInfo.CurrentBlock = (uint16_t)
1229 static NFCSTATUS phFriNfc_MfStd_H_ErrRdSectTr( phFriNfc_sNdefSmtCrdFmt_t *NdefSmtCrdFmt )
1231 NFCSTATUS Result = NdefSmtCrdFmt->FmtProcStatus;
1238 if(NdefSmtCrdFmt->AddInfo.MfStdInfo.AuthState ==
1242 NdefSmtCrdFmt->State = PH_FRINFC_MFSTD_FMT_AUTH_SECT;
1244 NdefSmtCrdFmt->AddInfo.MfStdInfo.AuthState = PH_FRINFC_MFSTD_FMT_AUTH_KEYB;
1246 Result = phFriNfc_MfStd_H_WrRdAuth(NdefSmtCrdFmt);
1254 NdefSmtCrdFmt->AddInfo.MfStdInfo.SectCompl[SectIndex] = (uint8_t)
1255 ((NdefSmtCrdFmt->FmtProcStatus != NFCSTATUS_SUCCESS)?
1269 NdefSmtCrdFmt->State = PH_FRINFC_MFSTD_FMT_AUTH_SECT;
1271 NdefSmtCrdFmt->AddInfo.MfStdInfo.AuthState =
1274 Result = phFriNfc_MfStd_H_WrRdAuth(NdefSmtCrdFmt);