You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
22 lines
417 B
22 lines
417 B
/*
|
|
* Copyright (c) 2013 Google, Inc
|
|
*
|
|
* SPDX-License-Identifier: GPL-2.0+
|
|
*/
|
|
|
|
#include "crc.h"
|
|
|
|
uint32_t crc8(const uint8_t *vptr, size_t len ){
|
|
const uint8_t * data = vptr;
|
|
uint32_t crc = 0;
|
|
uint32_t i, j;
|
|
for( j = len; j; j--, data++ ){
|
|
crc ^= (*data << 8);
|
|
for (i = 8; i; i--) {
|
|
if (crc & 0x8000) crc ^= (0x1070 << 3);
|
|
crc <<= 1;
|
|
};
|
|
};
|
|
return (crc >> 8) & 0xff;
|
|
};
|
|
|