This commit is contained in:
2021-09-22 04:09:21 +01:00
parent 4002cca010
commit c17752dbf0
6 changed files with 13 additions and 6 deletions

View File

@@ -35,9 +35,10 @@ AARU_EXPORT crc16_ccitt_ctx* AARU_CALL crc16_ccitt_init(void)
AARU_EXPORT int AARU_CALL crc16_ccitt_update(crc16_ccitt_ctx* ctx, const uint8_t* data, uint32_t len)
{
uint32_t i;
if(!ctx || !data) return -1;
for(uint32_t i = 0; i < len; i++) ctx->crc = crc16_ccitt_table[(ctx->crc >> 8) ^ data[i]] ^ (ctx->crc << 8);
for(i = 0; i < len; i++) ctx->crc = crc16_ccitt_table[(ctx->crc >> 8) ^ data[i]] ^ (ctx->crc << 8);
return 0;
}