Created
February 29, 2024 17:08
-
-
Save profi200/6379364d07824c0374618163e1b839b4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static u8 crc7(const u8 *data, u32 len) | |
{ | |
u32 crc = 0; // u32 to avoid "and rX, rX, #0xFF" in the bit loop. | |
while(len--) | |
{ | |
crc ^= *data++; | |
for(u32 i = 0; i < 8; i++) | |
{ | |
if(crc & 0x80u) crc ^= 0x89u; | |
crc <<= 1; | |
} | |
} | |
return crc | 1u; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment