首先感谢菜农大哥帮忙添加了CRC48,使用最新版本V1.06的生成CRC小表和C语言算法,在ARM里验证成功。
设置见插图,点击“小表”生成方框中的代码,点击“保存”,指定到所需文件就可。
由于ARM中只能处理32位变量,对代码进行了一定处理,处理后的主要代码如下:
typedef struct tagCRC48
{
unsigned short CRC48_High; /* CRC48高字 */
unsigned int CRC48_Low; /* CRC48低双字 */
} CRC48;
//CRC位域4表(大端):
const unsigned short CRCL48_Table_High[16] = {
0x0000,0xD28D,0x7796,0xA51B,0xEF2D,0x3DA0,0x98BB,0x4A36,
0x0CD6,0xDE5B,0x7B40,0xA9CD,0xE3FB,0x3176,0x946D,0x46E0};
const unsigned int CRCL48_Table_Low[16] = {
0x00000000,0xB3FA4AAD,0xD40EDFF7,0x67F4955A,0xA81DBFEE,0x1BE7F543,0x7C136019,0xCFE92AB4,
0xE3C13571,0x503B7FDC,0x37CFEA86,0x8435A02B,0x4BDC8A9F,0xF826C032,0x9FD25568,0x2C281FC5};
CRC48 GetCRCL48(unsigned char *crcBuff, unsigned short crcLen)
{
unsigned int i;
CRC48 crc;
unsigned char crcTemp;
unsigned char table_index = 0;
crc.CRC48_High = 0;
crc.CRC48_Low = 0;
for(i = 0; i < (crcLen * 2); i ++)
{
if (i BITAND 1)
crcTemp = crcBuff[i SH_RIGHT 1] BITAND 0x0F;
else
crcTemp = crcBuff[i SH_RIGHT 1] SH_RIGHT 4;
table_index = (crc.CRC48_High SH_RIGHT 12) XOR crcTemp;
crc.CRC48_High = ((crc.CRC48_High SH_LEFT 4) BITOR
(unsigned short)((crc.CRC48_Low BITAND 0xF0000000) SH_RIGHT 28)) XOR CRCL48_Table_High[table_index];
crc.CRC48_Low = (crc.CRC48_Low SH_LEFT 4) XOR CRCL48_Table_Low[table_index];
}
return crc;
}
经验证算**确。再次感谢菜农大哥! |