Implementation of CRC16 using polynomial 0x8005 - (X^16+X^15+X^2+1)

Dependents:   HC05 S5info_APP4

cyclic redundancy check

A cyclic redundancy check (CRC) is an error-detecting code commonly used in digital networks and storage devices to detect accidental changes to raw data. Blocks of data entering these systems get a short check value attached, based on the remainder of a polynomial division of their contents; on retrieval the calculation is repeated, and corrective action can be taken against presumed data corruption if the check values do not match.

[source:http://en.wikipedia.org/wiki/Cyclic_redundancy_check]

This class implements a basic CRC16 (17Bits) using polynomial 0x8005 (X^16 + X^15 + X^2 +1).

How to use this library

basic use of CRC 16t

    char testdata[]= "123456789";    
    CRC16 *myCRC = new CRC16();
    unsigned short resultCRC = myCRC->calculateCRC16(testdata,9); //9 is the length of the character array //
    pc.printf("%x",resultCRC);
Revision:
0:585ead300cab
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/CRC16.h	Wed Feb 12 21:34:53 2014 +0000
@@ -0,0 +1,15 @@
+#ifndef CRC16_H
+#define CRC16_H
+
+class CRC16
+{
+    private:
+    const unsigned int SHIFTER = 0x00FF;
+    unsigned short crc16table[256];
+    
+    public:
+    unsigned short calculateCRC16(char input[], int lenght);
+    CRC16();
+    ~CRC16();
+};
+#endif
\ No newline at end of file