Program Listing for File crc.hpp

Return to documentation for file (src/tap/algorithms/crc.hpp)

/*
 * Copyright (c) 2020-2021 Advanced Robotics at the University of Washington <robomstr@uw.edu>
 *
 * This file is part of Taproot.
 *
 * Taproot is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * Taproot is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Taproot.  If not, see <https://www.gnu.org/licenses/>.
 */

#ifndef TAPROOT_CRC_HPP_
#define TAPROOT_CRC_HPP_

#include <cstdint>

namespace tap
{
namespace algorithms
{
#define CRC8_INIT 0xff
#define CRC16_INIT 0xffff

uint8_t calculateCRC8(const uint8_t *message, uint32_t messageLength, uint8_t initCRC8 = CRC8_INIT);

uint16_t calculateCRC16(
    const uint8_t *message,
    uint32_t messageLength,
    uint16_t initCRC16 = CRC16_INIT);

}  // namespace algorithms

}  // namespace tap

#endif  // TAPROOT_CRC_HPP_