Du kan inte välja fler än 25 ämnen
Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.
|
|
/*
|
|
|
* CRC.c
|
|
|
*
|
|
|
* Created on: 2022Äê3ÔÂ28ÈÕ
|
|
|
* Author: Laputa
|
|
|
*/
|
|
|
|
|
|
#include "CRC.h"
|
|
|
|
|
|
UINT32 CRC32_Table[256];
|
|
|
unsigned int GetCrc32(unsigned char *InStr,unsigned int len, unsigned int value)
|
|
|
{
|
|
|
unsigned int a = value;
|
|
|
|
|
|
for(;len>0;len--)
|
|
|
{
|
|
|
a = (a >> 8) ^ CRC32_Table[(a &0xFF)^(*InStr)];
|
|
|
InStr++;
|
|
|
}
|
|
|
|
|
|
return a;
|
|
|
}
|
|
|
|
|
|
void Make_CRC32_Table(void)
|
|
|
{
|
|
|
uint32_t c;
|
|
|
uint32_t i = 0;
|
|
|
uint32_t bit = 0;
|
|
|
|
|
|
for(i = 0; i < 256; i++)
|
|
|
{
|
|
|
c = (uint32_t)i;
|
|
|
|
|
|
for(bit = 0; bit < 8; bit++)
|
|
|
{
|
|
|
if(c&1)
|
|
|
{
|
|
|
c = (c >> 1)^(0xEDB88320);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
c = c >> 1;
|
|
|
}
|
|
|
}
|
|
|
CRC32_Table[i] = c;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|