From 87db9e7ec903346ad281aa7489c438a007fda894 Mon Sep 17 00:00:00 2001 From: merlokk <807634+merlokk@users.noreply.github.com> Date: Sun, 3 Jul 2022 21:32:29 +0300 Subject: [PATCH] pm3-pm3 works --- armsrc/hfops.c | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/armsrc/hfops.c b/armsrc/hfops.c index 976cd7d64..9dc803804 100644 --- a/armsrc/hfops.c +++ b/armsrc/hfops.c @@ -107,12 +107,12 @@ static uint32_t HfEncodeTkm(uint8_t *uid, uint8_t modulation, uint8_t *data) { for (int j = 0; j < 8; j++) { if (((uid[i] << j) & 0x80) != 0) { // `1` - data[indx++] = 125; - data[indx++] = 63; + data[indx++] = 1; + data[indx++] = 0; } else { // `0` - data[indx++] = 63; - data[indx++] = 125; + data[indx++] = 0; + data[indx++] = 1; } } } @@ -149,7 +149,7 @@ int HfWriteTkm(uint8_t *uid, uint8_t modulation, uint32_t timeout) { LED_C_ON(); FpgaDownloadAndGo(FPGA_BITSTREAM_HF); SetAdcMuxFor(GPIO_MUXSEL_HIPKD); - FpgaWriteConfWord(FPGA_MAJOR_MODE_HF_SIMULATOR | FPGA_HF_SIMULATOR_MODULATE_424K); + FpgaWriteConfWord(FPGA_MAJOR_MODE_HF_SIMULATOR | FPGA_HF_SIMULATOR_MODULATE_212K); FpgaSetupSsc(FPGA_MAJOR_MODE_HF_SIMULATOR); int vHf = 0; // in mV @@ -173,19 +173,18 @@ int HfWriteTkm(uint8_t *uid, uint8_t modulation, uint32_t timeout) { SpinDelay(10); for (int i = 0; i < elen; i++) { - if (data[i] == 0) - data[i] = 10; - - for (int j = 0; j < 13;) { + for (int j = 0; j < 1;) { if (AT91C_BASE_SSC->SSC_SR & AT91C_SSC_TXRDY) { - AT91C_BASE_SSC->SSC_THR = 0xff; + AT91C_BASE_SSC->SSC_THR = 0x80; j++; } } - for (int j = 0; j < data[i];) { - if (AT91C_BASE_SSC->SSC_SR & AT91C_SSC_TXRDY) { - AT91C_BASE_SSC->SSC_THR = 0x00; - j++; + if (data[i] > 0) { + for (int j = 0; j < data[i];) { + if (AT91C_BASE_SSC->SSC_SR & AT91C_SSC_TXRDY) { + AT91C_BASE_SSC->SSC_THR = 0x00; + j++; + } } } }