/* * @file utils.h * @brief Utility functions and helpers * * Created: 21.09.2025 * Author: ThePetrovich * * Copyright YKSA - Sakha Aerospace Systems, LLC. * See the LICENSE file for details. * * SPDX-License-Identifier: BSD-3-Clause */ #ifndef UTILS_H #define UTILS_H #include #define SERIAL_BUFFER_CLEAR() \ do { \ while (Serial.available()) { \ Serial.read(); \ } \ } while (0) #define SERIAL_SEND_OK() \ do { \ Serial.print("ok\n"); \ Serial.flush(); \ SERIAL_BUFFER_CLEAR(); \ } while (0) /** * @brief Calculate CRC16 using XMODEM polynomial * @param data Pointer to data buffer * @param len Length of data in bytes * @return CRC16 checksum */ uint16_t calculate_crc16_xmodem(uint8_t *data, uint16_t len); #endif // UTILS_H