2018-02-12 01:07:39 +08:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2018 Google LLC.
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
*/
|
|
|
|
|
2022-05-06 17:23:05 +08:00
|
|
|
#include <zephyr/sys/crc.h>
|
2018-02-12 01:07:39 +08:00
|
|
|
|
2020-05-28 00:26:57 +08:00
|
|
|
uint8_t crc7_be(uint8_t seed, const uint8_t *src, size_t len)
|
2018-02-12 01:07:39 +08:00
|
|
|
{
|
2024-06-07 22:51:44 +08:00
|
|
|
while (len-- != 0UL) {
|
2020-05-28 00:26:57 +08:00
|
|
|
uint8_t e = seed ^ *src++;
|
|
|
|
uint8_t f = e ^ (e >> 4) ^ (e >> 7);
|
2018-02-12 01:07:39 +08:00
|
|
|
|
|
|
|
seed = (f << 1) ^ (f << 4);
|
|
|
|
}
|
|
|
|
|
|
|
|
return seed;
|
|
|
|
}
|