12 #ifndef INCLUDE_UTIL_H_ 13 #define INCLUDE_UTIL_H_ 19 #define MAX(a,b) ((a) > (b) ? (a) : (b)) 22 #define MIN(a,b) ((a) < (b) ? (a) : (b)) unsigned extract_nibbles_4b1s(uint8_t *message, unsigned offset_bits, unsigned num_bits, uint8_t *dst)
Unstuff nibbles with 1-bit separator (4B1S) to bytes, returns number of successfully unstuffed nibble...
Definition: util.c:46
uint8_t crc8(uint8_t const message[], unsigned nBytes, uint8_t polynomial, uint8_t init)
Generic Cyclic Redundancy Check CRC-8.
Definition: util.c:102
uint8_t lfsr_digest8(uint8_t const message[], unsigned bytes, uint8_t gen, uint8_t key)
Digest-8 by "LFSR-based Toeplitz hash".
Definition: util.c:177
int add_nibbles(uint8_t const message[], unsigned num_bytes)
Compute Addition of a number of nibbles (byte wise).
Definition: util.c:283
unsigned short uint16_t
Definition: mongoose.h:271
int parity_bytes(uint8_t const message[], unsigned num_bytes)
Compute bit parity of a number of bytes.
Definition: util.c:256
uint8_t crc4(uint8_t const message[], unsigned nBytes, uint8_t polynomial, uint8_t init)
CRC-4.
Definition: util.c:64
uint16_t crc16(uint8_t const message[], unsigned nBytes, uint16_t polynomial, uint16_t init)
CRC-16.
Definition: util.c:158
int parity8(uint8_t byte)
Compute bit parity of a single byte (8 bits).
Definition: util.c:249
uint16_t lfsr_digest16(uint32_t data, int bits, uint16_t gen, uint16_t key)
Digest-16 by "LFSR-based Toeplitz hash".
Definition: util.c:199
uint8_t crc7(uint8_t const message[], unsigned nBytes, uint8_t polynomial, uint8_t init)
CRC-7.
Definition: util.c:83
uint16_t crc16lsb(uint8_t const message[], unsigned nBytes, uint16_t polynomial, uint16_t init)
CRC-16 LSB.
Definition: util.c:139
unsigned int uint32_t
Definition: mongoose.h:269
uint8_t reverse8(uint8_t x)
Reverse (reflect) the bits in an 8 bit byte.
Definition: util.c:17
uint8_t crc8le(uint8_t const message[], unsigned nBytes, uint8_t polynomial, uint8_t init)
"Little-endian" Cyclic Redundancy Check CRC-8 LE Input and output are reflected, i.e.
Definition: util.c:120
uint8_t reflect4(uint8_t x)
Reflect (reverse LSB to MSB) each nibble in an 8 bit byte, preserves nibble order.
Definition: util.c:32
void reflect_nibbles(uint8_t message[], unsigned num_bytes)
Reflect (reverse LSB to MSB) each nibble in a number of bytes.
Definition: util.c:39
void reflect_bytes(uint8_t message[], unsigned num_bytes)
Reflect (reverse LSB to MSB) each byte of a number of bytes.
Definition: util.c:25
unsigned char uint8_t
Definition: mongoose.h:267
uint8_t xor_bytes(uint8_t const message[], unsigned num_bytes)
Compute XOR (byte-wide parity) of a number of bytes.
Definition: util.c:265
int add_bytes(uint8_t const message[], unsigned num_bytes)
Compute Addition of a number of bytes.
Definition: util.c:274