X-Git-Url: http://git.zerfleddert.de/cgi-bin/gitweb.cgi/proxmark3-svn/blobdiff_plain/872e3d4d6f6dd1ae01ef67e4ad8255243f1e24ec..78f5b1a77cad221aaa9739b8003c4ab3d2c7fbe8:/armsrc/lfops.c diff --git a/armsrc/lfops.c b/armsrc/lfops.c index ea36cdec..13cf2967 100644 --- a/armsrc/lfops.c +++ b/armsrc/lfops.c @@ -399,6 +399,7 @@ void SimulateTagLowFrequency(int period, int gap, int ledcontrol) i = 0; for(;;) { + //wait until SSC_CLK goes HIGH while(!(AT91C_BASE_PIOA->PIO_PDSR & GPIO_SSC_CLK)) { if(BUTTON_PRESS()) { DbpString("Stopped"); @@ -406,7 +407,6 @@ void SimulateTagLowFrequency(int period, int gap, int ledcontrol) } WDT_HIT(); } - if (ledcontrol) LED_D_ON(); @@ -417,17 +417,18 @@ void SimulateTagLowFrequency(int period, int gap, int ledcontrol) if (ledcontrol) LED_D_OFF(); - //wait for next sample time + //wait until SSC_CLK goes LOW while(AT91C_BASE_PIOA->PIO_PDSR & GPIO_SSC_CLK) { if(BUTTON_PRESS()) { DbpString("Stopped"); return; } WDT_HIT(); - } - + } + i++; if(i == period) { + i = 0; if (gap) { SHORT_COIL(); @@ -491,32 +492,50 @@ static void fc(int c, int *n) } } // compose fc/X fc/Y waveform (FSKx) -static void fcAll(uint8_t c, int *n, uint8_t clock) +static void fcAll(uint8_t c, int *n, uint8_t clock, uint16_t *modCnt) { uint8_t *dest = BigBuf_get_addr(); uint8_t idx; uint8_t fcCnt; // c = count of field clock for this bit - - int mod = clock % c; + uint8_t mod = clock % c; + uint8_t modAdj = c/mod; + bool modAdjOk=FALSE; + if (c % mod==0) modAdjOk=TRUE; // loop through clock - step field clock for (idx=0; idx < (uint8_t) clock/c; idx++){ // loop through field clock length - put 1/2 FC length 1's and 1/2 0's per field clock wave (to create the wave) - for (fcCnt=0; fcCnt < c; fcCnt++){ + for (fcCnt=0; fcCnt < c; fcCnt++){ //fudge slow transition from low to high - shorten wave by 1 if (fcCnt < c/2){ - dest[((*n)++)]=1; + dest[((*n)++)]=0; } else { - dest[((*n)++)]=0; + //fudge low to high transition + //if (idx==clock/c && dest[*n-1]==1 && mod>0) dest[((*n++))]=0; + //if (c==8 && fcCnt==5) continue; + dest[((*n)++)]=1; } } } - Dbprintf("mod: %d",mod); - if (mod>0){ //for FC counts that don't add up to a full clock cycle padd with extra wave + if (mod>0) (*modCnt)++; + if ((mod>0) && modAdjOk){ //fsk2 + if ((*modCnt % modAdj) == 0){ //if 4th 8 length wave in a rf/50 add extra 8 length wave + for (fcCnt=0; fcCnt < c; fcCnt++){ //fudge slow transition from low to high - shorten wave by 1 + if (fcCnt < c/2){ + dest[((*n)++)]=0; + } else { + //if (c==8 && fcCnt==5) continue; + dest[((*n)++)]=1; + } + } + } + } + //Dbprintf("mod: %d, modAdj %d, modc %d",mod, modAdj, c % mod); + if (mod>0 && !modAdjOk){ //fsk1 for (idx=0; idx < mod; idx++){ if (idx < mod/2) { - dest[((*n)++)]=1; - } else { dest[((*n)++)]=0; + } else { + dest[((*n)++)]=1; } } } @@ -538,7 +557,7 @@ void CmdHIDsimTAG(int hi, int lo, int ledcontrol) */ if (hi>0xFFF) { - DbpString("Tags can only have 44 bits."); + DbpString("Tags can only have 44 bits. - USE lf simfsk for larger tags"); return; } fc(0,&n); @@ -587,6 +606,7 @@ void CmdFSKsimTAG(uint16_t arg1, uint16_t arg2, size_t size, uint8_t *BitStream) int n=0, i=0; uint8_t fcHigh = arg1 >> 8; uint8_t fcLow = arg1 & 0xFF; + uint16_t modCnt = 0; //spacer bit uint8_t clk = arg2 & 0xFF; uint8_t invert = (arg2 >> 8) & 1; @@ -595,23 +615,46 @@ void CmdFSKsimTAG(uint16_t arg1, uint16_t arg2, size_t size, uint8_t *BitStream) WDT_HIT(); for (i=0; i> 8) & 1; - WDT_HIT(); for (i=0; i> 8; uint8_t carrier = arg1 & 0xFF; uint8_t invert = arg2 & 0xFF; - uint8_t phase = carrier/2; //extra phase changing bits = 1/2 a carrier wave to change the phase + //uint8_t phase = carrier/2; //extra phase changing bits = 1/2 a carrier wave to change the phase //uint8_t invert = (arg2 >> 8) & 1; - uint8_t curPhase = 0; WDT_HIT(); + uint8_t curPhase = 0; for (i=0; i