unsigned short bcc = 0x0; void crc16(int addr, int word) { int i; unsigned short x16, x15, x2; for (i = 0; i < 32; i++) { x16 = ((bcc >> 15) & 0x1) ^ ((word >> i) & 0x1); x15 = ((bcc >> 14) & 0x1) ^ x16; x2 = ((bcc >> 1) & 0x1) ^ x16; bcc = (x15 << 15) | (((bcc >> 2) & 0x7ff) << 14) | (x2 << 2) | ((bcc & 0x1) << 1) | (x16 & 0x1); } // TODO: the address part printf("bcc: 0x%08x\n", bcc); return; }