📄 crc.c
字号:
#define CRC_POLY 0x25
//unsigned int CRC_POLY 0x9240;
union WordUnion
{
struct
{
unsigned char lowbyte;
unsigned char highbyte;
}twobyte;
unsigned int word;
};
main()
{
union WordUnion TempWord;
unsigned char i,lowbyte,highbyte;
highbyte=0x70;
lowbyte=0x00;
TempWord.twobyte.lowbyte =lowbyte;
TempWord.twobyte.highbyte =highbyte;
for ( i=0 ; i<16; i++)
{
if (TempWord.twobyte.highbyte & 0x80)
{
//TempWord.word <<= 1;
TempWord.twobyte.highbyte <<= 1;
if(TempWord.twobyte.lowbyte & 0x80)
{
TempWord.twobyte.highbyte|=0x01;
}
TempWord.twobyte.lowbyte<<=1;
TempWord.twobyte.highbyte ^= CRC_POLY;
}
else
{
TempWord.twobyte.highbyte <<= 1;
if(TempWord.twobyte.lowbyte & 0x80)
{
TempWord.twobyte.highbyte|=0x01;
}
TempWord.twobyte.lowbyte<<=1;
}
}
TempWord.twobyte.highbyte=TempWord.twobyte.highbyte;
i=TempWord.twobyte.highbyte;
i=TempWord.twobyte.lowbyte;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -