/* Computes the CRC checksum for a data buffer.  */
uint8_t ad7124_compute_crc8(uint8_t *p_buf, uint8_t buf_size)
/* Computes the CRC checksum for a data buffer.  */
uint8_t ad7124_compute_crc8(uint8_t *p_buf, uint8_t buf_size)
{
	uint8_t i = 0;
	uint8_t crc = 0;
	while(buf_size) {
		for(i = 0x80; i != 0; i >>= 1) {
			bool cmp1 = (crc & 0x80) != 0;
			bool cmp2 = (*p_buf & i) != 0;
			if(cmp1 != cmp2) {
				crc <<= 1;
				crc ^= AD7124_CRC8_POLYNOMIAL_REPRESENTATION;
			} else {
				crc <<= 1;
			}
		}
		p_buf++;
		buf_size--;
	}
	return crc;
}