Bluetooth Low Energy for Smart Plug

Dependencies:   BLE_API mbed nRF51822

Fork of SmartPlugBLE by Pavit Noinongyao

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers crc2.h Source File

crc2.h

00001 /**********************************************************************
00002  *
00003  * Filename:    crc.h
00004  * 
00005  * Description: A header file describing the various CRC standards.
00006  *
00007  * Notes:       
00008  *
00009  * 
00010  * Copyright (c) 2000 by Michael Barr.  This software is placed into
00011  * the public domain and may be used for any purpose.  However, this
00012  * notice must not be changed or removed and no warranty is either
00013  * expressed or implied by its publication or distribution.
00014  **********************************************************************/
00015 
00016 #ifndef _crc2_h
00017 #define _crc2_h
00018 
00019 
00020 #define FALSE   0
00021 #define TRUE    !FALSE
00022 
00023 /*
00024  * Select the CRC standard from the list that follows.
00025  */
00026 #define CRC_CCITT
00027 
00028 
00029 #if defined(CRC_CCITT)
00030 
00031 typedef unsigned short  crc;
00032 
00033 #define CRC_NAME            "CRC-CCITT"
00034 #define POLYNOMIAL          0x1021
00035 #define INITIAL_REMAINDER   0xFFFF
00036 #define FINAL_XOR_VALUE     0x0000
00037 #define REFLECT_DATA        FALSE
00038 #define REFLECT_REMAINDER   FALSE
00039 #define CHECK_VALUE         0x29B1
00040 
00041 #elif defined(CRC16)
00042 
00043 typedef unsigned short  crc;
00044 
00045 #define CRC_NAME            "CRC-16"
00046 #define POLYNOMIAL          0x8005
00047 #define INITIAL_REMAINDER   0x0000
00048 #define FINAL_XOR_VALUE     0x0000
00049 #define REFLECT_DATA        TRUE
00050 #define REFLECT_REMAINDER   TRUE
00051 #define CHECK_VALUE         0xBB3D
00052 
00053 #elif defined(CRC32)
00054 
00055 typedef unsigned long  crc;
00056 
00057 #define CRC_NAME            "CRC-32"
00058 #define POLYNOMIAL          0x04C11DB7
00059 #define INITIAL_REMAINDER   0xFFFFFFFF
00060 #define FINAL_XOR_VALUE     0xFFFFFFFF
00061 #define REFLECT_DATA        TRUE
00062 #define REFLECT_REMAINDER   TRUE
00063 #define CHECK_VALUE         0xCBF43926
00064 
00065 #else
00066 
00067 #error "One of CRC_CCITT, CRC16, or CRC32 must be #define'd."
00068 
00069 #endif
00070 
00071 
00072 void  crcInit();
00073 crc   crcSlow(unsigned char const message[], int nBytes);
00074 crc   crcFast(unsigned char const message[], int nBytes);
00075 
00076 
00077 #endif /* _crc_h */
00078