]> git.zerfleddert.de Git - proxmark3-svn/blobdiff - common/lfdemod.c
Add Viking demod,
[proxmark3-svn] / common / lfdemod.c
index 3b9402cca18ef45f0dca6c788ef2adcad7a02df4..5d19c89734f052e5929b257c796d045eb6e5d909 100644 (file)
@@ -282,6 +282,16 @@ int manrawdecode(uint8_t * BitStream, size_t *size, uint8_t invert)
        return bestErr;
 }
 
+uint32_t manchesterEncode2Bytes(uint16_t datain) {
+       uint32_t output = 0;
+       uint8_t curBit = 0;
+       for (uint8_t i=0; i<16; i++) {
+               curBit = (datain >> (15-i) & 1);
+               output |= (1<<(((15-i)*2)+curBit));
+       }
+       return output;
+}
+
 //by marshmellow
 //encode binary data into binary manchester 
 int ManchesterEncode(uint8_t *BitStream, size_t size)
@@ -587,6 +597,23 @@ int IOdemodFSK(uint8_t *dest, size_t size)
                return (int) startIdx;
        }
        return -5;
+} 
+
+// by marshmellow
+// find viking preamble 0xF200 in already demoded data
+int VikingDemod_AM(uint8_t *dest, size_t *size) {
+       if (justNoise(dest, *size)) return -1;
+       //make sure buffer has data
+       if (*size < 64*2) return -2;
+
+       size_t startIdx = 0;
+       uint8_t preamble[] = {1,1,1,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
+       uint8_t errChk = preambleSearch(dest, preamble, sizeof(preamble), size, &startIdx);
+       if (errChk == 0) return -4; //preamble not found
+
+       if (*size != 64) return -5;
+       //return start position
+       return (int) startIdx;
 }
 
 // by marshmellow
Impressum, Datenschutz