diff --git a/common/crc.c b/common/crc.c index c9a049df..b6d7551e 100644 --- a/common/crc.c +++ b/common/crc.c @@ -26,13 +26,10 @@ uint32_t reflect(uint32_t v, int b) { void crc_init(crc_t *crc, int order, uint32_t polynom, uint32_t initial_value, uint32_t final_xor) { crc->order = order; - crc->topbit = BITMASK(order - 1); crc->polynom = polynom; crc->initial_value = initial_value; crc->final_xor = final_xor; crc->mask = (1L<refin = false; - crc->refout = false; crc_clear(crc); } @@ -49,28 +46,9 @@ void crc_update(crc_t *crc, uint32_t data, int data_width) } } -void crc_update2(crc_t *crc, uint32_t data, int data_width) { - - if (crc->refin) - data = reflect(data, data_width); - - // Bring the next byte into the remainder. - crc->state ^= data << (crc->order - data_width); - - for (uint8_t bit = data_width; bit > 0; --bit) { - - if (crc->state & crc->topbit) - crc->state = (crc->state << 1) ^ crc->polynom; - else - crc->state = (crc->state << 1); - } -} - void crc_clear(crc_t *crc) { crc->state = crc->initial_value & crc->mask; - if (crc->refin) - crc->state = reflect(crc->state, crc->order); } uint32_t crc_finish(crc_t *crc) diff --git a/common/crc.h b/common/crc.h index 0fac2dad..e2ccd34b 100644 --- a/common/crc.h +++ b/common/crc.h @@ -20,9 +20,6 @@ typedef struct crc { uint32_t initial_value; uint32_t final_xor; uint32_t mask; - int topbit; - bool refin; /* Parameter: Reflect input bytes? */ - bool refout; /* Parameter: Reflect output CRC? */ } crc_t; /* Initialize a crc structure. order is the order of the polynom, e.g. 32 for a CRC-32