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