Skip to content

Commit

Permalink
fiddling with thinfilm, which suffers in simulation
Browse files Browse the repository at this point in the history
  • Loading branch information
iceman1001 committed Dec 18, 2023
1 parent 2c20c0c commit 0eea4e3
Showing 1 changed file with 19 additions and 11 deletions.
30 changes: 19 additions & 11 deletions armsrc/thinfilm.c
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ static int EmSendCmdThinfilmRaw(const uint8_t *resp, uint16_t respLen) {
}

if (AT91C_BASE_SSC->SSC_SR & (AT91C_SSC_RXRDY)) {
b = (uint16_t)(AT91C_BASE_SSC->SSC_RHR);
b = (uint8_t)(AT91C_BASE_SSC->SSC_RHR);
(void)b;
}
if (BUTTON_PRESS()) break;
Expand All @@ -121,13 +121,12 @@ static int EmSendCmdThinfilmRaw(const uint8_t *resp, uint16_t respLen) {
}

void SimulateThinFilm(uint8_t *data, size_t len) {
Dbprintf("Simulate %i-bit Thinfilm tag", len * 8);
Dbhexdump(len, data, true);
int16_t status = PM3_SUCCESS;
CodeThinfilmAsTag(data, len);

FpgaDownloadAndGo(FPGA_BITSTREAM_HF);

Dbprintf("Simulate " _YELLOW_("%i-bit Thinfilm") " tag", len * 8);
Dbhexdump(len, data, true);

// Set up the synchronous serial port
FpgaSetupSsc(FPGA_MAJOR_MODE_HF_READER);

Expand All @@ -136,37 +135,46 @@ void SimulateThinFilm(uint8_t *data, size_t len) {

FpgaWriteConfWord(FPGA_MAJOR_MODE_HF_ISO14443A | FPGA_HF_ISO14443A_TAGSIM_MOD);
SpinDelay(100);
// Start the timer
StartCountSspClk();

uint16_t hf_baseline = ReadReaderField();

tosend_t *ts = get_tosend();
int16_t status = PM3_SUCCESS;
CodeThinfilmAsTag(data, len);

// Start the timer
StartCountSspClk();
tosend_t *ts = get_tosend();

bool reader_detected = false;
LED_A_ON();
for (;;) {

WDT_HIT();

if (BUTTON_PRESS() || data_available()) {
status = PM3_EOPABORTED;
break;
}

uint16_t hf_av = ReadReaderField();
if (hf_av < hf_baseline)

if (hf_av < hf_baseline) {
hf_baseline = hf_av;
}

if (hf_av > hf_baseline + 10) {

EmSendCmdThinfilmRaw(ts->buf, ts->max);
if (!reader_detected) {

if (reader_detected == false) {
LED_B_ON();
//Dbprintf("Reader detected, start beaming data");
reader_detected = true;
}
} else {
if (reader_detected) {
LED_B_OFF();
//Dbprintf("Reader gone, stop beaming data");
// Dbprintf("Reader gone, stop beaming data");
reader_detected = false;
}
}
Expand Down

0 comments on commit 0eea4e3

Please sign in to comment.