From a1f3bb120f103c89dbc160d25b31d811e425d29e Mon Sep 17 00:00:00 2001 From: penturalabs Date: Tue, 18 Mar 2014 20:52:48 +0000 Subject: [PATCH] Added Kantech ioProx Support --- armsrc/appmain.c | 8 +- armsrc/apps.h | 2 + armsrc/lfops.c | 278 ++++++++++++++++++++++++++++++++++++++++++++++ client/Makefile | 1 + client/cmdlf.c | 4 +- include/usb_cmd.h | 2 + 6 files changed, 293 insertions(+), 2 deletions(-) diff --git a/armsrc/appmain.c b/armsrc/appmain.c index 3f309520..7af47a51 100644 --- a/armsrc/appmain.c +++ b/armsrc/appmain.c @@ -639,9 +639,15 @@ void UsbPacketReceived(uint8_t *packet, int len) case CMD_HID_SIM_TAG: CmdHIDsimTAG(c->arg[0], c->arg[1], 1); // Simulate HID tag by ID break; - case CMD_HID_CLONE_TAG: // Clone HID tag by ID to T55x7 + case CMD_HID_CLONE_TAG: // Clone HID tag by ID to T55x7 CopyHIDtoT55x7(c->arg[0], c->arg[1], c->arg[2], c->d.asBytes[0]); break; + case CMD_IO_DEMOD_FSK: + CmdIOdemodFSK(1, 0, 0, 1); // Demodulate IO tag + break; + case CMD_IO_CLONE_TAG: // Clone IO tag by ID to T55x7 + CopyIOtoT55x7(c->arg[0], c->arg[1], c->d.asBytes[0]); + break; case CMD_EM410X_WRITE_TAG: WriteEM410x(c->arg[0], c->arg[1], c->arg[2]); break; diff --git a/armsrc/apps.h b/armsrc/apps.h index 497692be..e21b5ce5 100644 --- a/armsrc/apps.h +++ b/armsrc/apps.h @@ -117,6 +117,8 @@ void AcquireRawBitsTI(void); void SimulateTagLowFrequency(int period, int gap, int ledcontrol); void CmdHIDsimTAG(int hi, int lo, int ledcontrol); void CmdHIDdemodFSK(int findone, int *high, int *low, int ledcontrol); +void CmdIOdemodFSK(int findone, int *high, int *low, int ledcontrol); +void CopyIOtoT55x7(uint32_t hi, uint32_t lo, uint8_t longFMT); // Clone an ioProx card to T5557/T5567 void SimulateTagLowFrequencyBidir(int divisor, int max_bitlen); void CopyHIDtoT55x7(uint32_t hi2, uint32_t hi, uint32_t lo, uint8_t longFMT); // Clone an HID card to T5557/T5567 void WriteEM410x(uint32_t card, uint32_t id_hi, uint32_t id_lo); diff --git a/armsrc/lfops.c b/armsrc/lfops.c index fbd07e65..76c4b44e 100644 --- a/armsrc/lfops.c +++ b/armsrc/lfops.c @@ -807,6 +807,264 @@ void CmdHIDdemodFSK(int findone, int *high, int *low, int ledcontrol) } } +void CmdIOdemodFSK(int findone, int *high, int *low, int ledcontrol) +{ + uint8_t *dest = (uint8_t *)BigBuf; + int m=0, n=0, i=0, idx=0, lastval=0; + int found=0; + uint32_t code=0, code2=0; + //uint32_t hi2=0, hi=0, lo=0; + + FpgaSendCommand(FPGA_CMD_SET_DIVISOR, 95); //125Khz + FpgaWriteConfWord(FPGA_MAJOR_MODE_LF_READER); + + // Connect the A/D to the peak-detected low-frequency path. + SetAdcMuxFor(GPIO_MUXSEL_LOPKD); + + // Give it a bit of time for the resonant antenna to settle. + SpinDelay(50); + + // Now set up the SSC to get the ADC samples that are now streaming at us. + FpgaSetupSsc(); + + for(;;) { + WDT_HIT(); + if (ledcontrol) + LED_A_ON(); + if(BUTTON_PRESS()) { + DbpString("Stopped"); + if (ledcontrol) + LED_A_OFF(); + return; + } + + i = 0; + m = sizeof(BigBuf); + memset(dest,128,m); + for(;;) { + if(AT91C_BASE_SSC->SSC_SR & (AT91C_SSC_TXRDY)) { + AT91C_BASE_SSC->SSC_THR = 0x43; + if (ledcontrol) + LED_D_ON(); + } + if(AT91C_BASE_SSC->SSC_SR & (AT91C_SSC_RXRDY)) { + dest[i] = (uint8_t)AT91C_BASE_SSC->SSC_RHR; + // we don't care about actual value, only if it's more or less than a + // threshold essentially we capture zero crossings for later analysis + if(dest[i] < 127) dest[i] = 0; else dest[i] = 1; + i++; + if (ledcontrol) + LED_D_OFF(); + if(i >= m) { + break; + } + } + } + + // FSK demodulator + + // sync to first lo-hi transition + for( idx=1; idx ['l']-- Clone Indala to T55x7 (tag must be in antenna)(UID in HEX)(option 'l' for 224 UID"}, {"read", CmdLFRead, 0, "['h'|] -- Read 125/134 kHz LF ID-only tag (option 'h' for 134, alternatively: f=12MHz/(divisor+1))"}, diff --git a/include/usb_cmd.h b/include/usb_cmd.h index a107e392..9c25555d 100644 --- a/include/usb_cmd.h +++ b/include/usb_cmd.h @@ -79,6 +79,8 @@ typedef struct { #define CMD_PCF7931_READ 0x0217 #define CMD_EM4X_READ_WORD 0x0218 #define CMD_EM4X_WRITE_WORD 0x0219 +#define CMD_IO_DEMOD_FSK 0x021A +#define CMD_IO_CLONE_TAG 0x021B /* CMD_SET_ADC_MUX: ext1 is 0 for lopkd, 1 for loraw, 2 for hipkd, 3 for hiraw */ // For the 13.56 MHz tags -- 2.39.2