Skip to main content

crc16

Function crc16 

Source
pub fn crc16(crc: u16, data: &[u8]) -> u16
Expand description

CRC16-CCITT (poly 0x1021, init 0xFFFF).

Bit-bang implementation — no lookup table, minimal flash footprint. Call incrementally by passing the previous return value as crc:

let mut crc = 0xFFFF;
crc = crc16(crc, b"1234");
crc = crc16(crc, b"56789");
assert_eq!(crc, 0x29B1);