// 9.4395us = 1etu.
// clock is about 1.5 us
iso14b_timeout = timeout;
- if(MF_DBGLEVEL >= 2) Dbprintf("ISO14443B Timeout set to %ld fwt", iso14b_timeout);
+ if(MF_DBGLEVEL >= 3) Dbprintf("ISO14443B Timeout set to %ld fwt", iso14b_timeout);
}
static void switch_off(void){
}
FpgaDisableSscDma();
-
+
+ if ( upTo ) upTo = NULL;
+
if (MF_DBGLEVEL >= 3) {
- Dbprintf("time_stop = %u PDC_RCR = %u", time_stop, AT91C_BASE_PDC_SSC->PDC_RCR);
- Dbprintf("#Samples = %d, Demod.state = %d, Demod.len = %u",
- samples,
+ Dbprintf("Demod.state = %d, Demod.len = %u, PDC_RCR = %u",
Demod.state,
- Demod.len
+ Demod.len,
+ AT91C_BASE_PDC_SSC->PDC_RCR
);
}
+ // print the last batch of IQ values from FPGA
if (MF_DBGLEVEL == 4)
Dbhexdump(ISO14443B_DMA_BUFFER_SIZE, (uint8_t *)dmaBuf, FALSE);
void RAMFUNC SnoopIso14443b(void) {
uint32_t time_0 = 0, time_start = 0, time_stop = 0;
-
+ int ci = 0, cq = 0;
+ int lastRxCounter = ISO14443B_DMA_BUFFER_SIZE;
+
// We won't start recording the frames that we acquire until we trigger;
// a good trigger condition to get started is probably when we see a
// response from the tag.
- int triggered = TRUE; // TODO: set and evaluate trigger condition
- int ci, cq;
- int maxBehindBy = 0;
- //int behindBy = 0;
- int lastRxCounter = ISO14443B_DMA_BUFFER_SIZE;
-
+ bool triggered = TRUE; // TODO: set and evaluate trigger condition
bool TagIsActive = FALSE;
bool ReaderIsActive = FALSE;
for(;;) {
WDT_HIT();
-
- /* iceman: the & (and) should do what?
- ISO14443B_DMA_BUFFER_SIZE = 256
- Should it be a "mod 255" ?
-
- (lastRxCounter - AT91C_BASE_PDC_SSC->PDC_RCR) & (ISO14443B_DMA_BUFFER_SIZE-1);
-
- */
- int behindBy = (lastRxCounter - AT91C_BASE_PDC_SSC->PDC_RCR) & RECEIVE_MASK;
- if ( behindBy > maxBehindBy )
- maxBehindBy = behindBy;
-
- // this one needs the inner loop from tr
- if ( behindBy < 2 ) continue;
-
ci = upTo[0];
cq = upTo[1];
- upTo += 2;
-
+ upTo += 2;
lastRxCounter -= 2;
if (upTo >= dmaBuf + ISO14443B_DMA_BUFFER_SIZE) {
lastRxCounter = ISO14443B_DMA_BUFFER_SIZE;
AT91C_BASE_PDC_SSC->PDC_RNPR = (uint32_t) dmaBuf;
AT91C_BASE_PDC_SSC->PDC_RNCR = ISO14443B_DMA_BUFFER_SIZE;
- WDT_HIT();
-
- // TODO: understand whether we can increase/decrease as we want or not?
- if ( behindBy > ( 9 * ISO14443B_DMA_BUFFER_SIZE/10) ) {
- Dbprintf("blew circular buffer! behindBy = %d", behindBy);
- break;
- }
-
- if(!tracing) {
- DbpString("Trace full");
+
+ if (!tracing) {
+ if (MF_DBGLEVEL >= 2) DbpString("Trace full");
break;
}
- if(BUTTON_PRESS()) {
- DbpString("cancelled");
+ if (BUTTON_PRESS()) {
+ if (MF_DBGLEVEL >= 2) DbpString("cancelled");
break;
}
}
LED_A_OFF();
}
- if(!ReaderIsActive) {
+ if (!ReaderIsActive) {
// no need to try decoding tag data if the reader is sending - and we cannot afford the time
// is this | 0x01 the error? & 0xfe in https://github.com/Proxmark/proxmark3/issues/103
- if(Handle14443bTagSamplesDemod(ci & 0xFE, cq & 0xFE)) {
+ // LSB is a fpga signal bit.
+ if (Handle14443bTagSamplesDemod(ci >> 1, cq >> 1)) {
time_stop = GetCountSspClk() - time_0;
switch_off(); // Snoop
DbpString("Snoop statistics:");
- Dbprintf(" Max behind by: %i", maxBehindBy);
Dbprintf(" Uart State: %x ByteCount: %i ByteCountMax: %i", Uart.state, Uart.byteCnt, Uart.byteCntMax);
Dbprintf(" Trace length: %i", BigBuf_get_traceLen());
// free mem refs.
- if ( upTo ) upTo = NULL;
+ if ( upTo ) upTo = NULL;
// Uart.byteCntMax should be set with ATQB value..
}