From dfc3c5053cb9347fc2ff63342aad7abc3bbf94c6 Mon Sep 17 00:00:00 2001 From: "roel@libnfc.org" <roel@libnfc.org@ef4ab9da-24cd-11de-8aaa-f3a34680c41f> Date: Wed, 3 Apr 2013 11:18:01 +0000 Subject: [PATCH] removed another redundant function to compose reader short frame --- armsrc/iso14443a.c | 35 ++++++++++++----------------------- armsrc/iso14443a.h | 2 +- armsrc/mifarecmd.c | 6 +++--- 3 files changed, 16 insertions(+), 27 deletions(-) diff --git a/armsrc/iso14443a.c b/armsrc/iso14443a.c index 5a01178d..6c80c02d 100644 --- a/armsrc/iso14443a.c +++ b/armsrc/iso14443a.c @@ -1547,44 +1547,33 @@ static int GetIso14443aAnswerFromTag(uint8_t *receivedResponse, int maxLen, int } } -void ReaderTransmitShort(const uint8_t* bt) +void ReaderTransmitBitsPar(uint8_t* frame, int bits, uint32_t par) { int wait = 0; int samples = 0; - -// ShortFrameFromReader(*bt); - CodeIso14443aBitsAsReaderPar(bt,7,0); - - // Select the card - TransmitFor14443a(ToSend, ToSendMax, &samples, &wait); - - // Store reader command in buffer - if (tracing) LogTrace(bt,1,0,GetParity(bt,1),TRUE); -} - -void ReaderTransmitPar(uint8_t* frame, int len, uint32_t par) -{ - int wait = 0; - int samples = 0; - + // This is tied to other size changes // uint8_t* frame_addr = ((uint8_t*)BigBuf) + 2024; - CodeIso14443aAsReaderPar(frame,len,par); - + CodeIso14443aBitsAsReaderPar(frame,bits,par); + // Select the card TransmitFor14443a(ToSend, ToSendMax, &samples, &wait); if(trigger) LED_A_ON(); - + // Store reader command in buffer - if (tracing) LogTrace(frame,len,0,par,TRUE); + if (tracing) LogTrace(frame,nbytes(bits),0,par,TRUE); } +void ReaderTransmitPar(uint8_t* frame, int len, uint32_t par) +{ + ReaderTransmitBitsPar(frame,len*8,par); +} void ReaderTransmit(uint8_t* frame, int len) { // Generate parity and redirect - ReaderTransmitPar(frame,len,GetParity(frame,len)); + ReaderTransmitBitsPar(frame,len*8,GetParity(frame,len)); } int ReaderReceive(uint8_t* receivedAnswer) @@ -1623,7 +1612,7 @@ int iso14443a_select_card(byte_t* uid_ptr, iso14a_card_select_t* p_hi14a_card, u int len; // Broadcast for a card, WUPA (0x52) will force response from all cards in the field - ReaderTransmitShort(wupa); + ReaderTransmitBitsPar(wupa,7,0); // Receive the ATQA if(!ReaderReceive(resp)) return 0; // Dbprintf("atqa: %02x %02x",resp[0],resp[1]); diff --git a/armsrc/iso14443a.h b/armsrc/iso14443a.h index 8422f6cb..c3051d48 100644 --- a/armsrc/iso14443a.h +++ b/armsrc/iso14443a.h @@ -82,8 +82,8 @@ extern byte_t oddparity (const byte_t bt); extern uint32_t GetParity(const uint8_t * pbtCmd, int iLen); extern void AppendCrc14443a(uint8_t* data, int len); -extern void ReaderTransmitShort(const uint8_t* bt); extern void ReaderTransmit(uint8_t* frame, int len); +extern void ReaderTransmitBitsPar(uint8_t* frame, int bits, uint32_t par); extern void ReaderTransmitPar(uint8_t* frame, int len, uint32_t par); extern int ReaderReceive(uint8_t* receivedAnswer); extern int ReaderReceivePar(uint8_t* receivedAnswer, uint32_t * parptr); diff --git a/armsrc/mifarecmd.c b/armsrc/mifarecmd.c index e7850b3f..6ca9e4e9 100644 --- a/armsrc/mifarecmd.c +++ b/armsrc/mifarecmd.c @@ -801,7 +801,7 @@ void MifareCSetBlock(uint32_t arg0, uint32_t arg1, uint32_t arg2, uint8_t *datai // reset chip if (needWipe){ - ReaderTransmitShort(wupC1); + ReaderTransmitBitsPar(wupC1,7,0); if(!ReaderReceive(receivedAnswer) || (receivedAnswer[0] != 0x0a)) { if (MF_DBGLEVEL >= 1) Dbprintf("wupC1 error"); break; @@ -821,7 +821,7 @@ void MifareCSetBlock(uint32_t arg0, uint32_t arg1, uint32_t arg2, uint8_t *datai // write block if (workFlags & 0x02) { - ReaderTransmitShort(wupC1); + ReaderTransmitBitsPar(wupC1,7,0); if(!ReaderReceive(receivedAnswer) || (receivedAnswer[0] != 0x0a)) { if (MF_DBGLEVEL >= 1) Dbprintf("wupC1 error"); break; @@ -919,7 +919,7 @@ void MifareCGetBlock(uint32_t arg0, uint32_t arg1, uint32_t arg2, uint8_t *datai while (true) { if (workFlags & 0x02) { - ReaderTransmitShort(wupC1); + ReaderTransmitBitsPar(wupC1,7,0); if(!ReaderReceive(receivedAnswer) || (receivedAnswer[0] != 0x0a)) { if (MF_DBGLEVEL >= 1) Dbprintf("wupC1 error"); break; -- 2.39.5