zephyr/lib/os/crc7_sw.c
Anas Nashif db92e5c66e lib: flatten all loose components into one lib
lib/ was starting to get messy and inconsitent. Files being either
dumped in the root or in sub-directories without a clear plan.
Move all library components into one single folder and call it 'os'.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-01-22 07:45:22 -05:00

20 lines
287 B
C

/*
* Copyright (c) 2018 Google LLC.
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <crc.h>
u8_t crc7_be(u8_t seed, const u8_t *src, size_t len)
{
while (len--) {
u8_t e = seed ^ *src++;
u8_t f = e ^ (e >> 4) ^ (e >> 7);
seed = (f << 1) ^ (f << 4);
}
return seed;
}