diff --git a/common/iso15693tools.c b/common/iso15693tools.c index 7ee52d450..05a4bfc3d 100644 --- a/common/iso15693tools.c +++ b/common/iso15693tools.c @@ -72,22 +72,22 @@ char* Iso15693sprintUID(char *target, uint8_t *uid) { return target; } -uint16_t iclass_crc16(char *data_p, unsigned short length) { - unsigned char i; +uint16_t iclass_crc16(uint8_t *d, uint16_t n) { + unsigned int data; uint16_t crc = 0xffff; - if (length == 0) + if (n == 0) return (~crc); do { - for (i=0, data = (unsigned int)0xff & *data_p++; i < 8; i++, data >>= 1) { + for (uint8_t i=0, data = *d++; i < 8; i++, data >>= 1) { if ((crc & 0x0001) ^ (data & 0x0001)) crc = (crc >> 1) ^ POLY; else crc >>= 1; } - } while (--length); + } while (--n); crc = ~crc; data = crc; diff --git a/common/iso15693tools.h b/common/iso15693tools.h index a0b50974b..66e9ae35f 100644 --- a/common/iso15693tools.h +++ b/common/iso15693tools.h @@ -78,7 +78,8 @@ uint16_t Iso15693Crc(uint8_t *v, int n); int Iso15693AddCrc(uint8_t *req, int n); bool Iso15693CheckCrc(uint8_t *d, int n); char* Iso15693sprintUID(char *target,uint8_t *uid); -unsigned short iclass_crc16(char *data_p, unsigned short length); + +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