/** * crc4 - calculate the 4-bit crc of a value. * @c: starting crc4 * @x: value to checksum * @bits: number of bits in @x to checksum * * Returns the crc4 value of @x, using polynomial 0b10111. * * The @x value is treated as left-aligned, and bits above @bits are ignored * in the crc calculations.
*/
uint8_t crc4(uint8_t c, uint64_t x, int bits)
{ int i;
/* mask off anything above the top bit */
x &= (1ull << bits) - 1;
/* Align to 4-bits */
bits = (bits + 3) & ~0x3;
/* Calculate crc4 over four-bit nibbles, starting at the MSbit */ for (i = bits - 4; i >= 0; i -= 4)
c = crc4_tab[c ^ ((x >> i) & 0xf)];
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.