Loading files
This file is pinned to the selected release. Download the original to open it in your design tool.
#include <stdio.h>
#include "utils.h"
#include <stdint.h>
uint32_t parity(uint32_t v) {
// Taken from: http://www.graphics.stanford.edu/~seander/bithacks.html#ParityParallel
v ^= v >> 16;
v ^= v >> 8;
v ^= v >> 4;
v &= 0xf;
return (0x6996 >> v) & 1;
}
uint8_t crc8(uint8_t *ptr, uint8_t len) {
uint8_t crc = 0xFF;
while (len--) {
crc ^= *ptr++;
for (uint8_t i = 0; i < 8; i++) {
if (crc & 0x80) {
crc <<= 1;
crc ^= 0x31;
} else {
crc <<= 1;
}
}
}
return crc;
}
const char* get_filename(const char* path) {
size_t i = 0;
size_t pos = 0;
char* p = (char*)path;
while (*p) {
i++;
if (*p == '/' || *p == '\\') {
pos = i;
}
p++;
}
return path + pos;
}
d9bedbeffThis file is pinned to the selected release. Download the original to open it in your design tool.