diff options
Diffstat (limited to 'example-fs-bb48/crc32.c')
-rw-r--r-- | example-fs-bb48/crc32.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/example-fs-bb48/crc32.c b/example-fs-bb48/crc32.c new file mode 100644 index 0000000..4335295 --- /dev/null +++ b/example-fs-bb48/crc32.c @@ -0,0 +1,22 @@ +const unsigned int *const crc32_table= (const unsigned int *const)0x00000480; + +void +crc32_init (unsigned int *p) +{ + *p = 0xffffffff; +} + +static void +crc32_u8 (unsigned int *p, unsigned char v) +{ + *p = crc32_table[(*p & 0xff) ^ v] ^ (*p >> 8); +} + +void +crc32_u32 (unsigned int *p, unsigned int u) +{ + crc32_u8 (p, u & 0xff); + crc32_u8 (p, (u >> 8)& 0xff); + crc32_u8 (p, (u >> 16)& 0xff); + crc32_u8 (p, (u >> 24)& 0xff); +} |