From 24d332fac702e529e317a2e284d093108a208f6a Mon Sep 17 00:00:00 2001 From: iceman1001 Date: Tue, 11 Jul 2017 18:27:59 +0200 Subject: [PATCH] fixes.. --- armsrc/iclass.c | 2 +- armsrc/iso14443a.c | 6 +++-- armsrc/legicrf.c | 10 ++++---- armsrc/lfops.c | 59 ++++++++++++++++++++++++--------------------- armsrc/lfsampling.c | 15 ++++++------ 5 files changed, 49 insertions(+), 43 deletions(-) diff --git a/armsrc/iclass.c b/armsrc/iclass.c index 8a47ff2d1..94c00b6c0 100644 --- a/armsrc/iclass.c +++ b/armsrc/iclass.c @@ -1760,7 +1760,7 @@ void ReaderIClass(uint8_t arg0) { cmd_send(CMD_ACK, result_status, 0, 0, card_data, sizeof(card_data) ); if (abort_after_read) { LEDsoff(); - set_tracing(FALSE); + set_tracing(false); return; } //Save that we already sent this.... diff --git a/armsrc/iso14443a.c b/armsrc/iso14443a.c index f9882694a..6a4981f4e 100644 --- a/armsrc/iso14443a.c +++ b/armsrc/iso14443a.c @@ -242,8 +242,10 @@ static RAMFUNC bool MillerDecoding(uint8_t bit, uint32_t non_real_time) { // Sequence X followed by Sequence Y followed by Sequence Z (111100x1 11111111 00x11111) // we therefore look for a ...xx1111 11111111 00x11111xxxxxx... pattern // (12 '1's followed by 2 '0's, eventually followed by another '0', followed by 5 '1's) - #define ISO14443A_STARTBIT_MASK 0x07FFEF80 // mask is 00000111 11111111 11101111 10000000 - #define ISO14443A_STARTBIT_PATTERN 0x07FF8F80 // pattern is 00000111 11111111 10001111 10000000 + // +#define ISO14443A_STARTBIT_MASK 0x07FFEF80 // mask is 00001111 11111111 1110 1111 10000000 +#define ISO14443A_STARTBIT_PATTERN 0x07FF8F80 // pattern is 00001111 11111111 1000 1111 10000000 + if ((Uart.fourBits & (ISO14443A_STARTBIT_MASK >> 0)) == ISO14443A_STARTBIT_PATTERN >> 0) Uart.syncBit = 7; else if ((Uart.fourBits & (ISO14443A_STARTBIT_MASK >> 1)) == ISO14443A_STARTBIT_PATTERN >> 1) Uart.syncBit = 6; else if ((Uart.fourBits & (ISO14443A_STARTBIT_MASK >> 2)) == ISO14443A_STARTBIT_PATTERN >> 2) Uart.syncBit = 5; diff --git a/armsrc/legicrf.c b/armsrc/legicrf.c index f58cb4426..aaf2e1108 100644 --- a/armsrc/legicrf.c +++ b/armsrc/legicrf.c @@ -350,7 +350,7 @@ void LegicCommonInit(bool clear_mem) { memset(cardmem, 0x00, LEGIC_CARD_MEMSIZE); clear_trace(); - set_tracing(TRUE); + set_tracing(true); crc_init(&legic_crc, 4, 0x19 >> 1, 0x5, 0); StartTicks(); @@ -470,7 +470,7 @@ int LegicRfReader(uint16_t offset, uint16_t len, uint8_t iv) { uint8_t isOK = 1; legic_card_select_t card; - LegicCommonInit(TRUE); + LegicCommonInit(true); if ( legic_select_card_iv(&card, iv) ) { isOK = 0; @@ -513,7 +513,7 @@ void LegicRfWriter(uint16_t offset, uint16_t len, uint8_t iv, uint8_t *data) { goto OUT; } - LegicCommonInit(TRUE); + LegicCommonInit(false); if ( legic_select_card_iv(&card, iv) ) { isOK = 0; @@ -613,7 +613,7 @@ void LegicRfInfo(void){ uint8_t buf[sizeof(legic_card_select_t)] = {0x00}; legic_card_select_t *card = (legic_card_select_t*) buf; - LegicCommonInit(FALSE); + LegicCommonInit(false); if ( legic_select_card(card) ) { cmd_send(CMD_ACK,0,0,0,0,0); @@ -653,7 +653,7 @@ static void frame_handle_tag(struct legic_frame const * const f) { // log //uint8_t cmdbytes[] = {bits, BYTEx(data, 0), BYTEx(data, 1)}; - //LogTrace(cmdbytes, sizeof(cmdbytes), starttime, GET_TICKS, NULL, FALSE); + //LogTrace(cmdbytes, sizeof(cmdbytes), starttime, GET_TICKS, NULL, false); //Dbprintf("ICE: enter frame_handle_tag: %02x ", f->bits); /* First Part of Handshake (IV) */ diff --git a/armsrc/lfops.c b/armsrc/lfops.c index e0536236e..930279969 100644 --- a/armsrc/lfops.c +++ b/armsrc/lfops.c @@ -237,10 +237,10 @@ void WriteTIbyte(uint8_t b) HIGH(GPIO_SSC_DOUT); WaitUS(1000); } else { - // stop modulating antenna 1ms + // stop modulating antenna 0.3ms LOW(GPIO_SSC_DOUT); WaitUS(300); - // modulate antenna 1m + // modulate antenna 1.7ms HIGH(GPIO_SSC_DOUT); WaitUS(1700); } @@ -337,7 +337,7 @@ void WriteTItag(uint32_t idhi, uint32_t idlo, uint16_t crc) crc = update_crc16(crc, (idhi>>16)&0xff); crc = update_crc16(crc, (idhi>>24)&0xff); } - Dbprintf("Writing to tag: %x%08x, crc=%x", (unsigned int) idhi, (unsigned int) idlo, crc); + Dbprintf("Writing to tag: %x%08x, crc=%x", idhi, idlo, crc); // TI tags charge at 134.2Khz FpgaSendCommand(FPGA_CMD_SET_DIVISOR, 88); //134.8Khz @@ -413,17 +413,11 @@ void SimulateTagLowFrequency(int period, int gap, int ledcontrol) else FpgaSendCommand(FPGA_CMD_SET_DIVISOR, sc->divisor); - //SetAdcMuxFor(GPIO_MUXSEL_LOPKD); AT91C_BASE_PIOA->PIO_PER = GPIO_SSC_DOUT | GPIO_SSC_CLK; AT91C_BASE_PIOA->PIO_OER = GPIO_SSC_DOUT; AT91C_BASE_PIOA->PIO_ODR = GPIO_SSC_CLK; - // power on antenna - //OPEN_COIL(); - // charge time - //WaitMS(50); - for(;;) { WDT_HIT(); @@ -529,7 +523,7 @@ static void fcAll(uint8_t fc, int *n, uint8_t clock, uint16_t *modCnt) uint8_t wavesPerClock = clock/fc; uint8_t mod = clock % fc; //modifier uint8_t modAdj = fc/mod; //how often to apply modifier - bool modAdjOk = !(fc % mod); //if (fc % mod==0) modAdjOk=TRUE; + bool modAdjOk = !(fc % mod); //if (fc % mod==0) modAdjOk = true; // loop through clock - step field clock for (uint8_t idx=0; idx < wavesPerClock; idx++){ // put 1/2 FC length 1's and 1/2 0's per field clock wave (to create the wave) @@ -557,7 +551,7 @@ static void fcAll(uint8_t fc, int *n, uint8_t clock, uint16_t *modCnt) void CmdHIDsimTAG(int hi, int lo, int ledcontrol) { FpgaDownloadAndGo(FPGA_BITSTREAM_LF); - set_tracing(FALSE); + set_tracing(false); int n = 0, i = 0; /* @@ -619,7 +613,7 @@ void CmdFSKsimTAG(uint16_t arg1, uint16_t arg2, size_t size, uint8_t *BitStream) // free eventually allocated BigBuf memory BigBuf_free(); BigBuf_Clear_ext(false); clear_trace(); - set_tracing(FALSE); + set_tracing(false); int ledcontrol = 1, n = 0, i = 0; uint8_t fcHigh = arg1 >> 8; @@ -689,7 +683,7 @@ static void stAskSimBit(int *n, uint8_t clock) { void CmdASKsimTag(uint16_t arg1, uint16_t arg2, size_t size, uint8_t *BitStream) { FpgaDownloadAndGo(FPGA_BITSTREAM_LF); - set_tracing(FALSE); + set_tracing(false); int ledcontrol = 1, n = 0, i = 0; uint8_t clk = (arg1 >> 8) & 0xFF; @@ -758,7 +752,7 @@ static void pskSimBit(uint8_t waveLen, int *n, uint8_t clk, uint8_t *curPhase, b void CmdPSKsimTag(uint16_t arg1, uint16_t arg2, size_t size, uint8_t *BitStream) { FpgaDownloadAndGo(FPGA_BITSTREAM_LF); - set_tracing(FALSE); + set_tracing(false); int ledcontrol = 1, n = 0, i = 0; uint8_t clk = arg1 >> 8; @@ -767,9 +761,9 @@ void CmdPSKsimTag(uint16_t arg1, uint16_t arg2, size_t size, uint8_t *BitStream) uint8_t curPhase = 0; for (i=0; i 0) { //prepare next bit modulation if(((*fwd_write_ptr++) & 1) == 1) { - WaitUS(32); + WaitUS(32*8); } else { TurnReadLF_off(23*8); - TurnReadLFOn(16*8); + TurnReadLFOn(18*8); } } } @@ -1699,6 +1703,7 @@ void EM4xReadWord(uint8_t addr, uint32_t pwd, uint8_t usepwd) { //clear buffer now so it does not interfere with timing later BigBuf_Clear_ext(false); + StartTicks(); /* should we read answer from Logincommand? * * should receive @@ -1732,7 +1737,7 @@ void EM4xWriteWord(uint32_t flag, uint32_t data, uint32_t pwd) { //clear buffer now so it does not interfere with timing later BigBuf_Clear_ext(false); - + StartTicks(); /* should we read answer from Logincommand? * * should receive diff --git a/armsrc/lfsampling.c b/armsrc/lfsampling.c index fe595bf2f..668b2493c 100644 --- a/armsrc/lfsampling.c +++ b/armsrc/lfsampling.c @@ -20,11 +20,11 @@ sample_config config = { 1, 8, 1, 95, 0 } ; void printConfig() { Dbprintf("LF Sampling config: "); - Dbprintf(" [q] divisor: %d (%d KHz)", config.divisor, 12000 / (config.divisor+1)); - Dbprintf(" [b] bps: %d ", config.bits_per_sample); - Dbprintf(" [d] decimation: %d ", config.decimation); - Dbprintf(" [a] averaging: %s ", (config.averaging) ? "Yes" : "No"); - Dbprintf(" [t] trigger threshold: %d ", config.trigger_threshold); + Dbprintf(" [q] divisor..............%d (%d KHz)", config.divisor, 12000 / (config.divisor+1)); + Dbprintf(" [b] bps..................%d", config.bits_per_sample); + Dbprintf(" [d] decimation...........%d", config.decimation); + Dbprintf(" [a] averaging............%s", (config.averaging) ? "Yes" : "No"); + Dbprintf(" [t] trigger threshold....%d", config.trigger_threshold); } /** @@ -121,7 +121,6 @@ uint32_t DoAcquisition(uint8_t decimation, uint32_t bits_per_sample, bool averag uint8_t *dest = BigBuf_get_addr(); bufsize = (bufsize > 0 && bufsize < BigBuf_max_traceLen()) ? bufsize : BigBuf_max_traceLen(); - //BigBuf_Clear_ext(false); //creates issues with cmdread (marshmellow) if(bits_per_sample < 1) bits_per_sample = 1; if(bits_per_sample > 8) bits_per_sample = 8; @@ -175,8 +174,8 @@ uint32_t DoAcquisition(uint8_t decimation, uint32_t bits_per_sample, bool averag dest[sample_total_saved-1] = sample; data.numbits = sample_total_saved << 3;//Get the return value correct if(sample_total_saved >= bufsize) break; - } - else{ + + } else { pushBit(&data, sample & 0x80); if(bits_per_sample > 1) pushBit(&data, sample & 0x40); if(bits_per_sample > 2) pushBit(&data, sample & 0x20);