]>
cvs.zerfleddert.de Git - proxmark3-svn/blob - include/crc.h
2ee9a4ddb0c6c865751e0aa14f679acef4da1a75
4 * Generic CRC calculation code.
17 uint32_t initial_value
;
22 /* Initialize a crc structure. order is the order of the polynom, e.g. 32 for a CRC-32
23 * polynom is the CRC polynom. initial_value is the initial value of a clean state.
24 * final_xor is XORed onto the state before returning it from crc_result(). */
25 extern void crc_init(crc_t
*crc
, int order
, uint32_t polynom
, uint32_t initial_value
, uint32_t final_xor
);
27 /* Update the crc state. data is the data of length data_width bits (only the the
28 * data_width lower-most bits are used).
30 extern void crc_update(crc_t
*crc
, uint32_t data
, int data_width
);
32 /* Clean the crc state, e.g. reset it to initial_value */
33 extern void crc_clear(crc_t
*crc
);
35 /* Get the result of the crc calculation */
36 extern uint32_t crc_finish(crc_t
*crc
);
38 /* Static initialization of a crc structure */
39 #define CRC_INITIALIZER(_order, _polynom, _initial_value, _final_xor) { \
40 .state = ((_initial_value) & ((1L<<(_order))-1)), \
42 .polynom = (_polynom), \
43 .initial_value = (_initial_value), \
44 .final_xor = (_final_xor), \
45 .mask = ((1L<<(_order))-1) }