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_ctx* AARU_CALL crc16_init(void)
AARU_EXPORT int AARU_CALL crc16_update(crc16_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 = (ctx->crc >> 8) ^ crc16_table[data[i] ^ (ctx->crc & 0xFF)];
for(i = 0; i < len; i++) ctx->crc = (ctx->crc >> 8) ^ crc16_table[data[i] ^ (ctx->crc & 0xFF)];
return 0;
}