Projectlab Elektronica-ICT KULeuven

Dependencies:   EthernetInterface TMP102 TextLCD mbed-rtos mbed

werking.pdf

Committer:
seppeduwe
Date:
Mon Mar 17 18:40:46 2014 +0000
Revision:
4:466d859bfb13
Parent:
0:ae3af7d18c4a
Einde Labo

Who changed what in which revision?

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