www.digiembedded.com
401
Ethernet Communication Module
mcap++;
for (bit_index = 0; bit_index < 16; bit_index++)
{
bx = (WORD16) (crc >> 16); /* get high word of crc*/
bx = rotate (bx, LEFT, 1); /* bit 31 to lsb*/
bx ^= bp; /* combine with incoming*/
crc <<= 1; /* shift crc left 1 bit*/
bx &= 1; /* get control bit*/
if (bx) /* if bit set*/
{
crc ^= POLYNOMIAL; /* xero crc with polynomial*/
}
crc |= bx: /* or in control bit*/
bp = rotate (bp, RIGHT, 1);
}
}
// CRC calculation done. The 6-bit result resides in bit
// locations 28:23
result = (crc >> 23) & 0x3f;
return result;
}