avrdudes / avr-libc

The AVR-LibC package provides a subset of the standard C library for AVR 8-bit RISC microcontrollers.
https://avrdudes.github.io/avr-libc/
Other
257 stars 56 forks source link

[patch #3925] Dallas iButton 8-bit CRC #715

Closed avrs-admin closed 2 years ago

avrs-admin commented 2 years ago

Wed 20 Apr 2005 11:32:23 PM CEST

I couldn't find this when I went looking for it. So I modified the example in the crc_xmodem_update function, to come up with the following code. This saved me 252 bytes vs. a lookup table. I don't know if this CRC is too specific to this application to be included in this project or not, but here it is anyways. Maybe it will help someone.

uint8_t crc_ibutton_update (uint8_t crc, uint8_t data) { char i;

crc = crc ^ data; for (i=0; i<8; i++) { if (crc & 0x01) crc = (crc >> 1) ^ 0x8C; else crc >>= 1; }

return crc; }

This issue was migrated from https://savannah.nongnu.org/patch/?3925

avrs-admin commented 2 years ago

Joerg Wunsch Mon 14 Nov 2005 11:55:32 PM CET

Implemented as inline asm.