/* * For a byte array whose accumulated crc value is stored in *crc, computes * resultant crc obtained by appending m to the byte array */ void crc8( unsigned char *crc, unsigned char m ) { if ( !made_table ) { init_crc8(); } *crc = crc8_table[(*crc) ^ m]; *crc &= 0xFF; }
uint8_t dprot_master_init_protocol (fn_put_char put_function, fn_get_char_to get_function) { // initialize the crc table init_crc8( ); master_last_parity = 0; // initialize the slip protocol return slip_init (put_function, NULL, get_function, &master_channel); }
unsigned char compute_crc8(unsigned char *p,unsigned char length) { unsigned char crc8; unsigned char i; unsigned char offset; if (!made_table) init_crc8(); crc8 = 0; for(i = 0; i < length; i++) { offset = crc8 ^ *(p + i); crc8 = crc8_table[offset]; } return crc8 ^ 0x55; }