/* * @file utils.cpp * @brief Utility functions implementation * * Created: 21.09.2025 * Author: ThePetrovich * * Copyright YKSA - Sakha Aerospace Systems, LLC. * See the LICENSE file for details. * * SPDX-License-Identifier: BSD-3-Clause */ #include "utils.h" #include "config.h" #include uint16_t calculate_crc16_xmodem(uint8_t *data, uint16_t len) { uint16_t crc = 0; uint8_t i; while (len--) { crc ^= (uint16_t)(*data++) << 8; for (i = 0; i < 8; i++) { if (crc & 0x8000) { crc = (crc << 1) ^ 0x1021; } else { crc <<= 1; } } } return crc; }