/* * Copyright (c) 2023 HPMicro * * SPDX-License-Identifier: BSD-3-Clause * */ #include "hpm_crc32.h" uint32_t crc32(const uint8_t *buf, uint32_t len) { uint8_t i; uint32_t crc = 0xFFFFFFFF; while (len--) { crc ^= *buf++; for (i = 0; i < 8; ++i) { if (crc & 1) crc = (crc >> 1) ^ 0xEDB88320; else crc = (crc >> 1); } } return ~crc; }