From: Pavel Pisa Date: Mon, 21 Nov 2011 16:43:05 +0000 (+0100) Subject: Tool to compute LIN ID parity table. X-Git-Url: http://rtime.felk.cvut.cz/gitweb/linux-lin.git/commitdiff_plain/a45b010031bbc9720a19a75e9f4d042489fcbc5f Tool to compute LIN ID parity table. Signed-off-by: Pavel Pisa --- diff --git a/misc/lin-parity/lin-id-parity.c b/misc/lin-parity/lin-id-parity.c new file mode 100644 index 0000000..8c02cba --- /dev/null +++ b/misc/lin-parity/lin-id-parity.c @@ -0,0 +1,13 @@ +#include + +int main(void) +{ + unsigned int x, p0, p1; + for (x = 0; x <= 0x3f; x++) { + p0 = (x ^ (x >> 1) ^ (x >> 2) ^ (x >> 4)) & 0x1; + p1 = ~(((x >> 1) ^ (x >> 3) ^ (x >> 4) ^ (x >> 5))) & 0x1; + printf("%s0x%02x%s", x & 0x7? "": "\n\t", + ((p1 & 1) << 7) | ((p0 & 0x1) << 6), + x!=0x3f? ",": "\n"); + } +}