mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2025-12-29 18:11:05 +00:00
Ref: http://smbus.org/specs/smbus20.pdf - Support software CRC8 generation and checking. - Support read/write word (2-bytes) - Support read/write blocks (up to 32 bytes) BUG=chrome-os-partner:24741 BRANCH=ToT,glimmer TEST=Verified with smart battery firmware update application on glimmer. Passed LGC & Simplo Battery. Change-Id: Ic2e7f759af80c06741ed49fee1826213429fbf8a Signed-off-by: Sheng-Liang Song <ssl@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/209747 Reviewed-by: Randall Spangler <rspangler@chromium.org>
22 lines
664 B
C
22 lines
664 B
C
/* Copyright (c) 2014 The Chromium OS Authors. All rights reserved.
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
* found in the LICENSE file.
|
|
*
|
|
* Very simple 8-bit CRC function.
|
|
*/
|
|
#ifndef __EC_CRC8_H__
|
|
#define __EC_CRC8_H__
|
|
|
|
/**
|
|
* crc8
|
|
* Return CRC-8 of the data, using x^8 + x^2 + x + 1 polynomial. A table-based
|
|
* algorithm would be faster, but for only a few bytes it isn't worth the code
|
|
* size.
|
|
* @param data uint8_t *, input, a pointer to input data
|
|
* @param len int, input, size of iput data in byte
|
|
* @return the crc-8 of the input data.
|
|
*/
|
|
uint8_t crc8(const uint8_t *data, int len);
|
|
|
|
#endif /* __EC_CRC8_H__ */
|