EmbHMI/machine/comm/crc16.h

61 lines
1.1 KiB
C
Raw Permalink Normal View History

2024-02-06 06:27:07 +00:00
//-------------------------------------------------------------------------------
// File Name: crc16.h
// Brief:
// Version: 1.0.0
// Create Date: 2017/05/08
// Create by: Marshal Lee
// Copyright:
// Copyright (c) 2017, Richpeace Co., LTD.
// All rights reserved.
//
// Modify by: Marshal Lee
// Modify Date: 2017/05/08
//-------------------------------------------------------------------------------
#ifndef __CRC16_H__
#define __CRC16_H__
/*
CRC16
CRC16
*/
#include "typedef.h"
#define USE_CRC_TABLE // 用查表法crc, 否则, 用移位法计算
#define SHIFT_RIGHT // 右移位
#ifdef USE_CRC_TABLE
#define CRC_INIT 0x0000 // 并且crc初值为0
#else
#ifdef SHIFT_RIGHT // 如果是右移
#define CRC_INIT 0xFFFF // crc初值为0xFFFF
#else // 如果是左移
#define CRC_INIT 0x0000 // 并且crc初值为0
#endif // #ifdef SHIFT_RIGHT
#endif
u16 calcCrc16(u8 * pBuf, int lenBuf);
u8 calcCheckSum8(u8 * pBuf, int lenBuf);
u32 calcCheckSum32(u8 * pBuf, int lenBuf);
#endif