X-Git-Url: http://git.zerfleddert.de/cgi-bin/gitweb.cgi/proxmark3-svn/blobdiff_plain/534983d7352171526a6d43b112e0baaefdb1e3cd..cee5a30d53c7aff4c4830eae53eaf58414ecf806:/armsrc/iso14443a.c diff --git a/armsrc/iso14443a.c b/armsrc/iso14443a.c index c3f6647b..1c5e9265 100644 --- a/armsrc/iso14443a.c +++ b/armsrc/iso14443a.c @@ -146,7 +146,7 @@ static struct { uint8_t *output; } Uart; -static int MillerDecoding(int bit) +static RAMFUNC int MillerDecoding(int bit) { int error = 0; int bitright; @@ -348,7 +348,7 @@ static int MillerDecoding(int bit) if(!Uart.syncBit) { Uart.syncBit = bit & 2; Uart.samples = 1; } else if(bit & 2) { Uart.syncBit = bit & 2; Uart.samples = 1; bit <<= 1; } if(!Uart.syncBit) { Uart.syncBit = bit & 1; Uart.samples = 0; - if(Uart.syncBit & (Uart.bitBuffer & 8)) { + if(Uart.syncBit && (Uart.bitBuffer & 8)) { Uart.syncBit = 8; // the first half bit period is expected in next sample @@ -410,7 +410,7 @@ static struct { uint8_t *output; } Demod; -static int ManchesterDecoding(int v) +static RAMFUNC int ManchesterDecoding(int v) { int bit; int modulation; @@ -431,28 +431,29 @@ static int ManchesterDecoding(int v) Demod.syncBit = 0; //Demod.samples = 0; Demod.posCount = 1; // This is the first half bit period, so after syncing handle the second part - if(bit & 0x08) { Demod.syncBit = 0x08; } - if(!Demod.syncBit) { - if(bit & 0x04) { Demod.syncBit = 0x04; } - } - else if(bit & 0x04) { Demod.syncBit = 0x04; bit <<= 4; } - if(!Demod.syncBit) { - if(bit & 0x02) { Demod.syncBit = 0x02; } + + if(bit & 0x08) { + Demod.syncBit = 0x08; } - else if(bit & 0x02) { Demod.syncBit = 0x02; bit <<= 4; } - if(!Demod.syncBit) { - if(bit & 0x01) { Demod.syncBit = 0x01; } - if(Demod.syncBit & (Demod.buffer & 0x08)) { - Demod.syncBit = 0x08; + if(bit & 0x04) { + if(Demod.syncBit) { + bit <<= 4; + } + Demod.syncBit = 0x04; + } - // The first half bitperiod is expected in next sample - Demod.posCount = 0; - Demod.output[Demod.len] = 0xfb; + if(bit & 0x02) { + if(Demod.syncBit) { + bit <<= 2; } + Demod.syncBit = 0x02; } - else if(bit & 0x01) { Demod.syncBit = 0x01; } + if(bit & 0x01 && Demod.syncBit) { + Demod.syncBit = 0x01; + } + if(Demod.syncBit) { Demod.len = 0; Demod.state = DEMOD_START_OF_COMMUNICATION; @@ -607,7 +608,7 @@ static int ManchesterDecoding(int v) // triggering so that we start recording at the point that the tag is moved // near the reader. //----------------------------------------------------------------------------- -void SnoopIso14443a(void) +void RAMFUNC SnoopIso14443a(void) { // #define RECV_CMD_OFFSET 2032 // original (working as of 21/2/09) values // #define RECV_RES_OFFSET 2096 // original (working as of 21/2/09) values @@ -630,7 +631,8 @@ void SnoopIso14443a(void) // As we receive stuff, we copy it from receivedCmd or receivedResponse // into trace, along with its length and other annotations. //uint8_t *trace = (uint8_t *)BigBuf; - //int traceLen = 0; + + traceLen = 0; // uncommented to fix ISSUE 15 - gerhard - jan2011 // The DMA buffer, used to stream samples from the FPGA int8_t *dmaBuf = ((int8_t *)BigBuf) + DMA_BUFFER_OFFSET; @@ -642,7 +644,7 @@ void SnoopIso14443a(void) // Count of samples received so far, so that we can include timing // information in the trace buffer. int samples = 0; - int rsamples = 0; + int rsamples = 0; memset(trace, 0x44, RECV_CMD_OFFSET);