pub fn crc8(data: &[u8]) -> u8Expand description
Computes the Maxim 1-Wire CRC-8 over data.
This is the CRC every 1-Wire device appends to its ROM code, and the DS18B20 to its
scratchpad. The polynomial is X^8 + X^5 + X^4 + 1, processed least-significant-bit
first from a zero shift register, which is the reflected form 0x8C.
§Arguments
data- the bytes the CRC covers, in transmission order.
§Returns
The 8-bit CRC. Over a message followed by its own CRC byte the result is zero.
§Examples
use pamoja_hal::onewire::crc8;
// The published check value of CRC-8/MAXIM over the ASCII digits 1 to 9.
assert_eq!(crc8(b"123456789"), 0xA1);