2017-12-13 21:57:38 +08:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2017 Nordic Semiconductor ASA
|
|
|
|
* Copyright (c) 2015 Runtime Inc
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
*/
|
|
|
|
|
2018-09-15 01:43:44 +08:00
|
|
|
#ifndef ZEPHYR_INCLUDE_CRC8_H_
|
|
|
|
#define ZEPHYR_INCLUDE_CRC8_H_
|
2017-12-13 21:57:38 +08:00
|
|
|
|
|
|
|
#include <zephyr/types.h>
|
2018-03-11 05:20:18 +08:00
|
|
|
#include <stddef.h>
|
2017-12-13 21:57:38 +08:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* Initial value expected to be used at the beginning of the crc8_ccitt
|
|
|
|
* computation.
|
|
|
|
*/
|
|
|
|
#define CRC8_CCITT_INITIAL_VALUE 0xFF
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Compute CCITT variant of CRC 8
|
|
|
|
*
|
|
|
|
* Normal CCITT variant of CRC 8 is using 0x07.
|
|
|
|
*
|
|
|
|
* @param initial_value Initial value for the CRC computation
|
|
|
|
* @param buf Input bytes for the computation
|
|
|
|
* @param len Length of the input in bytes
|
|
|
|
*
|
|
|
|
* @return The computed CRC8 value
|
|
|
|
*/
|
2018-03-11 05:20:18 +08:00
|
|
|
u8_t crc8_ccitt(u8_t initial_value, const void *buf, size_t len);
|
2017-12-13 21:57:38 +08:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif
|