CRC library by Lammert Bies

Dependents:   chuk

Fork of CRC by Jacques Pelletier

Committer:
eisd
Date:
Sat Jun 25 07:08:44 2016 +0000
Revision:
1:a12f8c917af9
Parent:
0:58b0642c11b0
Library only

Who changed what in which revision?

UserRevisionLine numberNew contents of line
jpelletier 0:58b0642c11b0 1 /*******************************************************************\
jpelletier 0:58b0642c11b0 2 * *
jpelletier 0:58b0642c11b0 3 * Library : lib_crc *
jpelletier 0:58b0642c11b0 4 * File : lib_crc.h *
jpelletier 0:58b0642c11b0 5 * Author : Lammert Bies 1999-2008 *
jpelletier 0:58b0642c11b0 6 * E-mail : info@lammertbies.nl *
jpelletier 0:58b0642c11b0 7 * Language : ANSI C *
jpelletier 0:58b0642c11b0 8 * *
jpelletier 0:58b0642c11b0 9 * *
jpelletier 0:58b0642c11b0 10 * Description *
jpelletier 0:58b0642c11b0 11 * =========== *
jpelletier 0:58b0642c11b0 12 * *
jpelletier 0:58b0642c11b0 13 * The file lib_crc.h contains public definitions and proto- *
jpelletier 0:58b0642c11b0 14 * types for the CRC functions present in lib_crc.c. *
jpelletier 0:58b0642c11b0 15 * *
jpelletier 0:58b0642c11b0 16 * *
jpelletier 0:58b0642c11b0 17 * Dependencies *
jpelletier 0:58b0642c11b0 18 * ============ *
jpelletier 0:58b0642c11b0 19 * *
jpelletier 0:58b0642c11b0 20 * none *
jpelletier 0:58b0642c11b0 21 * *
jpelletier 0:58b0642c11b0 22 * *
jpelletier 0:58b0642c11b0 23 * Modification history *
jpelletier 0:58b0642c11b0 24 * ==================== *
jpelletier 0:58b0642c11b0 25 * *
jpelletier 0:58b0642c11b0 26 * Date Version Comment *
jpelletier 0:58b0642c11b0 27 * *
jpelletier 0:58b0642c11b0 28 * 2010-10-20 1.17 Added several routines (JP) *
jpelletier 0:58b0642c11b0 29 * 2008-04-20 1.16 Added CRC-CCITT routine for Kermit *
jpelletier 0:58b0642c11b0 30 * *
jpelletier 0:58b0642c11b0 31 * 2007-04-01 1.15 Added CRC16 calculation for Modbus *
jpelletier 0:58b0642c11b0 32 * *
jpelletier 0:58b0642c11b0 33 * 2007-03-28 1.14 Added CRC16 routine for Sick devices *
jpelletier 0:58b0642c11b0 34 * *
jpelletier 0:58b0642c11b0 35 * 2005-12-17 1.13 Added CRC-CCITT with initial 0x1D0F *
jpelletier 0:58b0642c11b0 36 * *
jpelletier 0:58b0642c11b0 37 * 2005-02-14 1.12 Added CRC-CCITT with initial 0x0000 *
jpelletier 0:58b0642c11b0 38 * *
jpelletier 0:58b0642c11b0 39 * 2005-02-05 1.11 Fixed bug in CRC-DNP routine *
jpelletier 0:58b0642c11b0 40 * *
jpelletier 0:58b0642c11b0 41 * 2005-02-04 1.10 Added CRC-DNP routines *
jpelletier 0:58b0642c11b0 42 * *
jpelletier 0:58b0642c11b0 43 * 2005-01-07 1.02 Changes in tst_crc.c *
jpelletier 0:58b0642c11b0 44 * *
jpelletier 0:58b0642c11b0 45 * 1999-02-21 1.01 Added FALSE and TRUE mnemonics *
jpelletier 0:58b0642c11b0 46 * *
jpelletier 0:58b0642c11b0 47 * 1999-01-22 1.00 Initial source *
jpelletier 0:58b0642c11b0 48 * *
jpelletier 0:58b0642c11b0 49 \*******************************************************************/
jpelletier 0:58b0642c11b0 50 #ifndef _LIB_CRC_H_
jpelletier 0:58b0642c11b0 51 #define _LIB_CRC_H_
jpelletier 0:58b0642c11b0 52
jpelletier 0:58b0642c11b0 53 #include <stdint.h>
jpelletier 0:58b0642c11b0 54
jpelletier 0:58b0642c11b0 55 #define CRC_VERSION "2.0"
jpelletier 0:58b0642c11b0 56
jpelletier 0:58b0642c11b0 57 uint16_t update_crc16_normal( uint16_t *table, uint16_t crc, char c );
jpelletier 0:58b0642c11b0 58 uint16_t update_crc16_reflected( uint16_t *table, uint16_t crc, char c );
jpelletier 0:58b0642c11b0 59 uint32_t update_crc24_normal( uint32_t *table, uint32_t crc, char c );
jpelletier 0:58b0642c11b0 60 // update_crc24_reflected same as update_crc32_reflected
jpelletier 0:58b0642c11b0 61 uint32_t update_crc32_normal( uint32_t *table, uint32_t crc, char c );
jpelletier 0:58b0642c11b0 62 uint32_t update_crc32_reflected( uint32_t *table, uint32_t crc, char c );
jpelletier 0:58b0642c11b0 63
jpelletier 0:58b0642c11b0 64 uint64_t update_crc40_normal( uint64_t *table, uint64_t crc, char c );
jpelletier 0:58b0642c11b0 65 // update_crc40_reflected same as update_crc64_reflected
jpelletier 0:58b0642c11b0 66 uint64_t update_crc64_normal( uint64_t *table, uint64_t crc, char c );
jpelletier 0:58b0642c11b0 67 uint64_t update_crc64_reflected( uint64_t *table, uint64_t crc, char c );
jpelletier 0:58b0642c11b0 68
jpelletier 0:58b0642c11b0 69 /* Does the CRC calculation 1 byte at a time */
jpelletier 0:58b0642c11b0 70 uint8_t update_crc8_atm(uint8_t crc, uint8_t c);
jpelletier 0:58b0642c11b0 71 uint8_t update_crc8_ccitt(uint8_t crc, uint8_t c);
jpelletier 0:58b0642c11b0 72 uint8_t update_crc8_maxim(uint8_t crc, uint8_t c);
jpelletier 0:58b0642c11b0 73 uint8_t update_crc8(uint8_t crc, uint8_t c);
jpelletier 0:58b0642c11b0 74 uint8_t update_crc8_j1850(uint8_t crc, uint8_t c);
jpelletier 0:58b0642c11b0 75 uint8_t update_crc8_wcdma(uint8_t crc, uint8_t c);
jpelletier 0:58b0642c11b0 76 uint8_t update_crc8_rohc(uint8_t crc, uint8_t c);
jpelletier 0:58b0642c11b0 77 uint8_t update_crc8_darc(uint8_t crc, uint8_t c);
jpelletier 0:58b0642c11b0 78 uint16_t update_crc16_8005( uint16_t crc, char c );
jpelletier 0:58b0642c11b0 79 uint16_t update_crc16_A001( uint16_t crc, char c );
jpelletier 0:58b0642c11b0 80 uint16_t update_crc16_1021( uint16_t crc, char c );
jpelletier 0:58b0642c11b0 81 uint16_t update_crc16_8408( uint16_t crc, char c );
jpelletier 0:58b0642c11b0 82 uint16_t update_crc16_3D65( uint16_t crc, char c );
jpelletier 0:58b0642c11b0 83 uint16_t update_crc16_dnp( uint16_t crc, char c );
jpelletier 0:58b0642c11b0 84 uint16_t update_crc16_t10_dif( uint16_t crc, char c );
jpelletier 0:58b0642c11b0 85 uint16_t update_crc16_0589( uint16_t crc, char c );
jpelletier 0:58b0642c11b0 86 uint16_t update_crc16_teledisk( uint16_t crc, char c );
jpelletier 0:58b0642c11b0 87 uint32_t update_crc24( uint32_t crc, char c );
jpelletier 0:58b0642c11b0 88 uint32_t update_crc24_r64( uint32_t crc, char c );
jpelletier 0:58b0642c11b0 89 uint32_t update_crc32_refl( uint32_t crc, char c );
jpelletier 0:58b0642c11b0 90 uint32_t update_crc32_norm( uint32_t crc, char c );
jpelletier 0:58b0642c11b0 91 uint32_t update_crc32_xfer( uint32_t crc, char c );
jpelletier 0:58b0642c11b0 92 uint32_t update_crc32_c( uint32_t crc, char c );
jpelletier 0:58b0642c11b0 93 uint32_t update_crc32_d( uint32_t crc, char c );
jpelletier 0:58b0642c11b0 94 uint32_t update_crc32_k( uint32_t crc, char c );
jpelletier 0:58b0642c11b0 95 uint32_t update_crc32_q( uint32_t crc, char c );
jpelletier 0:58b0642c11b0 96 uint16_t update_crc_sick( uint16_t crc, char c, char prev_byte );
jpelletier 0:58b0642c11b0 97
jpelletier 0:58b0642c11b0 98 uint64_t update_crc40_gsm(uint64_t crc, char c);
jpelletier 0:58b0642c11b0 99 uint64_t update_crc64(uint64_t crc, char c);
jpelletier 0:58b0642c11b0 100 uint64_t update_crc64_1B(uint64_t crc, char c);
jpelletier 0:58b0642c11b0 101 uint64_t update_crc64_jones(uint64_t crc, char c);
jpelletier 0:58b0642c11b0 102
jpelletier 0:58b0642c11b0 103 /* Does the CRC calculation over a string specified by length (allows 00 inside string) */
jpelletier 0:58b0642c11b0 104 uint8_t calculate_crc8_itu(char *p, unsigned int length);
jpelletier 0:58b0642c11b0 105 uint8_t calculate_crc8_atm(char *p, unsigned int length);
jpelletier 0:58b0642c11b0 106 uint8_t calculate_crc8_ccitt(char *p, unsigned int length);
jpelletier 0:58b0642c11b0 107 uint8_t calculate_crc8_maxim(char *p, unsigned int length);
jpelletier 0:58b0642c11b0 108 uint8_t calculate_crc8(char *p, unsigned int length);
jpelletier 0:58b0642c11b0 109 uint8_t calculate_crc8_icode(char *p, unsigned int length);
jpelletier 0:58b0642c11b0 110 uint8_t calculate_crc8_j1850(char *p, unsigned int length);
jpelletier 0:58b0642c11b0 111 uint8_t calculate_crc8_wcdma(char *p, unsigned int length);
jpelletier 0:58b0642c11b0 112 uint8_t calculate_crc8_rohc(char *p, unsigned int length);
jpelletier 0:58b0642c11b0 113 uint8_t calculate_crc8_darc(char *p, unsigned int length);
jpelletier 0:58b0642c11b0 114
jpelletier 0:58b0642c11b0 115 uint16_t calculate_crc16_Buypass(char *p, unsigned int length);
jpelletier 0:58b0642c11b0 116 uint16_t calculate_crc16_DDS_110(char *p, unsigned int length);
jpelletier 0:58b0642c11b0 117 uint16_t calculate_crc16_EN_13757(char *p, unsigned int length);
jpelletier 0:58b0642c11b0 118 uint16_t calculate_crc16_Teledisk(char *p, unsigned int length);
jpelletier 0:58b0642c11b0 119 uint16_t calculate_crc16(char *p, unsigned int length);
jpelletier 0:58b0642c11b0 120 uint16_t calculate_crc16_Modbus(char *p, unsigned int length);
jpelletier 0:58b0642c11b0 121 uint16_t calculate_crc16_Maxim(char *p, unsigned int length);
jpelletier 0:58b0642c11b0 122 uint16_t calculate_crc16_USB(char *p, unsigned int length);
jpelletier 0:58b0642c11b0 123 uint16_t calculate_crc16_T10_DIF(char *p, unsigned int length);
jpelletier 0:58b0642c11b0 124 uint16_t calculate_crc16_Dect_X(char *p, unsigned int length);
jpelletier 0:58b0642c11b0 125 uint16_t calculate_crc16_Dect_R(char *p, unsigned int length);
jpelletier 0:58b0642c11b0 126 uint16_t calculate_crc16_sick(char *p, unsigned int length);
jpelletier 0:58b0642c11b0 127 uint16_t calculate_crc16_DNP(char *p, unsigned int length);
jpelletier 0:58b0642c11b0 128 uint16_t calculate_crc16_Ccitt_Xmodem(char *p, unsigned int length);
jpelletier 0:58b0642c11b0 129 uint16_t calculate_crc16_Ccitt_FFFF(char *p, unsigned int length);
jpelletier 0:58b0642c11b0 130 uint16_t calculate_crc16_Ccitt_1D0F(char *p, unsigned int length);
jpelletier 0:58b0642c11b0 131 uint16_t calculate_crc16_Genibus(char *p, unsigned int length);
jpelletier 0:58b0642c11b0 132 uint16_t calculate_crc16_Kermit(char *p, unsigned int length);
jpelletier 0:58b0642c11b0 133 uint16_t calculate_crc16_X25(char *p, unsigned int length);
jpelletier 0:58b0642c11b0 134 uint16_t calculate_crc16_MCRF4XX(char *p, unsigned int length);
jpelletier 0:58b0642c11b0 135 uint16_t calculate_crc16_Riello(char *p, unsigned int length);
jpelletier 0:58b0642c11b0 136 uint16_t calculate_chk16_Fletcher(char *p, unsigned int length);
jpelletier 0:58b0642c11b0 137
jpelletier 0:58b0642c11b0 138 uint32_t calculate_crc24_flexray_a(char *p, unsigned int length);
jpelletier 0:58b0642c11b0 139 uint32_t calculate_crc24_flexray_b(char *p, unsigned int length);
jpelletier 0:58b0642c11b0 140 uint32_t calculate_crc24_r64(char *p, unsigned int length);
jpelletier 0:58b0642c11b0 141 uint32_t calculate_crc32(char *p, unsigned int length);
jpelletier 0:58b0642c11b0 142 uint32_t calculate_crc32_jamcrc(char *p, unsigned int length);
jpelletier 0:58b0642c11b0 143 uint32_t calculate_crc32_c(char *p, unsigned int length);
jpelletier 0:58b0642c11b0 144 uint32_t calculate_crc32_d(char *p, unsigned int length);
jpelletier 0:58b0642c11b0 145 uint32_t calculate_crc32_bzip2(char *p, unsigned int length);
jpelletier 0:58b0642c11b0 146 uint32_t calculate_crc32_mpeg2(char *p, unsigned int length);
jpelletier 0:58b0642c11b0 147 uint32_t calculate_crc32_posix(char *p, unsigned int length);
jpelletier 0:58b0642c11b0 148 uint32_t calculate_crc32_k(char *p, unsigned int length);
jpelletier 0:58b0642c11b0 149 uint32_t calculate_crc32_q(char *p, unsigned int length);
jpelletier 0:58b0642c11b0 150 uint32_t calculate_crc32_xfer(char *p, unsigned int length);
jpelletier 0:58b0642c11b0 151 uint64_t calculate_crc40_gsm(char *p, unsigned int length);
jpelletier 0:58b0642c11b0 152 uint64_t calculate_crc64(char *p, unsigned int length);
jpelletier 0:58b0642c11b0 153 uint64_t calculate_crc64_1b(char *p, unsigned int length);
jpelletier 0:58b0642c11b0 154 uint64_t calculate_crc64_we(char *p, unsigned int length);
jpelletier 0:58b0642c11b0 155 uint64_t calculate_crc64_jones(char *p, unsigned int length);
jpelletier 0:58b0642c11b0 156
jpelletier 0:58b0642c11b0 157 #endif /* _LIB_CRC_H_ */