Last active
March 15, 2019 13:49
-
-
Save martinandrovich/e0db72650f487bfa8ab1be045f83eccd to your computer and use it in GitHub Desktop.
Demo of CHECKSUM module
This file contains hidden or 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
// chksum.h | |
// version 1.2.2 | |
// WARNING! | |
// rewrite "0b0011'0101" to "0b00110101" when using C | |
// 4-bit checksum test | |
// input: 1011'1000'1110 | |
// size: 3 nibbles (12 bits) | |
// output: 1000 | |
uint16_t data_4bit = 0b1011'1000'1110; | |
uint8_t chks_4bit = chksum.gen_4bit(data_4bit, 3); | |
bool vali_4bit = chksum.val_4bit(data_4bit, 2, 0b1000); | |
// 8-bit checksum test | |
// input: 1010'1011 ; 1000'1110 | |
// size: 2 bytes (16 bits) | |
// output: 0010'0101 | |
uint8_t data_8bit[2] = { 0b1010'1011, 0b1000'1110 }; | |
uint8_t chks_8bit = chksum.gen_8bit(data_8bit, 2); | |
bool vali_8bit = chksum.val_8bit(data_8bit, 2, 0b0010'0101); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment