64,648
社区成员
发帖
与我相关
我的任务
分享
WORD CRC16_LH(unsigned char* pBuf,int nLength)
{
WORD nCRC = 0x0000;
WORD ch;
WORD tmp;
int nIndex;
int nPos=0;
while(nLength>0)
{
nLength -= 1;
ch = WORD(BYTE(pBuf[nPos]));
nPos += 1;
for(nIndex = 0;nIndex<=7;nIndex++)
{ tmp = nCRC & 0x8000;
nCRC <<= 1;
if(ch & 0x80)
nCRC += 1;
if(tmp)
nCRC = nCRC ^ 0x1021;
ch <<= 1;
}
}
return nCRC;
}
typedef unsigned short WORD;
typedef unsigned char BYTE;