//------------------------------------------------------------------------------- // 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