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.
crc16.h
00001 #ifndef CRC16_H_ 00002 #define CRC16_H_ 00003 00004 /* General Layout Design taken from Erik van Wijk's crc8 library found at 00005 http://mbed.org/users/evwijk/code/crc8/ 00006 */ 00007 00008 /* Takes in a character array with a given number of bytes. Returns the 00009 16 bit CRC tag as a 32 bit integer. numberOfBytes exceeds 16, function returns 0. 00010 */ 00011 00012 int crc16 (char* dataIn, int numberOfBytes); 00013 00014 /* Takes in a character array with at least (numberOfBytes + 2) entries. A 16-bit 00015 CRC tag is created from the first numberOfBytes elements of dataIn. The 16-bit tag is then 00016 broken into two 8 bit tags. The most significant is stored in dataIn at (numberOfBytes+1) 00017 and the least significant is stored in dataIn at (numberOfBytes+2) 00018 00019 ******************************************************************************* 00020 Note: numberOfBytes indicates the number of data elements to generate the CRC. 00021 dataIn must be at least of length numberOfBytes + 2 for the two bytes of CRC 00022 ******************************************************************************* 00023 */ 00024 00025 void crc16_attach (char* dataIn, int numberOfBytes); 00026 00027 /* Takes in a character array of length (numberOfBytes + 2). A 16-bit CRC is created from the first 00028 numberOfBytes elements of dataIn. The elements at numberOfBytes + 1 and numberOfBytes + 2 are assumed 00029 to be a CRC tag created in the form described above and are reassembled into a single integer. 00030 00031 The calculated CRC and the input CRC are compared 00032 00033 If they match, funtion is true. 00034 If the two CRC tags to not match, function is false. 00035 00036 ******************************************************************************* 00037 Note: numberOfBytes indicates the number of data elements to generate the CRC. 00038 dataIn must be at least of length numberOfBytes + 2 for the two bytes of CRC 00039 ******************************************************************************* 00040 */ 00041 bool crc16_match (char* dataIn, int numberOfBytes); 00042 00043 00044 #endif
Generated on Thu Jul 14 2022 22:34:28 by
1.7.2