You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

49 regels
622 B

/*
 * 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;
	}
}