+ samples++;
+
+ if (!TagIsActive) { // no need to try decoding reader data if the tag is sending
+ if (Handle15693SampleFromReader(snoopdata & 0x02, &DecodeReader)) {
+ FpgaDisableSscDma();
+ ExpectTagAnswer = true;
+ LogTrace(DecodeReader.output, DecodeReader.byteCount, samples, samples, NULL, true);
+ /* And ready to receive another command. */
+ DecodeReaderReset(&DecodeReader);
+ /* And also reset the demod code, which might have been */
+ /* false-triggered by the commands from the reader. */
+ DecodeTagReset(&DecodeTag);
+ upTo = dmaBuf;
+ FpgaSetupSscDma((uint8_t*) dmaBuf, ISO15693_DMA_BUFFER_SIZE);
+ }
+ if (Handle15693SampleFromReader(snoopdata & 0x01, &DecodeReader)) {
+ FpgaDisableSscDma();
+ ExpectTagAnswer = true;
+ LogTrace(DecodeReader.output, DecodeReader.byteCount, samples, samples, NULL, true);
+ /* And ready to receive another command. */
+ DecodeReaderReset(&DecodeReader);
+ /* And also reset the demod code, which might have been */
+ /* false-triggered by the commands from the reader. */
+ DecodeTagReset(&DecodeTag);
+ upTo = dmaBuf;
+ FpgaSetupSscDma((uint8_t*) dmaBuf, ISO15693_DMA_BUFFER_SIZE);
+ }
+ ReaderIsActive = (DecodeReader.state >= STATE_READER_AWAIT_2ND_RISING_EDGE_OF_SOF);
+ }
+
+ if (!ReaderIsActive && ExpectTagAnswer) { // no need to try decoding tag data if the reader is currently sending or no answer expected yet
+ if (Handle15693SamplesFromTag(snoopdata >> 2, &DecodeTag)) {
+ FpgaDisableSscDma();
+ //Use samples as a time measurement
+ LogTrace(DecodeTag.output, DecodeTag.len, samples, samples, NULL, false);
+ // And ready to receive another response.
+ DecodeTagReset(&DecodeTag);
+ DecodeReaderReset(&DecodeReader);
+ ExpectTagAnswer = false;
+ upTo = dmaBuf;
+ FpgaSetupSscDma((uint8_t*) dmaBuf, ISO15693_DMA_BUFFER_SIZE);
+ }
+ TagIsActive = (DecodeTag.state >= STATE_TAG_RECEIVING_DATA);
+ }
+