/*******CRC16校验**********************************************/
unsigned crc16_ccitt(unsigned char *ptr, uint32_t len) {
unsigned int crc;
unsigned char da;
unsigned int crc_ta[16]={ 0x0000,0x1021,0x2042,0x3063,0x4084,0x50a5,0x60c6,0x70e7,
0x8108,0x9129,0xa14a,0xb16b,0xc18c,0xd1ad,0xe1ce,0xf1ef,
};
crc=0;
while(len--!=0) {
da=((unsigned char)(crc/256))/16;
crc<<=4;
crc^=crc_ta[da^(*ptr/16)];
da=((unsigned char)(crc/256))/16;
crc<<=4;
crc^=crc_ta[da^(*ptr&0x0f)];
ptr++;
}
return(crc);
}
/*****************************************************************/
unsigned crc16_ccitt(unsigned char *ptr, uint32_t len) {
unsigned int crc;
unsigned char da;
unsigned int crc_ta[16]={ 0x0000,0x1021,0x2042,0x3063,0x4084,0x50a5,0x60c6,0x70e7,
0x8108,0x9129,0xa14a,0xb16b,0xc18c,0xd1ad,0xe1ce,0xf1ef,
};
crc=0;
while(len--!=0) {
da=((unsigned char)(crc/256))/16;
crc<<=4;
crc^=crc_ta[da^(*ptr/16)];
da=((unsigned char)(crc/256))/16;
crc<<=4;
crc^=crc_ta[da^(*ptr&0x0f)];
ptr++;
}
return(crc);
}
/*****************************************************************/