crc16: fix error

This commit is contained in:
Paul A. Patience 2016-06-10 09:13:43 -04:00
parent e6ca12f4c3
commit fdbbe8dc9a
3 changed files with 7 additions and 7 deletions

View File

@ -114,9 +114,9 @@ uint16_t crc16part(FAR const uint8_t *src, size_t len, uint16_t crc16val)
{ {
size_t i; size_t i;
for (i = 0; i < len; i++) for (i = 0; i < len; i++)
{ {
crc16val = crc16_tab[((crc16val >> 8) & 255)] ^ (crc16val << 8) ^ src[i]; crc16val = crc16_tab[((crc16val >> 8) & 0xff) ^ src[i]] ^ (crc16val << 8);
} }
return crc16val; return crc16val;

View File

@ -102,9 +102,9 @@ uint32_t crc32part(FAR const uint8_t *src, size_t len, uint32_t crc32val)
{ {
size_t i; size_t i;
for (i = 0; i < len; i++) for (i = 0; i < len; i++)
{ {
crc32val = crc32_tab[(crc32val ^ src[i]) & 0xff] ^ (crc32val >> 8); crc32val = crc32_tab[(crc32val & 0xff) ^ src[i]] ^ (crc32val >> 8);
} }
return crc32val; return crc32val;
} }

View File

@ -124,13 +124,13 @@ uint8_t crc8part(FAR const uint8_t *src, size_t len, uint8_t crc8val)
{ {
size_t i; size_t i;
crc8val ^= 0xFF; crc8val ^= 0xff;
for (i = 0; i < len; i++) for (i = 0; i < len; i++)
{ {
crc8val = crc8_tab[crc8val ^ src[i]]; crc8val = crc8_tab[crc8val ^ src[i]];
} }
return crc8val ^ 0xFF; return crc8val ^ 0xff;
} }
/************************************************************************************************ /************************************************************************************************