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_CCITT.h@0:253105d48c3c, 2017-09-02 (annotated)
- Committer:
- hudakz
- Date:
- Sat Sep 02 08:26:22 2017 +0000
- Revision:
- 0:253105d48c3c
- Child:
- 1:6ecc3a64bf7b
Implementation of CRC16-CCITT using polynomial 0x1021 = x^16 + x^12 + x^5 + 1
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| hudakz | 0:253105d48c3c | 1 | /* |
| hudakz | 0:253105d48c3c | 2 | * This is a fork of the CRC16 library COPYRIGHT(c) Emilie Laverge |
| hudakz | 0:253105d48c3c | 3 | * published at [https://developer.mbed.org/users/EmLa/code/CRC16/] |
| hudakz | 0:253105d48c3c | 4 | * |
| hudakz | 0:253105d48c3c | 5 | * Modified by Zoltan Hudak to implement CRC16-CCITT |
| hudakz | 0:253105d48c3c | 6 | * using the polynomial 0x1021: X^16 + X^15 + X^2 + 1. |
| hudakz | 0:253105d48c3c | 7 | * Initial CRC register = 0x0000 |
| hudakz | 0:253105d48c3c | 8 | */ |
| hudakz | 0:253105d48c3c | 9 | |
| hudakz | 0:253105d48c3c | 10 | #ifndef CRC16_CCITT_H |
| hudakz | 0:253105d48c3c | 11 | #define CRC16_CCITT_H |
| hudakz | 0:253105d48c3c | 12 | |
| hudakz | 0:253105d48c3c | 13 | class CRC16_CCITT |
| hudakz | 0:253105d48c3c | 14 | { |
| hudakz | 0:253105d48c3c | 15 | private: |
| hudakz | 0:253105d48c3c | 16 | static const unsigned int SHIFTER; |
| hudakz | 0:253105d48c3c | 17 | static const unsigned short TABLE[]; |
| hudakz | 0:253105d48c3c | 18 | public: |
| hudakz | 0:253105d48c3c | 19 | CRC16_CCITT(void) { }; |
| hudakz | 0:253105d48c3c | 20 | ~CRC16_CCITT(void){ }; |
| hudakz | 0:253105d48c3c | 21 | unsigned short calc(char input[], int length); |
| hudakz | 0:253105d48c3c | 22 | }; |
| hudakz | 0:253105d48c3c | 23 | #endif // CRC16_CCITT_H |