This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
uint16_t ax25crc16(unsigned char *data_p, uint16_t length) { | |
uint16_t crc = 0xFFFF; | |
uint32_t data; | |
uint16_t crc16_table[] = { | |
0x0000, 0x1081, 0x2102, 0x3183, | |
0x4204, 0x5285, 0x6306, 0x7387, | |
0x8408, 0x9489, 0xa50a, 0xb58b, | |
0xc60c, 0xd68d, 0xe70e, 0xf78f | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
uint16_t crc16(char* pData, int length) | |
{ | |
uint8_t i; | |
uint16_t wCrc = 0xffff; | |
while (length--) { | |
wCrc ^= *(unsigned char *)pData++ << 8; | |
for (i=0; i < 8; i++) | |
wCrc = wCrc & 0x8000 ? (wCrc << 1) ^ 0x1021 : wCrc << 1; | |
} | |
return wCrc & 0xffff; |