X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;f=algo%2Fcrc.h;h=3fb3381292bf18a4164f99b38d5bc12b2c3eaefe;hb=HEAD;hp=d6a1f45de21ca688c7b83615d3287b15a85a4a9a;hpb=6efccabd909ecee0607e10c57bb5e64162a19eb7;p=bertos.git diff --git a/algo/crc.h b/algo/crc.h deleted file mode 100644 index d6a1f45d..00000000 --- a/algo/crc.h +++ /dev/null @@ -1,102 +0,0 @@ -/** - * \file - * - * - * \brief XModem-CRC16 algorithm (interface) - * - * \note This algorithm is incompatible with the CCITT-CRC16. - * - * This code is based on the article Copyright 1986 Stephen Satchell. - * - * Programmers may incorporate any or all code into their programs, - * giving proper credit within the source. Publication of the - * source routines is permitted so long as proper credit is given - * to Stephen Satchell, Satchell Evaluations and Chuck Forsberg, - * Omen Technology. - * - * \version $Id$ - * \author Bernardo Innocenti - */ - -#ifndef ALGO_CRC_H -#define ALGO_CRC_H - -#include - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - - -/* CRC table */ -extern const uint16_t crc16tab[256]; - - -/** - * \brief Compute the updated CRC16 value for one octet (macro version) - * - * \note This version is only intended for old/broken compilers. - * Use the inline function in new code. - * - * \param c New octet (range 0-255) - * \param oldcrc Previous CRC16 value (referenced twice, beware of side effects) - */ -#define UPDCRC16(c, oldcrc) (crc16tab[((oldcrc) >> 8) ^ ((unsigned char)(c))] ^ ((oldcrc) << 8)) - - -#ifdef INLINE -/** - * \brief Compute the updated CRC16 value for one octet (macro version) - */ -INLINE uint16_t updcrc16(uint8_t c, uint16_t oldcrc) -{ - return crc16tab[(oldcrc >> 8) ^ c] ^ (oldcrc << 8); -} -#endif // INLINE - - -/** - * This function implements the CRC 16 calculation on a buffer. - * - * \param crc Current CRC16 value. - * \param buf The buffer to perform CRC calculation on. - * \param len The length of the Buffer. - * - * \return The updated CRC16 value. - */ -extern uint16_t crc16(uint16_t crc, const void *buf, size_t len); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* ALGO_CRC_H */