4 * Copyright 2003,2004 Develer S.r.l. (http://www.develer.com/)
5 * Copyright 1999 Bernardo Innocenti <bernie@develer.com>
6 * This file is part of DevLib - See devlib/README for information.
9 * \brief Definitions for CRC generator
12 * \author Bernardo Innocenti <bernie@develer.com>
17 * Revision 1.2 2004/06/03 11:27:09 bernie
18 * Add dual-license information.
20 * Revision 1.1 2004/06/03 08:58:16 bernie
29 #endif /* __cplusplus */
31 #include <stdint.h> // uint16_t
32 #include <stddef.h> // size_t
35 extern const uint16_t crc16tab[256];
39 * updcrc macro derived from article Copyright (C) 1986 Stephen Satchell.
40 * \note First argument must be in range 0 to 255.
41 * \note Second argument is referenced twice.
43 * Programmers may incorporate any or all code into their programs,
44 * giving proper credit within the source. Publication of the
45 * source routines is permitted so long as proper credit is given
46 * to Stephen Satchell, Satchell Evaluations and Chuck Forsberg,
49 #define UPDCRC16(c, oldcrc) (crc16tab[((oldcrc) >> 8) ^ ((unsigned char)(c))] ^ ((oldcrc) << 8))
52 * This function implements the CRC 16 calculation on a buffer.
54 * \param crc Current CRC16 value.
55 * \param buf The buffer to perform CRC calculation on.
56 * \param len The length of the Buffer.
58 * \return The updated CRC 16 value.
60 extern uint16_t crc16(uint16_t crc, const void *buf, size_t len);
64 #endif /* __cplusplus */