CRC basic library

Dependents:   D7A_1x_demo_CodeUpgradeProtocol D7A_1x_demo_big_file D7A_1x_demo_sensors_v3 D7A_1x_demo_send_file_data

Revision:
1:3f4e25d35b1d
Parent:
0:ad1af95e9c7f
--- a/crc.h	Thu Dec 14 14:22:13 2017 +0000
+++ b/crc.h	Thu Dec 14 18:25:37 2017 +0000
@@ -47,111 +47,35 @@
     *   1999-01-22  1.00    Initial source                              *
     *                                                                   *
     \*******************************************************************/
-#ifndef _LIB_CRC_H_
-#define _LIB_CRC_H_
+#ifndef _CRC_H_
+#define _CRC_H_
 
-#include <stdint.h>
+#include "mbed.h"
 
 #define CRC_VERSION     "2.0"
 
-uint16_t update_crc16_normal( uint16_t *table, uint16_t crc, char c );
-uint16_t update_crc16_reflected( uint16_t *table, uint16_t crc, char c );
-uint32_t update_crc24_normal( uint32_t *table, uint32_t crc, char c );
-// update_crc24_reflected  same as update_crc32_reflected
-uint32_t update_crc32_normal( uint32_t *table, uint32_t crc, char c );
-uint32_t update_crc32_reflected( uint32_t *table, uint32_t crc, char c );
-
-uint64_t update_crc40_normal( uint64_t *table, uint64_t crc, char c );
-// update_crc40_reflected  same as update_crc64_reflected
-uint64_t update_crc64_normal( uint64_t *table, uint64_t crc, char c );
-uint64_t update_crc64_reflected( uint64_t *table, uint64_t crc, char c );
+//#define CRC8
+//#define CRC16
+#define CRC32
+//#define CRC64
 
-/* Does the CRC calculation 1 byte at a time */
-uint8_t update_crc8_atm(uint8_t crc, uint8_t c);
-uint8_t update_crc8_ccitt(uint8_t crc, uint8_t c);
-uint8_t update_crc8_maxim(uint8_t crc, uint8_t c);
-uint8_t update_crc8(uint8_t crc, uint8_t c);
-uint8_t update_crc8_j1850(uint8_t crc, uint8_t c);
-uint8_t update_crc8_wcdma(uint8_t crc, uint8_t c);
-uint8_t update_crc8_rohc(uint8_t crc, uint8_t c);
-uint8_t update_crc8_darc(uint8_t crc, uint8_t c);
-uint16_t update_crc16_8005( uint16_t crc, char c );
-uint16_t update_crc16_A001( uint16_t crc, char c );
-uint16_t update_crc16_1021( uint16_t crc, char c );
-uint16_t update_crc16_8408( uint16_t crc, char c );
-uint16_t update_crc16_3D65( uint16_t crc, char c );
-uint16_t update_crc16_dnp( uint16_t crc, char c );
-uint16_t update_crc16_t10_dif( uint16_t crc, char c );
-uint16_t update_crc16_0589( uint16_t crc, char c );
-uint16_t update_crc16_teledisk( uint16_t crc, char c );
-uint32_t update_crc24( uint32_t crc, char c );
-uint32_t update_crc24_r64( uint32_t crc, char c );
-uint32_t update_crc32_refl( uint32_t crc, char c );
-uint32_t update_crc32_norm( uint32_t crc, char c );
-uint32_t update_crc32_xfer( uint32_t crc, char c );
-uint32_t update_crc32_c( uint32_t crc, char c );
-uint32_t update_crc32_d( uint32_t crc, char c );
-uint32_t update_crc32_k( uint32_t crc, char c );
-uint32_t update_crc32_q( uint32_t crc, char c );
-uint16_t update_crc_sick( uint16_t crc, char c, char prev_byte );
-
-uint64_t update_crc40_gsm(uint64_t crc, char c);
-uint64_t update_crc64(uint64_t crc, char c);
-uint64_t update_crc64_1B(uint64_t crc, char c);
-uint64_t update_crc64_jones(uint64_t crc, char c);
 
 /* Does the CRC calculation over a string specified by length (allows 00 inside string) */
