diff --git a/armsrc/iclass.c b/armsrc/iclass.c index e3f0296be..a55943e69 100644 --- a/armsrc/iclass.c +++ b/armsrc/iclass.c @@ -1825,6 +1825,8 @@ void setupIclassReader() { FpgaWriteConfWord(FPGA_MAJOR_MODE_HF_ISO14443A | FPGA_HF_ISO14443A_READER_MOD); SpinDelay(300); + init_table(CRC_15_ICLASS); + // Start the timer StartCountSspClk(); @@ -2291,7 +2293,7 @@ out: bool iClass_ReadBlock(uint8_t blockNo, uint8_t *readdata) { uint8_t readcmd[] = {ICLASS_CMD_READ_OR_IDENTIFY, blockNo, 0x00, 0x00}; //0x88, 0x00 // can i use 0C? - uint16_t crc = iclass_crc16(readcmd+1, 1); + uint16_t crc = crc16_iclass(readcmd+1, 1); readcmd[2] = crc >> 8; readcmd[3] = crc & 0xff; uint8_t resp[] = {0,0,0,0,0,0,0,0,0,0}; @@ -2348,7 +2350,7 @@ void iClass_Dump(uint8_t blockno, uint8_t numblks) { bool iClass_WriteBlock_ext(uint8_t blockNo, uint8_t *data) { uint8_t write[] = { ICLASS_CMD_UPDATE, blockNo, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; memcpy(write+2, data, 12); // data + mac - uint16_t crc = iclass_crc16(write+1, 13); + uint16_t crc = crc16_iclass(write+1, 13); write[14] = crc >> 8; write[15] = crc & 0xff; uint8_t resp[] = {0,0,0,0,0,0,0,0,0,0}; diff --git a/common/iso15693tools.c b/common/iso15693tools.c index a20bea148..03d0892cb 100644 --- a/common/iso15693tools.c +++ b/common/iso15693tools.c @@ -50,29 +50,4 @@ char* Iso15693sprintUID(char *target, uint8_t *uid) { uid[3], uid[2], uid[1], uid[0] ); return target; -} - -uint16_t iclass_crc16(uint8_t *d, uint16_t n) { - - unsigned int data; - uint16_t crc = 0xffff; - - - if (n == 0) - return (~crc); - - do { - for (uint8_t i=0, data = *d++; i < 8; i++, data >>= 1) { - if ((crc & 0x0001) ^ (data & 0x0001)) - crc = (crc >> 1) ^ ISO15_CRC_POLY; - else - crc >>= 1; - } - } while (--n); - - crc = ~crc; - data = crc; - crc = (crc << 8) | (data >> 8 & 0xff); - crc = crc ^ 0xBC3; - return crc; } \ No newline at end of file diff --git a/common/iso15693tools.h b/common/iso15693tools.h index c32b70354..ebb4f047a 100644 --- a/common/iso15693tools.h +++ b/common/iso15693tools.h @@ -77,7 +77,6 @@ int Iso15693AddCrc(uint8_t *d, size_t n); bool Iso15693CheckCrc(uint8_t *d, size_t n); char* Iso15693sprintUID(char *target, uint8_t *uid); -uint16_t iclass_crc16(uint8_t *d, uint16_t n); //----------------------------------------------------------------------------- // Map a sequence of octets (~layer 2 command) into the set of bits to feed