개발

jackryu 2011. 5. 31. 22:49


crc7 code


unsigned char CRC7(unsigned char * chr, int cnt) 
{
int i,a;
unsigned char crc,Data;

crc=0;
for (a=0;a<cnt;a++) {
Data=chr[a];
for (i=0;i<8;i++) {
crc <<= 1;

if ((Data & 0x80)^(crc & 0x80))
crc ^=0x09;
Data <<= 1;
}
}
crc=(crc<<1)|1;
return(crc);
}