-uint8_t calculate_crc8_itu(char *p, unsigned int length);
-uint8_t calculate_crc8_atm(char *p, unsigned int length);
-uint8_t calculate_crc8_ccitt(char *p, unsigned int length);
-uint8_t calculate_crc8_maxim(char *p, unsigned int length);
-uint8_t calculate_crc8(char *p, unsigned int length);
-uint8_t calculate_crc8_icode(char *p, unsigned int length);
-uint8_t calculate_crc8_j1850(char *p, unsigned int length);
-uint8_t calculate_crc8_wcdma(char *p, unsigned int length);
-uint8_t calculate_crc8_rohc(char *p, unsigned int length);
-uint8_t calculate_crc8_darc(char *p, unsigned int length);
+
+#ifdef CRC8
+uint8_t crc8(char *p, uint32_t length);
+#endif
+
+#ifdef CRC16
+uint16_t crc16(char *p, uint32_t length);
+#endif
 
-uint16_t calculate_crc16_Buypass(char *p, unsigned int length);
-uint16_t calculate_crc16_DDS_110(char *p, unsigned int length);
-uint16_t calculate_crc16_EN_13757(char *p, unsigned int length);
-uint16_t calculate_crc16_Teledisk(char *p, unsigned int length);
-uint16_t calculate_crc16(char *p, unsigned int length);
-uint16_t calculate_crc16_Modbus(char *p, unsigned int length);
-uint16_t calculate_crc16_Maxim(char *p, unsigned int length);
-uint16_t calculate_crc16_USB(char *p, unsigned int length);
-uint16_t calculate_crc16_T10_DIF(char *p, unsigned int length);
-uint16_t calculate_crc16_Dect_X(char *p, unsigned int length);
-uint16_t calculate_crc16_Dect_R(char *p, unsigned int length);
-uint16_t calculate_crc16_sick(char *p, unsigned int length);
-uint16_t calculate_crc16_DNP(char *p, unsigned int length);
-uint16_t calculate_crc16_Ccitt_Xmodem(char *p, unsigned int length);
-uint16_t calculate_crc16_Ccitt_FFFF(char *p, unsigned int length);
-uint16_t calculate_crc16_Ccitt_1D0F(char *p, unsigned int length);
-uint16_t calculate_crc16_Genibus(char *p, unsigned int length);
-uint16_t calculate_crc16_Kermit(char *p, unsigned int length);
-uint16_t calculate_crc16_X25(char *p, unsigned int length);
-uint16_t calculate_crc16_MCRF4XX(char *p, unsigned int length);
-uint16_t calculate_crc16_Riello(char *p, unsigned int length);
-uint16_t calculate_chk16_Fletcher(char *p, unsigned int length);
+#ifdef CRC32
+uint32_t crc32(char *p, uint32_t length);
+#endif
 
-uint32_t calculate_crc24_flexray_a(char *p, unsigned int length);
-uint32_t calculate_crc24_flexray_b(char *p, unsigned int length);
-uint32_t calculate_crc24_r64(char *p, unsigned int length);
-uint32_t calculate_crc32(char *p, unsigned int length);
-uint32_t calculate_crc32_jamcrc(char *p, unsigned int length);
-uint32_t calculate_crc32_c(char *p, unsigned int length);
-uint32_t calculate_crc32_d(char *p, unsigned int length);
-uint32_t calculate_crc32_bzip2(char *p, unsigned int length);
-uint32_t calculate_crc32_mpeg2(char *p, unsigned int length);
-uint32_t calculate_crc32_posix(char *p, unsigned int length);
-uint32_t calculate_crc32_k(char *p, unsigned int length);
-uint32_t calculate_crc32_q(char *p, unsigned int length);
-uint32_t calculate_crc32_xfer(char *p, unsigned int length);
-uint64_t calculate_crc40_gsm(char *p, unsigned int length);
-uint64_t calculate_crc64(char *p, unsigned int length);
-uint64_t calculate_crc64_1b(char *p, unsigned int length);
-uint64_t calculate_crc64_we(char *p, unsigned int length);
-uint64_t calculate_crc64_jones(char *p, unsigned int length);
+#ifdef CRC64
+uint64_t crc64(char *p, uint32_t length);
+#endif
 
-#endif /* _LIB_CRC_H_ */
+#endif /* _CRC_H_ */