Code/CRC16
Jump to navigation
Jump to search
CRC16
uint16_t x_crcAddByte(uint16_t crc_val, uint8_t byte) { crc_val ^= (uint16_t) ((uint16_t) (byte) << 8U); for (uint8_t j = 0; j < 8; j++) { if (crc_val & 0x8000U) { crc_val = (uint16_t) ((uint16_t) (crc_val << 1U) ^ 0x1021U); } else { crc_val = (uint16_t) (crc_val << 1U); } } return crc_val; }