Blame view
lib/crc8.c
563 Bytes
83d290c56 SPDX: Convert all... |
1 |
// SPDX-License-Identifier: GPL-2.0+ |
60d18d3fe Add crc8 routine |
2 3 |
/* * Copyright (c) 2013 Google, Inc |
60d18d3fe Add crc8 routine |
4 |
*/ |
c3a4d1c3e common: Drop linu... |
5 6 7 8 9 10 |
#ifdef USE_HOSTCC #include <arpa/inet.h> #else #include <common.h> #endif #include <u-boot/crc.h> |
60d18d3fe Add crc8 routine |
11 |
|
456ecd08e lib/crc8: Add crc... |
12 13 14 |
#define POLY (0x1070U << 3) static unsigned char _crc8(unsigned short data) |
60d18d3fe Add crc8 routine |
15 |
{ |
456ecd08e lib/crc8: Add crc... |
16 17 18 19 20 21 |
int i; for (i = 0; i < 8; i++) { if (data & 0x8000) data = data ^ POLY; data = data << 1; |
60d18d3fe Add crc8 routine |
22 |
} |
456ecd08e lib/crc8: Add crc... |
23 24 25 26 27 28 29 30 31 32 33 |
return (unsigned char)(data >> 8); } unsigned int crc8(unsigned int crc, const unsigned char *vptr, int len) { int i; for (i = 0; i < len; i++) crc = _crc8((crc ^ vptr[i]) << 8); return crc; |
60d18d3fe Add crc8 routine |
34 |
} |