From 09c66f1f09776989fda2d1005a2c9feb1db6b3ac Mon Sep 17 00:00:00 2001 From: pwpiwi Date: Wed, 3 Jun 2015 13:28:28 +0200 Subject: [PATCH] fixing iso14443b (issue #103): fix timing issue (speeding up the decoders) --- armsrc/iso14443b.c | 22 +++++++++++----------- fpga/hi_read_rx_xcorr.v | 4 +++- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/armsrc/iso14443b.c b/armsrc/iso14443b.c index d6595586..4e40bb68 100644 --- a/armsrc/iso14443b.c +++ b/armsrc/iso14443b.c @@ -210,7 +210,6 @@ static int Handle14443UartBit(int bit) Uart.bitCnt = 0; Uart.shiftReg = 0; Uart.state = STATE_RECEIVING_DATA; - LED_A_ON(); // Indicate we're receiving } break; @@ -263,6 +262,7 @@ static int Handle14443UartBit(int bit) Uart.posCnt++; if(Uart.posCnt > 10) { Uart.state = STATE_UNSYNCD; + LED_A_OFF(); } break; @@ -271,8 +271,6 @@ static int Handle14443UartBit(int bit) break; } - if (Uart.state == STATE_UNSYNCD) LED_A_OFF(); - return FALSE; } @@ -548,6 +546,7 @@ static RAMFUNC int Handle14443SamplesDemod(int ci, int cq) } else { if(Demod.posCount > 100) { Demod.state = DEMOD_UNSYNCD; + LED_C_OFF(); } } Demod.posCount++; @@ -558,6 +557,7 @@ static RAMFUNC int Handle14443SamplesDemod(int ci, int cq) if(v > 0) { if(Demod.posCount > 10) { Demod.state = DEMOD_UNSYNCD; + LED_C_OFF(); } } else { Demod.bitCount = 0; @@ -596,13 +596,13 @@ static RAMFUNC int Handle14443SamplesDemod(int ci, int cq) Demod.output[Demod.len] = b; Demod.len++; Demod.state = DEMOD_AWAITING_START_BIT; - } else if(s == 0x000) { - // This is EOF - LED_C_OFF(); - Demod.state = DEMOD_UNSYNCD; - return TRUE; } else { Demod.state = DEMOD_UNSYNCD; + LED_C_OFF(); + if(s == 0x000) { + // This is EOF + return TRUE; + } } } Demod.posCount = 0; @@ -611,10 +611,10 @@ static RAMFUNC int Handle14443SamplesDemod(int ci, int cq) default: Demod.state = DEMOD_UNSYNCD; + LED_C_OFF(); break; } - if (Demod.state == DEMOD_UNSYNCD) LED_C_OFF(); // Not synchronized... return FALSE; } @@ -1168,14 +1168,14 @@ void RAMFUNC SnoopIso14443(void) } if(!ReaderIsActive) { // no need to try decoding tag data if the reader is sending - and we cannot afford the time - if(Handle14443SamplesDemod(ci, cq)) { + if(Handle14443SamplesDemod(ci & 0xFE, cq & 0xFE)) { //Use samples as a time measurement if(tracing) { uint8_t parity[MAX_PARITY_SIZE]; GetParity(Demod.output, Demod.len, parity); - LogTrace(Demod.output, Demod.len,samples, samples, parity, FALSE); + LogTrace(Demod.output, Demod.len, samples, samples, parity, FALSE); } triggered = TRUE; LED_A_OFF(); diff --git a/fpga/hi_read_rx_xcorr.v b/fpga/hi_read_rx_xcorr.v index ec6583b2..06142637 100644 --- a/fpga/hi_read_rx_xcorr.v +++ b/fpga/hi_read_rx_xcorr.v @@ -171,7 +171,9 @@ begin end end - if(corr_i_cnt[5:2] == 4'b000 || corr_i_cnt[5:2] == 4'b1000) + // set ssp_frame signal for corr_i_cnt = 0..3 and corr_i_cnt = 32..35 + // (two frames with 8 Bits each) + if(corr_i_cnt[5:2] == 4'b0000 || corr_i_cnt[5:2] == 4'b1000) ssp_frame = 1'b1; else ssp_frame = 1'b0; -- 2.39.2