edu16_sbc/sbc_fw/utils.h
ThePetrovich 3e77d34ccc Freeze
2026-05-07 23:21:11 +08:00

40 lines
1.6 KiB
C

/*
* @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 <stdint.h>
#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