Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
lib_crc.h
00001 /*******************************************************************\ 00002 * * 00003 * Library : lib_crc * 00004 * File : lib_crc.h * 00005 * Author : Lammert Bies 1999-2008 * 00006 * E-mail : info@lammertbies.nl * 00007 * Language : ANSI C * 00008 * * 00009 * * 00010 * Description * 00011 * =========== * 00012 * * 00013 * The file lib_crc.h contains public definitions and proto- * 00014 * types for the CRC functions present in lib_crc.c. * 00015 * * 00016 * * 00017 * Dependencies * 00018 * ============ * 00019 * * 00020 * none * 00021 * * 00022 * * 00023 * Modification history * 00024 * ==================== * 00025 * * 00026 * Date Version Comment * 00027 * * 00028 * 2010-10-20 1.17 Added several routines (JP) * 00029 * 2008-04-20 1.16 Added CRC-CCITT routine for Kermit * 00030 * * 00031 * 2007-04-01 1.15 Added CRC16 calculation for Modbus * 00032 * * 00033 * 2007-03-28 1.14 Added CRC16 routine for Sick devices * 00034 * * 00035 * 2005-12-17 1.13 Added CRC-CCITT with initial 0x1D0F * 00036 * * 00037 * 2005-02-14 1.12 Added CRC-CCITT with initial 0x0000 * 00038 * * 00039 * 2005-02-05 1.11 Fixed bug in CRC-DNP routine * 00040 * * 00041 * 2005-02-04 1.10 Added CRC-DNP routines * 00042 * * 00043 * 2005-01-07 1.02 Changes in tst_crc.c * 00044 * * 00045 * 1999-02-21 1.01 Added FALSE and TRUE mnemonics * 00046 * * 00047 * 1999-01-22 1.00 Initial source * 00048 * * 00049 \*******************************************************************/ 00050 #ifndef _LIB_CRC_H_ 00051 #define _LIB_CRC_H_ 00052 00053 #include <stdint.h> 00054 00055 #define CRC_VERSION "2.0" 00056 00057 uint16_t update_crc16_normal( uint16_t *table, uint16_t crc, char c ); 00058 uint16_t update_crc16_reflected( uint16_t *table, uint16_t crc, char c ); 00059 uint32_t update_crc24_normal( uint32_t *table, uint32_t crc, char c ); 00060 // update_crc24_reflected same as update_crc32_reflected 00061 uint32_t update_crc32_normal( uint32_t *table, uint32_t crc, char c ); 00062 uint32_t update_crc32_reflected( uint32_t *table, uint32_t crc, char c ); 00063 00064 uint64_t update_crc40_normal( uint64_t *table, uint64_t crc, char c ); 00065 // update_crc40_reflected same as update_crc64_reflected 00066 uint64_t update_crc64_normal( uint64_t *table, uint64_t crc, char c ); 00067 uint64_t update_crc64_reflected( uint64_t *table, uint64_t crc, char c ); 00068 00069 /* Does the CRC calculation 1 byte at a time */ 00070 uint8_t update_crc8_atm(uint8_t crc, uint8_t c); 00071 uint8_t update_crc8_ccitt(uint8_t crc, uint8_t c); 00072 uint8_t update_crc8_maxim(uint8_t crc, uint8_t c); 00073 uint8_t update_crc8(uint8_t crc, uint8_t c); 00074 uint8_t update_crc8_j1850(uint8_t crc, uint8_t c); 00075 uint8_t update_crc8_wcdma(uint8_t crc, uint8_t c); 00076 uint8_t update_crc8_rohc(uint8_t crc, uint8_t c); 00077 uint8_t update_crc8_darc(uint8_t crc, uint8_t c); 00078 uint16_t update_crc16_8005( uint16_t crc, char c ); 00079 uint16_t update_crc16_A001( uint16_t crc, char c ); 00080 uint16_t update_crc16_1021( uint16_t crc, char c ); 00081 uint16_t update_crc16_8408( uint16_t crc, char c ); 00082 uint16_t update_crc16_3D65( uint16_t crc, char c ); 00083 uint16_t update_crc16_dnp( uint16_t crc, char c ); 00084 uint16_t update_crc16_t10_dif( uint16_t crc, char c ); 00085 uint16_t update_crc16_0589( uint16_t crc, char c ); 00086 uint16_t update_crc16_teledisk( uint16_t crc, char c ); 00087 uint32_t update_crc24( uint32_t crc, char c ); 00088 uint32_t update_crc24_r64( uint32_t crc, char c ); 00089 uint32_t update_crc32_refl( uint32_t crc, char c ); 00090 uint32_t update_crc32_norm( uint32_t crc, char c ); 00091 uint32_t update_crc32_xfer( uint32_t crc, char c ); 00092 uint32_t update_crc32_c( uint32_t crc, char c ); 00093 uint32_t update_crc32_d( uint32_t crc, char c ); 00094 uint32_t update_crc32_k( uint32_t crc, char c ); 00095 uint32_t update_crc32_q( uint32_t crc, char c ); 00096 uint16_t update_crc_sick( uint16_t crc, char c, char prev_byte ); 00097 00098 uint64_t update_crc40_gsm(uint64_t crc, char c); 00099 uint64_t update_crc64(uint64_t crc, char c); 00100 uint64_t update_crc64_1B(uint64_t crc, char c); 00101 uint64_t update_crc64_jones(uint64_t crc, char c); 00102 00103 /* Does the CRC calculation over a string specified by length (allows 00 inside string) */ 00104 uint8_t calculate_crc8_itu(char *p, unsigned int length); 00105 uint8_t calculate_crc8_atm(char *p, unsigned int length); 00106 uint8_t calculate_crc8_ccitt(char *p, unsigned int length); 00107 uint8_t calculate_crc8_maxim(char *p, unsigned int length); 00108 uint8_t calculate_crc8(char *p, unsigned int length); 00109 uint8_t calculate_crc8_icode(char *p, unsigned int length); 00110 uint8_t calculate_crc8_j1850(char *p, unsigned int length); 00111 uint8_t calculate_crc8_wcdma(char *p, unsigned int length); 00112 uint8_t calculate_crc8_rohc(char *p, unsigned int length); 00113 uint8_t calculate_crc8_darc(char *p, unsigned int length); 00114 00115 uint16_t calculate_crc16_Buypass(char *p, unsigned int length); 00116 uint16_t calculate_crc16_DDS_110(char *p, unsigned int length); 00117 uint16_t calculate_crc16_EN_13757(char *p, unsigned int length); 00118 uint16_t calculate_crc16_Teledisk(char *p, unsigned int length); 00119 uint16_t calculate_crc16(char *p, unsigned int length); 00120 uint16_t calculate_crc16_Modbus(char *p, unsigned int length); 00121 uint16_t calculate_crc16_Maxim(char *p, unsigned int length); 00122 uint16_t calculate_crc16_USB(char *p, unsigned int length); 00123 uint16_t calculate_crc16_T10_DIF(char *p, unsigned int length); 00124 uint16_t calculate_crc16_Dect_X(char *p, unsigned int length); 00125 uint16_t calculate_crc16_Dect_R(char *p, unsigned int length); 00126 uint16_t calculate_crc16_sick(char *p, unsigned int length); 00127 uint16_t calculate_crc16_DNP(char *p, unsigned int length); 00128 uint16_t calculate_crc16_Ccitt_Xmodem(char *p, unsigned int length); 00129 uint16_t calculate_crc16_Ccitt_FFFF(char *p, unsigned int length); 00130 uint16_t calculate_crc16_Ccitt_1D0F(char *p, unsigned int length); 00131 uint16_t calculate_crc16_Genibus(char *p, unsigned int length); 00132 uint16_t calculate_crc16_Kermit(char *p, unsigned int length); 00133 uint16_t calculate_crc16_X25(char *p, unsigned int length); 00134 uint16_t calculate_crc16_MCRF4XX(char *p, unsigned int length); 00135 uint16_t calculate_crc16_Riello(char *p, unsigned int length); 00136 uint16_t calculate_chk16_Fletcher(char *p, unsigned int length); 00137 00138 uint32_t calculate_crc24_flexray_a(char *p, unsigned int length); 00139 uint32_t calculate_crc24_flexray_b(char *p, unsigned int length); 00140 uint32_t calculate_crc24_r64(char *p, unsigned int length); 00141 uint32_t calculate_crc32(char *p, unsigned int length); 00142 uint32_t calculate_crc32_jamcrc(char *p, unsigned int length); 00143 uint32_t calculate_crc32_c(char *p, unsigned int length); 00144 uint32_t calculate_crc32_d(char *p, unsigned int length); 00145 uint32_t calculate_crc32_bzip2(char *p, unsigned int length); 00146 uint32_t calculate_crc32_mpeg2(char *p, unsigned int length); 00147 uint32_t calculate_crc32_posix(char *p, unsigned int length); 00148 uint32_t calculate_crc32_k(char *p, unsigned int length); 00149 uint32_t calculate_crc32_q(char *p, unsigned int length); 00150 uint32_t calculate_crc32_xfer(char *p, unsigned int length); 00151 uint64_t calculate_crc40_gsm(char *p, unsigned int length); 00152 uint64_t calculate_crc64(char *p, unsigned int length); 00153 uint64_t calculate_crc64_1b(char *p, unsigned int length); 00154 uint64_t calculate_crc64_we(char *p, unsigned int length); 00155 uint64_t calculate_crc64_jones(char *p, unsigned int length); 00156 00157 #endif /* _LIB_CRC_H_ */
Generated on Wed Jul 27 2022 13:56:09 by
