/* * ===== CalcCRC16Words ===== * Calculate the CRC for a buffer of 16-bit words. Supports both * Little and Big Endian formats using conditional compilation. * Note: minimum count is 1 (0 case not handled) */ CRC16 CalcCRC16Words(unsigned int count, short *buffer) { int crc = 0; do { int value = *buffer++; #ifdef _BIG_ENDIAN crc = ByteCRC16(value >> 8, crc); crc = ByteCRC16(value, crc); #else crc = ByteCRC16(value, crc); crc = ByteCRC16(value >> 8, crc); #endif } while (--count); return (CRC16) crc; }
/* * ===== CalcCRC16Bytes ===== * Calculate the CRC for a buffer of 8-bit words. * Note: minimum count is 1 (0 case not handled) */ unsigned short CCRC16::CalcCRC16Bytes(unsigned int count, char *buffer) { int crc = 0; do { int value = *buffer++; crc = ByteCRC16(value, crc); } while (--count); return crc; }
/* * ===== CalcCRC16Words ===== * Calculate the CRC for a buffer of 16-bit words. Supports both * Little and Big Endian formats using conditional compilation. * Note: minimum count is 1 (0 case not handled) */ unsigned short CCRC16::CalcCRC16Words(unsigned int count, short *buffer) { int crc = 0; do { int value = *buffer++; crc = ByteCRC16(value, crc); crc = ByteCRC16(value >> 8, crc); } while (--count); return (unsigned short) crc; }