|
本帖最后由 emwin 于 2020-7-29 23:25 编辑
出处:https://wiki.segger.com/CRC
- U32 CRC_Calc(const U8* pData, unsigned NumBytes, U32 crc, U32 Polynom) {
- int i;
- U8 Data;
- U8 Xor;
- do {
- Data = *pData++;
- i = 8;
- do {
- Xor = crc ^ Data;
- crc >>= 1;
- if (Xor & 1)
- crc ^= Polynom;
- }
- Data >>= 1;
- } while (--i);
- } while (--NumBytes);
- return crc;
- }
复制代码
The CRC used is the CRC32-CCITT polynomial.
Normal form: 0x04C11DB7
Reversed form: 0xEDB88320 (used by J-Flash)
Please note, that the initial CRC used for the calculation is 0x00000000 (some calculators use 0xFFFFFFFF).
|
|